summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-08-17 17:27:46 +0000
committerJim Meyering <jim@meyering.net>1996-08-17 17:27:46 +0000
commit39cf848828c314c1d701bb5007a93c9f318a04f2 (patch)
treeade3f59680eea7d10705cffba2bdf746ef673f42 /tests
parent8dd548d8955bafe512335d0f578ee255dc6811a6 (diff)
downloadcoreutils-39cf848828c314c1d701bb5007a93c9f318a04f2.tar.xz
Revamp to use perl5-style list of lists.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/tr/build-script.pl29
-rwxr-xr-xtests/tr/test.data.pl141
2 files changed, 86 insertions, 84 deletions
diff --git a/tests/tr/build-script.pl b/tests/tr/build-script.pl
index c12461b4c..60241415c 100755
--- a/tests/tr/build-script.pl
+++ b/tests/tr/build-script.pl
@@ -4,6 +4,7 @@
require 5.002;
use strict;
+use Trtest;
$| = 1;
@@ -16,26 +17,20 @@ case \$# in
0) xx='$xx';;
*) xx="\$1";;
esac
-echo=:
+test "\$VERBOSE" && echo=echo || echo=:
\$echo testing with $xx=\$xx
errors=0
test "\$srcdir" || srcdir=.
-test "\$verbose" && \$xx --version 2> /dev/null
+test "\$VERBOSE" && \$xx --version 2> /dev/null
EOF
-
my %seen;
-while (<>)
+my $test_vector;
+foreach $test_vector (@Trtest::t)
{
- next if (/^\s*#/);
-
- chomp;
- my ($test_name, $input, $flags, $s1, $s2, $expected, $e_ret_code);
- my $prog =
- '($test_name, $input, $flags, $s1, $s2, $expected, $e_ret_code) = '
- . $_ . ';';
- eval $prog;
+ my ($test_name, $input, $flags, $s1, $s2, $expected, $e_ret_code)
+ = @{$test_vector};
die "$0: $.: duplicate test name \`$test_name'\n"
if (defined ($seen{$test_name}));
$seen{$test_name} = 1;
@@ -43,12 +38,12 @@ while (<>)
my $exp_name = "t$test_name.exp";
my $out = "t$test_name.out";
- open(IN, ">$in") || die "$0: $in: $!\n";
+ open (IN, ">$in") || die "$0: $in: $!\n";
print IN $input;
- close(IN);
- open(EXP, ">$exp_name") || die "$0: $in: $!\n";
+ close (IN);
+ open (EXP, ">$exp_name") || die "$0: $in: $!\n";
print EXP $expected;
- close(EXP);
+ close (EXP);
my $arg2 = ($s2 ? " '$s2'" : '');
my $err_output = "t$test_name.err";
my $cmd = "\$xx $flags \'$s1\'$arg2 < \$srcdir/$in > $out 2> $err_output";
@@ -62,7 +57,7 @@ if test \$code != $e_ret_code ; then
else
cmp $out \$srcdir/$exp_name
case \$? in
- 0) if test "\$verbose" ; then \$echo passed $test_name; fi ;; # equal files
+ 0) if test "\$VERBOSE" ; then \$echo passed $test_name; fi ;; # equal files
1) \$echo Test $test_name failed: files $out and $exp_name differ 1>&2;
errors=`expr \$errors + 1` ;;
2) \$echo Test $test_name may have failed. 1>&2;
diff --git a/tests/tr/test.data.pl b/tests/tr/test.data.pl
index 78200d033..d227cbd88 100755
--- a/tests/tr/test.data.pl
+++ b/tests/tr/test.data.pl
@@ -1,81 +1,88 @@
-# input flags 1 or 2 strings expected output expected return code
+package Trtest;
+require 5.002;
+
+@Trtest::t = (
+# test input flags 1 or 2 strings expected output expected return code
#
-('1', 'abcd', '', 'abcd','[]*]', ']]]]', 0);
-('2', 'abc', '', 'abc','[%*]xyz', 'xyz', 0);
-('3', 'abc', '', '','[.*]', 'abc', 0);
+['1', 'abcd', '', 'abcd','[]*]', ']]]]', 0],
+['2', 'abc', '', 'abc','[%*]xyz', 'xyz', 0],
+['3', 'abc', '', '','[.*]', 'abc', 0],
# Test --truncate-set1 behavior when string1 is longer than string2
-('4', 'abcde', '-t', 'abcd','xy', 'xycde', 0);
+['4', 'abcde', '-t', 'abcd','xy', 'xycde', 0],
# Test bsd behavior (the default) when string1 is longer than string2
-('5', 'abcde', '', 'abcd','xy', 'xyyye', 0);
+['5', 'abcde', '', 'abcd','xy', 'xyyye', 0],
# Do it the posix way
-('6', 'abcde', '', 'abcd','x[y*]', 'xyyye', 0);
+['6', 'abcde', '', 'abcd','x[y*]', 'xyyye', 0],
#
-('7', 'abcdefghijklmnop', '-s', 'a-p','%[.*]$', '%.$', 0);
-('8', 'abcdefghijklmnop', '-s', 'a-p','[.*]$', '.$', 0);
-('9', 'abcdefghijklmnop', '-s', 'a-p','%[.*]', '%.', 0);
-('a', 'aabbcc', '-s', '[a-z]','', 'abc', 0);
-('b', 'aabbcc', '-s', '[a-c]','', 'abc', 0);
-('c', 'aabbcc', '-s', '[a-b]','', 'abcc', 0);
-('d', 'aabbcc', '-s', '[b-c]','', 'aabc', 0);
-('e', "\0\0a\1\1b\2\2\2c\3\3\3d\4\4\4\4e\5\5", \
- '-s', '[\0-\5]','', "\0a\1b\2c\3d\4e\5", 0);
+['7', 'abcdefghijklmnop', '-s', 'a-p','%[.*]$', '%.$', 0],
+['8', 'abcdefghijklmnop', '-s', 'a-p','[.*]$', '.$', 0],
+['9', 'abcdefghijklmnop', '-s', 'a-p','%[.*]', '%.', 0],
+['a', 'aabbcc', '-s', '[a-z]','', 'abc', 0],
+['b', 'aabbcc', '-s', '[a-c]','', 'abc', 0],
+['c', 'aabbcc', '-s', '[a-b]','', 'abcc', 0],
+['d', 'aabbcc', '-s', '[b-c]','', 'aabc', 0],
+['e', "\0\0a\1\1b\2\2\2c\3\3\3d\4\4\4\4e\5\5",
+ '-s', '[\0-\5]','', "\0a\1b\2c\3d\4e\5", 0],
# tests of delete
-('f', '[[[[[[[]]]]]]]]', '-d', '[=[=]','', ']]]]]]]]', 0);
-('g', '[[[[[[[]]]]]]]]', '-d', '[=]=]','', '[[[[[[[', 0);
-('h', '0123456789acbdefABCDEF', '-d', '[:xdigit:]','', '', 0);
-('i', 'w0x1y2z3456789acbdefABCDEFz', '-d', '[:xdigit:]','', 'wxyzz', 0);
-('j', '0123456789', '-d', '[:digit:]','', '', 0);
-('k', 'a0b1c2d3e4f5g6h7i8j9k', '-d', '[:digit:]','', 'abcdefghijk', 0);
-('l', 'abcdefghijklmnopqrstuvwxyz', '-d', '[:lower:]','', '', 0);
-('m', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '-d', '[:upper:]','', '', 0);
-('n', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', \
- '-d', '[:lower:][:upper:]','', '', 0);
-('o', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', \
- '-d', '[:alpha:]','', '', 0);
-('p', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', \
- '-d', '[:alnum:]','', '', 0);
-('q', '.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.', \
- '-d', '[:alnum:]','', '..', 0);
-('r', '.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.', \
- '-ds', '[:alnum:]','.', '.', 0);
+['f', '[[[[[[[]]]]]]]]', '-d', '[=[=]','', ']]]]]]]]', 0],
+['g', '[[[[[[[]]]]]]]]', '-d', '[=]=]','', '[[[[[[[', 0],
+['h', '0123456789acbdefABCDEF', '-d', '[:xdigit:]','', '', 0],
+['i', 'w0x1y2z3456789acbdefABCDEFz', '-d', '[:xdigit:]','', 'wxyzz', 0],
+['j', '0123456789', '-d', '[:digit:]','', '', 0],
+['k', 'a0b1c2d3e4f5g6h7i8j9k', '-d', '[:digit:]','', 'abcdefghijk', 0],
+['l', 'abcdefghijklmnopqrstuvwxyz', '-d', '[:lower:]','', '', 0],
+['m', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '-d', '[:upper:]','', '', 0],
+['n', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ '-d', '[:lower:][:upper:]','', '', 0],
+['o', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+ '-d', '[:alpha:]','', '', 0],
+['p', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
+ '-d', '[:alnum:]','', '', 0],
+['q', '.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.',
+ '-d', '[:alnum:]','', '..', 0],
+['r', '.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.',
+ '-ds', '[:alnum:]','.', '.', 0],
# The classic example, with string2 BSD-style
-('s', 'The big black fox jumped over the fence.', \
- '-cs', '[:alnum:]','\n', \
- "The\nbig\nblack\nfox\njumped\nover\nthe\nfence\n", 0);
+['s', 'The big black fox jumped over the fence.',
+ '-cs', '[:alnum:]','\n',
+ "The\nbig\nblack\nfox\njumped\nover\nthe\nfence\n", 0],
# The classic example, POSIX-style
-('t', 'The big black fox jumped over the fence.', \
- '-cs', '[:alnum:]','[\n*]', \
- "The\nbig\nblack\nfox\njumped\nover\nthe\nfence\n", 0);
-('u', 'aabbaa', '-ds', 'b','a', 'a', 0);
-('v', 'ZZ0123456789acbdefABCDEFZZ', \
- '-ds', '[:xdigit:]','Z', 'Z', 0);
+['t', 'The big black fox jumped over the fence.',
+ '-cs', '[:alnum:]','[\n*]',
+ "The\nbig\nblack\nfox\njumped\nover\nthe\nfence\n", 0],
+['u', 'aabbaa', '-ds', 'b','a', 'a', 0],
+['v', 'ZZ0123456789acbdefABCDEFZZ',
+ '-ds', '[:xdigit:]','Z', 'Z', 0],
# Try some data with 8th bit set in case something is mistakenly sign-extended.
-('w', "\300\301\377\345\345\350\345", \
- '-ds', '\350','\345', "\300\301\377\345", 0);
-('x', 'abcdefghijklmnop', '-s', 'abcdefghijklmn','[:*016]', ':op', 0);
-('y', 'abc $code', '-d', 'a-z','', ' $', 0);
-('z', 'a.b.c $$$$code\\', '-ds', 'a-z','$.', '. $\\', 0);
+['w', "\300\301\377\345\345\350\345",
+ '-ds', '\350','\345', "\300\301\377\345", 0],
+['x', 'abcdefghijklmnop', '-s', 'abcdefghijklmn','[:*016]', ':op', 0],
+['y', 'abc $code', '-d', 'a-z','', ' $', 0],
+['z', 'a.b.c $$$$code\\', '-ds', 'a-z','$.', '. $\\', 0],
# Make sure that a-a is accepted, even though POSIX 1001.2 says it is illegal.
-('A', 'abc', '', 'a-a','z', 'zbc', 0);
+['A', 'abc', '', 'a-a','z', 'zbc', 0],
#
-('B', '', '', 'a',"''", '', 1);
-('C', "abcxyzABCXYZ", '', '[:lower:]', '[:upper:]', 'ABCXYZABCXYZ', 0);
-('D', 'abcxyzABCXYZ', '', '[:upper:]', '[:lower:]', 'abcxyzabcxyz', 0);
+['B', '', '', 'a',"''", '', 1],
+['C', "abcxyzABCXYZ", '', '[:lower:]', '[:upper:]', 'ABCXYZABCXYZ', 0],
+['D', 'abcxyzABCXYZ', '', '[:upper:]', '[:lower:]', 'abcxyzabcxyz', 0],
#
-('E', 'a=c', '', 'a[=*2][=c=]', 'xyyz', 'xyz', 0);
-('F', ':1239', '', '[:*3][:digit:]', 'a-m', 'cefgm', 0);
-('G', 'abc', '', 'a[b*512]c', '1[x*]2', '1x2', 0);
-('H', 'abc', '', 'a[b*513]c', '1[x*]2', '1x2', 0);
-('I', 'abc-z', '', 'a\-z', 'A-Z', 'AbcBC', 0);
+['E', 'a=c', '', 'a[=*2][=c=]', 'xyyz', 'xyz', 0],
+['F', ':1239', '', '[:*3][:digit:]', 'a-m', 'cefgm', 0],
+['G', 'abc', '', 'a[b*512]c', '1[x*]2', '1x2', 0],
+['H', 'abc', '', 'a[b*513]c', '1[x*]2', '1x2', 0],
+['I', 'abc-z', '', 'a\-z', 'A-Z', 'AbcBC', 0],
#
# From Ross
-('R0.0', '', '-cs', '[:upper:]', 'X[Y*]', '', 1);
-('R0.1', '', '-cs', '[:cntrl:]', 'X[Y*]', '', 1);
-('R1.0', 'AMZamz123.-+AMZ', '-cs', '[:upper:]', '[X*]', 'AMZXAMZ', 0);
-('R1.1', '', '-cs', '[:upper:][:digit:]', '[Z*]', '', 0);
-('R2', 'amzAMZ123.-+amz', '-dcs', '[:lower:]', 'n-rs-z', 'amzamz', 0);
-('R3', '.ZABCDEFGzabcdefg.0123456788899.GG', '-ds', \
- '[:xdigit:]', '[:alnum:]', '.ZGzg..G', 0);
-('R4', '', '-dcs', '[:alnum:]', '[:digit:]', '', 0);
-('R5', '', '-dc', '[:lower:]', '', '', 0);
-('R6', '', '-dc', '[:upper:]', '', '', 0);
+['R0.0', '', '-cs', '[:upper:]', 'X[Y*]', '', 1],
+['R0.1', '', '-cs', '[:cntrl:]', 'X[Y*]', '', 1],
+['R1.0', 'AMZamz123.-+AMZ', '-cs', '[:upper:]', '[X*]', 'AMZXAMZ', 0],
+['R1.1', '', '-cs', '[:upper:][:digit:]', '[Z*]', '', 0],
+['R2', 'amzAMZ123.-+amz', '-dcs', '[:lower:]', 'n-rs-z', 'amzamz', 0],
+['R3', '.ZABCDEFGzabcdefg.0123456788899.GG', '-ds',
+ '[:xdigit:]', '[:alnum:]', '.ZGzg..G', 0],
+['R4', '', '-dcs', '[:alnum:]', '[:digit:]', '', 0],
+['R5', '', '-dc', '[:lower:]', '', '', 0],
+['R6', '', '-dc', '[:upper:]', '', '', 0],
+);
+
+1;