Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Mar 2012 13:02:57 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r233116 - in stable/9/tools/regression/bin/sh: builtins expansion parameters
Message-ID:  <201203181302.q2ID2vsD020197@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sun Mar 18 13:02:56 2012
New Revision: 233116
URL: http://svn.freebsd.org/changeset/base/233116

Log:
  MFC r226892,r228007,r228873,r230121,r232839: sh: Various testcases that
  already work.

Added:
  stable/9/tools/regression/bin/sh/builtins/case11.0
     - copied unchanged from r228007, head/tools/regression/bin/sh/builtins/case11.0
  stable/9/tools/regression/bin/sh/builtins/case12.0
     - copied unchanged from r228007, head/tools/regression/bin/sh/builtins/case12.0
  stable/9/tools/regression/bin/sh/builtins/for1.0
     - copied unchanged from r226892, head/tools/regression/bin/sh/builtins/for1.0
  stable/9/tools/regression/bin/sh/expansion/arith12.0
     - copied unchanged from r232839, head/tools/regression/bin/sh/expansion/arith12.0
  stable/9/tools/regression/bin/sh/expansion/cmdsubst12.0
     - copied unchanged from r230121, head/tools/regression/bin/sh/expansion/cmdsubst12.0
  stable/9/tools/regression/bin/sh/expansion/cmdsubst13.0
     - copied unchanged from r230121, head/tools/regression/bin/sh/expansion/cmdsubst13.0
  stable/9/tools/regression/bin/sh/parameters/positional2.0
     - copied unchanged from r228873, head/tools/regression/bin/sh/parameters/positional2.0
Modified:
Directory Properties:
  stable/9/tools/regression/bin/sh/   (props changed)

Copied: stable/9/tools/regression/bin/sh/builtins/case11.0 (from r228007, head/tools/regression/bin/sh/builtins/case11.0)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/tools/regression/bin/sh/builtins/case11.0	Sun Mar 18 13:02:56 2012	(r233116, copy of r228007, head/tools/regression/bin/sh/builtins/case11.0)
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+false
+case x in
+*)
+esac

Copied: stable/9/tools/regression/bin/sh/builtins/case12.0 (from r228007, head/tools/regression/bin/sh/builtins/case12.0)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/tools/regression/bin/sh/builtins/case12.0	Sun Mar 18 13:02:56 2012	(r233116, copy of r228007, head/tools/regression/bin/sh/builtins/case12.0)
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+false
+case x in
+y)
+esac

Copied: stable/9/tools/regression/bin/sh/builtins/for1.0 (from r226892, head/tools/regression/bin/sh/builtins/for1.0)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/tools/regression/bin/sh/builtins/for1.0	Sun Mar 18 13:02:56 2012	(r233116, copy of r226892, head/tools/regression/bin/sh/builtins/for1.0)
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+false
+for i in `false`; do exit 3; done

Copied: stable/9/tools/regression/bin/sh/expansion/arith12.0 (from r232839, head/tools/regression/bin/sh/expansion/arith12.0)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/tools/regression/bin/sh/expansion/arith12.0	Sun Mar 18 13:02:56 2012	(r233116, copy of r232839, head/tools/regression/bin/sh/expansion/arith12.0)
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+_x=4 y_=5 z_z=6
+[ "$((_x*100+y_*10+z_z))" = 456 ]

Copied: stable/9/tools/regression/bin/sh/expansion/cmdsubst12.0 (from r230121, head/tools/regression/bin/sh/expansion/cmdsubst12.0)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/tools/regression/bin/sh/expansion/cmdsubst12.0	Sun Mar 18 13:02:56 2012	(r233116, copy of r230121, head/tools/regression/bin/sh/expansion/cmdsubst12.0)
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+f() {
+	echo x$(printf foo >&2)y
+}
+[ "$(f 2>&1)" = "fooxy" ]

Copied: stable/9/tools/regression/bin/sh/expansion/cmdsubst13.0 (from r230121, head/tools/regression/bin/sh/expansion/cmdsubst13.0)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/tools/regression/bin/sh/expansion/cmdsubst13.0	Sun Mar 18 13:02:56 2012	(r233116, copy of r230121, head/tools/regression/bin/sh/expansion/cmdsubst13.0)
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+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"

Copied: stable/9/tools/regression/bin/sh/parameters/positional2.0 (from r228873, head/tools/regression/bin/sh/parameters/positional2.0)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/9/tools/regression/bin/sh/parameters/positional2.0	Sun Mar 18 13:02:56 2012	(r233116, copy of r228873, head/tools/regression/bin/sh/parameters/positional2.0)
@@ -0,0 +1,65 @@
+# $FreeBSD$
+
+failures=''
+ok=''
+
+testcase() {
+	code="$1"
+	expected="$2"
+	oIFS="$IFS"
+	eval "$code"
+	IFS='|'
+	result="$#|$*"
+	IFS="$oIFS"
+	if [ "x$result" = "x$expected" ]; then
+		ok=x$ok
+	else
+		failures=x$failures
+		echo "For $code, expected $expected actual $result"
+	fi
+}
+
+testcase 'set -- a b; set -- p$@q'		'2|pa|bq'
+testcase 'set -- a b; set -- $@q'		'2|a|bq'
+testcase 'set -- a b; set -- p$@'		'2|pa|b'
+testcase 'set -- a b; set -- p$@q'		'2|pa|bq'
+testcase 'set -- a b; set -- $@q'		'2|a|bq'
+testcase 'set -- a b; set -- p$@'		'2|pa|b'
+testcase 'set -- a b; set -- p$*q'		'2|pa|bq'
+testcase 'set -- a b; set -- $*q'		'2|a|bq'
+testcase 'set -- a b; set -- p$*'		'2|pa|b'
+testcase 'set -- a b; set -- p$*q'		'2|pa|bq'
+testcase 'set -- a b; set -- $*q'		'2|a|bq'
+testcase 'set -- a b; set -- p$*'		'2|pa|b'
+testcase 'set -- a b; set -- "p$@q"'		'2|pa|bq'
+testcase 'set -- a b; set -- "$@q"'		'2|a|bq'
+testcase 'set -- a b; set -- "p$@"'		'2|pa|b'
+testcase 'set -- a b; set -- p"$@"q'		'2|pa|bq'
+testcase 'set -- a b; set -- "$@"q'		'2|a|bq'
+testcase 'set -- a b; set -- p"$@"'		'2|pa|b'
+testcase 'set -- "" a b; set -- "p$@q"'		'3|p|a|bq'
+testcase 'set -- "" a b; set -- "$@q"'		'3||a|bq'
+testcase 'set -- "" a b; set -- "p$@"'		'3|p|a|b'
+testcase 'set -- "" a b; set -- p"$@"q'		'3|p|a|bq'
+testcase 'set -- "" a b; set -- "$@"q'		'3||a|bq'
+testcase 'set -- "" a b; set -- p"$@"'		'3|p|a|b'
+testcase 'set -- a; set -- p$@q'		'1|paq'
+testcase 'set -- a; set -- $@q'			'1|aq'
+testcase 'set -- a; set -- p$@'			'1|pa'
+testcase 'set -- a; set -- p$@q'		'1|paq'
+testcase 'set -- a; set -- $@q'			'1|aq'
+testcase 'set -- a; set -- p$@'			'1|pa'
+testcase 'set -- a; set -- p$*q'		'1|paq'
+testcase 'set -- a; set -- $*q'			'1|aq'
+testcase 'set -- a; set -- p$*'			'1|pa'
+testcase 'set -- a; set -- p$*q'		'1|paq'
+testcase 'set -- a; set -- $*q'			'1|aq'
+testcase 'set -- a; set -- p$*'			'1|pa'
+testcase 'set -- a; set -- "p$@q"'		'1|paq'
+testcase 'set -- a; set -- "$@q"'		'1|aq'
+testcase 'set -- a; set -- "p$@"'		'1|pa'
+testcase 'set -- a; set -- p"$@"q'		'1|paq'
+testcase 'set -- a; set -- "$@"q'		'1|aq'
+testcase 'set -- a; set -- p"$@"'		'1|pa'
+
+test "x$failures" = x



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203181302.q2ID2vsD020197>