Port test8 to littlecheck

This one tests a bunch of separate stuff, so we put it into a few
different files.

The main, new one is "slices.fish", which tests various index expressions.
This commit is contained in:
Fabian Homborg 2020-02-08 15:37:10 +01:00
parent 22edf3213f
commit ee8ca246f8
7 changed files with 62 additions and 117 deletions

View File

@ -7,3 +7,16 @@ eval 'true | and'
eval 'true | or'
# CHECKERR: {{.*}}: The 'or' command can not be used in a pipeline
# Verify and/or behavior with if and while
if false ; or true ; echo "success1" ; end
# CHECK: success1
if false ; and false ; echo "failure1" ; end
while false ; and false ; or true ; echo "success2"; break ; end
# CHECK: success2
while false; or begin ; false; or true; end; echo "success3"; break ; end
# CHECK: success3
if false ; else if false ; and true ; else if false ; and false ; else if false; or true; echo "success4"; end
# CHECK: success4
if false ; else if false ; and true ; else if false ; or false ; else if false; echo "failure 4"; end
if false ; or true | false ; echo "failure5" ; end

View File

@ -78,3 +78,15 @@ false
while false; end
echo "Empty Loop Status: $status"
#CHECK: Empty Loop Status: 0
# Loop control in conditions, should have no output.
for i in 1 2 3
while break; end
echo $i
end
for i in 1 2 3
while continue; end
echo $i
end
if false ; or --help ; end

33
tests/checks/slices.fish Normal file
View File

@ -0,0 +1,33 @@
#RUN: %fish %s
set n 10
set test (seq $n)
echo $test[1..$n] # normal range
#CHECK: 1 2 3 4 5 6 7 8 9 10
echo $test[$n..1] # inverted range
#CHECK: 10 9 8 7 6 5 4 3 2 1
echo $test[2..5 8..6] # several ranges
#CHECK: 2 3 4 5 8 7 6
echo $test[-1..-2] # range with negative limits
#CHECK: 10 9
echo $test[-1..1] # range with mixed limits
#CHECK: 10 9 8 7 6 5 4 3 2 1
set test1 $test
set test1[-1..1] $test; echo $test1
#CHECK: 10 9 8 7 6 5 4 3 2 1
set test1[1..$n] $test; echo $test1
#CHECK: 1 2 3 4 5 6 7 8 9 10
set test1[$n..1] $test; echo $test1
#CHECK: 10 9 8 7 6 5 4 3 2 1
set test1[2..4 -2..-4] $test1[4..2 -4..-2]; echo $test1
#CHECK: 10 7 8 9 6 5 2 3 4 1
echo (seq 5)[-1..1]
#CHECK: 5 4 3 2 1
echo (seq $n)[3..5 -2..2]
#CHECK: 3 4 5 9 8 7 6 5 4 3 2
echo $test[(count $test)..1]
#CHECK: 10 9 8 7 6 5 4 3 2 1
echo $test[1..(count $test)]
#CHECK: 1 2 3 4 5 6 7 8 9 10

View File

@ -70,3 +70,7 @@ end
false; echo_last; echo $status #1
#CHECK: 1
#CHECK: 0
# Verify that if swallows failure - see #1061
if false ; end ; echo $status
#CHECK: 0

View File

@ -1,24 +0,0 @@
####################
# Test variable expand
####################
# Test variable set
####################
# Test using slices of command substitution
####################
# Test more
####################
# Verify that if statements swallow failure
####################
# Verify and/or behavior with if and while statements
####################
# Catch this corner case, which should produce an error
####################
# Loop control in conditions

View File

@ -1,51 +0,0 @@
# Test index ranges
logmsg Test variable expand
set n 10
set test (seq $n)
echo $test[1..$n] # normal range
echo $test[$n..1] # inverted range
echo $test[2..5 8..6] # several ranges
echo $test[-1..-2] # range with negative limits
echo $test[-1..1] # range with mixed limits
logmsg Test variable set
set test1 $test
set test1[-1..1] $test; echo $test1
set test1[1..$n] $test; echo $test1
set test1[$n..1] $test; echo $test1
set test1[2..4 -2..-4] $test1[4..2 -4..-2]; echo $test1
logmsg Test using slices of command substitution
echo (seq 5)[-1..1]
echo (seq $n)[3..5 -2..2]
logmsg Test more
echo $test[(count $test)..1]
echo $test[1..(count $test)]
# See issue 1061
logmsg Verify that if statements swallow failure
if false ; end ; echo $status
logmsg Verify and/or behavior with if and while statements
if false ; or true ; echo "success1" ; end
if false ; and false ; echo "failure1" ; end
while false ; and false ; or true ; echo "success2"; break ; end
while false; or begin ; false; or true; end; echo "success3"; break ; end
if false ; else if false ; and true ; else if false ; and false ; else if false; or true; echo "success4"; end
if false ; else if false ; and true ; else if false ; or false ; else if false; echo "failure 4"; end
if false ; or true | false ; echo "failure5" ; end
logmsg Catch this corner case, which should produce an error
if false ; or --help ; end
logmsg Loop control in conditions
for i in 1 2 3
while break; end
echo $i
end
for i in 1 2 3
while continue; end
echo $i
end

View File

@ -1,42 +0,0 @@
####################
# Test variable expand
1 2 3 4 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1
2 3 4 5 8 7 6
10 9
10 9 8 7 6 5 4 3 2 1
####################
# Test variable set
10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10
10 9 8 7 6 5 4 3 2 1
10 7 8 9 6 5 2 3 4 1
####################
# Test using slices of command substitution
5 4 3 2 1
3 4 5 9 8 7 6 5 4 3 2
####################
# Test more
10 9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9 10
####################
# Verify that if statements swallow failure
0
####################
# Verify and/or behavior with if and while statements
success1
success2
success3
success4
####################
# Catch this corner case, which should produce an error
####################
# Loop control in conditions