fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

NahorAdd tests to exercise all builtin error messages99d63c21f

master
1.0 KiB51 linesraw
1#RUN: fish=%fish %fish %s
2# Some tests of the "return" builtin.
3
4$fish -c 'return 5'
5echo $status
6# CHECK: 5
7
8$fish -c 'exit 5'
9echo $status
10# CHECK: 5
11
12$fish -c 'echo foo; return 2; echo bar'
13# CHECK: foo
14# but not bar
15echo $status
16# CHECK: 2
17
18begin
19    $fish -ic 'echo interactive-foo; return 69; echo interactive-bar'
20    # CHECK: interactive-foo
21    # but not bar
22    echo $status
23    # CHECK: 69
24end
25
26# Verify negative return values don't cause UB and never map to 0
27function empty_return
28    return $argv[1]
29end
30
31for i in (seq -- -550 -1)
32    empty_return $i
33    if test $status -eq 0
34        echo returning $i from a fish script maps to a $status of 0!
35    end
36end
37# CHECK:
38
39$fish -c "return 1 2"
40# CHECKERR: return: too many arguments
41# CHECKERR: Standard input (line 1):
42# CHECKERR: return 1 2
43# CHECKERR: ^
44# CHECKERR: (Type 'help return' for related documentation)
45
46$fish -c "return abc"
47# CHECKERR: return: abc: invalid integer
48# CHECKERR: Standard input (line 1):
49# CHECKERR: return abc
50# CHECKERR: ^
51# CHECKERR: (Type 'help return' for related documentation)