svn commit: r218469 - head/tools/regression/bin/sh/expansion
Jilles Tjoelker
jilles at FreeBSD.org
Tue Feb 8 23:23:55 UTC 2011
Author: jilles
Date: Tue Feb 8 23:23:55 2011
New Revision: 218469
URL: http://svn.freebsd.org/changeset/base/218469
Log:
sh: Add tests for new features in arithmetic.
Added:
head/tools/regression/bin/sh/expansion/arith10.0 (contents, props changed)
head/tools/regression/bin/sh/expansion/arith9.0 (contents, props changed)
Added: head/tools/regression/bin/sh/expansion/arith10.0
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/tools/regression/bin/sh/expansion/arith10.0 Tue Feb 8 23:23:55 2011 (r218469)
@@ -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))
Added: head/tools/regression/bin/sh/expansion/arith9.0
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/tools/regression/bin/sh/expansion/arith9.0 Tue Feb 8 23:23:55 2011 (r218469)
@@ -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))
More information about the svn-src-head
mailing list