aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2009-03-28 18:55:34 +0000
committerMike Frysinger <vapier@gentoo.org>2009-03-28 18:55:34 +0000
commit78f9d8eb7adc10f1af8977212f24ab3c418a9c2b (patch)
treed63f339b310304c2c8c116503b41f589882ba2be
parent6379bb4fde15dae3be641625e9af377eeb5a64d8 (diff)
downloadbusybox-w32-78f9d8eb7adc10f1af8977212f24ab3c418a9c2b.tar.gz
busybox-w32-78f9d8eb7adc10f1af8977212f24ab3c418a9c2b.tar.bz2
busybox-w32-78f9d8eb7adc10f1af8977212f24ab3c418a9c2b.zip
add hush tests for parameter expansion
-rw-r--r--shell/hush_test/hush-vars/param_expand_alt.right8
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_alt.tests22
-rw-r--r--shell/hush_test/hush-vars/param_expand_assign.right27
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_assign.tests38
-rw-r--r--shell/hush_test/hush-vars/param_expand_default.right8
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_default.tests22
-rw-r--r--shell/hush_test/hush-vars/param_expand_indicate_error.right29
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_indicate_error.tests40
-rw-r--r--shell/hush_test/hush-vars/param_expand_len.right4
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_len.tests12
10 files changed, 210 insertions, 0 deletions
diff --git a/shell/hush_test/hush-vars/param_expand_alt.right b/shell/hush_test/hush-vars/param_expand_alt.right
new file mode 100644
index 000000000..4d2197a5e
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_alt.right
@@ -0,0 +1,8 @@
1hush: syntax error: unterminated ${name}
2hush: syntax error: unterminated ${name}
3_0 _0
4_ _ _ _ _
5_aaaa _ _ _word _word
6_ _ _ _ _
7_ _ _ _word _
8_fff _ _ _word _word
diff --git a/shell/hush_test/hush-vars/param_expand_alt.tests b/shell/hush_test/hush-vars/param_expand_alt.tests
new file mode 100755
index 000000000..c46075b8d
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_alt.tests
@@ -0,0 +1,22 @@
1# first try some invalid patterns (do in subshell due to parsing error)
2hush -c 'echo ${+} ; echo moo'
3hush -c 'echo ${:+} ; echo moo'
4
5# now some funky ones
6echo _${#+} _${#:+}
7
8# now some valid ones
9set --
10echo _$1 _${1+} _${1:+} _${1+word} _${1:+word}
11
12set -- aaaa
13echo _$1 _${1+} _${1:+} _${1+word} _${1:+word}
14
15unset f
16echo _$f _${f+} _${f:+} _${f+word} _${f:+word}
17
18f=
19echo _$f _${f+} _${f:+} _${f+word} _${f:+word}
20
21f=fff
22echo _$f _${f+} _${f:+} _${f+word} _${f:+word}
diff --git a/shell/hush_test/hush-vars/param_expand_assign.right b/shell/hush_test/hush-vars/param_expand_assign.right
new file mode 100644
index 000000000..fff4ead33
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_assign.right
@@ -0,0 +1,27 @@
1hush: syntax error: unterminated ${name}
2hush: syntax error: unterminated ${name}
30
40
5hush: 1: special vars cannot assign in this way
6hush: 1: special vars cannot assign in this way
7hush: 1: special vars cannot assign in this way
8hush: 1: special vars cannot assign in this way
9_aa
10_aa
11_aa
12_aa
13_
14_
15_
16_word
17_word
18_
19_
20_
21_
22_word
23_fff
24_fff
25_fff
26_fff
27_fff
diff --git a/shell/hush_test/hush-vars/param_expand_assign.tests b/shell/hush_test/hush-vars/param_expand_assign.tests
new file mode 100755
index 000000000..1fba556e4
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_assign.tests
@@ -0,0 +1,38 @@
1# first try some invalid patterns (do in subshell due to parsing error)
2hush -c 'echo ${=}'
3hush -c 'echo ${:=}'
4
5# now some funky ones
6hush -c 'echo ${#=}'
7hush -c 'echo ${#:=}'
8
9# should error out
10hush -c 'set --; echo _${1=}'
11hush -c 'set --; echo _${1:=}'
12hush -c 'set --; echo _${1=word}'
13hush -c 'set --; echo _${1:=word}'
14
15# should not error
16hush -c 'set aa; echo _${1=}'
17hush -c 'set aa; echo _${1:=}'
18hush -c 'set aa; echo _${1=word}'
19hush -c 'set aa; echo _${1:=word}'
20
21# should work fine
22unset f; echo _$f
23unset f; echo _${f=}
24unset f; echo _${f:=}
25unset f; echo _${f=word}
26unset f; echo _${f:=word}
27
28f=; echo _$f
29f=; echo _${f=}
30f=; echo _${f:=}
31f=; echo _${f=word}
32f=; echo _${f:=word}
33
34f=fff; echo _$f
35f=fff; echo _${f=}
36f=fff; echo _${f:=}
37f=fff; echo _${f=word}
38f=fff; echo _${f:=word}
diff --git a/shell/hush_test/hush-vars/param_expand_default.right b/shell/hush_test/hush-vars/param_expand_default.right
new file mode 100644
index 000000000..acc717205
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_default.right
@@ -0,0 +1,8 @@
1hush: syntax error: unterminated ${name}
2hush: syntax error: unterminated ${name}
3_0 _0
4_ _ _ _word _word
5_aaaa _aaaa _aaaa _aaaa _aaaa
6_ _ _ _word _word
7_ _ _ _ _word
8_fff _fff _fff _fff _fff
diff --git a/shell/hush_test/hush-vars/param_expand_default.tests b/shell/hush_test/hush-vars/param_expand_default.tests
new file mode 100755
index 000000000..2320ece42
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_default.tests
@@ -0,0 +1,22 @@
1# first try some invalid patterns (do in subshell due to parsing error)
2hush -c 'echo ${-}'
3hush -c 'echo ${:-}'
4
5# now some funky ones
6echo _${#-} _${#:-}
7
8# now some valid ones
9set --
10echo _$1 _${1-} _${1:-} _${1-word} _${1:-word}
11
12set -- aaaa
13echo _$1 _${1-} _${1:-} _${1-word} _${1:-word}
14
15unset f
16echo _$f _${f-} _${f:-} _${f-word} _${f:-word}
17
18f=
19echo _$f _${f-} _${f:-} _${f-word} _${f:-word}
20
21f=fff
22echo _$f _${f-} _${f:-} _${f-word} _${f:-word}
diff --git a/shell/hush_test/hush-vars/param_expand_indicate_error.right b/shell/hush_test/hush-vars/param_expand_indicate_error.right
new file mode 100644
index 000000000..f440f6fae
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_indicate_error.right
@@ -0,0 +1,29 @@
1hush: syntax error: unterminated ${name}
2hush: syntax error: unterminated ${name}
30
40
5_
6hush: 1: parameter null or not set
7hush: 1: parameter null or not set
8hush: 1: word
9hush: 1: word
10_aaaa
11_aaaa
12_aaaa
13_aaaa
14_aaaa
15_
16hush: f: parameter null or not set
17hush: f: parameter null or not set
18hush: f: word
19hush: f: word
20_
21_
22hush: f: parameter null or not set
23_
24hush: f: word
25_fff
26_fff
27_fff
28_fff
29_fff
diff --git a/shell/hush_test/hush-vars/param_expand_indicate_error.tests b/shell/hush_test/hush-vars/param_expand_indicate_error.tests
new file mode 100755
index 000000000..6b431d311
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_indicate_error.tests
@@ -0,0 +1,40 @@
1# do all of these in subshells since it's supposed to error out
2
3# first try some invalid patterns
4hush -c 'echo ${?}'
5hush -c 'echo ${:?}'
6
7# then some funky ones
8hush -c 'echo ${#?}'
9hush -c 'echo ${#:?}'
10
11# now some valid ones
12hush -c 'set --; echo _$1'
13hush -c 'set --; echo _${1?}'
14hush -c 'set --; echo _${1:?}'
15hush -c 'set --; echo _${1?word}'
16hush -c 'set --; echo _${1:?word}'
17
18hush -c 'set -- aaaa; echo _$1'
19hush -c 'set -- aaaa; echo _${1?}'
20hush -c 'set -- aaaa; echo _${1:?}'
21hush -c 'set -- aaaa; echo _${1?word}'
22hush -c 'set -- aaaa; echo _${1:?word}'
23
24hush -c 'unset f; echo _$f'
25hush -c 'unset f; echo _${f?}'
26hush -c 'unset f; echo _${f:?}'
27hush -c 'unset f; echo _${f?word}'
28hush -c 'unset f; echo _${f:?word}'
29
30hush -c 'f=; echo _$f'
31hush -c 'f=; echo _${f?}'
32hush -c 'f=; echo _${f:?}'
33hush -c 'f=; echo _${f?word}'
34hush -c 'f=; echo _${f:?word}'
35
36hush -c 'f=fff; echo _$f'
37hush -c 'f=fff; echo _${f?}'
38hush -c 'f=fff; echo _${f:?}'
39hush -c 'f=fff; echo _${f?word}'
40hush -c 'f=fff; echo _${f:?word}'
diff --git a/shell/hush_test/hush-vars/param_expand_len.right b/shell/hush_test/hush-vars/param_expand_len.right
new file mode 100644
index 000000000..2d633a148
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_len.right
@@ -0,0 +1,4 @@
10 0
24 4
34 3 2 1 0 0
40 3 0
diff --git a/shell/hush_test/hush-vars/param_expand_len.tests b/shell/hush_test/hush-vars/param_expand_len.tests
new file mode 100755
index 000000000..90f47d2fb
--- /dev/null
+++ b/shell/hush_test/hush-vars/param_expand_len.tests
@@ -0,0 +1,12 @@
1# make sure len parsing doesnt break arg count
2set --
3echo $# ${#}
4set -- aaaa bbb cc d
5echo $# ${#}
6
7echo ${#1} ${#2} ${#3} ${#4} ${#5} ${#6}
8
9unset e
10f=abc
11g=
12echo ${#e} ${#f} ${#g}