aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/test3.in
diff options
context:
space:
mode:
authorGravatar Jan Kanis <jan.code@jankanis.nl>2012-12-29 19:25:00 +0100
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2013-01-02 23:31:30 -0800
commit9ee7b0a5010eaf406ad3f9277b29e8fd06c3d628 (patch)
tree38f1055713fe238b242f96e3073e83d65660a922 /tests/test3.in
parent3c116f6ab3105b321c8b2e659d8fc63e315bc423 (diff)
really fix bug in export status of universal vars; add tests for that bug
Diffstat (limited to 'tests/test3.in')
-rw-r--r--tests/test3.in84
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/test3.in b/tests/test3.in
index e1594683..92cc1c86 100644
--- a/tests/test3.in
+++ b/tests/test3.in
@@ -134,3 +134,87 @@ if test $foo '=' def
else
echo Test 11 fail
end
+
+# Test combinations of export and scope
+
+set -ge foo
+
+set -Ue foo
+set -Ux foo bar
+set foo baz
+if test (/bin/sh -c 'echo $foo') = baz -a (../fish -c 'echo $foo') = baz
+ echo Test 12 pass
+else
+ echo Test 12 fail
+end
+
+set -Ue foo
+set -Ux foo bar
+set -U foo baz
+if test (/bin/sh -c 'echo $foo') = baz -a (../fish -c 'echo $foo') = baz
+ echo Test 13 pass
+else
+ echo Test 13 fail
+end
+
+set -Ux foo bar
+set -u foo bar
+if test (/bin/sh -c 'echo $foo') = '' -a (../fish -c 'echo $foo') = bar
+ echo Test 14 pass
+else
+ echo Test 14 fail
+end
+
+set -Ux foo bar
+set -Uu foo baz
+if test (/bin/sh -c 'echo $foo') = '' -a (../fish -c 'echo $foo') = baz
+ echo Test 15 pass
+else
+ echo Test 15 fail
+end
+
+set -eU foo
+
+# test erasing variables without a specified scope
+
+set -g test16res
+
+set -U foo universal
+set -g foo global
+begin
+ set -l foo blocklocal
+ function test16
+ set -l foo function
+ begin
+ set -l foo functionblock
+
+ set test16res $test16res (echo $foo)
+ set -e foo
+ set test16res $test16res (echo $foo)
+ set -e foo
+ set test16res $test16res (echo $foo)
+ set -e foo
+ set test16res $test16res (echo $foo)
+ set -e foo
+ set test16res $test16res (echo $foo)
+ end
+ set test16res $test16res (echo $foo)
+ set -e foo
+ end
+ test16
+ set test16res $test16res (echo $foo)
+end
+set test16res $test16res (echo $foo)
+
+#echo count: (count $test16res) "content:[$test16res]"
+
+if test (count $test16res) = 8 -a "$test16res" = "functionblock function global universal blocklocal "
+ echo Test 16 pass
+else
+ echo Test 16 fail
+end
+
+
+# clear foo for other shells
+set -eU foo
+true