3 # This script generates 6856 tests for the set(1) and read(1)
4 # builtins w.r.t. IFS whitespace and non-whitespace characters.
5 # Each failed test produces one line on the standard output that
6 # contains the test along with the expected and actual results.
7 # The last output line contains the test result counts. ordered>0
8 # are the number of tests where IFS=": " produced different results
9 # than IFS=" :". If a test fails the same way for IFS=": " and
10 # IFS=" :" then the second output line is suppressed.
15 echo 1 | read ksh_read
17 eval '((ksh_arith+=1))' 2>/dev/null
25 i=$1 s=$2 r=$3 S='' R=''
40 "$s") case $ksh_arith in
42 *) passed=`expr $passed + 1` ;;
50 *) ordered=`expr $ordered + 1` ;;
55 "$S") case $ksh_arith in
57 *) failed=`expr $failed + 1` ;;
62 *) failed=`expr $failed + 1` ;;
66 ?0*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#]\" # expected \"$s\" got \"$g\"" ;;
67 ?1*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#](\$1)\" # expected \"$s\" got \"$g\"" ;;
68 ?2*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#](\$1)(\$2)\" # expected \"$s\" got \"$g\"" ;;
69 ?3*) echo "IFS=\"$ifs\"; x=\"$i\"; set x \$x; shift; echo \"[\$#](\$1)(\$2)(\$3)\" # expected \"$s\" got \"$g\"" ;;
70 *) echo TEST ERROR i="'$i'" s="'$s'" ;;
78 *) ordered=`expr $ordered + 1` ;;
84 1) echo "$i" | IFS=$ifs read x y; g="($x)($y)" ;;
85 *) g=`export ifs; echo "$i" | ( IFS=$ifs; read x y; echo "($x)($y)" )` ;;
88 "$r") case $ksh_arith in
90 *) passed=`expr $passed + 1` ;;
98 *) ordered=`expr $ordered + 1` ;;
103 "$R") case $ksh_arith in
105 *) failed=`expr $failed + 1` ;;
108 *) case $ksh_arith in
110 *) failed=`expr $failed + 1` ;;
114 *) echo "echo \"$i\" | ( IFS=\"$ifs\" read x y; echo \"(\$x)(\$y)\" ) # expected \"$r\" got \"$g\"" ;;
120 *) case $ksh_arith in
122 *) ordered=`expr $ordered + 1` ;;
165 for d1 in '' ' ' ':' ' :' ': ' ' : '
168 '') split "$d0$f1$d1" "[0]" "()()" ;;
170 *) split "$d0$f1$d1" "[1]($f1)" "($f1)()" ;;
186 for d1 in ' ' ':' ' :' ': ' ' : '
189 $f1$d1|$d1$f2) continue ;;
191 for d2 in '' ' ' ':' ' :' ': ' ' : '
194 '') split "$d0$f1$d1$f2$d2" "[1]($f1)" "($f1)()" ;;
196 *) split "$d0$f1$d1$f2$d2" "[2]($f1)($f2)" "($f1)($f2)" ;;
213 for d1 in ':' ' :' ': ' ' : '
216 $f1$d1|$d1$f2) continue ;;
218 for d2 in ' ' ':' ' :' ': ' ' : '
224 $f2$d2|$d2$f3) continue ;;
226 for d3 in '' ' ' ':' ' :' ': ' ' : '
229 '') split "$d0$f1$d1$f2$d2$f3$d3" "[2]($f1)($f2)" "($f1)($f2)" ;;
234 split "$d0$f1$d1$f2$d2$f3$d3" "[3]($f1)($f2)($f3)" "($f1)($x)"
246 1) ((tests=passed+failed)) ;;
247 *) tests=`expr $passed + $failed` ;;
251 *) ordered=" ordered $ordered" ;;
255 *) fatal=" -- fundamental IFS error -- $TESTS tests expected"
257 echo "# tests $tests passed $passed failed $failed$ordered$fatal"