summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2015-09-13 14:24:12 +0000
committerjilles <jilles@FreeBSD.org>2015-09-13 14:24:12 +0000
commitbc3c6d9c811a33f3915a77326c82c00f9909f43e (patch)
tree3e1766922fcb502397bb3c7891ba343de82106fd /bin
parent4c6f14a861a3f125cf0a54644a95aaa138e549db (diff)
downloadFreeBSD-src-bc3c6d9c811a33f3915a77326c82c00f9909f43e.zip
FreeBSD-src-bc3c6d9c811a33f3915a77326c82c00f9909f43e.tar.gz
MFC r268436,273243,278806,280920,286971: sh: Add various tests.
These new tests from head pass with unmodified stable/10 sh.
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/tests/expansion/Makefile4
-rw-r--r--bin/sh/tests/expansion/ifs5.04
-rw-r--r--bin/sh/tests/expansion/ifs6.06
-rw-r--r--bin/sh/tests/expansion/ifs7.05
-rw-r--r--bin/sh/tests/expansion/pathname5.03
-rw-r--r--bin/sh/tests/parameters/Makefile1
-rw-r--r--bin/sh/tests/parameters/positional3.04
-rw-r--r--bin/sh/tests/parser/Makefile4
-rw-r--r--bin/sh/tests/parser/dollar-quote12.07
-rw-r--r--bin/sh/tests/parser/line-cont1.016
-rw-r--r--bin/sh/tests/parser/line-cont2.04
-rw-r--r--bin/sh/tests/parser/line-cont3.07
12 files changed, 65 insertions, 0 deletions
diff --git a/bin/sh/tests/expansion/Makefile b/bin/sh/tests/expansion/Makefile
index 5b52efc..e62fea4 100644
--- a/bin/sh/tests/expansion/Makefile
+++ b/bin/sh/tests/expansion/Makefile
@@ -45,6 +45,9 @@ FILES+= ifs1.0
FILES+= ifs2.0
FILES+= ifs3.0
FILES+= ifs4.0
+FILES+= ifs5.0
+FILES+= ifs6.0
+FILES+= ifs7.0
FILES+= length1.0
FILES+= length2.0
FILES+= length3.0
@@ -59,6 +62,7 @@ FILES+= pathname1.0
FILES+= pathname2.0
FILES+= pathname3.0
FILES+= pathname4.0
+FILES+= pathname5.0
FILES+= plus-minus1.0
FILES+= plus-minus2.0
FILES+= plus-minus3.0
diff --git a/bin/sh/tests/expansion/ifs5.0 b/bin/sh/tests/expansion/ifs5.0
new file mode 100644
index 0000000..ab0e646
--- /dev/null
+++ b/bin/sh/tests/expansion/ifs5.0
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+set -- $(echo a b c d)
+[ "$#" = 4 ]
diff --git a/bin/sh/tests/expansion/ifs6.0 b/bin/sh/tests/expansion/ifs6.0
new file mode 100644
index 0000000..be77945
--- /dev/null
+++ b/bin/sh/tests/expansion/ifs6.0
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+IFS=': '
+x=': :'
+set -- $x
+[ "$#|$1|$2|$3" = "2|||" ]
diff --git a/bin/sh/tests/expansion/ifs7.0 b/bin/sh/tests/expansion/ifs7.0
new file mode 100644
index 0000000..0cc0834
--- /dev/null
+++ b/bin/sh/tests/expansion/ifs7.0
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+IFS=2
+set -- $((123))
+[ "$#|$1|$2|$3" = "2|1|3|" ]
diff --git a/bin/sh/tests/expansion/pathname5.0 b/bin/sh/tests/expansion/pathname5.0
new file mode 100644
index 0000000..bc27812
--- /dev/null
+++ b/bin/sh/tests/expansion/pathname5.0
@@ -0,0 +1,3 @@
+# $FreeBSD$
+
+[ `echo '/[e]tc'` = /etc ]
diff --git a/bin/sh/tests/parameters/Makefile b/bin/sh/tests/parameters/Makefile
index 982b133..e31b78f 100644
--- a/bin/sh/tests/parameters/Makefile
+++ b/bin/sh/tests/parameters/Makefile
@@ -13,6 +13,7 @@ FILES+= optind1.0
FILES+= optind2.0
FILES+= positional1.0
FILES+= positional2.0
+FILES+= positional3.0
FILES+= positional5.0
FILES+= pwd1.0
FILES+= pwd2.0
diff --git a/bin/sh/tests/parameters/positional3.0 b/bin/sh/tests/parameters/positional3.0
new file mode 100644
index 0000000..1200469
--- /dev/null
+++ b/bin/sh/tests/parameters/positional3.0
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+r=$(${SH} -c 'echo ${01:+yes}${010:+yes}' '' a '' '' '' '' '' '' '' '' b)
+[ "$r" = yesyes ]
diff --git a/bin/sh/tests/parser/Makefile b/bin/sh/tests/parser/Makefile
index 03650b1..b769a30 100644
--- a/bin/sh/tests/parser/Makefile
+++ b/bin/sh/tests/parser/Makefile
@@ -34,6 +34,7 @@ FILES+= dollar-quote8.0
FILES+= dollar-quote9.0
FILES+= dollar-quote10.0
FILES+= dollar-quote11.0
+FILES+= dollar-quote12.0
FILES+= empty-braces1.0
FILES+= empty-cmd1.0
FILES+= for1.0
@@ -52,6 +53,9 @@ FILES+= heredoc8.0
FILES+= heredoc9.0
FILES+= heredoc10.0
FILES+= heredoc11.0
+FILES+= line-cont1.0
+FILES+= line-cont2.0
+FILES+= line-cont3.0
FILES+= no-space1.0
FILES+= no-space2.0
FILES+= only-redir1.0
diff --git a/bin/sh/tests/parser/dollar-quote12.0 b/bin/sh/tests/parser/dollar-quote12.0
new file mode 100644
index 0000000..838e27c
--- /dev/null
+++ b/bin/sh/tests/parser/dollar-quote12.0
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+# \u without any digits at all remains invalid.
+# Our choice is a parse error.
+
+v=$( (eval ": \$'\u'") 2>&1 >/dev/null)
+[ $? -ne 0 ] && [ -n "$v" ]
diff --git a/bin/sh/tests/parser/line-cont1.0 b/bin/sh/tests/parser/line-cont1.0
new file mode 100644
index 0000000..7ef5eba
--- /dev/null
+++ b/bin/sh/tests/parser/line-cont1.0
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+i\
+f
+t\
+r\
+u\
+e
+t\
+h\
+e\
+n
+:
+\
+f\
+i
diff --git a/bin/sh/tests/parser/line-cont2.0 b/bin/sh/tests/parser/line-cont2.0
new file mode 100644
index 0000000..9a293fa
--- /dev/null
+++ b/bin/sh/tests/parser/line-cont2.0
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+[ "a\
+b" = ab ]
diff --git a/bin/sh/tests/parser/line-cont3.0 b/bin/sh/tests/parser/line-cont3.0
new file mode 100644
index 0000000..09d3aa8
--- /dev/null
+++ b/bin/sh/tests/parser/line-cont3.0
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+v=`printf %s 'a\
+b'`
+w="`printf %s 'c\
+d'`"
+[ "$v$w" = abcd ]
OpenPOWER on IntegriCloud