From cb4c5aaf0a1884bcae21c7d31b70864e64bb55fa Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 7 Nov 1994 12:47:50 +0000 Subject: Initial revision --- tests/join/.cvsignore | 3 +++ tests/join/Makefile | 19 ++++++++++++++++ tests/join/TODO | 0 tests/join/build-script | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/join/failures | 19 ++++++++++++++++ tests/join/main | 3 +++ tests/join/range-tests | 18 +++++++++++++++ tests/join/test.data.pl | 4 ++++ 8 files changed, 125 insertions(+) create mode 100644 tests/join/.cvsignore create mode 100644 tests/join/Makefile create mode 100644 tests/join/TODO create mode 100755 tests/join/build-script create mode 100644 tests/join/failures create mode 100755 tests/join/main create mode 100644 tests/join/range-tests create mode 100755 tests/join/test.data.pl (limited to 'tests') diff --git a/tests/join/.cvsignore b/tests/join/.cvsignore new file mode 100644 index 000000000..ca18a4c8d --- /dev/null +++ b/tests/join/.cvsignore @@ -0,0 +1,3 @@ +t*.out +t*.in +t*.exp diff --git a/tests/join/Makefile b/tests/join/Makefile new file mode 100644 index 000000000..391f1a04f --- /dev/null +++ b/tests/join/Makefile @@ -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 diff --git a/tests/join/TODO b/tests/join/TODO new file mode 100644 index 000000000..e69de29bb diff --git a/tests/join/build-script b/tests/join/build-script new file mode 100755 index 000000000..ab064d5cb --- /dev/null +++ b/tests/join/build-script @@ -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 < /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 <&2 +fi +EOF2 diff --git a/tests/join/failures b/tests/join/failures new file mode 100644 index 000000000..defc474ce --- /dev/null +++ b/tests/join/failures @@ -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. diff --git a/tests/join/main b/tests/join/main new file mode 100755 index 000000000..dd2da71f4 --- /dev/null +++ b/tests/join/main @@ -0,0 +1,3 @@ +: +perl -pe 's/\\\n$//' "$@" \ + | ./build-script diff --git a/tests/join/range-tests b/tests/join/range-tests new file mode 100644 index 000000000..d13d472cf --- /dev/null +++ b/tests/join/range-tests @@ -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 [:*] diff --git a/tests/join/test.data.pl b/tests/join/test.data.pl new file mode 100755 index 000000000..35322ca11 --- /dev/null +++ b/tests/join/test.data.pl @@ -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); -- cgit v1.2.3-54-g00ecf