From 1e5d7d98a85d024204dd72bc42655316dc7a632a Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 11 Mar 2018 23:34:58 -0500 Subject: [PATCH] Add tests for new parameter expansion features --- tests/parameter_expansion.err | 0 tests/parameter_expansion.in | 34 ++++++++++++++++++++++++++++++++++ tests/parameter_expansion.out | 14 ++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/parameter_expansion.err create mode 100644 tests/parameter_expansion.in create mode 100644 tests/parameter_expansion.out diff --git a/tests/parameter_expansion.err b/tests/parameter_expansion.err new file mode 100644 index 000000000..e69de29bb diff --git a/tests/parameter_expansion.in b/tests/parameter_expansion.in new file mode 100644 index 000000000..89ba2b2d9 --- /dev/null +++ b/tests/parameter_expansion.in @@ -0,0 +1,34 @@ +# basic expansion test +echo {} +echo {apple} +echo {apple,orange} + +# expansion tests with spaces +echo {apple, orange} +echo { apple, orange, banana } + +# expansion with spaces and cartesian products +echo \'{ hello , world }\' + +# expansion with escapes +for phrase in {good\,, beautiful ,morning}; echo -n "$phrase "; end | string trim; +for phrase in {goodbye\,,\ cruel\ ,world\n}; echo -n $phrase; end; + +# whitespace within entries converted to spaces in a single entry +for foo in { hello +world } + echo \'$foo\' +end + +# dual expansion cartesian product +echo { alpha, beta }\ {lambda, gamma }, | sed -r 's/(.*),/\1/' + +# expansion with subshells +for name in { (echo Meg), (echo Jo) } + echo $name +end + +# subshells with expansion +for name in (for name in {Beth, Amy}; printf "$name\n"; end); printf "$name\n"; end + +# vim: set ft=fish: diff --git a/tests/parameter_expansion.out b/tests/parameter_expansion.out new file mode 100644 index 000000000..d89373285 --- /dev/null +++ b/tests/parameter_expansion.out @@ -0,0 +1,14 @@ +{} +apple +apple orange +apple orange +apple orange banana +'hello' 'world' +good, beautiful morning +goodbye, cruel world +'hello world' +alpha lambda, beta lambda, alpha gamma, beta gamma +Meg +Jo +Beth +Amy