summaryrefslogtreecommitdiff
path: root/tests/join
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-11-07 12:47:50 +0000
committerJim Meyering <jim@meyering.net>1994-11-07 12:47:50 +0000
commitcb4c5aaf0a1884bcae21c7d31b70864e64bb55fa (patch)
tree9dc6a5b7b0ee4449a7513c29f79f552ff01b93fc /tests/join
parent87615079293ffe40e844d1d6138572ac33967d3c (diff)
downloadcoreutils-cb4c5aaf0a1884bcae21c7d31b70864e64bb55fa.tar.xz
Initial revision
Diffstat (limited to 'tests/join')
-rw-r--r--tests/join/.cvsignore3
-rw-r--r--tests/join/Makefile19
-rw-r--r--tests/join/TODO0
-rwxr-xr-xtests/join/build-script59
-rw-r--r--tests/join/failures19
-rwxr-xr-xtests/join/main3
-rw-r--r--tests/join/range-tests18
-rwxr-xr-xtests/join/test.data.pl4
8 files changed, 125 insertions, 0 deletions
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
--- /dev/null
+++ b/tests/join/TODO
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 <<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
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);