summaryrefslogtreecommitdiff
path: root/test/reline
diff options
context:
space:
mode:
authortomoya ishida <[email protected]>2024-12-16 22:53:30 +0900
committergit <[email protected]>2024-12-16 13:53:34 +0000
commit4428c51f01638c1ce6ba8a9eb8ffea00a4c78318 (patch)
tree80b517cb30d6b578c6e9a6d3042f71814f0ad340 /test/reline
parent3c9f3c3e9b135653be9b790207c3b04a244e3db9 (diff)
[ruby/reline] Change quoted_insert and bracketed_paste to a single
key input (https://github.com/ruby/reline/pull/792) https://github.com/ruby/reline/commit/8f331edb07
Diffstat (limited to 'test/reline')
-rw-r--r--test/reline/helper.rb6
-rw-r--r--test/reline/test_key_actor_emacs.rb26
-rw-r--r--test/reline/test_key_actor_vi.rb12
3 files changed, 32 insertions, 12 deletions
diff --git a/test/reline/helper.rb b/test/reline/helper.rb
index a0c1b097e6..37a99bb18a 100644
--- a/test/reline/helper.rb
+++ b/test/reline/helper.rb
@@ -108,9 +108,9 @@ class Reline::TestCase < Test::Unit::TestCase
input
end
- def input_key_by_symbol(method_symbol, csi: false)
- dummy_char = csi ? "\e[A" : "\C-a"
- @line_editor.input_key(Reline::Key.new(dummy_char, method_symbol, false))
+ def input_key_by_symbol(method_symbol, char: nil, csi: false)
+ char ||= csi ? "\e[A" : "\C-a"
+ @line_editor.input_key(Reline::Key.new(char, method_symbol, false))
end
def input_keys(input, convert = true)
diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb
index 4aea3a6547..e52c6c2d9a 100644
--- a/test/reline/test_key_actor_emacs.rb
+++ b/test/reline/test_key_actor_emacs.rb
@@ -138,11 +138,25 @@ class Reline::KeyActor::EmacsTest < Reline::TestCase
assert_line_around_cursor("か\u3099", '')
end
+ def test_bracketed_paste_insert
+ set_line_around_cursor('A', 'Z')
+ input_key_by_symbol(:insert_multiline_text, char: "abc\n\C-abc")
+ assert_whole_lines(['Aabc', "\C-abcZ"])
+ assert_line_around_cursor("\C-abc", 'Z')
+ end
+
def test_ed_quoted_insert
- input_keys("ab\C-v\C-acd")
- assert_line_around_cursor("ab\C-acd", '')
- input_keys("\C-q\C-b")
- assert_line_around_cursor("ab\C-acd\C-b", '')
+ set_line_around_cursor('A', 'Z')
+ input_key_by_symbol(:insert_raw_char, char: "\C-a")
+ assert_line_around_cursor("A\C-a", 'Z')
+ end
+
+ def test_ed_quoted_insert_with_vi_arg
+ input_keys("a\C-[3")
+ input_key_by_symbol(:insert_raw_char, char: "\C-a")
+ input_keys("b\C-[4")
+ input_key_by_symbol(:insert_raw_char, char: '1')
+ assert_line_around_cursor("a\C-a\C-a\C-ab1111", '')
end
def test_ed_kill_line
@@ -1474,7 +1488,9 @@ class Reline::KeyActor::EmacsTest < Reline::TestCase
end
def test_ignore_NUL_by_ed_quoted_insert
- input_keys(%Q{"\C-v\C-@"}, false)
+ input_keys('"')
+ input_key_by_symbol(:insert_raw_char, char: 0.chr)
+ input_keys('"')
assert_line_around_cursor('""', '')
end
diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb
index 6d5b7e20c4..928adace2b 100644
--- a/test/reline/test_key_actor_vi.rb
+++ b/test/reline/test_key_actor_vi.rb
@@ -344,13 +344,17 @@ class Reline::ViInsertTest < Reline::TestCase
end
def test_ed_quoted_insert
- input_keys("ab\C-v\C-acd")
- assert_line_around_cursor("ab\C-acd", '')
+ input_keys('ab')
+ input_key_by_symbol(:insert_raw_char, char: "\C-a")
+ assert_line_around_cursor("ab\C-a", '')
end
def test_ed_quoted_insert_with_vi_arg
- input_keys("ab\C-[3\C-v\C-aacd")
- assert_line_around_cursor("a\C-a\C-a\C-abcd", '')
+ input_keys("ab\C-[3")
+ input_key_by_symbol(:insert_raw_char, char: "\C-a")
+ input_keys('4')
+ input_key_by_symbol(:insert_raw_char, char: '1')
+ assert_line_around_cursor("a\C-a\C-a\C-a1111", 'b')
end
def test_vi_replace_char