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

[ruby/reline] Add a simple test for autocomplete

11f83b2f4b
This commit is contained in:
aycabta 2021-09-09 07:22:53 +09:00 committed by git
parent 7983fb9658
commit 4475953378
2 changed files with 22 additions and 0 deletions

View file

@ -35,6 +35,12 @@ opt.on('--complete') {
%w{String ScriptError SyntaxError Signal}
}
}
opt.on('--autocomplete') {
Reline.autocompletion = true
Reline.completion_proc = lambda { |target, preposing = nil, postposing = nil|
%w{String Struct Symbol ScriptError SyntaxError Signal}
}
}
opt.parse!(ARGV)
begin

View file

@ -835,6 +835,22 @@ begin
EOC
end
def test_autocomplete
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
write("Stri")
close
assert_screen(<<~'EOC')
Multiline REPL.
prompt> Stri
String
Struct
Symbol
ScriptError
SyntaxError
Signal
EOC
end
def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content