summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2019-11-15 16:50:11 +0900
committeraycabta <aycabta@gmail.com>2019-11-15 16:50:40 +0900
commitfa7618e4c1b382cb5863161017ef89116af3e24f (patch)
tree5aa327533c1cd5a6b78152ba09c92cc1d6416dac /test
parent6744593b8cd836967b40a4d76a9ac301b9e0f973 (diff)
Implement em_set_mark and em_exchange_mark
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')