2013-06-16 23:26:43 -07:00
# ensure that builtins that produce no output can still truncate files
# (bug PCA almost reintroduced!)
echo "Testing that builtins can truncate files"
echo abc > /tmp/file_truncation_test.txt
cat /tmp/file_truncation_test.txt
echo -n > /tmp/file_truncation_test.txt
cat /tmp/file_truncation_test.txt
2012-12-19 15:56:19 +01:00
# Test events.
2013-06-16 23:26:43 -07:00
2012-12-19 15:56:19 +01:00
# This pattern caused a crash; github issue #449
set -g var before
function test1 --on-event test
set -g var $var:test1
functions -e test2
end
function test2 --on-event test
# this should not run, as test2 gets removed before it has a chance of running
set -g var $var:test2a
end
emit test
echo $var
function test3 --on-event test3
echo received event test3 with args: $argv
end
emit test3 foo bar
2012-12-22 18:38:28 +01:00
# test empty argument
2013-06-16 23:26:43 -07:00
emit
2013-12-28 22:52:06 -08:00
echo "Test break and continue"
# This should output Ping once
for i in a b c
if not contains $i c ; continue ; end
echo Ping
end
# This should output Pong not at all
for i in a b c
if not contains $i c ; break ; end
echo Pong
end
# This should output Foop three times, and Boop not at all
set i a a a
while contains $i a
set -e i[-1]
echo Foop
continue
echo Boop
end
# This should output Doop once
set i a a a
while contains $i a
set -e i[-1]
echo Doop
break
echo Darp
end
2013-12-29 16:23:26 -08:00
# Test implicit cd. This should do nothing.
./
2013-12-28 22:52:06 -08:00
2014-02-21 18:20:51 -08:00
# Test special for loop expansion
# Here we the name of the variable is derived from another variable
echo "Testing for loop"
set var1 var2
for $var1 in 1 2 3
echo -n $var2
end
echo
2014-03-01 16:04:13 -08:00
# Test status -n
eval 'status -n
status -n
status -n'
2014-04-02 00:32:08 -07:00
# Test psub
cat (echo foo | psub)
cat (echo bar | psub)
cat (echo baz | psub)
2013-12-28 22:52:06 -08:00
false