diff options
author | aycabta <aycabta@gmail.com> | 2021-12-24 20:07:55 +0900 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2021-12-25 00:32:58 +0900 |
commit | c815c0be46b83c1c5c50a88cd1452635208fbee4 (patch) | |
tree | 4b01a6bb92732274e7dcc2b5f779dbf57370263f /test | |
parent | b0db420b0e70753986d42579439acdd7ff0d9e95 (diff) |
[ruby/reline] Escape newline(s) in dynamic prompt
https://github.com/ruby/reline/commit/9b209ee1ea
Diffstat (limited to 'test')
-rwxr-xr-x | test/reline/yamatanooroti/multiline_repl | 8 | ||||
-rw-r--r-- | test/reline/yamatanooroti/test_rendering.rb | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/test/reline/yamatanooroti/multiline_repl b/test/reline/yamatanooroti/multiline_repl index 1f2a023724..3c47184b8e 100755 --- a/test/reline/yamatanooroti/multiline_repl +++ b/test/reline/yamatanooroti/multiline_repl @@ -27,6 +27,14 @@ opt.on('--broken-dynamic-prompt') { opt.on('--dynamic-prompt-returns-empty') { Reline.prompt_proc = proc { |l| [] } } +opt.on('--dynamic-prompt-with-newline') { + Reline.prompt_proc = proc { |lines| + range = lines.size > 1 ? (0..(lines.size - 2)) : (0..0) + lines[range].each_with_index.map { |l, i| + '[%04d\n]> ' % i + } + } +} opt.on('--auto-indent') { AutoIndent.new } diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index 8ddf95c1ba..43c24f6412 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -1241,6 +1241,18 @@ begin EOC end + def test_dynamic_prompt_with_newline + start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dynamic-prompt-with-newline}, startup_message: 'Multiline REPL.') + write("def hoge\n 3\nend") + close + assert_screen(<<~'EOC') + Multiline REPL. + [0000\n]> def hoge + [0001\n]> 3 + [0001\n]> end + EOC + end + def write_inputrc(content) File.open(@inputrc_file, 'w') do |f| f.write content |