From 3112e876a17aa750a75d56a7841902bff799b796 Mon Sep 17 00:00:00 2001 From: aycabta Date: Sun, 10 Oct 2021 18:58:46 +0900 Subject: [PATCH] [ruby/reline] Add tests for dialog with fullwidth chars and corner cases https://github.com/ruby/reline/commit/35ab5d47a8 --- test/reline/yamatanooroti/multiline_repl | 9 ++++++ test/reline/yamatanooroti/test_rendering.rb | 34 +++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/test/reline/yamatanooroti/multiline_repl b/test/reline/yamatanooroti/multiline_repl index 2e826793fa..da886b8f06 100755 --- a/test/reline/yamatanooroti/multiline_repl +++ b/test/reline/yamatanooroti/multiline_repl @@ -55,6 +55,15 @@ opt.on('--dialog VAL') { |v| natural to read and easy to write. RUBY + elsif v.include?('fullwidth') + contents = <<~RUBY.split("\n") + Rubyとは... + + オープンソースの動的なプログラミン + グ言語で、シンプルさと高い生産性を + 備えています。エレガントな文法を持 + ち、自然に読み書きができます。 + RUBY end if v.include?('scrollkey') dialog.trap_key = nil diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index d716ac5a0a..e1dde83589 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -935,6 +935,40 @@ begin EOC end + def test_dialog_with_fullwidth_chars + ENV['RELINE_TEST_PROMPT'] = '> ' + start_terminal(30, 5, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog fullwidth,scrollkey,scrollbar}, startup_message: 'Multiline REPL.') + 6.times{ write('j') } + close + assert_screen(<<~'EOC') + Multi + line + REPL. + > + オー + グ言▄ + 備え█ + ち、█ + EOC + end + + def test_dialog_with_fullwidth_chars_split + ENV['RELINE_TEST_PROMPT'] = '> ' + start_terminal(30, 6, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog fullwidth,scrollkey,scrollbar}, startup_message: 'Multiline REPL.') + 6.times{ write('j') } + close + assert_screen(<<~'EOC') + Multil + ine RE + PL. + > + オー + グ言 ▄ + 備え █ + ち、 █ + EOC + end + def test_autocomplete_empty start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.') write('Street')