2019-05-05 10:51:49 +00:00
|
|
|
set -l indent ../test/root/bin/fish_indent
|
|
|
|
|
2014-12-23 23:46:47 +00:00
|
|
|
echo Test1
|
|
|
|
echo -n '
|
|
|
|
begin
|
|
|
|
echo hi
|
|
|
|
|
|
|
|
|
|
|
|
end | cat | cat | begin ; echo hi ; end | begin ; begin ; echo hi ; end ; end arg
|
2019-05-05 10:51:49 +00:00
|
|
|
' | $indent
|
2014-12-23 23:46:47 +00:00
|
|
|
|
|
|
|
echo \nTest2
|
|
|
|
echo -n '
|
|
|
|
switch aloha
|
|
|
|
|
|
|
|
case alpha
|
|
|
|
echo sup
|
|
|
|
|
|
|
|
case beta gamma
|
|
|
|
echo hi
|
|
|
|
|
|
|
|
end
|
2019-05-05 10:51:49 +00:00
|
|
|
' | $indent
|
2014-12-23 23:46:47 +00:00
|
|
|
|
|
|
|
echo \nTest3
|
|
|
|
echo -n '
|
|
|
|
function hello_world
|
|
|
|
|
|
|
|
'begin'
|
|
|
|
echo hi
|
|
|
|
end | cat
|
|
|
|
|
|
|
|
echo sup; echo sup
|
|
|
|
echo hello;
|
|
|
|
|
|
|
|
echo hello
|
2016-02-07 02:08:22 +00:00
|
|
|
end
|
2019-05-05 10:51:49 +00:00
|
|
|
' | $indent
|
2014-12-23 23:46:47 +00:00
|
|
|
|
|
|
|
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
|
2019-05-05 10:51:49 +00:00
|
|
|
end' | $indent
|
2014-12-23 23:46:47 +00:00
|
|
|
|
|
|
|
echo \nTest5
|
|
|
|
echo -n '
|
|
|
|
if true
|
|
|
|
else if false
|
|
|
|
echo alpha
|
|
|
|
switch beta
|
|
|
|
case gamma
|
|
|
|
echo delta
|
|
|
|
end
|
|
|
|
end
|
2019-05-05 10:51:49 +00:00
|
|
|
' | $indent -i
|
2014-12-23 23:46:47 +00:00
|
|
|
|
|
|
|
echo \nTest6
|
|
|
|
# Test errors
|
|
|
|
echo -n '
|
|
|
|
begin
|
|
|
|
echo hi
|
|
|
|
else
|
|
|
|
echo bye
|
|
|
|
end; echo alpha "
|
2019-05-05 10:51:49 +00:00
|
|
|
' | $indent
|
2014-12-24 00:30:39 +00:00
|
|
|
|
|
|
|
echo \nTest7
|
|
|
|
# issue 1665
|
|
|
|
echo -n '
|
|
|
|
if begin ; false; end; echo hi ; end
|
|
|
|
while begin ; false; end; echo hi ; end
|
2019-05-05 10:51:49 +00:00
|
|
|
' | $indent
|
2016-04-05 22:43:24 +00:00
|
|
|
|
|
|
|
echo \nTest redir formatting
|
|
|
|
# issue 2899
|
|
|
|
echo -n '
|
|
|
|
echo < stdin >>appended yes 2>&1 no > stdout maybe 2>& 4 | cat 2>| cat
|
2019-05-05 10:51:49 +00:00
|
|
|
' | $indent
|
2016-04-10 01:56:13 +00:00
|
|
|
|
|
|
|
echo \nTest normalization of keywords
|
|
|
|
# issue 2921
|
|
|
|
echo -n '
|
|
|
|
i\
|
|
|
|
f true
|
|
|
|
echo yes
|
|
|
|
en\
|
|
|
|
d
|
|
|
|
|
|
|
|
"whil\
|
|
|
|
e" true
|
|
|
|
"builtin" yes
|
|
|
|
en"d"
|
2018-05-07 22:52:04 +00:00
|
|
|
|
|
|
|
alpha | \
|
|
|
|
beta
|
|
|
|
|
|
|
|
gamma | \
|
|
|
|
# comment3
|
|
|
|
delta
|
|
|
|
|
|
|
|
if true
|
|
|
|
echo abc
|
|
|
|
end
|
|
|
|
|
|
|
|
if false # comment4
|
|
|
|
and true && false
|
|
|
|
echo abc;end
|
|
|
|
|
|
|
|
echo hi |
|
|
|
|
|
|
|
|
echo bye
|
2019-05-05 10:51:49 +00:00
|
|
|
' | $indent
|
|
|
|
|
|
|
|
echo 'a;;;;;;' | $indent
|
|
|
|
echo 'echo; echo' | $indent
|
2019-05-03 17:00:55 +00:00
|
|
|
|
2019-05-05 10:51:49 +00:00
|
|
|
# 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
|