summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2019-12-12 08:40:44 +0900
committeraycabta <aycabta@gmail.com>2019-12-12 08:40:50 +0900
commit7d991a0571ab33f44c00fdc227f076d1eaf5fb2b (patch)
tree0a3dd18a863ae51833d2f1b4d553ebbdf4c30545 /test
parent50ae8895f32f5fc620f0a0f288dae62815cb2a6f (diff)
Suppress to crash IRB if completed list has nil
Diffstat (limited to 'test')
-rw-r--r--test/reline/test_key_actor_emacs.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/reline/test_key_actor_emacs.rb b/test/reline/test_key_actor_emacs.rb
index cd5b926afe..4e3184bd3f 100644
--- a/test/reline/test_key_actor_emacs.rb
+++ b/test/reline/test_key_actor_emacs.rb
@@ -1363,6 +1363,51 @@ class Reline::KeyActor::Emacs::Test < Reline::TestCase
assert_line('abcde foo_o_ ABCDE')
end
+ def test_completion_with_nil_value
+ @line_editor.completion_proc = proc { |word|
+ %w{
+ foo_foo
+ foo_bar
+ Foo_baz
+ qux
+ }.map { |i|
+ i.encode(@encoding)
+ }.prepend(nil)
+ }
+ @config.completion_ignore_case = true
+ input_keys('fo')
+ assert_byte_pointer_size('fo')
+ assert_cursor(2)
+ assert_cursor_max(2)
+ assert_line('fo')
+ assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
+ input_keys("\C-i", false)
+ assert_byte_pointer_size('foo_')
+ assert_cursor(4)
+ assert_cursor_max(4)
+ assert_line('foo_')
+ assert_equal(nil, @line_editor.instance_variable_get(:@menu_info))
+ input_keys("\C-i", false)
+ assert_byte_pointer_size('foo_')
+ assert_cursor(4)
+ assert_cursor_max(4)
+ assert_line('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)
+ assert_byte_pointer_size('foo_a')
+ assert_cursor(5)
+ assert_cursor_max(5)
+ assert_line('foo_a')
+ input_keys("\C-h", false)
+ input_keys('b')
+ input_keys("\C-i", false)
+ assert_byte_pointer_size('foo_ba')
+ assert_cursor(6)
+ assert_cursor_max(6)
+ assert_line('foo_ba')
+ end
+
def test_em_kill_region
input_keys('abc def{bbb}ccc ddd ')
assert_byte_pointer_size('abc def{bbb}ccc ddd ')