summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-09-10 04:37:19 +0900
committergit <svn-admin@ruby-lang.org>2021-09-10 09:04:41 +0900
commitc94735fa240eae853265900876bbe67d9b9655d6 (patch)
tree53c86501201b54c1de60fd4cf46c826338d3ccc4 /test
parent364e646317fb9bf0f284532ad8a1c1e707bcbb21 (diff)
[ruby/reline] Add tests for autocomplete with scrollbar
https://github.com/ruby/reline/commit/29634cbc93
Diffstat (limited to 'test')
-rwxr-xr-xtest/reline/yamatanooroti/multiline_repl6
-rw-r--r--test/reline/yamatanooroti/test_rendering.rb50
2 files changed, 56 insertions, 0 deletions
diff --git a/test/reline/yamatanooroti/multiline_repl b/test/reline/yamatanooroti/multiline_repl
index 4de3f81c47..f3a1097dd8 100755
--- a/test/reline/yamatanooroti/multiline_repl
+++ b/test/reline/yamatanooroti/multiline_repl
@@ -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
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index 2ae0b81e2d..cd401e2f73 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -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