aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/function.in
diff options
context:
space:
mode:
Diffstat (limited to 'tests/function.in')
-rw-r--r--tests/function.in32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/function.in b/tests/function.in
new file mode 100644
index 00000000..e533b25b
--- /dev/null
+++ b/tests/function.in
@@ -0,0 +1,32 @@
+# vim: set filetype=fish:
+#
+# Test the `function` builtin
+
+# utility function
+function show_ary -a name --no-scope-shadowing
+ set -l count (count $$name)
+ echo "\$$name: ($count)"
+ if test $count -gt 0
+ for i in (seq $count)
+ echo "$i: '$$name[1][$i]'"
+ end
+ end
+end
+
+# Test the -V flag
+set -g foo 'global foo'
+set -l foo 'local foo'
+set bar one 'two 2' \t '' 3
+set baz
+function frob -V foo -V bar -V baz
+ show_ary foo
+ show_ary bar
+ show_ary baz
+end
+echo "Testing -V"
+frob
+echo "Testing -V with changed variables"
+set foo 'bad foo'
+set bar 'bad bar'
+set baz 'bad baz'
+frob