Skip to content

Commit

Permalink
[ruby/reline] Add tests for autocomplete with scrollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta authored and matzbot committed Sep 10, 2021
1 parent 364e646 commit c94735f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/reline/yamatanooroti/multiline_repl
Expand Up @@ -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
Expand Down
50 changes: 50 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Expand Up @@ -870,6 +870,56 @@ def test_autocomplete
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
Expand Down

0 comments on commit c94735f

Please sign in to comment.