diff options
author | 2014-08-23 16:13:25 -0700 | |
---|---|---|
committer | 2014-08-23 16:13:25 -0700 | |
commit | 0b7735d279f61865718b3d84eacf60b1e9cf540f (patch) | |
tree | 1b1574b20c94f535e3aa2ec624d525a84b91eea0 /tests | |
parent | 1f3a93a3afd81d842732ba96ecf11466e5be6255 (diff) | |
parent | 2974025010cac7b7238c88c88216c1722e61f5c9 (diff) |
Merge pull request #1630 from kballard/expand_variables_in_quoted_strings
Fix various expansions issues with variables
Diffstat (limited to 'tests')
-rw-r--r-- | tests/expansion.err | 30 | ||||
-rw-r--r-- | tests/expansion.in | 82 | ||||
-rw-r--r-- | tests/expansion.out | 42 | ||||
-rw-r--r-- | tests/expansion.status | 1 | ||||
-rw-r--r-- | tests/top.out | 1 |
5 files changed, 156 insertions, 0 deletions
diff --git a/tests/expansion.err b/tests/expansion.err new file mode 100644 index 00000000..e60c203d --- /dev/null +++ b/tests/expansion.err @@ -0,0 +1,30 @@ +Array index out of bounds +fish: show "$foo[2]" + ^ +Array index out of bounds +fish: show $foo[2] + ^ +Array index out of bounds +fish: show "$foo[1 2]" + ^ +Array index out of bounds +fish: show $foo[1 2] + ^ +Array index out of bounds +fish: show "$foo[2 1]" + ^ +Array index out of bounds +fish: show $foo[2 1] + ^ +Invalid index value +fish: echo "$foo[d]" + ^ +Invalid index value +fish: echo $foo[d] + ^ +Array index out of bounds +fish: echo ()[1] + ^ +Invalid index value +fish: echo ()[d] + ^ diff --git a/tests/expansion.in b/tests/expansion.in new file mode 100644 index 00000000..a2225127 --- /dev/null +++ b/tests/expansion.in @@ -0,0 +1,82 @@ +# Test expansion of variables + +function show --description 'Prints argument count followed by arguments' + echo (count $argv) $argv +end + +set -l foo +show "$foo" +show $foo +show "prefix$foo" +show prefix$foo + +show "$$foo" +show $$foo +show "prefix$$foo" +show prefix$$foo + +set -l foo '' +show "$foo" +show $foo +show "prefix$foo" +show prefix$foo + +show "$$foo" +show $$foo +show "prefix$$foo" +show prefix$$foo + +set -l foo bar +set -l bar +show "$$foo" +show $$foo +show "prefix$$foo" +show prefix$$foo + +set -l bar baz +show "$$foo" +show $$foo +show "prefix$$foo" +show prefix$$foo + +set -l bar baz quux +show "$$foo" +show $$foo +show "prefix$$foo" +show prefix$$foo + +set -l foo bar fooer fooest +set -l fooer +set -l fooest +show "$$foo" +show $$foo +show "prefix$$foo" +show prefix$$foo + +set -l fooer '' +show $$foo +show prefix$$foo + +set -l foo bar '' fooest +show "$$foo" +show $$foo +show "prefix$$foo" +show prefix$$foo + +set -l foo +show "$foo[1]" +show $foo[1] +show "$foo[-1]" +show $foo[-1] +show "$foo[2]" +show $foo[2] +show "$foo[1 2]" +show $foo[1 2] +show "$foo[2 1]" +show $foo[2 1] + +echo "$foo[d]" +echo $foo[d] + +echo ()[1] +echo ()[d] diff --git a/tests/expansion.out b/tests/expansion.out new file mode 100644 index 00000000..fe594539 --- /dev/null +++ b/tests/expansion.out @@ -0,0 +1,42 @@ +1 +0 +1 prefix +0 +1 +0 +1 prefix +0 +1 +1 +1 prefix +1 prefix +1 +0 +1 prefix +0 +1 +0 +1 prefix +0 +1 baz +1 baz +1 prefixbaz +1 prefixbaz +1 baz quux +2 baz quux +1 prefixbaz quux +2 prefixbaz prefixquux +1 baz quux fooer fooest +2 baz quux +1 prefixbaz quux fooer fooest +2 prefixbaz prefixquux +3 baz quux +3 prefixbaz prefixquux prefix +1 baz quux fooest +2 baz quux +1 prefixbaz quux fooest +2 prefixbaz prefixquux +1 +0 +1 +0 diff --git a/tests/expansion.status b/tests/expansion.status new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/tests/expansion.status @@ -0,0 +1 @@ +0 diff --git a/tests/top.out b/tests/top.out index f2873b15..a62ec047 100644 --- a/tests/top.out +++ b/tests/top.out @@ -1,4 +1,5 @@ Testing high level script functionality +File expansion.in tested ok File printf.in tested ok File read.in tested ok File test1.in tested ok |