svn commit: r206167 - head/tools/regression/bin/sh/expansion

Jilles Tjoelker jilles at FreeBSD.org
Sun Apr 4 16:29:49 UTC 2010


Author: jilles
Date: Sun Apr  4 16:29:48 2010
New Revision: 206167
URL: http://svn.freebsd.org/changeset/base/206167

Log:
  sh: Add test for some associativity in arithmetic.

Added:
  head/tools/regression/bin/sh/expansion/arith4.0   (contents, props changed)

Added: head/tools/regression/bin/sh/expansion/arith4.0
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/tools/regression/bin/sh/expansion/arith4.0	Sun Apr  4 16:29:48 2010	(r206167)
@@ -0,0 +1,20 @@
+# $FreeBSD$
+
+failures=0
+
+check() {
+	if [ $(($1)) != $2 ]; then
+		failures=$((failures+1))
+		echo "For $1, expected $2 actual $(($1))"
+	fi
+}
+
+check '20 / 2 / 2' 5
+check '20 - 2 - 2' 16
+unset a b c d
+check "a = b = c = d = 1" 1
+check "a == 1 && b == 1 && c == 1 && d == 1" 1
+check "a += b += c += d" 4
+check "a == 4 && b == 3 && c == 2 && d == 1" 1
+
+exit $((failures != 0))


More information about the svn-src-all mailing list