]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: date: test parenthesis comment handling
authorSylvestre Ledru <sylvestre@debian.org>
Wed, 7 Jan 2026 22:51:06 +0000 (23:51 +0100)
committerCollin Funk <collin.funk1@gmail.com>
Thu, 8 Jan 2026 03:58:55 +0000 (19:58 -0800)
* tests/date/date.pl: Add the check.

tests/date/date.pl

index 0fcdc72fd6cded7fa52056d8e193089b5f196d5d..0343cb913fd39a3371fea8660e655ade253a871a 100755 (executable)
@@ -319,6 +319,21 @@ my @Tests =
 
      # test with %%-N
      ['pct-pct', '+%%-N', {OUT => '%-N'}],
+
+     # Test parenthesis comment handling
+     # Single parenthesis - should be treated as empty string (midnight today)
+     ['paren-1', "-d '(' +'%H:%M:%S'", {OUT=>"00:00:00"}],
+
+     # Parenthesis with preceding text - comment should be ignored
+     ['paren-2', "-d '1(ignore this comment' +'%H:%M:%S'", {OUT=>"01:00:00"}],
+
+     # Parenthesis with date - comment should be ignored
+     ['paren-3', "-d '2026-01-05(this is a comment' -u +'%Y-%m-%d'",
+      {OUT=>"2026-01-05"}],
+
+     # Text enclosed in parentheses is treated as a comment
+     ['paren-4', "-d '2026(this is a comment)-01-05' -u +'%Y-%m-%d'",
+      {OUT=>"2026-01-05"}],
     );
 
 # Repeat the cross-dst test, using Jan 1, 2005 and every interval from 1..364.