mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-25 23:21:15 -03:00
Port fish_indent tests to littlecheck
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# RUN: %fish -C 'set -g fish_indent %fish_indent' %s
|
||||
# Test file for fish_indent
|
||||
# Note that littlecheck ignores leading whitespace, so we have to use {{ }} to explicitly match it.
|
||||
|
||||
echo 'echo foo \\
|
||||
| cat' | $fish_indent
|
||||
@@ -62,3 +63,245 @@ echo 'echo foo \\
|
||||
echo 'echo foo \\
|
||||
' | $fish_indent
|
||||
#CHECK: echo foo \
|
||||
|
||||
echo -n '
|
||||
begin
|
||||
echo hi
|
||||
|
||||
|
||||
end | cat | cat | begin ; echo hi ; end | begin ; begin ; echo hi ; end ; end arg
|
||||
' | $fish_indent
|
||||
|
||||
#CHECK: begin
|
||||
#CHECK: {{ }}echo hi
|
||||
#CHECK:
|
||||
#CHECK:
|
||||
#CHECK: end | cat | cat | begin
|
||||
#CHECK: {{ }}echo hi
|
||||
#CHECK: end | begin
|
||||
#CHECK: {{ }}begin
|
||||
#CHECK: {{ }}{{ }}echo hi
|
||||
#CHECK: {{ }}end
|
||||
#CHECK: end arg
|
||||
|
||||
echo -n '
|
||||
switch aloha
|
||||
|
||||
case alpha
|
||||
echo sup
|
||||
|
||||
case beta gamma
|
||||
echo hi
|
||||
|
||||
end
|
||||
' | $fish_indent
|
||||
|
||||
#CHECK: switch aloha
|
||||
#CHECK:
|
||||
#CHECK: {{ }}case alpha
|
||||
#CHECK: {{ }}{{ }}echo sup
|
||||
#CHECK:
|
||||
#CHECK: {{ }}case beta gamma
|
||||
#CHECK: {{ }}{{ }}echo hi
|
||||
#CHECK:
|
||||
#CHECK: end
|
||||
|
||||
echo -n '
|
||||
function hello_world
|
||||
|
||||
\'begin\'
|
||||
echo hi
|
||||
end | cat
|
||||
|
||||
echo sup; echo sup
|
||||
echo hello;
|
||||
|
||||
echo hello
|
||||
end
|
||||
' | $fish_indent
|
||||
|
||||
#CHECK: function hello_world
|
||||
#CHECK:
|
||||
#CHECK: {{ }}begin
|
||||
#CHECK: {{ }}{{ }}echo hi
|
||||
#CHECK: {{ }}end | cat
|
||||
#CHECK:
|
||||
#CHECK: {{ }}echo sup
|
||||
#CHECK: {{ }}echo sup
|
||||
#CHECK: {{ }}echo hello
|
||||
#CHECK:
|
||||
#CHECK: {{ }}echo hello
|
||||
#CHECK: end
|
||||
|
||||
echo -n '
|
||||
echo alpha #comment1
|
||||
#comment2
|
||||
|
||||
#comment3
|
||||
for i in abc #comment1
|
||||
#comment2
|
||||
echo hi
|
||||
end
|
||||
|
||||
switch foo #abc
|
||||
# bar
|
||||
case bar
|
||||
echo baz\
|
||||
qqq
|
||||
case "*"
|
||||
echo sup
|
||||
end' | $fish_indent
|
||||
#CHECK:
|
||||
#CHECK: echo alpha #comment1
|
||||
#CHECK: #comment2
|
||||
#CHECK:
|
||||
#CHECK: #comment3
|
||||
#CHECK: for i in abc #comment1
|
||||
#CHECK: {{ }}#comment2
|
||||
#CHECK: {{ }}echo hi
|
||||
#CHECK: end
|
||||
#CHECK:
|
||||
#CHECK: switch foo #abc
|
||||
#CHECK: {{ }}# bar
|
||||
#CHECK: {{ }}case bar
|
||||
#CHECK: {{ }}{{ }}echo baz\
|
||||
#CHECK: qqq
|
||||
#CHECK: {{ }}case "*"
|
||||
#CHECK: {{ }}{{ }}echo sup
|
||||
#CHECK: end
|
||||
|
||||
# No indent
|
||||
echo -n '
|
||||
if true
|
||||
else if false
|
||||
echo alpha
|
||||
switch beta
|
||||
case gamma
|
||||
echo delta
|
||||
end
|
||||
end
|
||||
' | $fish_indent -i
|
||||
#CHECK: if true
|
||||
#CHECK: else if false
|
||||
#CHECK: {{^}}echo alpha
|
||||
#CHECK: {{^}}switch beta
|
||||
#CHECK: {{^}}case gamma
|
||||
#CHECK: {{^}}echo delta
|
||||
#CHECK: {{^}}end
|
||||
#CHECK: end
|
||||
|
||||
# Test errors
|
||||
echo -n '
|
||||
begin
|
||||
echo hi
|
||||
else
|
||||
echo bye
|
||||
end; echo alpha "
|
||||
' | $fish_indent
|
||||
#CHECK: begin
|
||||
#CHECK: {{ }}echo hi
|
||||
#CHECK: else
|
||||
#CHECK: {{^}}echo bye
|
||||
#CHECK: end
|
||||
#CHECK: echo alpha "
|
||||
|
||||
# issue 1665
|
||||
echo -n '
|
||||
if begin ; false; end; echo hi ; end
|
||||
while begin ; false; end; echo hi ; end
|
||||
' | $fish_indent
|
||||
#CHECK: if begin
|
||||
#CHECK: {{ }}{{ }}false
|
||||
#CHECK: {{ }}end
|
||||
#CHECK: {{ }}echo hi
|
||||
#CHECK: end
|
||||
#CHECK: while begin
|
||||
#CHECK: {{ }}{{ }}false
|
||||
#CHECK: {{ }}end
|
||||
#CHECK: {{ }}echo hi
|
||||
#CHECK: end
|
||||
|
||||
# issue 2899
|
||||
echo -n '
|
||||
echo < stdin >>appended yes 2>&1 no > stdout maybe 2>& 4 | cat 2>| cat
|
||||
' | $fish_indent
|
||||
#CHECK: echo <stdin >>appended yes 2>&1 no >stdout maybe 2>&4 | cat 2>| cat
|
||||
|
||||
echo -n '
|
||||
i\
|
||||
f true
|
||||
echo yes
|
||||
en\
|
||||
d
|
||||
|
||||
"whil\
|
||||
e" true
|
||||
"builtin" yes
|
||||
en"d"
|
||||
|
||||
alpha | \
|
||||
beta
|
||||
|
||||
gamma | \
|
||||
# comment3
|
||||
delta
|
||||
|
||||
if true
|
||||
echo abc
|
||||
end
|
||||
|
||||
if false # comment4
|
||||
and true && false
|
||||
echo abc;end
|
||||
|
||||
echo hi |
|
||||
|
||||
echo bye
|
||||
' | $fish_indent
|
||||
#CHECK: i\
|
||||
#CHECK: f true
|
||||
#CHECK: {{ }}echo yes
|
||||
#CHECK: en\
|
||||
#CHECK: d
|
||||
#CHECK:
|
||||
#CHECK: while true
|
||||
#CHECK: {{ }}builtin yes
|
||||
#CHECK: end
|
||||
#CHECK:
|
||||
#CHECK: alpha | beta
|
||||
#CHECK:
|
||||
#CHECK: gamma | \
|
||||
#CHECK: # comment3
|
||||
#CHECK: delta
|
||||
#CHECK:
|
||||
#CHECK: if true
|
||||
#CHECK: {{ }}echo abc
|
||||
#CHECK: end
|
||||
#CHECK:
|
||||
#CHECK: if false # comment4
|
||||
#CHECK: {{ }}and true && false
|
||||
#CHECK: {{ }}echo abc
|
||||
#CHECK: end
|
||||
#CHECK:
|
||||
#CHECK: echo hi |
|
||||
#CHECK:
|
||||
#CHECK: echo bye
|
||||
|
||||
echo 'a;;;;;;' | $fish_indent
|
||||
#CHECK: a
|
||||
echo 'echo; echo' | $fish_indent
|
||||
#CHECK: echo
|
||||
#CHECK: echo
|
||||
|
||||
# Check that we keep semicolons for and and or, but only on the same line.
|
||||
printf '%s\n' "a; and b" | $fish_indent
|
||||
#CHECK: a; and b
|
||||
printf '%s\n' "a;" "and b" | $fish_indent
|
||||
#CHECK: a
|
||||
#CHECK: and b
|
||||
printf '%s\n' "a" "; and b" | $fish_indent
|
||||
#CHECK: a
|
||||
#CHECK: and b
|
||||
printf '%s\n' "a; b" | $fish_indent
|
||||
#CHECK: a
|
||||
#CHECK: b
|
||||
|
||||
135
tests/indent.in
135
tests/indent.in
@@ -1,135 +0,0 @@
|
||||
set -l indent ../test/root/bin/fish_indent
|
||||
|
||||
echo Test1
|
||||
echo -n '
|
||||
begin
|
||||
echo hi
|
||||
|
||||
|
||||
end | cat | cat | begin ; echo hi ; end | begin ; begin ; echo hi ; end ; end arg
|
||||
' | $indent
|
||||
|
||||
echo \nTest2
|
||||
echo -n '
|
||||
switch aloha
|
||||
|
||||
case alpha
|
||||
echo sup
|
||||
|
||||
case beta gamma
|
||||
echo hi
|
||||
|
||||
end
|
||||
' | $indent
|
||||
|
||||
echo \nTest3
|
||||
echo -n '
|
||||
function hello_world
|
||||
|
||||
'begin'
|
||||
echo hi
|
||||
end | cat
|
||||
|
||||
echo sup; echo sup
|
||||
echo hello;
|
||||
|
||||
echo hello
|
||||
end
|
||||
' | $indent
|
||||
|
||||
echo \nTest4
|
||||
echo -n '
|
||||
echo alpha #comment1
|
||||
#comment2
|
||||
|
||||
#comment3
|
||||
for i in abc #comment1
|
||||
#comment2
|
||||
echo hi
|
||||
end
|
||||
|
||||
switch foo #abc
|
||||
# bar
|
||||
case bar
|
||||
echo baz\
|
||||
qqq
|
||||
case "*"
|
||||
echo sup
|
||||
end' | $indent
|
||||
|
||||
echo \nTest5
|
||||
echo -n '
|
||||
if true
|
||||
else if false
|
||||
echo alpha
|
||||
switch beta
|
||||
case gamma
|
||||
echo delta
|
||||
end
|
||||
end
|
||||
' | $indent -i
|
||||
|
||||
echo \nTest6
|
||||
# Test errors
|
||||
echo -n '
|
||||
begin
|
||||
echo hi
|
||||
else
|
||||
echo bye
|
||||
end; echo alpha "
|
||||
' | $indent
|
||||
|
||||
echo \nTest7
|
||||
# issue 1665
|
||||
echo -n '
|
||||
if begin ; false; end; echo hi ; end
|
||||
while begin ; false; end; echo hi ; end
|
||||
' | $indent
|
||||
|
||||
echo \nTest redir formatting
|
||||
# issue 2899
|
||||
echo -n '
|
||||
echo < stdin >>appended yes 2>&1 no > stdout maybe 2>& 4 | cat 2>| cat
|
||||
' | $indent
|
||||
|
||||
echo \nTest normalization of keywords
|
||||
echo -n '
|
||||
i\
|
||||
f true
|
||||
echo yes
|
||||
en\
|
||||
d
|
||||
|
||||
"whil\
|
||||
e" true
|
||||
"builtin" yes
|
||||
en"d"
|
||||
|
||||
alpha | \
|
||||
beta
|
||||
|
||||
gamma | \
|
||||
# comment3
|
||||
delta
|
||||
|
||||
if true
|
||||
echo abc
|
||||
end
|
||||
|
||||
if false # comment4
|
||||
and true && false
|
||||
echo abc;end
|
||||
|
||||
echo hi |
|
||||
|
||||
echo bye
|
||||
' | $indent
|
||||
|
||||
echo 'a;;;;;;' | $indent
|
||||
echo 'echo; echo' | $indent
|
||||
|
||||
# Check that we keep semicolons for and and or, but only on the same line.
|
||||
printf '%s\n' "a; and b" | $indent
|
||||
printf '%s\n' "a;" "and b" | $indent
|
||||
printf '%s\n' "a" "; and b" | $indent
|
||||
printf '%s\n' "a; b" | $indent
|
||||
137
tests/indent.out
137
tests/indent.out
@@ -1,137 +0,0 @@
|
||||
Test1
|
||||
|
||||
begin
|
||||
echo hi
|
||||
|
||||
|
||||
end | cat | cat | begin
|
||||
echo hi
|
||||
end | begin
|
||||
begin
|
||||
echo hi
|
||||
end
|
||||
end arg
|
||||
|
||||
Test2
|
||||
|
||||
switch aloha
|
||||
|
||||
case alpha
|
||||
echo sup
|
||||
|
||||
case beta gamma
|
||||
echo hi
|
||||
|
||||
end
|
||||
|
||||
Test3
|
||||
|
||||
function hello_world
|
||||
|
||||
begin
|
||||
echo hi
|
||||
end | cat
|
||||
|
||||
echo sup
|
||||
echo sup
|
||||
echo hello
|
||||
|
||||
echo hello
|
||||
end
|
||||
|
||||
Test4
|
||||
|
||||
echo alpha #comment1
|
||||
#comment2
|
||||
|
||||
#comment3
|
||||
for i in abc #comment1
|
||||
#comment2
|
||||
echo hi
|
||||
end
|
||||
|
||||
switch foo #abc
|
||||
# bar
|
||||
case bar
|
||||
echo baz\
|
||||
qqq
|
||||
case "*"
|
||||
echo sup
|
||||
end
|
||||
Test5
|
||||
|
||||
if true
|
||||
else if false
|
||||
echo alpha
|
||||
switch beta
|
||||
case gamma
|
||||
echo delta
|
||||
end
|
||||
end
|
||||
|
||||
Test6
|
||||
|
||||
begin
|
||||
echo hi
|
||||
else
|
||||
echo bye
|
||||
end
|
||||
echo alpha "
|
||||
|
||||
Test7
|
||||
|
||||
if begin
|
||||
false
|
||||
end
|
||||
echo hi
|
||||
end
|
||||
while begin
|
||||
false
|
||||
end
|
||||
echo hi
|
||||
end
|
||||
|
||||
Test redir formatting
|
||||
|
||||
echo <stdin >>appended yes 2>&1 no >stdout maybe 2>&4 | cat 2>| cat
|
||||
|
||||
Test normalization of keywords
|
||||
|
||||
i\
|
||||
f true
|
||||
echo yes
|
||||
en\
|
||||
d
|
||||
|
||||
while true
|
||||
builtin yes
|
||||
end
|
||||
|
||||
alpha | beta
|
||||
|
||||
gamma | \
|
||||
# comment3
|
||||
delta
|
||||
|
||||
if true
|
||||
echo abc
|
||||
end
|
||||
|
||||
if false # comment4
|
||||
and true && false
|
||||
echo abc
|
||||
end
|
||||
|
||||
echo hi |
|
||||
|
||||
echo bye
|
||||
a
|
||||
echo
|
||||
echo
|
||||
a; and b
|
||||
a
|
||||
and b
|
||||
a
|
||||
and b
|
||||
a
|
||||
b
|
||||
Reference in New Issue
Block a user