2014-09-19 06:45:07 +08:00
|
|
|
# vim: set filetype=expect:
|
|
|
|
|
|
|
|
spawn $fish
|
|
|
|
|
|
|
|
expect_prompt
|
|
|
|
|
|
|
|
# test switching key bindings
|
|
|
|
# this should leave the mode in the appropriate state
|
|
|
|
|
|
|
|
send_line "set -g fish_key_bindings fish_vi_key_bindings"
|
|
|
|
expect_prompt
|
|
|
|
send_line -h "echo fail\033ddiecho success"
|
|
|
|
expect_prompt -re {\r\nsuccess\r\n} {
|
|
|
|
puts "success"
|
|
|
|
} -nounmatched -re {\r\nfail} {
|
|
|
|
puts stderr "fail"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "Couldn't find expected output 'success'"
|
|
|
|
}
|
|
|
|
# try again without the human typing
|
2015-10-18 21:11:21 +08:00
|
|
|
send_line -h "echo fail\033ddiecho success"
|
2014-09-19 06:45:07 +08:00
|
|
|
expect_prompt -re {\r\nsuccess\r\n} {
|
|
|
|
puts "success"
|
|
|
|
} -nounmatched -re {\r\nfail} {
|
|
|
|
puts stderr "fail"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "Couldn't find expected output 'success'"
|
|
|
|
}
|
|
|
|
|
2015-07-20 15:18:56 +08:00
|
|
|
# Test lowercase-r replace
|
2015-10-18 21:11:21 +08:00
|
|
|
send_line -h "\033ddiecho TEXT\033hhrAi"
|
2015-07-20 15:18:56 +08:00
|
|
|
expect_prompt -re {\r\nTAXT\r\n} {
|
|
|
|
puts "replace success"
|
|
|
|
} -nounmatched -re {\r\nfail} {
|
|
|
|
puts stderr "replace fail"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "Couldn't find expected output 'TAXT'"
|
|
|
|
}
|
|
|
|
|
2015-09-04 02:20:08 +08:00
|
|
|
# Test 't' binding that contains non-zero arity function (forward-jump) followed
|
|
|
|
# by another function (and) https://github.com/fish-shell/fish-shell/issues/2357
|
|
|
|
send_line "\033ddiecho TEXT\033hhtTrN"
|
|
|
|
expect_prompt -re {\r\nTENT\r\n} {
|
|
|
|
puts "t-binding success"
|
|
|
|
} -nounmatched -re {\r\nfail} {
|
|
|
|
puts stderr "t-binding fail"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "Couldn't find expected output 'TENT'"
|
|
|
|
}
|
|
|
|
|
2014-09-19 06:45:07 +08:00
|
|
|
# still in insert mode, switch back to regular key bindings
|
2015-10-18 21:11:21 +08:00
|
|
|
send_line -h "set -g fish_key_bindings fish_default_key_bindings"
|
2014-09-19 06:45:07 +08:00
|
|
|
expect_prompt
|
|
|
|
send_line "echo success"
|
|
|
|
expect_prompt -re {\r\nsuccess\r\n} {
|
|
|
|
puts "success"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "Couldn't find expected output 'success'"
|
|
|
|
} timeout {
|
|
|
|
set msg ""
|
|
|
|
append msg "Timeout after setting fish_key_bindings to fish_default_key_bindings\n" \
|
|
|
|
"\$fish_bind_mode is most likely still set to 'insert'"
|
|
|
|
abort $msg
|
|
|
|
}
|