summaryrefslogtreecommitdiff
path: root/test/reline/test_key_actor_emacs.rb
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-04-17 03:03:12 +0900
committeraycabta <aycabta@gmail.com>2020-04-18 23:12:52 +0900
commitbea3e31e5f8b85f0665b94312418f97e71c14fc6 (patch)
treec68fd132f15af4875d0748b0a84f6e17badaa549 /test/reline/test_key_actor_emacs.rb
parent1e4efbb6d3e1794222703c2df2b0bb69bc4956cc (diff)
[ruby/reline] Add ed_search_prev_history
https://github.com/ruby/reline/commit/e9ae288825
Diffstat (limited to 'test/reline/test_key_actor_emacs.rb')
-rw-r--r--test/reline/test_key_actor_emacs.rb69
1 files changed, 69 insertions, 0 deletions
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')