1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/reline] Add tests for autocomplete with scrollbar

https://github.com/ruby/reline/commit/29634cbc93
This commit is contained in:
aycabta 2021-09-10 04:37:19 +09:00 committed by git
parent 364e646317
commit c94735fa24
2 changed files with 56 additions and 0 deletions

View file

@ -54,6 +54,12 @@ opt.on('--autocomplete') {
%w{String Struct Symbol ScriptError SyntaxError Signal}
}
}
opt.on('--autocomplete-long') {
Reline.autocompletion = true
Reline.completion_proc = lambda { |target, preposing = nil, postposing = nil|
%w{String Struct Symbol StopIteration SystemCallError SystemExit SystemStackError ScriptError SyntaxError Signal SizedQueue Set SecureRandom Socket StringIO StringScanner Shellwords Syslog Singleton SDBM}
}
}
opt.parse!(ARGV)
begin

View file

@ -870,6 +870,56 @@ begin
EOC
end
def test_autocomplete_long_with_scrollbar
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete-long}, startup_message: 'Multiline REPL.')
write("S")
close
assert_screen(<<~'EOC')
Multiline REPL.
prompt> S
String
Struct
Symbol
StopIteration
SystemCallError
SystemExit
SystemStackError
ScriptError
SyntaxError
Signal
SizedQueue
Set
SecureRandom
Socket
StringIO
EOC
end
def test_autocomplete_long_with_scrollbar_scroll
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete-long}, startup_message: 'Multiline REPL.')
write("S" + "\C-i" * 16)
close
assert_screen(<<~'EOC')
Multiline REPL.
prompt> StringScanner
Struct
Symbol
StopIteration
SystemCallError
SystemExit
SystemStackError
ScriptError
SyntaxError
Signal
SizedQueue
Set
SecureRandom
Socket
StringIO
StringScanner
EOC
end
def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content