summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/reline/helper.rb4
-rw-r--r--test/reline/test_key_actor_emacs.rb32
2 files changed, 36 insertions, 0 deletions
diff --git a/test/reline/helper.rb b/test/reline/helper.rb
index b1759f1d80..0b5b8af310 100644
--- a/test/reline/helper.rb
+++ b/test/reline/helper.rb
@@ -44,6 +44,10 @@ class Reline::TestCase < Test::Unit::TestCase
retry
end
+ def input_key_by_symbol(input)
+ @line_editor.input_key(Reline::Key.new(input, input, false))
+ end
+
def input_keys(input, convert = true)
input = convert_str(input) if convert
input.chars.each do |c|
diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb
index 5c5e74f5c8..5857f653cf 100644
--- a/test/reline/test_key_actor_emacs.rb
+++ b/test/reline/test_key_actor_emacs.rb
@@ -1403,6 +1403,38 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
@config.history_size = history_size
end
+ def test_em_set_mark_and_em_exchange_mark
+ input_keys('aaa bbb ccc ddd')
+ assert_byte_pointer_size('aaa bbb ccc ddd')
+ assert_cursor(15)
+ assert_cursor_max(15)
+ assert_line('aaa bbb ccc ddd')
+ input_keys("\C-a\M-F\M-F", false)
+ assert_byte_pointer_size('aaa bbb')
+ assert_cursor(7)
+ assert_cursor_max(15)
+ assert_line('aaa bbb ccc ddd')
+ assert_equal(nil, @line_editor.instance_variable_get(:@mark_pointer))
+ input_keys("\x00", false) # C-Space
+ assert_byte_pointer_size('aaa bbb')
+ assert_cursor(7)
+ assert_cursor_max(15)
+ assert_line('aaa bbb ccc ddd')
+ assert_equal([7, 0], @line_editor.instance_variable_get(:@mark_pointer))
+ input_keys("\C-a", false)
+ assert_byte_pointer_size('')
+ assert_cursor(0)
+ assert_cursor_max(15)
+ assert_line('aaa bbb ccc ddd')
+ assert_equal([7, 0], @line_editor.instance_variable_get(:@mark_pointer))
+ input_key_by_symbol(:em_exchange_mark)
+ assert_byte_pointer_size('aaa bbb')
+ assert_cursor(7)
+ assert_cursor_max(15)
+ assert_line('aaa bbb ccc ddd')
+ assert_equal([0, 0], @line_editor.instance_variable_get(:@mark_pointer))
+ end
+
=begin # TODO: move KeyStroke instance from Reline to LineEditor
def test_key_delete
input_keys('ab')