2014-09-19 06:45:07 +08:00
|
|
|
# vim: set filetype=expect:
|
|
|
|
spawn $fish
|
|
|
|
expect_prompt
|
|
|
|
|
2016-02-01 09:37:51 +08:00
|
|
|
# Fish should start in default-mode (i.e., emacs) bindings. The default escape
|
|
|
|
# timeout is 300ms.
|
2014-09-19 06:45:07 +08:00
|
|
|
|
2016-02-01 09:37:51 +08:00
|
|
|
# Verify the emacs transpose word (\et) behavior using various delays,
|
|
|
|
# including none, after the escape character.
|
|
|
|
|
|
|
|
# Start by testing with no delay. This should transpose the words.
|
|
|
|
send "echo abc def"
|
|
|
|
send "\033t\r"
|
|
|
|
expect_prompt -re {\r\ndef abc\r\n} {
|
|
|
|
puts "emacs transpose words, default timeout: no delay"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "emacs transpose words fail, default timeout: no delay"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now test with a delay > 0 and < the escape timeout. This should transpose
|
|
|
|
# the words.
|
|
|
|
send "echo ghi jkl"
|
|
|
|
send "\033"
|
|
|
|
sleep 0.200
|
|
|
|
send "t\r"
|
|
|
|
expect_prompt -re {\r\njkl ghi\r\n} {
|
|
|
|
puts "emacs transpose words, default timeout: short delay"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "emacs transpose words fail, default timeout: short delay"
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now test with a delay > the escape timeout. The transposition should not
|
|
|
|
# occur and the "t" should become part of the text that is echoed.
|
|
|
|
send "echo mno pqr"
|
|
|
|
send "\033"
|
|
|
|
sleep 0.400
|
|
|
|
send "t\r"
|
|
|
|
expect_prompt -re {\r\nmno pqrt\r\n} {
|
|
|
|
puts "emacs transpose words, default timeout: long delay"
|
|
|
|
} unmatched {
|
|
|
|
puts stderr "emacs transpose words fail, default timeout: long delay"
|
|
|
|
}
|
2014-09-19 06:45:07 +08:00
|
|
|
|
2016-02-01 09:37:51 +08:00
|
|
|
# Test vi key bindings.
|
|
|
|
# This should leave vi mode in the insert state.
|
2015-12-24 07:24:45 +08:00
|
|
|
send "set -g fish_key_bindings fish_vi_key_bindings\r"
|
2014-09-19 06:45:07 +08:00
|
|
|
expect_prompt
|
2016-01-24 10:24:54 +08:00
|
|
|
|
2016-02-01 09:37:51 +08:00
|
|
|
# These vi tests assume the fish_vi_key_bindings default escape timeout of
|
|
|
|
# 10ms is in effect; not the 300ms timeout for the default-mode.
|
|
|
|
#
|
2016-01-24 10:24:54 +08:00
|
|
|
# This test is only present to make the Travis-CI framework succeed
|
2016-02-01 09:37:51 +08:00
|
|
|
# consistently. It's not clear why the subsequent tests succeed without this
|
2016-01-24 10:24:54 +08:00
|
|
|
# test when executed on a local machine but not in the Travis-CI framework.
|
|
|
|
send "echo success: default escape timeout\r"
|
|
|
|
expect_prompt -re {\r\nsuccess: default escape timeout\r\n} {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts "prime vi mode, default timeout"
|
2014-09-19 06:45:07 +08:00
|
|
|
} unmatched {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts stderr "prime vi mode, default timeout"
|
2014-09-19 06:45:07 +08:00
|
|
|
}
|
2016-01-24 10:24:54 +08:00
|
|
|
|
2016-01-15 13:46:53 +08:00
|
|
|
send "echo fail: default escape timeout"
|
|
|
|
send "\033"
|
2015-12-24 07:24:45 +08:00
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
2016-02-01 09:37:51 +08:00
|
|
|
sleep 0.020
|
2016-01-15 13:46:53 +08:00
|
|
|
send "ddi"
|
|
|
|
send "echo success: default escape timeout\r"
|
|
|
|
expect_prompt -re {\r\nsuccess: default escape timeout\r\n} {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts "vi replace line, default timeout: long delay"
|
2014-09-19 06:45:07 +08:00
|
|
|
} unmatched {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts stderr "vi replace line, default timeout: long delay"
|
2014-09-19 06:45:07 +08:00
|
|
|
}
|
2015-12-24 07:24:45 +08:00
|
|
|
|
|
|
|
# Verify that a human can transpose words using \et (which is an emacs default
|
2016-02-01 09:37:51 +08:00
|
|
|
# binding but should be valid while in vi insert or normal mode).
|
2016-01-15 13:46:53 +08:00
|
|
|
send "echo abc def"
|
|
|
|
send "\033"
|
2016-02-01 09:37:51 +08:00
|
|
|
sleep 0.005
|
2015-12-24 07:24:45 +08:00
|
|
|
send "t\r"
|
|
|
|
expect_prompt -re {\r\ndef abc\r\n} {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts "vi transpose words, default timeout: short delay"
|
2014-09-19 06:45:07 +08:00
|
|
|
} unmatched {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts stderr "vi transpose words, default timeout: short delay"
|
2014-09-19 06:45:07 +08:00
|
|
|
}
|
|
|
|
|
2015-12-24 07:24:45 +08:00
|
|
|
# Test replacing a single character.
|
2016-01-15 13:46:53 +08:00
|
|
|
send "echo TEXT"
|
|
|
|
send "\033"
|
2015-12-24 07:24:45 +08:00
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
2016-02-01 09:37:51 +08:00
|
|
|
sleep 0.020
|
2016-01-15 13:46:53 +08:00
|
|
|
send "hhrAi\r"
|
2015-07-20 15:18:56 +08:00
|
|
|
expect_prompt -re {\r\nTAXT\r\n} {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts "vi mode replace char, default timeout: long delay"
|
2015-07-20 15:18:56 +08:00
|
|
|
} unmatched {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts stderr "vi mode replace char, default timeout: long delay"
|
2016-01-15 13:46:53 +08:00
|
|
|
}
|
|
|
|
|
2016-02-01 09:37:51 +08:00
|
|
|
# Verify that changing the escape timeout has an effect.
|
2016-01-15 13:46:53 +08:00
|
|
|
send "set -g fish_escape_delay_ms 100\r"
|
2016-02-05 05:56:06 +08:00
|
|
|
|
2016-01-15 13:46:53 +08:00
|
|
|
expect_prompt
|
2016-02-01 09:37:51 +08:00
|
|
|
send "echo fail: lengthened escape timeout"
|
2016-01-15 13:46:53 +08:00
|
|
|
send "\033"
|
2016-01-24 10:24:54 +08:00
|
|
|
sleep 0.150
|
2016-01-15 13:46:53 +08:00
|
|
|
send "ddi"
|
2016-02-01 09:37:51 +08:00
|
|
|
send "echo success: lengthened escape timeout\r"
|
|
|
|
expect_prompt -re {\r\nsuccess: lengthened escape timeout\r\n} {
|
|
|
|
puts "vi replace line, 100ms timeout: long delay"
|
2016-01-15 13:46:53 +08:00
|
|
|
} unmatched {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts stderr "vi replace line, 100ms timeout: long delay"
|
2016-01-15 13:46:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Verify that we don't switch to vi normal mode if we don't wait long enough
|
2016-02-01 09:37:51 +08:00
|
|
|
# after sending escape.
|
2016-01-15 13:46:53 +08:00
|
|
|
send "echo fail: no normal mode"
|
|
|
|
send "\033"
|
|
|
|
sleep 0.050
|
|
|
|
send "ddi"
|
|
|
|
send "inserted\r"
|
|
|
|
expect_prompt -re {\r\nfail: no normal modediinserted\r\n} {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts "vi replace line, 100ms timeout: short delay"
|
2015-07-20 15:18:56 +08:00
|
|
|
} unmatched {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts stderr "vi replace line, 100ms timeout: short delay"
|
2015-07-20 15:18:56 +08:00
|
|
|
}
|
|
|
|
|
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
|
2016-02-03 10:13:08 +08:00
|
|
|
send "\033"
|
2016-02-05 05:56:06 +08:00
|
|
|
sleep 0.510
|
2016-02-03 10:13:08 +08:00
|
|
|
send "ddiecho TEXT\033"
|
2016-02-05 05:56:06 +08:00
|
|
|
sleep 0.510
|
2016-02-03 10:13:08 +08:00
|
|
|
send "hhtTrN\r"
|
2015-09-04 02:20:08 +08:00
|
|
|
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'"
|
|
|
|
}
|
|
|
|
|
2015-12-24 07:24:45 +08:00
|
|
|
# Switch back to regular (emacs mode) key bindings.
|
2016-02-01 09:37:51 +08:00
|
|
|
# The custom escape timeout of 100ms set earlier should still be in effect.
|
2016-01-15 13:46:53 +08:00
|
|
|
send "set -g fish_key_bindings fish_default_key_bindings\r"
|
2014-09-19 06:45:07 +08:00
|
|
|
expect_prompt
|
2016-01-15 13:46:53 +08:00
|
|
|
|
|
|
|
# Verify the emacs transpose word (\et) behavior using various delays,
|
|
|
|
# including none, after the escape character.
|
|
|
|
|
|
|
|
# Start by testing with no delay. This should transpose the words.
|
|
|
|
send "echo abc def"
|
2016-02-01 09:37:51 +08:00
|
|
|
send "\033"
|
|
|
|
send "t\r"
|
2016-01-15 13:46:53 +08:00
|
|
|
expect_prompt -re {\r\ndef abc\r\n} {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts "emacs transpose words, 100ms timeout: no delay"
|
2016-01-15 13:46:53 +08:00
|
|
|
} unmatched {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts stderr "emacs transpose words fail, 100ms timeout: no delay"
|
2016-01-15 13:46:53 +08:00
|
|
|
}
|
|
|
|
|
2016-01-24 10:24:54 +08:00
|
|
|
|
2016-02-01 09:37:51 +08:00
|
|
|
# Same test as above but with a slight delay less than the escape timeout.
|
2016-01-15 13:46:53 +08:00
|
|
|
send "echo ghi jkl"
|
|
|
|
send "\033"
|
2016-02-01 09:37:51 +08:00
|
|
|
sleep 0.080
|
2016-01-15 13:46:53 +08:00
|
|
|
send "t\r"
|
|
|
|
expect_prompt -re {\r\njkl ghi\r\n} {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts "emacs transpose words, 100ms timeout: short delay"
|
2016-01-15 13:46:53 +08:00
|
|
|
} unmatched {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts stderr "emacs transpose words fail, 100ms timeout: short delay"
|
2016-01-15 13:46:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Now test with a delay > the escape timeout. The transposition should not
|
|
|
|
# occur and the "t" should become part of the text that is echoed.
|
|
|
|
send "echo mno pqr"
|
|
|
|
send "\033"
|
2016-02-01 09:37:51 +08:00
|
|
|
sleep 0.120
|
2016-01-15 13:46:53 +08:00
|
|
|
send "t\r"
|
|
|
|
expect_prompt -re {\r\nmno pqrt\r\n} {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts "emacs transpose words, 100ms timeout: long delay"
|
2014-09-19 06:45:07 +08:00
|
|
|
} unmatched {
|
2016-02-01 09:37:51 +08:00
|
|
|
puts stderr "emacs transpose words fail, 100ms timeout: long delay"
|
2014-09-19 06:45:07 +08:00
|
|
|
}
|