Skip to content

Commit 29634cb

Browse files
committed
Add tests for autocomplete with scrollbar
1 parent d70f507 commit 29634cb

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

test/reline/yamatanooroti/multiline_repl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ opt.on('--autocomplete') {
5454
%w{String Struct Symbol ScriptError SyntaxError Signal}
5555
}
5656
}
57+
opt.on('--autocomplete-long') {
58+
Reline.autocompletion = true
59+
Reline.completion_proc = lambda { |target, preposing = nil, postposing = nil|
60+
%w{String Struct Symbol StopIteration SystemCallError SystemExit SystemStackError ScriptError SyntaxError Signal SizedQueue Set SecureRandom Socket StringIO StringScanner Shellwords Syslog Singleton SDBM}
61+
}
62+
}
5763
opt.parse!(ARGV)
5864

5965
begin

test/reline/yamatanooroti/test_rendering.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,56 @@ def test_autocomplete
870870
EOC
871871
end
872872

873+
def test_autocomplete_long_with_scrollbar
874+
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete-long}, startup_message: 'Multiline REPL.')
875+
write("S")
876+
close
877+
assert_screen(<<~'EOC')
878+
Multiline REPL.
879+
prompt> S
880+
String █
881+
Struct █
882+
Symbol █
883+
StopIteration █
884+
SystemCallError █
885+
SystemExit █
886+
SystemStackError█
887+
ScriptError █
888+
SyntaxError █
889+
Signal █
890+
SizedQueue █
891+
Set
892+
SecureRandom
893+
Socket
894+
StringIO
895+
EOC
896+
end
897+
898+
def test_autocomplete_long_with_scrollbar_scroll
899+
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete-long}, startup_message: 'Multiline REPL.')
900+
write("S" + "\C-i" * 16)
901+
close
902+
assert_screen(<<~'EOC')
903+
Multiline REPL.
904+
prompt> StringScanner
905+
Struct ▄
906+
Symbol █
907+
StopIteration █
908+
SystemCallError █
909+
SystemExit █
910+
SystemStackError█
911+
ScriptError █
912+
SyntaxError █
913+
Signal █
914+
SizedQueue █
915+
Set █
916+
SecureRandom ▀
917+
Socket
918+
StringIO
919+
StringScanner
920+
EOC
921+
end
922+
873923
def write_inputrc(content)
874924
File.open(@inputrc_file, 'w') do |f|
875925
f.write content

0 commit comments

Comments
 (0)