mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-02 05:41:16 -03:00
Port "test4" to littlecheck
It has to do with scoping, so call it "scoping.fish".
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
logmsg Test scoping rules for functions
|
||||
#RUN: %fish %s
|
||||
# Test scoping rules for functions and status
|
||||
|
||||
set -e smurf
|
||||
|
||||
@@ -19,7 +20,9 @@ set smurf blue; unsetter; if test $smurf = blue; echo Test 2 pass; else; echo Te
|
||||
end
|
||||
|
||||
call1
|
||||
#CHECK: Test 1 pass
|
||||
call2
|
||||
#CHECK: Test 2 pass
|
||||
|
||||
function call3
|
||||
setter; if test $smurf = green; echo Test 3 pass; else; echo Test 3 fail; end
|
||||
@@ -31,7 +34,9 @@ end
|
||||
|
||||
set -g smurf yellow
|
||||
call3
|
||||
#CHECK: Test 3 pass
|
||||
call4
|
||||
#CHECK: Test 4 pass
|
||||
|
||||
set -l foo 1
|
||||
set -g bar 2
|
||||
@@ -44,18 +49,21 @@ if test $status -ne 0
|
||||
else
|
||||
echo Test 5 pass
|
||||
end;
|
||||
#CHECK: Test 5 pass
|
||||
|
||||
if not set -g -q bar
|
||||
echo Test 6 fail
|
||||
else
|
||||
echo Test 6 pass
|
||||
end;
|
||||
#CHECK: Test 6 pass
|
||||
|
||||
if not set -U -q baz
|
||||
echo Test 7 fail
|
||||
else
|
||||
echo Test 7 pass
|
||||
end;
|
||||
#CHECK: Test 7 pass
|
||||
|
||||
set -u -l -q foo
|
||||
if test $status -ne 0
|
||||
@@ -64,18 +72,21 @@ else
|
||||
echo Test 8 pass
|
||||
|
||||
end;
|
||||
#CHECK: Test 8 pass
|
||||
|
||||
if not set -u -g -q bar
|
||||
echo Test 9 fail
|
||||
else
|
||||
echo Test 9 pass
|
||||
end;
|
||||
#CHECK: Test 9 pass
|
||||
|
||||
if not set -u -U -q baz
|
||||
echo Test 10 fail
|
||||
else
|
||||
echo Test 10 pass
|
||||
end;
|
||||
#CHECK: Test 10 pass
|
||||
|
||||
set -x -l -q foo
|
||||
if test $status -eq 0
|
||||
@@ -83,18 +94,21 @@ if test $status -eq 0
|
||||
else
|
||||
echo Test 11 pass
|
||||
end;
|
||||
#CHECK: Test 11 pass
|
||||
|
||||
if set -x -g -q bar
|
||||
echo Test 12 fail
|
||||
else
|
||||
echo Test 12 pass
|
||||
end;
|
||||
#CHECK: Test 12 pass
|
||||
|
||||
if set -x -U -q baz
|
||||
echo Test 13 fail
|
||||
else
|
||||
echo Test 13 pass
|
||||
end;
|
||||
#CHECK: Test 13 pass
|
||||
|
||||
set -x -l foo 1
|
||||
set -x -g bar 2
|
||||
@@ -106,12 +120,14 @@ if test $status -ne 0
|
||||
else
|
||||
echo Test 14 pass
|
||||
end;
|
||||
#CHECK: Test 14 pass
|
||||
|
||||
if not set -g -q bar
|
||||
echo Test 15 fail
|
||||
else
|
||||
echo Test 15 pass
|
||||
end;
|
||||
#CHECK: Test 15 pass
|
||||
|
||||
if not set -U -q baz
|
||||
echo Test 16 fail
|
||||
@@ -119,6 +135,7 @@ else
|
||||
echo Test 16 pass
|
||||
|
||||
end;
|
||||
#CHECK: Test 16 pass
|
||||
|
||||
set -u -l -q foo
|
||||
if test $status -ne 1
|
||||
@@ -126,12 +143,14 @@ if test $status -ne 1
|
||||
else
|
||||
echo Test 17 pass
|
||||
end;
|
||||
#CHECK: Test 17 pass
|
||||
|
||||
if set -u -g -q bar
|
||||
echo Test 18 fail
|
||||
else
|
||||
echo Test 18 pass
|
||||
end;
|
||||
#CHECK: Test 18 pass
|
||||
|
||||
if set -u -U -q baz
|
||||
echo Test 19 fail
|
||||
@@ -139,6 +158,7 @@ else
|
||||
echo Test 19 pass
|
||||
|
||||
end;
|
||||
#CHECK: Test 19 pass
|
||||
|
||||
set -x -l -q foo
|
||||
if test $status -ne 0
|
||||
@@ -146,39 +166,53 @@ if test $status -ne 0
|
||||
else
|
||||
echo Test 20 pass
|
||||
end;
|
||||
#CHECK: Test 20 pass
|
||||
|
||||
if not set -x -g -q bar
|
||||
echo Test 21 fail
|
||||
else
|
||||
echo Test 21 pass
|
||||
end;
|
||||
#CHECK: Test 21 pass
|
||||
|
||||
if not set -x -U -q baz
|
||||
echo Test 22 fail
|
||||
else
|
||||
echo Test 22 pass
|
||||
end;
|
||||
#CHECK: Test 22 pass
|
||||
|
||||
set -U -e baz
|
||||
|
||||
logmsg Verify subcommand statuses
|
||||
# Verify subcommand statuses
|
||||
echo (false) $status (true) $status (false) $status
|
||||
#CHECK: 1 0 1
|
||||
|
||||
logmsg Verify that set passes through exit status, except when passed -n or -q or -e
|
||||
# Verify that set passes through exit status, except when passed -n or -q or -e
|
||||
false ; set foo bar ; echo 1 $status # passthrough
|
||||
#CHECK: 1 1
|
||||
true ; set foo bar ; echo 2 $status # passthrough
|
||||
#CHECK: 2 0
|
||||
false ; set -q foo ; echo 3 $status # no passthrough
|
||||
#CHECK: 3 0
|
||||
true ; set -q foo ; echo 4 $status # no passthrough
|
||||
#CHECK: 4 0
|
||||
false ; set -n > /dev/null ; echo 5 $status # no passthrough
|
||||
#CHECK: 5 0
|
||||
false ; set -e foo ; echo 6 $status # no passthrough
|
||||
#CHECK: 6 0
|
||||
true ; set -e foo ; echo 7 $status # no passthrough
|
||||
#CHECK: 7 4
|
||||
false ; set -h > /dev/null ; echo 8 $status # no passthrough
|
||||
#CHECK: 8 0
|
||||
true ; set -NOT_AN_OPTION 2> /dev/null ; echo 9 $status # no passthrough
|
||||
#CHECK: 9 2
|
||||
false ; set foo (echo A; true) ; echo 10 $status $foo
|
||||
#CHECK: 10 0 A
|
||||
true ; set foo (echo B; false) ; echo 11 $status $foo
|
||||
#CHECK: 11 1 B
|
||||
true
|
||||
|
||||
logmsg "Verify set -ql behavior (#2502)"
|
||||
function setql_check
|
||||
set -l setql_foo val
|
||||
if set -ql setql_foo
|
||||
@@ -188,3 +222,4 @@ function setql_check
|
||||
end
|
||||
end
|
||||
setql_check
|
||||
#CHECK: Pass
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
####################
|
||||
# Test scoping rules for functions
|
||||
|
||||
####################
|
||||
# Verify subcommand statuses
|
||||
|
||||
####################
|
||||
# Verify that set passes through exit status, except when passed -n or -q or -e
|
||||
|
||||
####################
|
||||
# Verify set -ql behavior (#2502)
|
||||
@@ -1,47 +0,0 @@
|
||||
|
||||
####################
|
||||
# Test scoping rules for functions
|
||||
Test 1 pass
|
||||
Test 2 pass
|
||||
Test 3 pass
|
||||
Test 4 pass
|
||||
Test 5 pass
|
||||
Test 6 pass
|
||||
Test 7 pass
|
||||
Test 8 pass
|
||||
Test 9 pass
|
||||
Test 10 pass
|
||||
Test 11 pass
|
||||
Test 12 pass
|
||||
Test 13 pass
|
||||
Test 14 pass
|
||||
Test 15 pass
|
||||
Test 16 pass
|
||||
Test 17 pass
|
||||
Test 18 pass
|
||||
Test 19 pass
|
||||
Test 20 pass
|
||||
Test 21 pass
|
||||
Test 22 pass
|
||||
|
||||
####################
|
||||
# Verify subcommand statuses
|
||||
1 0 1
|
||||
|
||||
####################
|
||||
# Verify that set passes through exit status, except when passed -n or -q or -e
|
||||
1 1
|
||||
2 0
|
||||
3 0
|
||||
4 0
|
||||
5 0
|
||||
6 0
|
||||
7 4
|
||||
8 0
|
||||
9 2
|
||||
10 0 A
|
||||
11 1 B
|
||||
|
||||
####################
|
||||
# Verify set -ql behavior (#2502)
|
||||
Pass
|
||||
Reference in New Issue
Block a user