diff options
author | aycabta <aycabta@gmail.com> | 2020-11-08 21:56:27 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-12-05 02:58:58 +0900 |
commit | 9750c27afc99034960b74e8951718ca07cc353a8 (patch) | |
tree | ae96e40e00356d2c0f459e9aace599fe5be63996 /test/reline | |
parent | ba8e5f77eb2562cc0605f1414426a34c7e844964 (diff) | |
download | ruby-9750c27afc99034960b74e8951718ca07cc353a8.tar.gz |
[ruby/reline] Call process_insert when the end of pasting plural fullwidth chars
https://github.com/ruby/reline/commit/594484d9f9
Diffstat (limited to 'test/reline')
-rw-r--r-- | test/reline/helper.rb | 9 | ||||
-rw-r--r-- | test/reline/test_key_actor_vi.rb | 22 | ||||
-rw-r--r-- | test/reline/yamatanooroti/test_rendering.rb | 24 |
3 files changed, 55 insertions, 0 deletions
diff --git a/test/reline/helper.rb b/test/reline/helper.rb index 0b5b8af310..5593b0a602 100644 --- a/test/reline/helper.rb +++ b/test/reline/helper.rb @@ -7,6 +7,7 @@ module Reline def test_mode remove_const('IOGate') if const_defined?('IOGate') const_set('IOGate', Reline::GeneralIO) + Reline::GeneralIO.reset send(:core).config.instance_variable_set(:@test_mode, true) send(:core).config.reset end @@ -17,6 +18,14 @@ module Reline end end +def start_pasting + Reline::GeneralIO.start_pasting +end + +def finish_pasting + Reline::GeneralIO.finish_pasting +end + RELINE_TEST_ENCODING ||= if ENV['RELINE_TEST_ENCODING'] Encoding.find(ENV['RELINE_TEST_ENCODING']) diff --git a/test/reline/test_key_actor_vi.rb b/test/reline/test_key_actor_vi.rb index 7c0eea1fa1..fb7c8042ea 100644 --- a/test/reline/test_key_actor_vi.rb +++ b/test/reline/test_key_actor_vi.rb @@ -1353,4 +1353,26 @@ class Reline::KeyActor::ViInsert::Test < Reline::TestCase assert_cursor(0) assert_cursor_max(3) end + + def test_pasting + start_pasting + input_keys('ab') + finish_pasting + input_keys('c') + assert_line('abc') + assert_byte_pointer_size('abc') + assert_cursor(3) + assert_cursor_max(3) + end + + def test_pasting_fullwidth + start_pasting + input_keys('あ') + finish_pasting + input_keys('い') + assert_line('あい') + assert_byte_pointer_size('あい') + assert_cursor(4) + assert_cursor_max(4) + end end diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index 2cee62e0b8..8bd72db4ba 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -62,6 +62,30 @@ begin EOC end + def test_fullwidth + start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.') + write(":あ\n") + close + assert_screen(<<~EOC) + Multiline REPL. + prompt> :あ + => :あ + prompt> + EOC + end + + def test_two_fullwidth + start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.') + write(":あい\n") + close + assert_screen(<<~EOC) + Multiline REPL. + prompt> :あい + => :あい + prompt> + EOC + end + def test_finish_autowrapped_line start_terminal(10, 40, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.') write("[{'user'=>{'email'=>'a@a', 'id'=>'ABC'}, 'version'=>4, 'status'=>'succeeded'}]\n") |