diff options
| author | tomoya ishida <tomoyapenguin@gmail.com> | 2024-01-04 20:53:01 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-01-04 11:53:06 +0000 |
| commit | 542011ff6895f77204349ddfae7dcfb476e116df (patch) | |
| tree | c22a774cfcfbe4e23a28ec0335c1807891a60cf1 /test | |
| parent | a4bdf26781c09be9f8b8860d0032e28dbd3bf0b1 (diff) | |
[ruby/reline] Fix pasting tab-indented code crash
(https://github.com/ruby/reline/pull/630)
https://github.com/ruby/reline/commit/90155fd0d9
Diffstat (limited to 'test')
| -rwxr-xr-x | test/reline/yamatanooroti/multiline_repl | 4 | ||||
| -rw-r--r-- | test/reline/yamatanooroti/test_rendering.rb | 26 |
2 files changed, 30 insertions, 0 deletions
diff --git a/test/reline/yamatanooroti/multiline_repl b/test/reline/yamatanooroti/multiline_repl index e2a900b251..edf18ea796 100755 --- a/test/reline/yamatanooroti/multiline_repl +++ b/test/reline/yamatanooroti/multiline_repl @@ -153,6 +153,10 @@ opt.on('--autocomplete') { %w{String Struct Symbol ScriptError SyntaxError Signal}.select{ |c| c.start_with?(target) } } } +opt.on('--autocomplete-empty') { + Reline.autocompletion = true + Reline.completion_proc = lambda { |target, preposing = nil, postposing = nil| [] } +} opt.on('--autocomplete-long') { Reline.autocompletion = true Reline.completion_proc = lambda { |target, preposing = nil, postposing = nil| diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index 670432d86b..b61c84527d 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -1213,6 +1213,32 @@ begin EOC end + def test_autocomplete_empty_string + start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.') + write("\C-i") + close + assert_screen(<<~'EOC') + Multiline REPL. + prompt> String + String █ + Struct ▀ + Symbol + EOC + end + + def test_paste_code_with_tab_indent_does_not_fail + start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete-empty}, startup_message: 'Multiline REPL.') + write("2.times do\n\tputs\n\tputs\nend") + close + assert_screen(<<~'EOC') + Multiline REPL. + prompt> 2.times do + prompt> puts + prompt> puts + prompt> end + EOC + end + def test_autocomplete_after_2nd_line start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.') write("def hoge\n Str") |
