diff options
author | Mari Imaizumi <[email protected]> | 2024-04-19 21:08:18 +0900 |
---|---|---|
committer | git <[email protected]> | 2024-04-19 12:08:22 +0000 |
commit | 604c29e8a2e78ea5d6c0e76385000ed6cde78aca (patch) | |
tree | a5a2a946b3c136414e2657380279881abbc2ed86 /test/reline | |
parent | 4218e6bbd50f2e5bc1fd39d8e504c0d7ef96dc15 (diff) |
[ruby/reline] Implement `show-all-if-ambiguous` feature
(https://github.com/ruby/reline/pull/683)
https://github.com/ruby/reline/commit/0fe4fdc794
Diffstat (limited to 'test/reline')
-rwxr-xr-x | test/reline/yamatanooroti/multiline_repl | 5 | ||||
-rw-r--r-- | test/reline/yamatanooroti/test_rendering.rb | 41 |
2 files changed, 46 insertions, 0 deletions
diff --git a/test/reline/yamatanooroti/multiline_repl b/test/reline/yamatanooroti/multiline_repl index 66bcf51e1a..eba410f6dd 100755 --- a/test/reline/yamatanooroti/multiline_repl +++ b/test/reline/yamatanooroti/multiline_repl @@ -143,6 +143,11 @@ opt.on('--complete') { %w{String ScriptError SyntaxError Signal}.select{ |c| c.start_with?(target) } } } +opt.on('--complete-menu-with-perfect-match') { + Reline.completion_proc = lambda { |target, preposing = nil, postposing = nil| + %w{abs abs2}.select{ |c| c.start_with?(target) } + } +} opt.on('--autocomplete') { 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 09d064934a..7b96e7b6a6 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -1006,6 +1006,47 @@ begin EOC end + def test_completion_menu_is_displayed_horizontally + start_terminal(20, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --complete}, startup_message: 'Multiline REPL.') + write("S\t\t") + close + assert_screen(<<~'EOC') + Multiline REPL. + prompt> S + ScriptError String + Signal SyntaxError + EOC + end + + def test_show_all_if_ambiguous_on + write_inputrc <<~LINES + set show-all-if-ambiguous on + LINES + start_terminal(20, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --complete}, startup_message: 'Multiline REPL.') + write("S\t") + close + assert_screen(<<~'EOC') + Multiline REPL. + prompt> S + ScriptError String + Signal SyntaxError + EOC + end + + def test_show_all_if_ambiguous_on_and_menu_with_perfect_match + write_inputrc <<~LINES + set show-all-if-ambiguous on + LINES + start_terminal(20, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --complete-menu-with-perfect-match}, startup_message: 'Multiline REPL.') + write("a\t") + close + assert_screen(<<~'EOC') + Multiline REPL. + prompt> abs + abs abs2 + EOC + end + def test_simple_dialog iterate_over_face_configs do |config_name, config_file| start_terminal(20, 50, %W{ruby -I#{@pwd}/lib -r#{config_file.path} #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog simple}, startup_message: 'Multiline REPL.') |