summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-09-09 07:22:53 +0900
committergit <svn-admin@ruby-lang.org>2021-09-10 09:04:30 +0900
commit44759533786562d0ff5c49147d050ea685e97ea5 (patch)
treee6e3e76a0a8f48da2d920d581faa6dd8acc68169 /test
parent7983fb965891330f5c41919b266ada53ab822f12 (diff)
[ruby/reline] Add a simple test for autocomplete
https://github.com/ruby/reline/commit/11f83b2f4b
Diffstat (limited to 'test')
-rwxr-xr-xtest/reline/yamatanooroti/multiline_repl6
-rw-r--r--test/reline/yamatanooroti/test_rendering.rb16
2 files changed, 22 insertions, 0 deletions
diff --git a/test/reline/yamatanooroti/multiline_repl b/test/reline/yamatanooroti/multiline_repl
index 00d4825ee3..b21ad4bd8c 100755
--- a/test/reline/yamatanooroti/multiline_repl
+++ b/test/reline/yamatanooroti/multiline_repl
@@ -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
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index e93aa1a47d..55b122e0d8 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -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