sh: Add testcases that should not be broken by future optimizations.
authorPeter Avalos <pavalos@dragonflybsd.org>
Sun, 5 Feb 2012 20:38:57 +0000 (12:38 -0800)
committerPeter Avalos <pavalos@dragonflybsd.org>
Sun, 5 Feb 2012 20:48:29 +0000 (12:48 -0800)
Obtained-from:  FreeBSD 230121

tools/regression/bin/sh/expansion/cmdsubst12.0 [new file with mode: 0644]
tools/regression/bin/sh/expansion/cmdsubst13.0 [new file with mode: 0644]

diff --git a/tools/regression/bin/sh/expansion/cmdsubst12.0 b/tools/regression/bin/sh/expansion/cmdsubst12.0
new file mode 100644 (file)
index 0000000..3889f81
--- /dev/null
@@ -0,0 +1,6 @@
+# $FreeBSD: src/tools/regression/bin/sh/expansion/cmdsubst12.0,v 1.1 2012/01/14 23:10:18 jilles Exp $
+
+f() {
+       echo x$(printf foo >&2)y
+}
+[ "$(f 2>&1)" = "fooxy" ]
diff --git a/tools/regression/bin/sh/expansion/cmdsubst13.0 b/tools/regression/bin/sh/expansion/cmdsubst13.0
new file mode 100644 (file)
index 0000000..34298af
--- /dev/null
@@ -0,0 +1,12 @@
+# $FreeBSD: src/tools/regression/bin/sh/expansion/cmdsubst13.0,v 1.1 2012/01/14 23:10:18 jilles Exp $
+
+x=1 y=2
+[ "$(
+       case $((x+=1)) in
+       ($((y+=1)))     echo bad1 ;;
+       ($((y-1)))      echo $x.$y ;;
+       ($((y=2)))      echo bad2 ;;
+       (*)             echo bad3 ;;
+       esac
+)" = "2.3" ] || echo "Error at $LINENO"
+[ "$x.$y" = "1.2" ] || echo "Error at $LINENO"