From bea3e31e5f8b85f0665b94312418f97e71c14fc6 Mon Sep 17 00:00:00 2001 From: aycabta Date: Fri, 17 Apr 2020 03:03:12 +0900 Subject: [ruby/reline] Add ed_search_prev_history https://github.com/ruby/reline/commit/e9ae288825 --- test/reline/test_key_actor_emacs.rb | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'test/reline/test_key_actor_emacs.rb') diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb index 5ab3032f4e..a5de605314 100644 --- a/test/reline/test_key_actor_emacs.rb +++ b/test/reline/test_key_actor_emacs.rb @@ -1912,6 +1912,75 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase $VERBOSE = verbose end + def test_ed_search_prev_history + Reline::HISTORY.concat([ + '12356', # old + '12aaa', + '12345' # new + ]) + input_keys('123') + # The ed_search_prev_history doesn't have default binding + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('123') + assert_cursor(3) + assert_cursor_max(5) + assert_line('12345') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('123') + assert_cursor(3) + assert_cursor_max(5) + assert_line('12356') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('123') + assert_cursor(3) + assert_cursor_max(5) + assert_line('12356') + end + + def test_ed_search_prev_history_with_empty + Reline::HISTORY.concat([ + '12356', # old + '12aaa', + '12345' # new + ]) + # The ed_search_prev_history doesn't have default binding + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12345') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12aaa') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12356') + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('') + assert_cursor(0) + assert_cursor_max(5) + assert_line('12356') + end + + def test_ed_search_prev_history_without_match + Reline::HISTORY.concat([ + '12356', # old + '12aaa', + '12345' # new + ]) + input_keys('ABC') + # The ed_search_prev_history doesn't have default binding + @line_editor.__send__(:ed_search_prev_history, "\C-p".ord) + assert_byte_pointer_size('ABC') + assert_cursor(3) + assert_cursor_max(3) + assert_line('ABC') + end + =begin # TODO: move KeyStroke instance from Reline to LineEditor def test_key_delete input_keys('ab') -- cgit v1.2.3