aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/abbr.in4
-rw-r--r--tests/abbr.out2
-rw-r--r--tests/bind.expect6
-rw-r--r--tests/commandline.expect30
-rw-r--r--tests/commandline.expect.err0
-rw-r--r--tests/commandline.expect.out8
-rw-r--r--tests/commandline.expect.status1
-rw-r--r--tests/interactive.expect.rc2
-rw-r--r--tests/string.err0
-rw-r--r--tests/string.in63
-rw-r--r--tests/string.out46
-rw-r--r--tests/string.status1
-rw-r--r--tests/test3.in6
-rw-r--r--tests/test4.in11
-rw-r--r--tests/test4.out2
-rw-r--r--tests/test8.in12
-rw-r--r--tests/test8.out4
-rw-r--r--tests/test9.in23
-rw-r--r--tests/test9.out3
19 files changed, 215 insertions, 9 deletions
diff --git a/tests/abbr.in b/tests/abbr.in
index 69fdfb38..be828b08 100644
--- a/tests/abbr.in
+++ b/tests/abbr.in
@@ -31,3 +31,7 @@ abbr -e '~__abbr2'
abbr -- '--__abbr3' 'xyz'
abbr | grep __abbr3
abbr -e '--__abbr3'
+
+# Ensure we are not recognizing later "=" as separators
+abbr d2 env a=b banana
+abbr -l | string match -q d2; or echo "= test failed"
diff --git a/tests/abbr.out b/tests/abbr.out
index b0a9d5ad..53998613 100644
--- a/tests/abbr.out
+++ b/tests/abbr.out
@@ -5,4 +5,4 @@ abbr __abbr1 delta
abbr __abbr1 delta
abbr __abbr1 delta
abbr '~__abbr2' '$xyz'
-abbr -- '--__abbr3' xyz
+abbr -- --__abbr3 xyz
diff --git a/tests/bind.expect b/tests/bind.expect
index eedc9079..42cd3409 100644
--- a/tests/bind.expect
+++ b/tests/bind.expect
@@ -18,7 +18,7 @@ expect_prompt -re {\r\nsuccess\r\n} {
puts stderr "Couldn't find expected output 'success'"
}
# try again without the human typing
-send_line "echo fail\033ddiecho success"
+send_line -h "echo fail\033ddiecho success"
expect_prompt -re {\r\nsuccess\r\n} {
puts "success"
} -nounmatched -re {\r\nfail} {
@@ -28,7 +28,7 @@ expect_prompt -re {\r\nsuccess\r\n} {
}
# Test lowercase-r replace
-send_line "\033ddiecho TEXT\033hhrAi"
+send_line -h "\033ddiecho TEXT\033hhrAi"
expect_prompt -re {\r\nTAXT\r\n} {
puts "replace success"
} -nounmatched -re {\r\nfail} {
@@ -49,7 +49,7 @@ expect_prompt -re {\r\nTENT\r\n} {
}
# still in insert mode, switch back to regular key bindings
-send_line "set -g fish_key_bindings fish_default_key_bindings"
+send_line -h "set -g fish_key_bindings fish_default_key_bindings"
expect_prompt
send_line "echo success"
expect_prompt -re {\r\nsuccess\r\n} {
diff --git a/tests/commandline.expect b/tests/commandline.expect
new file mode 100644
index 00000000..8db0c833
--- /dev/null
+++ b/tests/commandline.expect
@@ -0,0 +1,30 @@
+# vim: set filetype=expect:
+
+spawn $fish
+
+expect_prompt
+
+send_line "bind '~' 'handle_tilde'"
+expect_prompt
+
+# printing the current buffer should not remove quoting
+send_line "function handle_tilde; echo; echo '@GUARD:1@'; commandline -b; echo '@/GUARD:1@'; commandline -b ''; end"
+expect_prompt
+send_line {echo \en one "two three" four'five six'{7} 'eight~}
+expect_prompt -re {\r\n@GUARD:1@\r\n(.*)\r\n@/GUARD:1@\r\n} {
+ puts "a:"
+ puts $expect_out(1,string)
+} unmatched {
+ abort "Couldn't find guard 1"
+}
+
+# printing the buffer with -o should remove quoting
+send_line "function handle_tilde; echo; echo '@GUARD:2@'; commandline -bo; echo '@/GUARD:2@'; commandline -b ''; end"
+expect_prompt
+send_line {echo one "two three" four'five six'{7} 'eight~}
+expect_prompt -re {\r\n@GUARD:2@\r\n(.*)\r\n@/GUARD:2@\r\n} {
+ puts "b:"
+ puts [string map {\r {}} $expect_out(1,string)]
+} unmatched {
+ abort "Couldn't find guard 2"
+}
diff --git a/tests/commandline.expect.err b/tests/commandline.expect.err
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/commandline.expect.err
diff --git a/tests/commandline.expect.out b/tests/commandline.expect.out
new file mode 100644
index 00000000..ea3879a8
--- /dev/null
+++ b/tests/commandline.expect.out
@@ -0,0 +1,8 @@
+a:
+echo \en one "two three" four'five six'{7} 'eight
+b:
+echo
+one
+two three
+fourfive six{7}
+eight
diff --git a/tests/commandline.expect.status b/tests/commandline.expect.status
new file mode 100644
index 00000000..573541ac
--- /dev/null
+++ b/tests/commandline.expect.status
@@ -0,0 +1 @@
+0
diff --git a/tests/interactive.expect.rc b/tests/interactive.expect.rc
index b2a0ddbf..c148b562 100644
--- a/tests/interactive.expect.rc
+++ b/tests/interactive.expect.rc
@@ -5,7 +5,7 @@ log_file -noappend interactive.tmp.log
set fish ../fish
-set timeout 2
+set timeout 4
set send_human {.05 .1 5 .02 .2}
diff --git a/tests/string.err b/tests/string.err
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/tests/string.err
diff --git a/tests/string.in b/tests/string.in
new file mode 100644
index 00000000..1c78e2b3
--- /dev/null
+++ b/tests/string.in
@@ -0,0 +1,63 @@
+# tests for string builtin
+# mostly taken from examples
+string length 'hello, world'
+
+string length -q ""; and echo not zero length
+
+string sub --length 2 abcde
+
+string sub -s 2 -l 2 abcde
+
+string sub --start=-2 abcde
+
+string split . example.com
+
+string split -r -m1 / /usr/local/bin/fish
+
+string split '' abc
+
+seq 3 | string join ...
+
+echo ' abc '
+string trim ' abc '
+
+string trim --right --chars=yz xyzzy zany
+
+echo \x07 | string escape
+
+string match '?' a
+
+string match 'a*b' axxb
+
+string match -i 'a??B' Axxb
+
+echo 'ok?' | string match '*\?'
+
+string match -r 'cat|dog|fish' 'nice dog'
+
+string match -r '(\d\d?):(\d\d):(\d\d)' 2:34:56
+
+string match -r '^(\w{2,4})\g1$' papa mud murmur
+
+string match -r -a -n at ratatat
+
+string match -r -i '0x[0-9a-f]{1,8}' 'int magic = 0xBadC0de;'
+
+string replace is was 'blue is my favorite'
+
+string replace 3rd last 1st 2nd 3rd
+
+string replace -a ' ' _ 'spaces to underscores'
+
+string replace -r -a '[^\d.]+' ' ' '0 one two 3.14 four 5x'
+
+string replace -r '(\w+)\s+(\w+)' '$2 $1 $$' 'left right'
+
+string replace -r '\s*newline\s*' '\n' 'put a newline here'
+
+# test some failure cases
+string match -r '[' 'a[sd' 2>/dev/null; or echo "invalid expression error"
+
+string invalidarg 2>/dev/null; or echo "invalid argument error"
+
+string length 2>/dev/null; or echo "missing argument returns 0"
diff --git a/tests/string.out b/tests/string.out
new file mode 100644
index 00000000..64b956e3
--- /dev/null
+++ b/tests/string.out
@@ -0,0 +1,46 @@
+12
+ab
+bc
+de
+example
+com
+/usr/local/bin
+fish
+a
+b
+c
+1...2...3
+ abc
+abc
+x
+zan
+\cg
+a
+axxb
+Axxb
+ok?
+dog
+2:34:56
+2
+34
+56
+papa
+pa
+murmur
+mur
+2 2
+4 2
+6 2
+0xBadC0de
+blue was my favorite
+1st
+2nd
+last
+spaces_to_underscores
+0 3.14 5
+right left $
+put a
+here
+invalid expression error
+invalid argument error
+missing argument returns 0
diff --git a/tests/string.status b/tests/string.status
new file mode 100644
index 00000000..573541ac
--- /dev/null
+++ b/tests/string.status
@@ -0,0 +1 @@
+0
diff --git a/tests/test3.in b/tests/test3.in
index fe20928c..ee1b8575 100644
--- a/tests/test3.in
+++ b/tests/test3.in
@@ -151,7 +151,7 @@ end
set -Ue __fish_test_universal_variables_variable_foo
# Should no longer be in environment (#2046)
-env | sgrep __fish_test_universal_variables_variable_foo
+env | __fish_sgrep __fish_test_universal_variables_variable_foo
set -Ux __fish_test_universal_variables_variable_foo bar
set -U __fish_test_universal_variables_variable_foo baz
@@ -229,10 +229,10 @@ end
# Test that shadowing with a non-exported variable works
set -gx __fish_test_env17 UNSHADOWED
-env | sgrep __fish_test_env17
+env | __fish_sgrep __fish_test_env17
function __fish_test_shadow
set -l __fish_test_env17
- env | sgrep __fish_test_env17 ; or echo SHADOWED
+ env | __fish_sgrep __fish_test_env17 ; or echo SHADOWED
end
__fish_test_shadow
diff --git a/tests/test4.in b/tests/test4.in
index f207e6b7..6d501455 100644
--- a/tests/test4.in
+++ b/tests/test4.in
@@ -177,3 +177,14 @@ true ; set -NOT_AN_OPTION 2> /dev/null ; echo 9 $status # no passthrough
false ; set foo (echo A; true) ; echo 10 $status $foo
true ; set foo (echo B; false) ; echo 11 $status $foo
true
+
+echo "Verify set -ql behavior" # see 2502
+function setql_check
+ set -l setql_foo val
+ if set -ql setql_foo
+ echo Pass
+ else
+ echo Fail
+ end
+end
+setql_check
diff --git a/tests/test4.out b/tests/test4.out
index 148d870c..f38fa96f 100644
--- a/tests/test4.out
+++ b/tests/test4.out
@@ -34,3 +34,5 @@ Verify that set passes through exit status, except when passed -n or -q or -e
9 1
10 0 A
11 1 B
+Verify set -ql behavior
+Pass
diff --git a/tests/test8.in b/tests/test8.in
index a31ad127..5e918fbe 100644
--- a/tests/test8.in
+++ b/tests/test8.in
@@ -27,3 +27,15 @@ echo $test[1..(count $test)]
# See issue 1061
echo "Verify that if statements swallow failure"
if false ; end ; echo $status
+
+# 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
+
+# Catch this corner case, which should produce an error
+if false ; or --help ; end
diff --git a/tests/test8.out b/tests/test8.out
index 4ac13406..1e9099f8 100644
--- a/tests/test8.out
+++ b/tests/test8.out
@@ -17,3 +17,7 @@ Test more
1 2 3 4 5 6 7 8 9 10
Verify that if statements swallow failure
0
+success1
+success2
+success3
+success4
diff --git a/tests/test9.in b/tests/test9.in
index b7ca78d8..1199609b 100644
--- a/tests/test9.in
+++ b/tests/test9.in
@@ -97,6 +97,27 @@ else
echo 'psub file was deleted'
end
+if count (echo foo | psub -s .cc | grep -o '\.cc$') >/dev/null
+ echo 'psub filename ends with .cc'
+else
+ echo 'psub filename does not end with .cc'
+end
+
+if count (echo foo | psub -f -s .cc | grep -o '\.cc$') >/dev/null
+ echo 'psub filename ends with .cc'
+else
+ echo 'psub filename does not end with .cc'
+end
+
+set -l filename (echo foo | psub -s .fish)
+if test -e (dirname $filename)
+ echo 'psub directory was not deleted'
+else
+ echo 'psub directory was deleted'
+end
+
+diff -q (__fish_print_help psub | psub) (psub -hs banana | psub)
+
# Test support for unbalanced blocks
function try_unbalanced_block
../fish -c "echo $argv | source " 2>&1 | grep "Missing end" 1>&2
@@ -115,7 +136,7 @@ try_unbalanced_block 'if false'
# BOM checking (see #1518)
# But only in UTF8
-if locale | sgrep -q -i utf-8
+if locale | __fish_sgrep -q -i utf-8
echo \uFEFF"echo bom_test" | source
else
echo "echo bom_test" | source
diff --git a/tests/test9.out b/tests/test9.out
index f33c85ac..8419e697 100644
--- a/tests/test9.out
+++ b/tests/test9.out
@@ -17,6 +17,9 @@ foo
bar
baz
psub file was deleted
+psub filename ends with .cc
+psub filename ends with .cc
+psub directory was deleted
bom_test
not#a#comment
is