summaryrefslogtreecommitdiff
path: root/tests/test
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1998-06-07 14:27:15 +0000
committerJim Meyering <jim@meyering.net>1998-06-07 14:27:15 +0000
commited1fdb8841bb741e45dc0a59f0dc87d0aa2267b1 (patch)
tree6155cde6401a7245900e22b0be09b398ef805ccb /tests/test
parent5d59e186181a68d2af8aca0c2cab5f0f379ce382 (diff)
downloadcoreutils-ed1fdb8841bb741e45dc0a59f0dc87d0aa2267b1.tar.xz
*** empty log message ***
Diffstat (limited to 'tests/test')
-rw-r--r--tests/test/Test.pm70
1 files changed, 43 insertions, 27 deletions
diff --git a/tests/test/Test.pm b/tests/test/Test.pm
index b584a8a87..b94c0c29e 100644
--- a/tests/test/Test.pm
+++ b/tests/test/Test.pm
@@ -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;