From 873af68d1ad9d3d06697b1285a87bf4112aa486d Mon Sep 17 00:00:00 2001 From: tompng Date: Thu, 2 Jan 2025 01:52:18 +0900 Subject: [PATCH 1/5] Remove invalid encoding string "\M-[char]" from test code, remove unused code/arg/options --- test/reline/helper.rb | 40 +- test/reline/test_key_actor_emacs.rb | 624 ++++++++++++++-------------- test/reline/test_key_actor_vi.rb | 16 +- 3 files changed, 332 insertions(+), 348 deletions(-) diff --git a/test/reline/helper.rb b/test/reline/helper.rb index 37a99bb18a..552c21778f 100644 --- a/test/reline/helper.rb +++ b/test/reline/helper.rb @@ -86,26 +86,18 @@ def test_rubybin end class Reline::TestCase < Test::Unit::TestCase - private def convert_str(input, options = {}, normalized = nil) + private def convert_str(input) return nil if input.nil? - input = input.chars.map { |c| - if Reline::Unicode::EscapedChars.include?(c.ord) - c - else - c.encode(@line_editor.encoding, Encoding::UTF_8, **options) - end - }.join - rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError - if unicode?(input.encoding) - input = input.unicode_normalize(:nfc) - if normalized - options[:undef] = :replace - options[:replace] = '?' - end - normalized = true - retry + input.encode(@line_editor.encoding, Encoding::UTF_8) + rescue Encoding::UndefinedConversionError + return input unless unicode?(input.encoding) + + input = input.unicode_normalize(:nfc) + begin + input.encode(@line_editor.encoding, Encoding::UTF_8) + rescue Encoding::UndefinedConversionError + input.encode(@line_editor.encoding, Encoding::UTF_8, undef: :replace, replace: '?') end - input end def input_key_by_symbol(method_symbol, char: nil, csi: false) @@ -113,17 +105,9 @@ def input_key_by_symbol(method_symbol, char: nil, csi: false) @line_editor.input_key(Reline::Key.new(char, method_symbol, false)) end - def input_keys(input, convert = true) - # Reline does not support convert-meta, but test data includes \M-char. It should be converted to ESC+char. - # Note that mixing unicode chars and \M-char is not recommended. "\M-C\M-\C-A" is a single unicode character. - input = input.chars.map do |c| - c.valid_encoding? ? c : "\e#{(c.bytes[0] & 0x7f).chr}" - end.join - input_raw_keys(input, convert) - end + def input_keys(input) + input = convert_str(input) - def input_raw_keys(input, convert = true) - input = convert_str(input) if convert key_stroke = Reline::KeyStroke.new(@config, @encoding) input_bytes = input.bytes until input_bytes.empty? diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index 190a41d735..7db62b89e2 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -50,11 +50,11 @@ def test_ed_insert_for_plural_mbchar_by_plural_code_points def test_move_next_and_prev input_keys('abd') assert_line_around_cursor('abd', '') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('ab', 'd') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('a', 'bd') - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor('ab', 'd') input_keys('c') assert_line_around_cursor('abc', 'd') @@ -63,11 +63,11 @@ def test_move_next_and_prev def test_move_next_and_prev_for_mbchar input_keys('かきけ') assert_line_around_cursor('かきけ', '') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('かき', 'け') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('か', 'きけ') - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor('かき', 'け') input_keys('く') assert_line_around_cursor('かきく', 'け') @@ -76,11 +76,11 @@ def test_move_next_and_prev_for_mbchar def test_move_next_and_prev_for_mbchar_by_plural_code_points input_keys("か\u3099き\u3099け\u3099") assert_line_around_cursor("か\u3099き\u3099け\u3099", '') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor("か\u3099き\u3099", "け\u3099") - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor("か\u3099", "き\u3099け\u3099") - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor("か\u3099き\u3099", "け\u3099") input_keys("く\u3099") assert_line_around_cursor("か\u3099き\u3099く\u3099", "け\u3099") @@ -89,11 +89,11 @@ def test_move_next_and_prev_for_mbchar_by_plural_code_points def test_move_to_beg_end input_keys('bcd') assert_line_around_cursor('bcd', '') - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', 'bcd') input_keys('a') assert_line_around_cursor('a', 'bcd') - input_keys("\C-e", false) + input_keys("\C-e") assert_line_around_cursor('abcd', '') input_keys('e') assert_line_around_cursor('abcde', '') @@ -103,7 +103,7 @@ def test_ed_newline_with_cr input_keys('ab') assert_line_around_cursor('ab', '') refute(@line_editor.finished?) - input_keys("\C-m", false) + input_keys("\C-m") assert_line_around_cursor('ab', '') assert(@line_editor.finished?) end @@ -112,7 +112,7 @@ def test_ed_newline_with_lf input_keys('ab') assert_line_around_cursor('ab', '') refute(@line_editor.finished?) - input_keys("\C-j", false) + input_keys("\C-j") assert_line_around_cursor('ab', '') assert(@line_editor.finished?) end @@ -120,21 +120,21 @@ def test_ed_newline_with_lf def test_em_delete_prev_char input_keys('ab') assert_line_around_cursor('ab', '') - input_keys("\C-h", false) + input_keys("\C-h") assert_line_around_cursor('a', '') end def test_em_delete_prev_char_for_mbchar input_keys('かき') assert_line_around_cursor('かき', '') - input_keys("\C-h", false) + input_keys("\C-h") assert_line_around_cursor('か', '') end def test_em_delete_prev_char_for_mbchar_by_plural_code_points input_keys("か\u3099き\u3099") assert_line_around_cursor("か\u3099き\u3099", '') - input_keys("\C-h", false) + input_keys("\C-h") assert_line_around_cursor("か\u3099", '') end @@ -160,13 +160,13 @@ def test_ed_quoted_insert_with_vi_arg end def test_ed_kill_line - input_keys("\C-k", false) + input_keys("\C-k") assert_line_around_cursor('', '') input_keys('abc') assert_line_around_cursor('abc', '') - input_keys("\C-k", false) + input_keys("\C-k") assert_line_around_cursor('abc', '') - input_keys("\C-b\C-k", false) + input_keys("\C-b\C-k") assert_line_around_cursor('ab', '') end @@ -177,11 +177,11 @@ def test_em_kill_line input_key_by_symbol(:em_kill_line) assert_line_around_cursor('', '') input_keys('abc') - input_keys("\C-b", false) + input_keys("\C-b") input_key_by_symbol(:em_kill_line) assert_line_around_cursor('', '') input_keys('abc') - input_keys("\C-a", false) + input_keys("\C-a") input_key_by_symbol(:em_kill_line) assert_line_around_cursor('', '') end @@ -189,19 +189,19 @@ def test_em_kill_line def test_ed_move_to_beg input_keys('abd') assert_line_around_cursor('abd', '') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('ab', 'd') input_keys('c') assert_line_around_cursor('abc', 'd') - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', 'abcd') input_keys('012') assert_line_around_cursor('012', 'abcd') - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', '012abcd') input_keys('ABC') assert_line_around_cursor('ABC', '012abcd') - input_keys("\C-f" * 10 + "\C-a", false) + input_keys("\C-f" * 10 + "\C-a") assert_line_around_cursor('', 'ABC012abcd') input_keys('a') assert_line_around_cursor('a', 'ABC012abcd') @@ -210,26 +210,26 @@ def test_ed_move_to_beg def test_ed_move_to_beg_with_blank input_keys(' abc') assert_line_around_cursor(' abc', '') - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', ' abc') end def test_ed_move_to_end input_keys('abd') assert_line_around_cursor('abd', '') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('ab', 'd') input_keys('c') assert_line_around_cursor('abc', 'd') - input_keys("\C-e", false) + input_keys("\C-e") assert_line_around_cursor('abcd', '') input_keys('012') assert_line_around_cursor('abcd012', '') - input_keys("\C-e", false) + input_keys("\C-e") assert_line_around_cursor('abcd012', '') input_keys('ABC') assert_line_around_cursor('abcd012ABC', '') - input_keys("\C-b" * 10 + "\C-e", false) + input_keys("\C-b" * 10 + "\C-e") assert_line_around_cursor('abcd012ABC', '') input_keys('a') assert_line_around_cursor('abcd012ABCa', '') @@ -238,27 +238,27 @@ def test_ed_move_to_end def test_em_delete input_keys('ab') assert_line_around_cursor('ab', '') - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', 'ab') - input_keys("\C-d", false) + input_keys("\C-d") assert_line_around_cursor('', 'b') end def test_em_delete_for_mbchar input_keys('かき') assert_line_around_cursor('かき', '') - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', 'かき') - input_keys("\C-d", false) + input_keys("\C-d") assert_line_around_cursor('', 'き') end def test_em_delete_for_mbchar_by_plural_code_points input_keys("か\u3099き\u3099") assert_line_around_cursor("か\u3099き\u3099", '') - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', "か\u3099き\u3099") - input_keys("\C-d", false) + input_keys("\C-d") assert_line_around_cursor('', "き\u3099") end @@ -270,16 +270,16 @@ def test_em_delete_ends_editing def test_ed_clear_screen @line_editor.instance_variable_get(:@rendered_screen).lines = [[]] - input_keys("\C-l", false) + input_keys("\C-l") assert_empty(@line_editor.instance_variable_get(:@rendered_screen).lines) end def test_ed_clear_screen_with_inputted input_keys('abc') - input_keys("\C-b", false) + input_keys("\C-b") @line_editor.instance_variable_get(:@rendered_screen).lines = [[]] assert_line_around_cursor('ab', 'c') - input_keys("\C-l", false) + input_keys("\C-l") assert_empty(@line_editor.instance_variable_get(:@rendered_screen).lines) assert_line_around_cursor('ab', 'c') end @@ -299,7 +299,7 @@ def test_key_delete_does_not_end_editing def test_key_delete_preserves_cursor input_keys('abc') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('ab', 'c') input_key_by_symbol(:key_delete) assert_line_around_cursor('ab', '') @@ -308,289 +308,289 @@ def test_key_delete_preserves_cursor def test_em_next_word assert_line_around_cursor('', '') input_keys('abc def{bbb}ccc') - input_keys("\C-a\M-F", false) + input_keys("\C-a\eF") assert_line_around_cursor('abc', ' def{bbb}ccc') - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor('abc def', '{bbb}ccc') - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor('abc def{bbb', '}ccc') - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor('abc def{bbb}ccc', '') - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor('abc def{bbb}ccc', '') end def test_em_next_word_for_mbchar assert_line_around_cursor('', '') input_keys('あいう かきく{さしす}たちつ') - input_keys("\C-a\M-F", false) + input_keys("\C-a\eF") assert_line_around_cursor('あいう', ' かきく{さしす}たちつ') - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor('あいう かきく', '{さしす}たちつ') - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor('あいう かきく{さしす', '}たちつ') - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor('あいう かきく{さしす}たちつ', '') - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor('あいう かきく{さしす}たちつ', '') end def test_em_next_word_for_mbchar_by_plural_code_points assert_line_around_cursor("", "") input_keys("あいう か\u3099き\u3099く\u3099{さしす}たちつ") - input_keys("\C-a\M-F", false) + input_keys("\C-a\eF") assert_line_around_cursor("あいう", " か\u3099き\u3099く\u3099{さしす}たちつ") - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099", "{さしす}たちつ") - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{さしす", "}たちつ") - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{さしす}たちつ", "") - input_keys("\M-F", false) + input_keys("\eF") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{さしす}たちつ", "") end def test_em_prev_word input_keys('abc def{bbb}ccc') assert_line_around_cursor('abc def{bbb}ccc', '') - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor('abc def{bbb}', 'ccc') - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor('abc def{', 'bbb}ccc') - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor('abc ', 'def{bbb}ccc') - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor('', 'abc def{bbb}ccc') - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor('', 'abc def{bbb}ccc') end def test_em_prev_word_for_mbchar input_keys('あいう かきく{さしす}たちつ') assert_line_around_cursor('あいう かきく{さしす}たちつ', '') - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor('あいう かきく{さしす}', 'たちつ') - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor('あいう かきく{', 'さしす}たちつ') - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor('あいう ', 'かきく{さしす}たちつ') - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor('', 'あいう かきく{さしす}たちつ') - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor('', 'あいう かきく{さしす}たちつ') end def test_em_prev_word_for_mbchar_by_plural_code_points input_keys("あいう か\u3099き\u3099く\u3099{さしす}たちつ") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{さしす}たちつ", "") - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{さしす}", "たちつ") - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{", "さしす}たちつ") - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor("あいう ", "か\u3099き\u3099く\u3099{さしす}たちつ") - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor("", "あいう か\u3099き\u3099く\u3099{さしす}たちつ") - input_keys("\M-B", false) + input_keys("\eB") assert_line_around_cursor("", "あいう か\u3099き\u3099く\u3099{さしす}たちつ") end def test_em_delete_next_word input_keys('abc def{bbb}ccc') - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', 'abc def{bbb}ccc') - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', ' def{bbb}ccc') - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', '{bbb}ccc') - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', '}ccc') - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', '') end def test_em_delete_next_word_for_mbchar input_keys('あいう かきく{さしす}たちつ') - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', 'あいう かきく{さしす}たちつ') - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', ' かきく{さしす}たちつ') - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', '{さしす}たちつ') - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', '}たちつ') - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', '') end def test_em_delete_next_word_for_mbchar_by_plural_code_points input_keys("あいう か\u3099き\u3099く\u3099{さしす}たちつ") - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', "あいう か\u3099き\u3099く\u3099{さしす}たちつ") - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', " か\u3099き\u3099く\u3099{さしす}たちつ") - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', '{さしす}たちつ') - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', '}たちつ') - input_keys("\M-d", false) + input_keys("\ed") assert_line_around_cursor('', '') end def test_ed_delete_prev_word input_keys('abc def{bbb}ccc') assert_line_around_cursor('abc def{bbb}ccc', '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor('abc def{bbb}', '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor('abc def{', '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor('abc ', '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor('', '') end def test_ed_delete_prev_word_for_mbchar input_keys('あいう かきく{さしす}たちつ') assert_line_around_cursor('あいう かきく{さしす}たちつ', '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor('あいう かきく{さしす}', '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor('あいう かきく{', '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor('あいう ', '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor('', '') end def test_ed_delete_prev_word_for_mbchar_by_plural_code_points input_keys("あいう か\u3099き\u3099く\u3099{さしす}たちつ") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{さしす}たちつ", '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{さしす}", '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{", '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor('あいう ', '') - input_keys("\M-\C-H", false) + input_keys("\e\C-H") assert_line_around_cursor('', '') end def test_ed_transpose_chars input_keys('abc') - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', 'abc') - input_keys("\C-t", false) + input_keys("\C-t") assert_line_around_cursor('', 'abc') - input_keys("\C-f\C-t", false) + input_keys("\C-f\C-t") assert_line_around_cursor('ba', 'c') - input_keys("\C-t", false) + input_keys("\C-t") assert_line_around_cursor('bca', '') - input_keys("\C-t", false) + input_keys("\C-t") assert_line_around_cursor('bac', '') end def test_ed_transpose_chars_for_mbchar input_keys('あかさ') - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', 'あかさ') - input_keys("\C-t", false) + input_keys("\C-t") assert_line_around_cursor('', 'あかさ') - input_keys("\C-f\C-t", false) + input_keys("\C-f\C-t") assert_line_around_cursor('かあ', 'さ') - input_keys("\C-t", false) + input_keys("\C-t") assert_line_around_cursor('かさあ', '') - input_keys("\C-t", false) + input_keys("\C-t") assert_line_around_cursor('かあさ', '') end def test_ed_transpose_chars_for_mbchar_by_plural_code_points input_keys("あか\u3099さ") - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', "あか\u3099さ") - input_keys("\C-t", false) + input_keys("\C-t") assert_line_around_cursor('', "あか\u3099さ") - input_keys("\C-f\C-t", false) + input_keys("\C-f\C-t") assert_line_around_cursor("か\u3099あ", 'さ') - input_keys("\C-t", false) + input_keys("\C-t") assert_line_around_cursor("か\u3099さあ", '') - input_keys("\C-t", false) + input_keys("\C-t") assert_line_around_cursor("か\u3099あさ", '') end def test_ed_transpose_words input_keys('abc def') assert_line_around_cursor('abc def', '') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor('def abc', '') - input_keys("\C-a\C-k", false) + input_keys("\C-a\C-k") input_keys(' abc def ') - input_keys("\C-b" * 4, false) + input_keys("\C-b" * 4) assert_line_around_cursor(' abc de', 'f ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor(' def abc', ' ') - input_keys("\C-a\C-k", false) + input_keys("\C-a\C-k") input_keys(' abc def ') - input_keys("\C-b" * 6, false) + input_keys("\C-b" * 6) assert_line_around_cursor(' abc ', 'def ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor(' def abc', ' ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor(' abc def', '') end def test_ed_transpose_words_for_mbchar input_keys('あいう かきく') assert_line_around_cursor('あいう かきく', '') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor('かきく あいう', '') - input_keys("\C-a\C-k", false) + input_keys("\C-a\C-k") input_keys(' あいう かきく ') - input_keys("\C-b" * 4, false) + input_keys("\C-b" * 4) assert_line_around_cursor(' あいう かき', 'く ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor(' かきく あいう', ' ') - input_keys("\C-a\C-k", false) + input_keys("\C-a\C-k") input_keys(' あいう かきく ') - input_keys("\C-b" * 6, false) + input_keys("\C-b" * 6) assert_line_around_cursor(' あいう ', 'かきく ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor(' かきく あいう', ' ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor(' あいう かきく', '') end def test_ed_transpose_words_with_one_word input_keys('abc ') assert_line_around_cursor('abc ', '') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor('abc ', '') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('abc ', ' ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor('abc ', ' ') - input_keys("\C-b" * 2, false) + input_keys("\C-b" * 2) assert_line_around_cursor('ab', 'c ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor('ab', 'c ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor('ab', 'c ') end def test_ed_transpose_words_with_one_word_for_mbchar input_keys('あいう ') assert_line_around_cursor('あいう ', '') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor('あいう ', '') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('あいう ', ' ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor('あいう ', ' ') - input_keys("\C-b" * 2, false) + input_keys("\C-b" * 2) assert_line_around_cursor('あい', 'う ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor('あい', 'う ') - input_keys("\M-t", false) + input_keys("\et") assert_line_around_cursor('あい', 'う ') end @@ -602,129 +602,129 @@ def test_ed_digit def test_ed_next_and_prev_char input_keys('abc') assert_line_around_cursor('abc', '') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('ab', 'c') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('a', 'bc') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('', 'abc') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('', 'abc') - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor('a', 'bc') - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor('ab', 'c') - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor('abc', '') - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor('abc', '') end def test_ed_next_and_prev_char_for_mbchar input_keys('あいう') assert_line_around_cursor('あいう', '') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('あい', 'う') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('あ', 'いう') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('', 'あいう') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('', 'あいう') - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor('あ', 'いう') - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor('あい', 'う') - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor('あいう', '') - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor('あいう', '') end def test_ed_next_and_prev_char_for_mbchar_by_plural_code_points input_keys("か\u3099き\u3099く\u3099") assert_line_around_cursor("か\u3099き\u3099く\u3099", '') - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor("か\u3099き\u3099", "く\u3099") - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor("か\u3099", "き\u3099く\u3099") - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('', "か\u3099き\u3099く\u3099") - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('', "か\u3099き\u3099く\u3099") - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor("か\u3099", "き\u3099く\u3099") - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor("か\u3099き\u3099", "く\u3099") - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor("か\u3099き\u3099く\u3099", '') - input_keys("\C-f", false) + input_keys("\C-f") assert_line_around_cursor("か\u3099き\u3099く\u3099", '') end def test_em_capitol_case input_keys('abc def{bbb}ccc') - input_keys("\C-a\M-c", false) + input_keys("\C-a\ec") assert_line_around_cursor('Abc', ' def{bbb}ccc') - input_keys("\M-c", false) + input_keys("\ec") assert_line_around_cursor('Abc Def', '{bbb}ccc') - input_keys("\M-c", false) + input_keys("\ec") assert_line_around_cursor('Abc Def{Bbb', '}ccc') - input_keys("\M-c", false) + input_keys("\ec") assert_line_around_cursor('Abc Def{Bbb}Ccc', '') end def test_em_capitol_case_with_complex_example input_keys('{}#* AaA!!!cCc ') - input_keys("\C-a\M-c", false) + input_keys("\C-a\ec") assert_line_around_cursor('{}#* Aaa', '!!!cCc ') - input_keys("\M-c", false) + input_keys("\ec") assert_line_around_cursor('{}#* Aaa!!!Ccc', ' ') - input_keys("\M-c", false) + input_keys("\ec") assert_line_around_cursor('{}#* Aaa!!!Ccc ', '') end def test_em_lower_case input_keys('AbC def{bBb}CCC') - input_keys("\C-a\M-l", false) + input_keys("\C-a\el") assert_line_around_cursor('abc', ' def{bBb}CCC') - input_keys("\M-l", false) + input_keys("\el") assert_line_around_cursor('abc def', '{bBb}CCC') - input_keys("\M-l", false) + input_keys("\el") assert_line_around_cursor('abc def{bbb', '}CCC') - input_keys("\M-l", false) + input_keys("\el") assert_line_around_cursor('abc def{bbb}ccc', '') end def test_em_lower_case_with_complex_example input_keys('{}#* AaA!!!cCc ') - input_keys("\C-a\M-l", false) + input_keys("\C-a\el") assert_line_around_cursor('{}#* aaa', '!!!cCc ') - input_keys("\M-l", false) + input_keys("\el") assert_line_around_cursor('{}#* aaa!!!ccc', ' ') - input_keys("\M-l", false) + input_keys("\el") assert_line_around_cursor('{}#* aaa!!!ccc ', '') end def test_em_upper_case input_keys('AbC def{bBb}CCC') - input_keys("\C-a\M-u", false) + input_keys("\C-a\eu") assert_line_around_cursor('ABC', ' def{bBb}CCC') - input_keys("\M-u", false) + input_keys("\eu") assert_line_around_cursor('ABC DEF', '{bBb}CCC') - input_keys("\M-u", false) + input_keys("\eu") assert_line_around_cursor('ABC DEF{BBB', '}CCC') - input_keys("\M-u", false) + input_keys("\eu") assert_line_around_cursor('ABC DEF{BBB}CCC', '') end def test_em_upper_case_with_complex_example input_keys('{}#* AaA!!!cCc ') - input_keys("\C-a\M-u", false) + input_keys("\C-a\eu") assert_line_around_cursor('{}#* AAA', '!!!cCc ') - input_keys("\M-u", false) + input_keys("\eu") assert_line_around_cursor('{}#* AAA!!!CCC', ' ') - input_keys("\M-u", false) + input_keys("\eu") assert_line_around_cursor('{}#* AAA!!!CCC ', '') end @@ -742,7 +742,7 @@ def test_em_delete_or_list input_keys('fooo') assert_line_around_cursor('fooo', '') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) - input_keys("\C-b", false) + input_keys("\C-b") assert_line_around_cursor('foo', 'o') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) input_key_by_symbol(:em_delete_or_list) @@ -766,10 +766,10 @@ def test_completion_duplicated_list input_keys('foo_') assert_line_around_cursor('foo_', '') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_', '') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_', '') assert_equal(%w{foo_foo foo_bar}, @line_editor.instance_variable_get(:@menu_info).list) end @@ -788,28 +788,28 @@ def test_completion input_keys('fo') assert_line_around_cursor('fo', '') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_', '') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_', '') assert_equal(%w{foo_foo foo_bar foo_baz}, @line_editor.instance_variable_get(:@menu_info).list) input_keys('a') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_a', '') - input_keys("\C-h", false) + input_keys("\C-h") input_keys('b') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_ba', '') input_keys("\C-h") input_key_by_symbol(:complete) assert_line_around_cursor('foo_ba', '') - input_keys("\C-h", false) + input_keys("\C-h") input_key_by_symbol(:menu_complete) assert_line_around_cursor('foo_bar', '') input_key_by_symbol(:menu_complete) assert_line_around_cursor('foo_baz', '') - input_keys("\C-h", false) + input_keys("\C-h") input_key_by_symbol(:menu_complete_backward) assert_line_around_cursor('foo_baz', '') input_key_by_symbol(:menu_complete_backward) @@ -829,9 +829,9 @@ def test_autocompletion } input_keys('Re') assert_line_around_cursor('Re', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('Readline', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('Regexp', '') input_key_by_symbol(:completion_journey_up) assert_line_around_cursor('Readline', '') @@ -859,10 +859,10 @@ def test_completion_with_indent input_keys(' fo') assert_line_around_cursor(' fo', '') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor(' foo_', '') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor(' foo_', '') assert_equal(%w{foo_foo foo_bar foo_baz}, @line_editor.instance_variable_get(:@menu_info).list) end @@ -884,25 +884,25 @@ def test_completion_with_perfect_match assert_line_around_cursor('fo', '') assert_equal(Reline::LineEditor::CompletionState::NORMAL, @line_editor.instance_variable_get(:@completion_state)) assert_equal(nil, matched) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo', '') assert_equal(Reline::LineEditor::CompletionState::MENU_WITH_PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state)) assert_equal(nil, matched) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo', '') assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state)) assert_equal(nil, matched) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo', '') assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state)) assert_equal('foo', matched) matched = nil input_keys('_') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_bar', '') assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state)) assert_equal(nil, matched) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_bar', '') assert_equal(Reline::LineEditor::CompletionState::PERFECT_MATCH, @line_editor.instance_variable_get(:@completion_state)) assert_equal('foo_bar', matched) @@ -913,9 +913,9 @@ def test_continuous_completion_with_perfect_match word == 'f' ? ['foo'] : %w[foobar foobaz] } input_keys('f') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('fooba', '') end @@ -925,9 +925,9 @@ def test_continuous_completion_disabled_with_perfect_match } @line_editor.dig_perfect_match_proc = proc {} input_keys('f') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo', '') end @@ -937,13 +937,13 @@ def test_completion_append_character } @line_editor.completion_append_character = 'X' input_keys('f') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_', '') input_keys('f') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_fooX', '') input_keys(' foo_bar') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_fooX foo_barX', '') end @@ -952,22 +952,22 @@ def test_completion_with_quote_append %w[foo bar baz].select { |s| s.start_with? word } } set_line_around_cursor('x = "b', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('x = "ba', '') set_line_around_cursor('x = "f', ' ') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('x = "foo', ' ') set_line_around_cursor("x = 'f", '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor("x = 'foo'", '') set_line_around_cursor('"a "f', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('"a "foo', '') set_line_around_cursor('"a\\" "f', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('"a\\" "foo', '') set_line_around_cursor('"a" "f', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('"a" "foo"', '') end @@ -985,25 +985,25 @@ def test_completion_with_completion_ignore_case input_keys('fo') assert_line_around_cursor('fo', '') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_', '') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_', '') assert_equal(%w{foo_foo foo_bar}, @line_editor.instance_variable_get(:@menu_info).list) @config.completion_ignore_case = true - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_', '') assert_equal(%w{foo_foo foo_bar Foo_baz}, @line_editor.instance_variable_get(:@menu_info).list) input_keys('a') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_a', '') - input_keys("\C-h", false) + input_keys("\C-h") input_keys('b') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_ba', '') input_keys('Z') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('Foo_baz', '') end @@ -1020,9 +1020,9 @@ def test_completion_in_middle_of_line } input_keys('abcde fo ABCDE') assert_line_around_cursor('abcde fo ABCDE', '') - input_keys("\C-b" * 6 + "\C-i", false) + input_keys("\C-b" * 6 + "\C-i") assert_line_around_cursor('abcde foo_', ' ABCDE') - input_keys("\C-b" * 2 + "\C-i", false) + input_keys("\C-b" * 2 + "\C-i") assert_line_around_cursor('abcde foo_', 'o_ ABCDE') end @@ -1041,42 +1041,42 @@ def test_completion_with_nil_value input_keys('fo') assert_line_around_cursor('fo', '') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_', '') assert_equal(nil, @line_editor.instance_variable_get(:@menu_info)) - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_', '') assert_equal(%w{foo_foo foo_bar Foo_baz}, @line_editor.instance_variable_get(:@menu_info).list) input_keys('a') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_a', '') - input_keys("\C-h", false) + input_keys("\C-h") input_keys('b') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('foo_ba', '') end def test_em_kill_region input_keys('abc def{bbb}ccc ddd ') assert_line_around_cursor('abc def{bbb}ccc ddd ', '') - input_keys("\C-w", false) + input_keys("\C-w") assert_line_around_cursor('abc def{bbb}ccc ', '') - input_keys("\C-w", false) + input_keys("\C-w") assert_line_around_cursor('abc ', '') - input_keys("\C-w", false) + input_keys("\C-w") assert_line_around_cursor('', '') - input_keys("\C-w", false) + input_keys("\C-w") assert_line_around_cursor('', '') end def test_em_kill_region_mbchar input_keys('あ い う{う}う ') assert_line_around_cursor('あ い う{う}う ', '') - input_keys("\C-w", false) + input_keys("\C-w") assert_line_around_cursor('あ い ', '') - input_keys("\C-w", false) + input_keys("\C-w") assert_line_around_cursor('あ ', '') - input_keys("\C-w", false) + input_keys("\C-w") assert_line_around_cursor('', '') end @@ -1232,13 +1232,13 @@ def test_search_history_with_isearch_terminator def test_em_set_mark_and_em_exchange_mark input_keys('aaa bbb ccc ddd') assert_line_around_cursor('aaa bbb ccc ddd', '') - input_keys("\C-a\M-F\M-F", false) + input_keys("\C-a\eF\eF") assert_line_around_cursor('aaa bbb', ' ccc ddd') assert_equal(nil, @line_editor.instance_variable_get(:@mark_pointer)) - input_keys("\x00", false) # C-Space + input_keys("\x00") # C-Space assert_line_around_cursor('aaa bbb', ' ccc ddd') assert_equal([7, 0], @line_editor.instance_variable_get(:@mark_pointer)) - input_keys("\C-a", false) + input_keys("\C-a") assert_line_around_cursor('', 'aaa bbb ccc ddd') assert_equal([7, 0], @line_editor.instance_variable_get(:@mark_pointer)) input_key_by_symbol(:em_exchange_mark) @@ -1249,7 +1249,7 @@ def test_em_set_mark_and_em_exchange_mark def test_em_exchange_mark_without_mark input_keys('aaa bbb ccc ddd') assert_line_around_cursor('aaa bbb ccc ddd', '') - input_keys("\C-a\M-f", false) + input_keys("\C-a\ef") assert_line_around_cursor('aaa', ' bbb ccc ddd') assert_equal(nil, @line_editor.instance_variable_get(:@mark_pointer)) input_key_by_symbol(:em_exchange_mark) @@ -1438,20 +1438,20 @@ def test_ed_insert_for_include_valiation_selector end def test_em_yank_pop - input_keys("def hoge\C-w\C-b\C-f\C-w", false) + input_keys("def hoge\C-w\C-b\C-f\C-w") assert_line_around_cursor('', '') - input_keys("\C-y", false) + input_keys("\C-y") assert_line_around_cursor('def ', '') - input_keys("\M-\C-y", false) + input_keys("\e\C-y") assert_line_around_cursor('hoge', '') end def test_em_kill_region_with_kill_ring - input_keys("def hoge\C-b\C-b\C-b\C-b", false) + input_keys("def hoge\C-b\C-b\C-b\C-b") assert_line_around_cursor('def ', 'hoge') - input_keys("\C-k\C-w", false) + input_keys("\C-k\C-w") assert_line_around_cursor('', '') - input_keys("\C-y", false) + input_keys("\C-y") assert_line_around_cursor('def hoge', '') end @@ -1497,28 +1497,28 @@ def test_ignore_NUL_by_ed_quoted_insert def test_ed_argument_digit_by_meta_num input_keys('abcdef') assert_line_around_cursor('abcdef', '') - input_keys("\M-2", false) - input_keys("\C-h", false) + input_keys("\e2") + input_keys("\C-h") assert_line_around_cursor('abcd', '') end def test_ed_digit_with_ed_argument_digit input_keys('1' * 30) assert_line_around_cursor('1' * 30, '') - input_keys("\M-2", false) + input_keys("\e2") input_keys('3') - input_keys("\C-h", false) + input_keys("\C-h") input_keys('4') assert_line_around_cursor('1' * 7 + '4', '') end def test_halfwidth_kana_width_dakuten omit "This test is for UTF-8 but the locale is #{Reline.core.encoding}" if Reline.core.encoding != Encoding::UTF_8 - input_raw_keys('ガギゲゴ') + input_keys('ガギゲゴ') assert_line_around_cursor('ガギゲゴ', '') - input_keys("\C-b\C-b", false) + input_keys("\C-b\C-b") assert_line_around_cursor('ガギ', 'ゲゴ') - input_raw_keys('グ', false) + input_keys('グ') assert_line_around_cursor('ガギグ', 'ゲゴ') end @@ -1528,13 +1528,13 @@ def test_input_unknown_char end def test_unix_line_discard - input_keys("\C-u", false) + input_keys("\C-u") assert_line_around_cursor('', '') input_keys('abc') assert_line_around_cursor('abc', '') - input_keys("\C-b\C-u", false) + input_keys("\C-b\C-u") assert_line_around_cursor('', 'c') - input_keys("\C-f\C-u", false) + input_keys("\C-f\C-u") assert_line_around_cursor('', '') end @@ -1544,59 +1544,59 @@ def test_vi_editing_mode end def test_undo - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('', '') - input_keys("aあb\C-h\C-h\C-h".encode(@encoding), false) + input_keys("aあb\C-h\C-h\C-h") assert_line_around_cursor('', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('a', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('aあ', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('aあb', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('aあ', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('a', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('', '') end def test_undo_with_cursor_position - input_keys("abc\C-b\C-h", false) + input_keys("abc\C-b\C-h") assert_line_around_cursor('a', 'c') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('ab', 'c') - input_keys("あいう\C-b\C-h".encode(@encoding), false) + input_keys("あいう\C-b\C-h") assert_line_around_cursor('abあ', 'うc') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('abあい', 'うc') end def test_undo_with_multiline @line_editor.multiline_on @line_editor.confirm_multiline_termination_proc = proc {} - input_keys("1\n2\n3", false) + input_keys("1\n2\n3") assert_whole_lines(["1", "2", "3"]) assert_line_index(2) assert_line_around_cursor('3', '') - input_keys("\C-p\C-h\C-h", false) + input_keys("\C-p\C-h\C-h") assert_whole_lines(["1", "3"]) assert_line_index(0) assert_line_around_cursor('1', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_whole_lines(["1", "", "3"]) assert_line_index(1) assert_line_around_cursor('', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_whole_lines(["1", "2", "3"]) assert_line_index(1) assert_line_around_cursor('2', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_whole_lines(["1", "2", ""]) assert_line_index(2) assert_line_around_cursor('', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_whole_lines(["1", "2"]) assert_line_index(1) assert_line_around_cursor('2', '') @@ -1604,99 +1604,99 @@ def test_undo_with_multiline def test_undo_with_many_times str = "a" + "b" * 99 - input_keys(str, false) - 100.times { input_keys("\C-_", false) } + input_keys(str) + 100.times { input_keys("\C-_") } assert_line_around_cursor('a', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('a', '') end def test_redo - input_keys("aあb".encode(@encoding), false) + input_keys("aあb") assert_line_around_cursor('aあb', '') - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_line_around_cursor('aあb', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('aあ', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('a', '') - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_line_around_cursor('aあ', '') - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_line_around_cursor('aあb', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('aあ', '') - input_keys("c", false) + input_keys("c") assert_line_around_cursor('aあc', '') - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_line_around_cursor('aあc', '') end def test_redo_with_cursor_position - input_keys("abc\C-b\C-h", false) + input_keys("abc\C-b\C-h") assert_line_around_cursor('a', 'c') - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_line_around_cursor('a', 'c') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('ab', 'c') - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_line_around_cursor('a', 'c') end def test_redo_with_multiline @line_editor.multiline_on @line_editor.confirm_multiline_termination_proc = proc {} - input_keys("1\n2\n3", false) + input_keys("1\n2\n3") assert_whole_lines(["1", "2", "3"]) assert_line_index(2) assert_line_around_cursor('3', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_whole_lines(["1", "2", ""]) assert_line_index(2) assert_line_around_cursor('', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_whole_lines(["1", "2"]) assert_line_index(1) assert_line_around_cursor('2', '') - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_whole_lines(["1", "2", ""]) assert_line_index(2) assert_line_around_cursor('', '') - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_whole_lines(["1", "2", "3"]) assert_line_index(2) assert_line_around_cursor('3', '') - input_keys("\C-p\C-h\C-h", false) + input_keys("\C-p\C-h\C-h") assert_whole_lines(["1", "3"]) assert_line_index(0) assert_line_around_cursor('1', '') - input_keys("\C-n", false) + input_keys("\C-n") assert_whole_lines(["1", "3"]) assert_line_index(1) assert_line_around_cursor('3', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_whole_lines(["1", "", "3"]) assert_line_index(1) assert_line_around_cursor('', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_whole_lines(["1", "2", "3"]) assert_line_index(1) assert_line_around_cursor('2', '') - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_whole_lines(["1", "", "3"]) assert_line_index(1) assert_line_around_cursor('', '') - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_whole_lines(["1", "3"]) assert_line_index(1) assert_line_around_cursor('3', '') @@ -1705,27 +1705,27 @@ def test_redo_with_multiline def test_undo_redo_restores_indentation @line_editor.multiline_on @line_editor.confirm_multiline_termination_proc = proc {} - input_keys(" 1", false) + input_keys(" 1") assert_whole_lines([' 1']) - input_keys("2", false) + input_keys("2") assert_whole_lines([' 12']) @line_editor.auto_indent_proc = proc { 2 } - input_keys("\C-_", false) + input_keys("\C-_") assert_whole_lines([' 1']) - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_whole_lines([' 12']) end def test_redo_with_many_times str = "a" + "b" * 98 + "c" - input_keys(str, false) - 100.times { input_keys("\C-_", false) } + input_keys(str) + 100.times { input_keys("\C-_") } assert_line_around_cursor('a', '') - input_keys("\C-_", false) + input_keys("\C-_") assert_line_around_cursor('a', '') - 100.times { input_keys("\M-\C-_", false) } + 100.times { input_keys("\e\C-_") } assert_line_around_cursor(str, '') - input_keys("\M-\C-_", false) + input_keys("\e\C-_") assert_line_around_cursor(str, '') end end diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb index 928adace2b..56c51c0b9e 100644 --- a/test/reline/test_key_actor_vi.rb +++ b/test/reline/test_key_actor_vi.rb @@ -659,9 +659,9 @@ def test_autocompletion_with_upward_navigation } input_keys('Re') assert_line_around_cursor('Re', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('Readline', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('Regexp', '') input_key_by_symbol(:completion_journey_up) assert_line_around_cursor('Readline', '') @@ -682,9 +682,9 @@ def test_autocompletion_with_upward_navigation_and_menu_complete_backward } input_keys('Re') assert_line_around_cursor('Re', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('Readline', '') - input_keys("\C-i", false) + input_keys("\C-i") assert_line_around_cursor('Regexp', '') input_key_by_symbol(:menu_complete_backward) assert_line_around_cursor('Readline', '') @@ -924,16 +924,16 @@ def test_ed_delete_next_char_at_eol end def test_vi_kill_line_prev - input_keys("\C-u", false) + input_keys("\C-u") assert_line_around_cursor('', '') input_keys('abc') assert_line_around_cursor('abc', '') - input_keys("\C-u", false) + input_keys("\C-u") assert_line_around_cursor('', '') input_keys('abc') - input_keys("\C-[\C-u", false) + input_keys("\C-[\C-u") assert_line_around_cursor('', 'c') - input_keys("\C-u", false) + input_keys("\C-u") assert_line_around_cursor('', 'c') end From 87a90cfad0f13bda31122dd96c4d299a9b31779b Mon Sep 17 00:00:00 2001 From: tompng Date: Thu, 2 Jan 2025 02:23:43 +0900 Subject: [PATCH 2/5] Omit unicode unnoralized input test in non-utf8 testcase --- test/reline/helper.rb | 14 ++++---------- test/reline/test_key_actor_emacs.rb | 18 +++++++++++++++--- test/reline/test_key_actor_vi.rb | 7 +++++++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/test/reline/helper.rb b/test/reline/helper.rb index 552c21778f..f76a1c0b19 100644 --- a/test/reline/helper.rb +++ b/test/reline/helper.rb @@ -87,17 +87,11 @@ def test_rubybin class Reline::TestCase < Test::Unit::TestCase private def convert_str(input) - return nil if input.nil? input.encode(@line_editor.encoding, Encoding::UTF_8) - rescue Encoding::UndefinedConversionError - return input unless unicode?(input.encoding) - - input = input.unicode_normalize(:nfc) - begin - input.encode(@line_editor.encoding, Encoding::UTF_8) - rescue Encoding::UndefinedConversionError - input.encode(@line_editor.encoding, Encoding::UTF_8, undef: :replace, replace: '?') - end + end + + def omit_unless_utf8 + omit "This test is for UTF-8 but the locale is #{Reline.core.encoding}" if Reline.core.encoding != Encoding::UTF_8 end def input_key_by_symbol(method_symbol, char: nil, csi: false) diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index 7db62b89e2..78b4c936b9 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -38,11 +38,13 @@ def test_ed_insert_mbchar_two end def test_ed_insert_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099") assert_line_around_cursor("か\u3099", '') end def test_ed_insert_for_plural_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099き\u3099") assert_line_around_cursor("か\u3099き\u3099", '') end @@ -74,6 +76,7 @@ def test_move_next_and_prev_for_mbchar end def test_move_next_and_prev_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099き\u3099け\u3099") assert_line_around_cursor("か\u3099き\u3099け\u3099", '') input_keys("\C-b") @@ -132,6 +135,7 @@ def test_em_delete_prev_char_for_mbchar end def test_em_delete_prev_char_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099き\u3099") assert_line_around_cursor("か\u3099き\u3099", '') input_keys("\C-h") @@ -254,6 +258,7 @@ def test_em_delete_for_mbchar end def test_em_delete_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099き\u3099") assert_line_around_cursor("か\u3099き\u3099", '') input_keys("\C-a") @@ -336,6 +341,7 @@ def test_em_next_word_for_mbchar end def test_em_next_word_for_mbchar_by_plural_code_points + omit_unless_utf8 assert_line_around_cursor("", "") input_keys("あいう か\u3099き\u3099く\u3099{さしす}たちつ") input_keys("\C-a\eF") @@ -381,6 +387,7 @@ def test_em_prev_word_for_mbchar end def test_em_prev_word_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("あいう か\u3099き\u3099く\u3099{さしす}たちつ") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{さしす}たちつ", "") input_keys("\eB") @@ -424,6 +431,7 @@ def test_em_delete_next_word_for_mbchar end def test_em_delete_next_word_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("あいう か\u3099き\u3099く\u3099{さしす}たちつ") input_keys("\C-a") assert_line_around_cursor('', "あいう か\u3099き\u3099く\u3099{さしす}たちつ") @@ -464,6 +472,7 @@ def test_ed_delete_prev_word_for_mbchar end def test_ed_delete_prev_word_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("あいう か\u3099き\u3099く\u3099{さしす}たちつ") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{さしす}たちつ", '') input_keys("\e\C-H") @@ -505,6 +514,7 @@ def test_ed_transpose_chars_for_mbchar end def test_ed_transpose_chars_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("あか\u3099さ") input_keys("\C-a") assert_line_around_cursor('', "あか\u3099さ") @@ -642,6 +652,7 @@ def test_ed_next_and_prev_char_for_mbchar end def test_ed_next_and_prev_char_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099き\u3099く\u3099") assert_line_around_cursor("か\u3099き\u3099く\u3099", '') input_keys("\C-b") @@ -1407,7 +1418,7 @@ def test_incremental_search_history_saves_and_restores_last_input # Unicode emoji test def test_ed_insert_for_include_zwj_emoji - omit "This test is for UTF-8 but the locale is #{Reline.core.encoding}" if Reline.core.encoding != Encoding::UTF_8 + omit_unless_utf8 # U+1F468 U+200D U+1F469 U+200D U+1F467 U+200D U+1F466 is family: man, woman, girl, boy "👨‍👩‍👧‍👦" input_keys("\u{1F468}") # U+1F468 is man "👨" assert_line_around_cursor('👨', '') @@ -1429,7 +1440,7 @@ def test_ed_insert_for_include_zwj_emoji end def test_ed_insert_for_include_valiation_selector - omit "This test is for UTF-8 but the locale is #{Reline.core.encoding}" if Reline.core.encoding != Encoding::UTF_8 + omit_unless_utf8 # U+0030 U+FE00 is DIGIT ZERO + VARIATION SELECTOR-1 "0︀" input_keys("\u0030") # U+0030 is DIGIT ZERO assert_line_around_cursor('0', '') @@ -1513,7 +1524,7 @@ def test_ed_digit_with_ed_argument_digit end def test_halfwidth_kana_width_dakuten - omit "This test is for UTF-8 but the locale is #{Reline.core.encoding}" if Reline.core.encoding != Encoding::UTF_8 + omit_unless_utf8 input_keys('ガギゲゴ') assert_line_around_cursor('ガギゲゴ', '') input_keys("\C-b\C-b") @@ -1523,6 +1534,7 @@ def test_halfwidth_kana_width_dakuten end def test_input_unknown_char + omit_unless_utf8 input_keys('͸') # U+0378 (unassigned) assert_line_around_cursor('͸', '') end diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb index 56c51c0b9e..083433f9a8 100644 --- a/test/reline/test_key_actor_vi.rb +++ b/test/reline/test_key_actor_vi.rb @@ -103,11 +103,13 @@ def test_ed_insert_mbchar_two end def test_ed_insert_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099") assert_line_around_cursor("か\u3099", '') end def test_ed_insert_for_plural_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099き\u3099") assert_line_around_cursor("か\u3099き\u3099", '') end @@ -208,6 +210,7 @@ def test_vi_paste_next_for_mbchar end def test_vi_paste_prev_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099き\u3099く\u3099け\u3099こ\u3099\C-[3h") assert_line_around_cursor("か\u3099", "き\u3099く\u3099け\u3099こ\u3099") input_keys('P') @@ -221,6 +224,7 @@ def test_vi_paste_prev_for_mbchar_by_plural_code_points end def test_vi_paste_next_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099き\u3099く\u3099け\u3099こ\u3099\C-[3h") assert_line_around_cursor("か\u3099", "き\u3099く\u3099け\u3099こ\u3099") input_keys('p') @@ -438,6 +442,7 @@ def test_vi_delete_next_char_for_mbchar end def test_vi_delete_next_char_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099き\u3099く\u3099\C-[h") assert_line_around_cursor("か\u3099", "き\u3099く\u3099") input_keys('x') @@ -465,6 +470,7 @@ def test_vi_delete_prev_char_for_mbchar end def test_vi_delete_prev_char_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("か\u3099き\u3099") assert_line_around_cursor("か\u3099き\u3099", '') input_keys("\C-h") @@ -509,6 +515,7 @@ def test_ed_delete_prev_word_for_mbchar end def test_ed_delete_prev_word_for_mbchar_by_plural_code_points + omit_unless_utf8 input_keys("あいう か\u3099き\u3099く\u3099{さしす}たちつ") assert_line_around_cursor("あいう か\u3099き\u3099く\u3099{さしす}たちつ", '') input_keys("\C-w") From 968922adf4ec2617ca20a9f4bcb6c89c87675f56 Mon Sep 17 00:00:00 2001 From: tompng Date: Sun, 5 Jan 2025 15:42:23 +0900 Subject: [PATCH 3/5] Remove helper method and constant no longer used in testcode --- lib/reline/unicode.rb | 1 - test/reline/helper.rb | 4 ---- 2 files changed, 5 deletions(-) diff --git a/lib/reline/unicode.rb b/lib/reline/unicode.rb index 7781d0c13a..21e4ea240e 100644 --- a/lib/reline/unicode.rb +++ b/lib/reline/unicode.rb @@ -34,7 +34,6 @@ class Reline::Unicode 0x1F => '^_', # C-_ C-7 0x7F => '^?', # C-? C-8 } - EscapedChars = EscapedPairs.keys.map(&:chr) NON_PRINTING_START = "\1" NON_PRINTING_END = "\2" diff --git a/test/reline/helper.rb b/test/reline/helper.rb index f76a1c0b19..6f470a617f 100644 --- a/test/reline/helper.rb +++ b/test/reline/helper.rb @@ -155,8 +155,4 @@ def assert_key_binding(input, method_symbol, editing_modes = [:emacs, :vi_insert assert_equal(method_symbol, @config.editing_mode.get(input.bytes)) end end - - private def unicode?(encoding) - [Encoding::UTF_8, Encoding::UTF_16BE, Encoding::UTF_16LE, Encoding::UTF_32BE, Encoding::UTF_32LE].include?(encoding) - end end From d0c06f52f8db36c155cc5b9dd05b2c8e837d0f24 Mon Sep 17 00:00:00 2001 From: tompng Date: Sun, 5 Jan 2025 15:47:28 +0900 Subject: [PATCH 4/5] Change key binding test to use realistic bytes instead of invalid byte sequence --- test/reline/test_within_pipe.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/reline/test_within_pipe.rb b/test/reline/test_within_pipe.rb index 4f05255301..e5d0c12b9c 100644 --- a/test/reline/test_within_pipe.rb +++ b/test/reline/test_within_pipe.rb @@ -42,9 +42,9 @@ def test_macro_commands_for_moving @config.add_default_key_binding("\C-x\C-e".bytes, :end_of_line) @config.add_default_key_binding("\C-x\C-f".bytes, :forward_char) @config.add_default_key_binding("\C-x\C-b".bytes, :backward_char) - @config.add_default_key_binding("\C-x\M-f".bytes, :forward_word) - @config.add_default_key_binding("\C-x\M-b".bytes, :backward_word) - @writer.write(" def\C-x\C-aabc\C-x\C-e ghi\C-x\C-a\C-x\C-f\C-x\C-f_\C-x\C-b\C-x\C-b_\C-x\C-f\C-x\C-f\C-x\C-f\C-x\M-f_\C-x\M-b\n") + @config.add_default_key_binding("\C-x\ef".bytes, :forward_word) + @config.add_default_key_binding("\C-x\eb".bytes, :backward_word) + @writer.write(" def\C-x\C-aabc\C-x\C-e ghi\C-x\C-a\C-x\C-f\C-x\C-f_\C-x\C-b\C-x\C-b_\C-x\C-f\C-x\C-f\C-x\C-f\C-x\ef_\C-x\eb\n") assert_equal 'a_b_c def_ ghi', Reline.readmultiline(&proc{ true }) end @@ -54,11 +54,11 @@ def test_macro_commands_for_editing @config.add_default_key_binding("\C-x\C-v".bytes, :quoted_insert) #@config.add_default_key_binding("\C-xa".bytes, :self_insert) @config.add_default_key_binding("\C-x\C-t".bytes, :transpose_chars) - @config.add_default_key_binding("\C-x\M-t".bytes, :transpose_words) - @config.add_default_key_binding("\C-x\M-u".bytes, :upcase_word) - @config.add_default_key_binding("\C-x\M-l".bytes, :downcase_word) - @config.add_default_key_binding("\C-x\M-c".bytes, :capitalize_word) - @writer.write("abcde\C-b\C-b\C-b\C-x\C-d\C-x\C-h\C-x\C-v\C-a\C-f\C-f EF\C-x\C-t gh\C-x\M-t\C-b\C-b\C-b\C-b\C-b\C-b\C-b\C-b\C-x\M-u\C-x\M-l\C-x\M-c\n") + @config.add_default_key_binding("\C-x\et".bytes, :transpose_words) + @config.add_default_key_binding("\C-x\eu".bytes, :upcase_word) + @config.add_default_key_binding("\C-x\el".bytes, :downcase_word) + @config.add_default_key_binding("\C-x\ec".bytes, :capitalize_word) + @writer.write("abcde\C-b\C-b\C-b\C-x\C-d\C-x\C-h\C-x\C-v\C-a\C-f\C-f EF\C-x\C-t gh\C-x\et\C-b\C-b\C-b\C-b\C-b\C-b\C-b\C-b\C-x\eu\C-x\el\C-x\ec\n") assert_equal "a\C-aDE gh Fe", Reline.readmultiline(&proc{ true }) end From c7b8dacc1bdbbfcd06a2217ebf686034f628f7f1 Mon Sep 17 00:00:00 2001 From: tompng Date: Sun, 5 Jan 2025 15:49:27 +0900 Subject: [PATCH 5/5] Remove invalid byte sequence input from rendering test yamatanooroti handles invalid byte sequence input "\M-[char]" and converts it to "\e[char]" We don't need to use these invalid byte sequence and rely on the hack implemented in yamatanooroti --- test/reline/yamatanooroti/test_rendering.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index 782ad71eb9..d946216001 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -571,7 +571,7 @@ def test_bracketed_paste_with_undo_redo Multiline REPL. prompt> abc EOC - write("\M-\C-_") + write("\e\C-_") assert_screen(<<~EOC) Multiline REPL. prompt> abcdef hoge @@ -853,7 +853,7 @@ def test_reset_rest_height_when_clear_screen def test_meta_key start_terminal(30, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.') - write("def ge\M-bho") + write("def ge\ebho") assert_screen(<<~EOC) Multiline REPL. prompt> def hoge @@ -874,7 +874,7 @@ def test_not_meta_key def test_force_enter start_terminal(30, 120, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.') write("def hoge\nend\C-p\C-e") - write("\M-\x0D") + write("\e\x0D") assert_screen(<<~EOC) Multiline REPL. prompt> def hoge @@ -919,7 +919,7 @@ def test_eof_without_newline def test_em_set_mark_and_em_exchange_mark start_terminal(10, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.') - write("aaa bbb ccc ddd\M-b\M-b\M-\x20\M-b\C-x\C-xX\C-x\C-xY") + write("aaa bbb ccc ddd\eb\eb\e\x20\eb\C-x\C-xX\C-x\C-xY") assert_screen(<<~'EOC') Multiline REPL. prompt> aaa Ybbb Xccc ddd @@ -1519,7 +1519,7 @@ def test_dialog_with_fullwidth_scrollbar def test_rerender_argument_prompt_after_pasting start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.') write('abcdef') - write("\M-3\C-h") + write("\e3\C-h") assert_screen(<<~'EOC') Multiline REPL. prompt> abc @@ -1655,7 +1655,7 @@ def test_insert_newline_in_the_middle_of_buffer_just_after_dialog write("class A\n def a\n 3\n end\nend") write("\n") write("\C-p\C-p\C-p\C-p\C-p\C-e\C-hS") - write("\M-\x0D") + write("\e\x0D") write(" 3") assert_screen(<<~'EOC') prompt> 3