summaryrefslogtreecommitdiff
path: root/bin/pdksh/tests
diff options
context:
space:
mode:
authorJason Downs <downsj@cvs.openbsd.org>1996-08-19 20:09:10 +0000
committerJason Downs <downsj@cvs.openbsd.org>1996-08-19 20:09:10 +0000
commite7e852656e3beb5f62f8c146ba24004cfda2cf88 (patch)
treeb312bc3e985b3f1cf19691c779e7870219573b6e /bin/pdksh/tests
parent1e9e82f84b5de8bcd110c41c780f476397c385d9 (diff)
update to pdksh-5.2.8
Diffstat (limited to 'bin/pdksh/tests')
-rw-r--r--bin/pdksh/tests/arith.t79
-rw-r--r--bin/pdksh/tests/regress.t24
-rw-r--r--bin/pdksh/tests/th8
-rw-r--r--bin/pdksh/tests/th.sh8
-rw-r--r--bin/pdksh/tests/version.t2
5 files changed, 118 insertions, 3 deletions
diff --git a/bin/pdksh/tests/arith.t b/bin/pdksh/tests/arith.t
new file mode 100644
index 00000000000..e18ea2e9d78
--- /dev/null
+++ b/bin/pdksh/tests/arith.t
@@ -0,0 +1,79 @@
+name: arith-lazy-1
+description:
+ Check that only one side of ternary operator is evaluated
+stdin:
+ x=i+=2
+ y=j+=2
+ typeset -i i=1 j=1
+ echo $((1 ? 20 : (x+=2)))
+ echo $i,$x
+ echo $((0 ? (y+=2) : 30))
+ echo $j,$y
+expected-stdout:
+ 20
+ 1,i+=2
+ 30
+ 1,j+=2
+---
+
+name: arith-lazy-2
+description:
+ Check that assignments not done on non-evaluated side of ternary
+ operator
+stdin:
+ x=i+=2
+ y=j+=2
+ typeset -i i=1 j=1
+ echo $((1 ? 20 : (x+=2)))
+ echo $i,$x
+ echo $((0 ? (y+=2) : 30))
+ echo $i,$y
+expected-stdout:
+ 20
+ 1,i+=2
+ 30
+ 1,j+=2
+---
+
+name: arith-ternary-prec-1
+description:
+ Check precidance of ternary operator vs assignment
+stdin:
+ typeset -i x=2
+ y=$((1 ? 20 : x+=2))
+expected-exit: e != 0
+expected-stderr-pattern:
+ /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
+---
+
+name: arith-ternary-prec-2
+description:
+ Check precidance of ternary operator vs assignment
+stdin:
+ typeset -i x=2
+ echo $((0 ? x+=2 : 20))
+expected-stdout:
+ 20
+---
+
+name: arith-div-assoc-1
+description:
+ Check associativity of division operator
+stdin:
+ echo $((20 / 2 / 2))
+expected-stdout:
+ 5
+---
+
+name: arith-assop-assoc-1
+description:
+ Check associativity of assignment-operator operator
+stdin:
+ typeset -i i=1 j=2 k=3
+ echo $((i += j += k))
+ echo $i,$j,$k
+expected-stdout:
+ 6
+ 6,5,3
+---
+
diff --git a/bin/pdksh/tests/regress.t b/bin/pdksh/tests/regress.t
index 95fe97b6b7c..d78a02641de 100644
--- a/bin/pdksh/tests/regress.t
+++ b/bin/pdksh/tests/regress.t
@@ -639,3 +639,27 @@ expected-exit: e != 0
expected-stderr-pattern:
/.*read *only.*/
---
+
+name: regression-43
+description:
+ Can subshells be prefixed by redirections (historical shells allow
+ this)
+stdin:
+ < /dev/null (cat -n)
+---
+
+name: regression-44
+description:
+ getopts sets OPTIND correctly for unparsed option
+stdin:
+ set -- -a -a -x
+ while getopts :a optc; do
+ echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
+ done
+ echo done
+expected-stdout:
+ OPTARG=, OPTIND=2, optc=a.
+ OPTARG=, OPTIND=3, optc=a.
+ OPTARG=x, OPTIND=3, optc=?.
+ done
+---
diff --git a/bin/pdksh/tests/th b/bin/pdksh/tests/th
index 496058ccd4e..340cbe2d5dc 100644
--- a/bin/pdksh/tests/th
+++ b/bin/pdksh/tests/th
@@ -169,7 +169,13 @@ foreach $env (('USER', 'LOGNAME', 'HOME', 'PATH', 'SHELL')) {
$new_env{$env} = $ENV{$env} if defined $ENV{$env};
}
%old_env = %ENV;
-%ENV = %new_env;
+
+# The following doesn't work with perl5... Need to do it explicitly - yuck.
+#%ENV = %new_env;
+foreach $k (keys(%ENV)) {
+ delete $ENV{$k};
+}
+$ENV{$k} = $v while ($k,$v) = each %new_env;
die "$prog: couldn't make directory $tempdir - $!\n" if !mkdir($tempdir, 0777);
diff --git a/bin/pdksh/tests/th.sh b/bin/pdksh/tests/th.sh
index 6e40c19dcf9..f26b8699e94 100644
--- a/bin/pdksh/tests/th.sh
+++ b/bin/pdksh/tests/th.sh
@@ -4,12 +4,18 @@
# Simple script to find perl and run it
#
+# Avoid common problems with ENV (though perl shouldn't let it through)
+unset ENV
+
+x=x
+[ -x /bin/sh ] 2> /dev/null || x=f
+
IFS=:$IFS
perl=
for i in $PATH; do
[ X"$i" = X ] && i=.
for j in perl perl4 perl5 ; do
- [ -x "$i/$j" ] && perl=$i/$j && break 2
+ [ -$x "$i/$j" ] && perl=$i/$j && break 2
done
done
diff --git a/bin/pdksh/tests/version.t b/bin/pdksh/tests/version.t
index aed94d01760..0ec6fbac7b5 100644
--- a/bin/pdksh/tests/version.t
+++ b/bin/pdksh/tests/version.t
@@ -4,5 +4,5 @@ description:
stdin:
echo $KSH_VERSION
expected-stdout:
- @(#)PD KSH v5.2.7 96/06/04
+ @(#)PD KSH v5.2.8 96/08/19
---