summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-02-08 23:23:55 +0000
committerjilles <jilles@FreeBSD.org>2011-02-08 23:23:55 +0000
commit3b911f3790d1c9244d75217cc4572346ac0c4163 (patch)
treee15dc88f16953d770bcce460c35845e9b99c17f3 /tools
parent884b45f606279385924f4f81674e4427dba2be00 (diff)
downloadFreeBSD-src-3b911f3790d1c9244d75217cc4572346ac0c4163.zip
FreeBSD-src-3b911f3790d1c9244d75217cc4572346ac0c4163.tar.gz
sh: Add tests for new features in arithmetic.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/expansion/arith10.035
-rw-r--r--tools/regression/bin/sh/expansion/arith9.020
2 files changed, 55 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/expansion/arith10.0 b/tools/regression/bin/sh/expansion/arith10.0
new file mode 100644
index 0000000..1aaf619
--- /dev/null
+++ b/tools/regression/bin/sh/expansion/arith10.0
@@ -0,0 +1,35 @@
+# $FreeBSD$
+
+failures=0
+
+check() {
+ if [ $(($1)) != $2 ]; then
+ failures=$((failures+1))
+ echo "For $1, expected $2 actual $(($1))"
+ fi
+}
+
+readonly ro=4
+rw=1
+check "0 && 0 / 0" 0
+check "1 || 0 / 0" 1
+check "0 && (ro = 2)" 0
+check "ro" 4
+check "1 || (ro = -1)" 1
+check "ro" 4
+check "0 && (rw += 1)" 0
+check "rw" 1
+check "1 || (rw += 1)" 1
+check "rw" 1
+check "0 ? 44 / 0 : 51" 51
+check "0 ? ro = 3 : 52" 52
+check "ro" 4
+check "0 ? rw += 1 : 52" 52
+check "rw" 1
+check "1 ? 68 : 30 / 0" 68
+check "2 ? 1 : (ro += 2)" 1
+check "ro" 4
+check "4 ? 1 : (rw += 1)" 1
+check "rw" 1
+
+exit $((failures != 0))
diff --git a/tools/regression/bin/sh/expansion/arith9.0 b/tools/regression/bin/sh/expansion/arith9.0
new file mode 100644
index 0000000..cc8b597
--- /dev/null
+++ b/tools/regression/bin/sh/expansion/arith9.0
@@ -0,0 +1,20 @@
+# $FreeBSD$
+
+failures=0
+
+check() {
+ if [ $(($1)) != $2 ]; then
+ failures=$((failures+1))
+ echo "For $1, expected $2 actual $(($1))"
+ fi
+}
+
+check "0 ? 44 : 51" 51
+check "1 ? 68 : 30" 68
+check "2 ? 1 : -5" 1
+check "0 ? 4 : 0 ? 5 : 6" 6
+check "0 ? 4 : 1 ? 5 : 6" 5
+check "1 ? 4 : 0 ? 5 : 6" 4
+check "1 ? 4 : 1 ? 5 : 6" 4
+
+exit $((failures != 0))
OpenPOWER on IntegriCloud