]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
*** empty log message ***
authorJim Meyering <jim@meyering.net>
Sun, 7 Jun 1998 14:27:15 +0000 (14:27 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 7 Jun 1998 14:27:15 +0000 (14:27 +0000)
tests/test/Test.pm

index b584a8a87387b0f8247e2e7077ada4c45ea378b3..b94c0c29eb4795e1bf33a9ffa5e1df9a7729727a 100644 (file)
@@ -3,11 +3,6 @@ package Test;
 require 5.002;
 use strict;
 
-# For each test...
-# Export LANG=C so that the locale-dependent strings match.
-# Export TZ=UTC so that zone-dependent strings match.
-$Test::env_default = ['LANG=C TZ=UTC'];
-
 sub test_vector
 {
   my @tvec =
@@ -19,10 +14,10 @@ sub test_vector
      ['1c', 'any-string', {}, '', 0],
      ['1d', '-n any-string', {}, '', 0],
 
-     ['eq-1', 't = t', {}, '', 0],
-     ['eq-2', 't = f', {}, '', 1],
-     ['ne-1', 't != t', {}, '', 1],
-     ['ne-2', 't != f', {}, '', 0],
+     ['streq-1', 't = t', {}, '', 0],
+     ['streq-2', 't = f', {}, '', 1],
+     ['strne-1', 't != t', {}, '', 1],
+     ['strne-2', 't != f', {}, '', 0],
 
      ['and-1', 't -a t', {}, '', 0],
      ['and-2', '"" -a t', {}, '', 1],
@@ -34,38 +29,59 @@ sub test_vector
      ['or-3', 't -o ""', {}, '', 0],
      ['or-4', '"" -o ""', {}, '', 1],
 
-     ['ieq-1', '9 -eq 9', {}, '', 0],
-     ['ieq-2', '0 -eq 0', {}, '', 0],
-     ['ieq-3', '0 -eq 00', {}, '', 0],
-     ['ieq-4', '8 -eq 9', {}, '', 1],
-     ['ieq-5', '1 -eq 0', {}, '', 1],
-     ['ieq-6', '0x0 -eq 00', {}, '', 1],
-
-     ['ge-1', '5 -ge 5', {}, '', 0],
-     ['ge-2', '5 -ge 4', {}, '', 0],
-     ['ge-3', '4 -ge 5', {}, '', 1],
-     ['ge-4', '-1 -ge -2', {}, '', 0],
+     ['eq-1', '9 -eq 9', {}, '', 0],
+     ['eq-2', '0 -eq 0', {}, '', 0],
+     ['eq-3', '0 -eq 00', {}, '', 0],
+     ['eq-4', '8 -eq 9', {}, '', 1],
+     ['eq-5', '1 -eq 0', {}, '', 1],
 
      ['gt-1', '5 -gt 5', {}, '', 1],
      ['gt-2', '5 -gt 4', {}, '', 0],
      ['gt-3', '4 -gt 5', {}, '', 1],
      ['gt-4', '-1 -gt -2', {}, '', 0],
 
-     ['le-1', '5 -le 5', {}, '', 0],
-     ['le-2', '5 -le 4', {}, '', 1],
-     ['le-3', '4 -le 5', {}, '', 0],
-     ['le-4', '-1 -le -2', {}, '', 1],
-
      ['lt-1', '5 -lt 5', {}, '', 1],
      ['lt-2', '5 -lt 4', {}, '', 1],
      ['lt-3', '4 -lt 5', {}, '', 0],
      ['lt-4', '-1 -lt -2', {}, '', 1],
 
+     # This evokes `test: 0x0: integer expression expected'.
+     ['inv-1', '0x0 -eq 00', {}, '', 1],
+
      ['t1', "-t", {}, '', 1],
      ['t2', "-t 1", {}, '', 1],
-     );
+    );
+
+  my %inverse_op =
+    (
+     eq => 'ne',
+     lt => 'ge',
+     gt => 'le',
+    );
+
+  # Generate corresponding tests of inverse ops.
+  # E.g. generate tests of `-ge' from those of `-lt'.
+  my @tv;
+  my $t;
+  foreach $t (@tvec)
+    {
+      my ($test_name, $flags, $in, $exp, $ret) = @$t;
+
+      my $op;
+      for $op (qw(gt lt eq))
+       {
+         if ($test_name =~ /$op-/ && $flags =~ / -$op /)
+           {
+             my $inv = $inverse_op{$op};
+             $test_name =~ s/$op/$inv/;
+             $flags =~ s/-$op/-$inv/;
+             $ret = 1 - $ret;
+             push (@tv, [$test_name, $flags, $in, $exp, $ret]);
+           }
+       }
+    }
 
-  return @tvec;
+  return (@tv, @tvec);
 }
 
 1;