mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-22 18:27:57 +08:00
Port while test to littlecheck
And we're gonna add more loop stuff, so port it to a file called "loop.fish"
This commit is contained in:
parent
0ddbd8d318
commit
6daab9c41f
@ -1,4 +1,4 @@
|
|||||||
# vim: set ft=fish:
|
#RUN: %fish %s
|
||||||
|
|
||||||
function never_runs
|
function never_runs
|
||||||
while false
|
while false
|
||||||
@ -17,16 +17,17 @@ function runs_once
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# this should return 1
|
# this should return 0
|
||||||
never_runs; echo "Empty Loop in Function: $status"
|
never_runs; echo "Empty Loop in Function: $status"
|
||||||
|
#CHECK: Empty Loop in Function: 0
|
||||||
|
|
||||||
# this should return 0
|
# this should return 0
|
||||||
runs_once; echo "Runs Once: $status"
|
runs_once; echo "Runs Once: $status"
|
||||||
|
#CHECK: Runs Once: 0
|
||||||
|
|
||||||
# this should return 2
|
# this should return 2
|
||||||
early_return; echo "Early Return: $status"
|
early_return; echo "Early Return: $status"
|
||||||
|
#CHECK: Early Return: 2
|
||||||
logmsg Loops exit status handling
|
|
||||||
|
|
||||||
function set_status ; return $argv[1]; end
|
function set_status ; return $argv[1]; end
|
||||||
|
|
||||||
@ -41,6 +42,7 @@ while begin
|
|||||||
end
|
end
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
#CHECK: Condition Status: 36
|
||||||
|
|
||||||
# The condition status IS visible in the loop body.
|
# The condition status IS visible in the loop body.
|
||||||
set_status 55
|
set_status 55
|
||||||
@ -48,6 +50,7 @@ while true
|
|||||||
echo "Body Status: $status"
|
echo "Body Status: $status"
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
#CHECK: Body Status: 0
|
||||||
|
|
||||||
# The status of the last command is visible in the loop condition
|
# The status of the last command is visible in the loop condition
|
||||||
set_status 13
|
set_status 13
|
||||||
@ -58,6 +61,8 @@ while begin
|
|||||||
end
|
end
|
||||||
set_status 5
|
set_status 5
|
||||||
end
|
end
|
||||||
|
#CHECK: Condition 2 Status: 13
|
||||||
|
#CHECK: Condition 2 Status: 5
|
||||||
|
|
||||||
# The status of the last command is visible outside the loop
|
# The status of the last command is visible outside the loop
|
||||||
set rem 5 7 11
|
set rem 5 7 11
|
||||||
@ -66,8 +71,10 @@ while [ (count $rem) -gt 0 ]
|
|||||||
set rem $rem[2..-1]
|
set rem $rem[2..-1]
|
||||||
end
|
end
|
||||||
echo "Loop Exit Status: $status"
|
echo "Loop Exit Status: $status"
|
||||||
|
#CHECK: Loop Exit Status: 11
|
||||||
|
|
||||||
# Empty loops succeed.
|
# Empty loops succeed.
|
||||||
false
|
false
|
||||||
while false; end
|
while false; end
|
||||||
echo "Empty Loop Status: $status"
|
echo "Empty Loop Status: $status"
|
||||||
|
#CHECK: Empty Loop Status: 0
|
@ -1,3 +0,0 @@
|
|||||||
|
|
||||||
####################
|
|
||||||
# Loops exit status handling
|
|
@ -1,12 +0,0 @@
|
|||||||
Empty Loop in Function: 0
|
|
||||||
Runs Once: 0
|
|
||||||
Early Return: 2
|
|
||||||
|
|
||||||
####################
|
|
||||||
# Loops exit status handling
|
|
||||||
Condition Status: 36
|
|
||||||
Body Status: 0
|
|
||||||
Condition 2 Status: 13
|
|
||||||
Condition 2 Status: 5
|
|
||||||
Loop Exit Status: 11
|
|
||||||
Empty Loop Status: 0
|
|
Loading…
x
Reference in New Issue
Block a user