mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-18 09:46:33 +02:00
Initial revision
This commit is contained in:
3
tests/join/.cvsignore
Normal file
3
tests/join/.cvsignore
Normal file
@@ -0,0 +1,3 @@
|
||||
t*.out
|
||||
t*.in
|
||||
t*.exp
|
||||
19
tests/join/Makefile
Normal file
19
tests/join/Makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
.PHONY: all
|
||||
all: tr-tests
|
||||
./tr-tests
|
||||
|
||||
tr-tests: main build-script test.data.pl
|
||||
./main test.data.pl > $@.n
|
||||
mv $@.n $@
|
||||
chmod 755 $@
|
||||
|
||||
.PHONY: distclean
|
||||
distclean:
|
||||
rm -f t*.out
|
||||
|
||||
.PHONY: clean
|
||||
clean: distclean
|
||||
|
||||
.PHONY: realclean
|
||||
realclean: clean
|
||||
rm -f tr-tests t*.in t*.exp
|
||||
0
tests/join/TODO
Normal file
0
tests/join/TODO
Normal file
59
tests/join/build-script
Executable file
59
tests/join/build-script
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/p/bin/perl5.000 -w
|
||||
|
||||
$tr = '../tr +io 5';
|
||||
$tr = 'tr';
|
||||
$test = 0;
|
||||
$| = 1;
|
||||
|
||||
print ":\nerrors=0\n";
|
||||
$expected = '';
|
||||
$s1 = '';
|
||||
$input = '';
|
||||
$flags = '';
|
||||
$s1 = '';
|
||||
|
||||
while (<>)
|
||||
{
|
||||
next if (/^\s*#/);
|
||||
|
||||
$test++;
|
||||
chop;
|
||||
$prog = '($test_name, $input,$flags,$s1,$s2,$expected,$e_ret_code) = ' . $_ . ';';
|
||||
eval $prog;
|
||||
$in = "t$test_name.in";
|
||||
$exp_name = 't' . $test_name . '.exp';
|
||||
$out = "t$test_name.out";
|
||||
|
||||
open(IN, ">$in") || die "Couldn't open $in for writing.\n";
|
||||
print IN $input;
|
||||
close(IN);
|
||||
open(EXP, ">$exp_name")
|
||||
|| die "Couldn't open $exp_name for writing.\n";
|
||||
print EXP $expected;
|
||||
close(EXP);
|
||||
$arg2 = ($s2 ? "'$s2'" : '');
|
||||
$cmd = "$tr $flags \'$s1\' $arg2 < $in > $out";
|
||||
print <<EOF ;
|
||||
$cmd 2> /dev/null
|
||||
code=\$?
|
||||
if test \$code != $e_ret_code ; then
|
||||
echo Test $test_name failed: tr return code \$code differs from expected value $e_ret_code 1>&2
|
||||
errors=`expr \$errors + 1`
|
||||
else
|
||||
cmp $out $exp_name
|
||||
case \$? in
|
||||
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;
|
||||
echo The command \"cmp $out $exp_name\" failed. 1>&2 ;
|
||||
errors=`expr \$errors + 1` ;;
|
||||
esac
|
||||
fi
|
||||
EOF
|
||||
}
|
||||
print <<EOF2 ;
|
||||
if test \$errors -gt 0 ; then
|
||||
echo Failed \$errors tests. 1>&2
|
||||
fi
|
||||
EOF2
|
||||
19
tests/join/failures
Normal file
19
tests/join/failures
Normal file
@@ -0,0 +1,19 @@
|
||||
# ./tr a '[c*]b'
|
||||
# ./tr -s abc zy
|
||||
# ./tr abc zy
|
||||
tr a '[:not-a-class:]' < /dev/null
|
||||
tr a '[:digit:]' < /dev/null
|
||||
tr '[c*]' k < /dev/null
|
||||
tr a '[=c=]' < /dev/null
|
||||
tr a '[c*][c*]' < /dev/null
|
||||
tr -ds abd '[c*]' < /dev/null
|
||||
tr -c '[:lower:]' '[:upper:]' < /dev/null
|
||||
tr '[:lower:]' '[:lower:]' < /dev/null
|
||||
tr '0-9[:lower:]' '[:upper:]' < /dev/null
|
||||
tr a '' < /dev/null
|
||||
tr -s '\432' < /dev/null
|
||||
tr a 'abc\' < /dev/null
|
||||
tr a '\x' < /dev/null
|
||||
tr -s < /dev/null
|
||||
|
||||
# And make sure tr does the right thing when POSIXLY_... is set.
|
||||
3
tests/join/main
Executable file
3
tests/join/main
Executable file
@@ -0,0 +1,3 @@
|
||||
:
|
||||
perl -pe 's/\\\n$//' "$@" \
|
||||
| ./build-script
|
||||
18
tests/join/range-tests
Normal file
18
tests/join/range-tests
Normal file
@@ -0,0 +1,18 @@
|
||||
[]*] # What about this?! valid
|
||||
[:*096] # invalid: 096 isn't a valid octal number
|
||||
a [:*0] # as many colons as string1 was long (not to be confused
|
||||
# with a character class)
|
||||
[:*] # ditto
|
||||
[:*016] # 14 colons
|
||||
[=]=] # valid: equivalence class containing ']'
|
||||
[-a # valid, assuming `[' is before 'a' in collating sequence
|
||||
-] # valid, assuming ` ' is before ']' in collating sequence
|
||||
--] # valid, assuming `-' is before ']' in collating sequence
|
||||
\0-\377 # valid
|
||||
[\0-\377]# valid, (but brackets will be mapped to corresponding chars
|
||||
# in other string)
|
||||
abcde[:* # valid, but none of the characters is considered special
|
||||
abc xyzdef # Should this (str2 longer than str1) evoke a warning?
|
||||
# Probably so if we're only translating, but if also deleting or
|
||||
# squeezing this makes sense.
|
||||
abcdef : # Map abcdef all to `:', as if str2 had been [:*]
|
||||
4
tests/join/test.data.pl
Executable file
4
tests/join/test.data.pl
Executable file
@@ -0,0 +1,4 @@
|
||||
# test name
|
||||
# flags file-1 file-2 expected output expected return code
|
||||
#
|
||||
("1", '-a1 -a2', "a 1\n", "\n", "a 1\n", 0);
|
||||
Reference in New Issue
Block a user