Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

sh: Add some testcases for pasting $*/$@ directly to a literal.

Obtained-from:  FreeBSD 228873
  • Loading branch information...
commit 88a45a953ab275fdb8c3164e4897ace06781a9ae 1 parent e532fd9
authored December 25, 2011
65  tools/regression/bin/sh/parameters/positional2.0
... ...
@@ -0,0 +1,65 @@
  1
+# $FreeBSD: src/tools/regression/bin/sh/parameters/positional2.0,v 1.1 2011/12/25 13:24:48 jilles Exp $
  2
+
  3
+failures=''
  4
+ok=''
  5
+
  6
+testcase() {
  7
+	code="$1"
  8
+	expected="$2"
  9
+	oIFS="$IFS"
  10
+	eval "$code"
  11
+	IFS='|'
  12
+	result="$#|$*"
  13
+	IFS="$oIFS"
  14
+	if [ "x$result" = "x$expected" ]; then
  15
+		ok=x$ok
  16
+	else
  17
+		failures=x$failures
  18
+		echo "For $code, expected $expected actual $result"
  19
+	fi
  20
+}
  21
+
  22
+testcase 'set -- a b; set -- p$@q'		'2|pa|bq'
  23
+testcase 'set -- a b; set -- $@q'		'2|a|bq'
  24
+testcase 'set -- a b; set -- p$@'		'2|pa|b'
  25
+testcase 'set -- a b; set -- p$@q'		'2|pa|bq'
  26
+testcase 'set -- a b; set -- $@q'		'2|a|bq'
  27
+testcase 'set -- a b; set -- p$@'		'2|pa|b'
  28
+testcase 'set -- a b; set -- p$*q'		'2|pa|bq'
  29
+testcase 'set -- a b; set -- $*q'		'2|a|bq'
  30
+testcase 'set -- a b; set -- p$*'		'2|pa|b'
  31
+testcase 'set -- a b; set -- p$*q'		'2|pa|bq'
  32
+testcase 'set -- a b; set -- $*q'		'2|a|bq'
  33
+testcase 'set -- a b; set -- p$*'		'2|pa|b'
  34
+testcase 'set -- a b; set -- "p$@q"'		'2|pa|bq'
  35
+testcase 'set -- a b; set -- "$@q"'		'2|a|bq'
  36
+testcase 'set -- a b; set -- "p$@"'		'2|pa|b'
  37
+testcase 'set -- a b; set -- p"$@"q'		'2|pa|bq'
  38
+testcase 'set -- a b; set -- "$@"q'		'2|a|bq'
  39
+testcase 'set -- a b; set -- p"$@"'		'2|pa|b'
  40
+testcase 'set -- "" a b; set -- "p$@q"'		'3|p|a|bq'
  41
+testcase 'set -- "" a b; set -- "$@q"'		'3||a|bq'
  42
+testcase 'set -- "" a b; set -- "p$@"'		'3|p|a|b'
  43
+testcase 'set -- "" a b; set -- p"$@"q'		'3|p|a|bq'
  44
+testcase 'set -- "" a b; set -- "$@"q'		'3||a|bq'
  45
+testcase 'set -- "" a b; set -- p"$@"'		'3|p|a|b'
  46
+testcase 'set -- a; set -- p$@q'		'1|paq'
  47
+testcase 'set -- a; set -- $@q'			'1|aq'
  48
+testcase 'set -- a; set -- p$@'			'1|pa'
  49
+testcase 'set -- a; set -- p$@q'		'1|paq'
  50
+testcase 'set -- a; set -- $@q'			'1|aq'
  51
+testcase 'set -- a; set -- p$@'			'1|pa'
  52
+testcase 'set -- a; set -- p$*q'		'1|paq'
  53
+testcase 'set -- a; set -- $*q'			'1|aq'
  54
+testcase 'set -- a; set -- p$*'			'1|pa'
  55
+testcase 'set -- a; set -- p$*q'		'1|paq'
  56
+testcase 'set -- a; set -- $*q'			'1|aq'
  57
+testcase 'set -- a; set -- p$*'			'1|pa'
  58
+testcase 'set -- a; set -- "p$@q"'		'1|paq'
  59
+testcase 'set -- a; set -- "$@q"'		'1|aq'
  60
+testcase 'set -- a; set -- "p$@"'		'1|pa'
  61
+testcase 'set -- a; set -- p"$@"q'		'1|paq'
  62
+testcase 'set -- a; set -- "$@"q'		'1|aq'
  63
+testcase 'set -- a; set -- p"$@"'		'1|pa'
  64
+
  65
+test "x$failures" = x

0 notes on commit 88a45a9

Please sign in to comment.
Something went wrong with that request. Please try again.