2020-03-21 05:40:15 -04:00
|
|
|
require 'reline'
|
|
|
|
|
2020-03-21 05:31:20 -04:00
|
|
|
begin
|
|
|
|
require 'yamatanooroti'
|
|
|
|
|
2020-03-21 05:40:15 -04:00
|
|
|
class Reline::TestRendering < Yamatanooroti::TestCase
|
2020-03-21 05:31:20 -04:00
|
|
|
def setup
|
2020-07-05 01:02:34 -04:00
|
|
|
@pwd = Dir.pwd
|
2020-11-27 09:11:46 -05:00
|
|
|
suffix = '%010d' % Random.rand(0..65535)
|
|
|
|
@tmpdir = File.join(File.expand_path(Dir.tmpdir), "test_reline_config_#{$$}_#{suffix}")
|
2020-07-05 01:02:34 -04:00
|
|
|
begin
|
|
|
|
Dir.mkdir(@tmpdir)
|
|
|
|
rescue Errno::EEXIST
|
|
|
|
FileUtils.rm_rf(@tmpdir)
|
|
|
|
Dir.mkdir(@tmpdir)
|
|
|
|
end
|
2020-07-12 10:29:45 -04:00
|
|
|
@inputrc_backup = ENV['INPUTRC']
|
|
|
|
@inputrc_file = ENV['INPUTRC'] = File.join(@tmpdir, 'temporaty_inputrc')
|
2020-07-05 01:02:34 -04:00
|
|
|
File.unlink(@inputrc_file) if File.exist?(@inputrc_file)
|
2020-03-21 05:31:20 -04:00
|
|
|
end
|
|
|
|
|
2020-07-05 01:02:34 -04:00
|
|
|
def teardown
|
|
|
|
FileUtils.rm_rf(@tmpdir)
|
2020-07-12 10:29:45 -04:00
|
|
|
ENV['INPUTRC'] = @inputrc_backup
|
2020-10-09 08:46:22 -04:00
|
|
|
ENV.delete('RELINE_TEST_PROMPT') if ENV['RELINE_TEST_PROMPT']
|
2020-07-05 01:02:34 -04:00
|
|
|
end
|
|
|
|
|
2020-03-21 05:31:20 -04:00
|
|
|
def test_history_back
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-03-21 05:31:20 -04:00
|
|
|
write(":a\n")
|
|
|
|
write("\C-p")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> :a
|
|
|
|
=> :a
|
|
|
|
prompt> :a
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_backspace
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-03-21 05:31:20 -04:00
|
|
|
write(":abc\C-h\n")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> :ab
|
|
|
|
=> :ab
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
2020-05-16 05:25:56 -04:00
|
|
|
|
|
|
|
def test_autowrap
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-05-16 05:25:56 -04:00
|
|
|
write('01234567890123456789012')
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> 0123456789012345678901
|
|
|
|
2
|
|
|
|
EOC
|
|
|
|
end
|
2020-07-12 10:29:45 -04:00
|
|
|
|
2020-11-08 07:56:27 -05:00
|
|
|
def test_fullwidth
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-11-08 07:56:27 -05:00
|
|
|
write(":あ\n")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> :あ
|
|
|
|
=> :あ
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_two_fullwidth
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-11-08 07:56:27 -05:00
|
|
|
write(":あい\n")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> :あい
|
|
|
|
=> :あい
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-09-10 16:48:59 -04:00
|
|
|
def test_finish_autowrapped_line
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(10, 40, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-09-10 16:48:59 -04:00
|
|
|
write("[{'user'=>{'email'=>'a@a', 'id'=>'ABC'}, 'version'=>4, 'status'=>'succeeded'}]\n")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> [{'user'=>{'email'=>'a@a', 'id'=
|
|
|
|
>'ABC'}, 'version'=>4, 'status'=>'succee
|
|
|
|
ded'}]
|
|
|
|
=> [{"user"=>{"email"=>"a@a", "id"=>"ABC
|
|
|
|
"}, "version"=>4, "status"=>"succeeded"}
|
|
|
|
]
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_finish_autowrapped_line_in_the_middle_of_lines
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-12-12 21:30:05 -05:00
|
|
|
write("[{'user'=>{'email'=>'abcdef@abcdef', 'id'=>'ABC'}, 'version'=>4, 'status'=>'succeeded'}]#{"\C-b"*7}")
|
|
|
|
write("\n")
|
2020-09-10 16:48:59 -04:00
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> [{'user'=>{'email'=>'a
|
|
|
|
bcdef@abcdef', 'id'=>'ABC'}, '
|
|
|
|
version'=>4, 'status'=>'succee
|
|
|
|
ded'}]
|
|
|
|
=> [{"user"=>{"email"=>"abcdef
|
|
|
|
@abcdef", "id"=>"ABC"}, "versi
|
|
|
|
on"=>4, "status"=>"succeeded"}
|
|
|
|
]
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-09-11 12:51:26 -04:00
|
|
|
def test_finish_autowrapped_line_in_the_middle_of_multilines
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(30, 16, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-09-11 12:51:26 -04:00
|
|
|
write("<<~EOM\n ABCDEFG\nEOM\n")
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> <<~EOM
|
|
|
|
prompt> ABCDEF
|
|
|
|
G
|
|
|
|
prompt> EOM
|
|
|
|
=> "ABCDEFG\n"
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-07-12 10:29:45 -04:00
|
|
|
def test_prompt
|
2020-10-06 10:55:33 -04:00
|
|
|
write_inputrc <<~'LINES'
|
|
|
|
"abc": "123"
|
|
|
|
LINES
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-07-12 10:29:45 -04:00
|
|
|
write("abc\n")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> 123
|
|
|
|
=> 123
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
2020-07-12 17:47:43 -04:00
|
|
|
|
2020-12-28 23:28:14 -05:00
|
|
|
def test_mode_string_emacs
|
2020-10-06 10:55:33 -04:00
|
|
|
write_inputrc <<~LINES
|
|
|
|
set show-mode-in-prompt on
|
|
|
|
LINES
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-07-12 17:47:43 -04:00
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
@prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-12-28 23:28:14 -05:00
|
|
|
def test_mode_string_vi
|
2020-10-06 10:55:33 -04:00
|
|
|
write_inputrc <<~LINES
|
|
|
|
set editing-mode vi
|
|
|
|
set show-mode-in-prompt on
|
|
|
|
LINES
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-07-12 17:47:43 -04:00
|
|
|
write(":a\n\C-[k")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
(ins)prompt> :a
|
|
|
|
=> :a
|
|
|
|
(cmd)prompt> :a
|
|
|
|
EOC
|
|
|
|
end
|
2020-07-20 07:52:07 -04:00
|
|
|
|
2020-12-28 23:28:14 -05:00
|
|
|
def test_original_mode_string_emacs
|
2020-10-06 10:55:33 -04:00
|
|
|
write_inputrc <<~LINES
|
|
|
|
set show-mode-in-prompt on
|
|
|
|
set emacs-mode-string [emacs]
|
|
|
|
LINES
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-07-20 07:52:07 -04:00
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
[emacs]prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-12-28 23:28:14 -05:00
|
|
|
def test_original_mode_string_with_quote
|
2020-10-06 10:55:33 -04:00
|
|
|
write_inputrc <<~LINES
|
|
|
|
set show-mode-in-prompt on
|
|
|
|
set emacs-mode-string "[emacs]"
|
|
|
|
LINES
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-07-20 07:52:07 -04:00
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
[emacs]prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-12-28 23:28:14 -05:00
|
|
|
def test_original_mode_string_vi
|
2020-10-06 10:55:33 -04:00
|
|
|
write_inputrc <<~LINES
|
|
|
|
set editing-mode vi
|
|
|
|
set show-mode-in-prompt on
|
|
|
|
set vi-ins-mode-string "{InS}"
|
|
|
|
set vi-cmd-mode-string "{CmD}"
|
|
|
|
LINES
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-07-20 07:52:07 -04:00
|
|
|
write(":a\n\C-[k")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
{InS}prompt> :a
|
|
|
|
=> :a
|
|
|
|
{CmD}prompt> :a
|
|
|
|
EOC
|
|
|
|
end
|
2020-10-06 10:55:33 -04:00
|
|
|
|
2020-12-28 23:28:14 -05:00
|
|
|
def test_mode_string_vi_changing
|
2020-12-23 17:15:54 -05:00
|
|
|
write_inputrc <<~LINES
|
|
|
|
set editing-mode vi
|
|
|
|
set show-mode-in-prompt on
|
|
|
|
LINES
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-12-23 17:15:54 -05:00
|
|
|
write(":a\C-[ab\C-[ac\C-h\C-h\C-h\C-h:a")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
(ins)prompt> :a
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-10-09 08:46:22 -04:00
|
|
|
def test_prompt_with_escape_sequence
|
|
|
|
ENV['RELINE_TEST_PROMPT'] = "\1\e[30m\2prompt> \1\e[m\2"
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-09 08:46:22 -04:00
|
|
|
write("123\n")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> 123
|
|
|
|
=> 123
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_prompt_with_escape_sequence_and_autowrap
|
|
|
|
ENV['RELINE_TEST_PROMPT'] = "\1\e[30m\2prompt> \1\e[m\2"
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-19 19:32:42 -04:00
|
|
|
write("1234567890123\n")
|
2020-10-09 08:46:22 -04:00
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
2020-10-19 19:32:42 -04:00
|
|
|
prompt> 123456789012
|
|
|
|
3
|
|
|
|
=> 1234567890123
|
2020-10-09 08:46:22 -04:00
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-10-09 14:00:04 -04:00
|
|
|
def test_multiline_and_autowrap
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(10, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-19 19:32:42 -04:00
|
|
|
write("def aaaaaaaaaa\n 33333333\n end\C-a\C-pputs\C-e\e\C-m888888888888888")
|
2020-10-09 14:00:04 -04:00
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
2020-10-19 19:32:42 -04:00
|
|
|
prompt> def aaaaaaaa
|
|
|
|
aa
|
|
|
|
prompt> puts 333333
|
|
|
|
33
|
|
|
|
prompt> 888888888888
|
|
|
|
888
|
|
|
|
prompt> e
|
|
|
|
nd
|
2020-10-09 14:00:04 -04:00
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_clear
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(10, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-09 14:00:04 -04:00
|
|
|
write("3\C-l")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
prompt> 3
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_clear_multiline_and_autowrap
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(10, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-09 14:00:04 -04:00
|
|
|
write("def aaaaaa\n 3\n\C-lend")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
prompt> def aaa
|
|
|
|
aaa
|
|
|
|
prompt> 3
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_nearest_cursor
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(10, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-09 14:00:04 -04:00
|
|
|
write("def ああ\n :いい\nend\C-pbb\C-pcc")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def ccああ
|
|
|
|
prompt> :bbいい
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_delete_line
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(10, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-09 14:00:04 -04:00
|
|
|
write("def a\n\nend\C-p\C-h")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def a
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_last_line_of_screen
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-09 14:00:04 -04:00
|
|
|
write("\n\n\n\n\ndef a\nend")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
prompt>
|
|
|
|
prompt>
|
|
|
|
prompt>
|
|
|
|
prompt> def a
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
# c17a09b7454352e2aff5a7d8722e80afb73e454b
|
|
|
|
def test_autowrap_at_last_line_of_screen
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-09 14:00:04 -04:00
|
|
|
write("def a\nend\n\C-p")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
prompt> def a
|
|
|
|
prompt> end
|
|
|
|
=> :a
|
|
|
|
prompt> def a
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
# f002483b27cdb325c5edf9e0fe4fa4e1c71c4b0e
|
|
|
|
def test_insert_line_in_the_middle_of_line
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-09 14:00:04 -04:00
|
|
|
write("333\C-b\C-b\e\C-m8")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> 3
|
|
|
|
prompt> 833
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
# 9d8978961c5de5064f949d56d7e0286df9e18f43
|
|
|
|
def test_insert_line_in_the_middle_of_line_at_last_line_of_screen
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(3, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-19 19:32:42 -04:00
|
|
|
write("333333333333333\C-a\C-f\e\C-m")
|
2020-10-09 14:00:04 -04:00
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
prompt> 3
|
2020-10-19 19:32:42 -04:00
|
|
|
prompt> 333333333333
|
2020-10-09 14:00:04 -04:00
|
|
|
33
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_insert_after_clear
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(10, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-09 14:00:04 -04:00
|
|
|
write("def a\n 01234\nend\C-l\C-p5678")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
prompt> def a
|
|
|
|
prompt> 056781234
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-11-20 23:08:53 -05:00
|
|
|
def test_foced_newline_insertion
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(10, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-11-20 23:08:53 -05:00
|
|
|
#write("def a\nend\C-p\C-e\e\C-m 3")
|
|
|
|
write("def a\nend\C-p\C-e\e\x0D")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def a
|
|
|
|
prompt>
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-10-09 14:00:04 -04:00
|
|
|
def test_multiline_incremental_search
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(6, 25, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-10-09 14:00:04 -04:00
|
|
|
write("def a\n 8\nend\ndef b\n 3\nend\C-s8")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
(i-search)`8'def a
|
|
|
|
(i-search)`8' 8
|
|
|
|
(i-search)`8'end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-12-21 09:02:46 -05:00
|
|
|
def test_multiline_incremental_search_finish
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(6, 25, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-12-21 09:02:46 -05:00
|
|
|
write("def a\n 8\nend\ndef b\n 3\nend\C-r8\C-j")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
prompt> def a
|
|
|
|
prompt> 8
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-11-09 01:59:52 -05:00
|
|
|
def test_binding_for_vi_movement_mode
|
|
|
|
write_inputrc <<~LINES
|
|
|
|
set editing-mode vi
|
2021-09-30 06:36:19 -04:00
|
|
|
"\\C-a": vi-movement-mode
|
2020-11-09 01:59:52 -05:00
|
|
|
LINES
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2021-09-30 06:36:19 -04:00
|
|
|
write(":1234\C-ahhhi0")
|
2020-11-09 01:59:52 -05:00
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> :01234
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-11-20 12:59:38 -05:00
|
|
|
def test_prompt_list_caching
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --prompt-list-cache-timeout 10 --dynamic-prompt}, startup_message: 'Multiline REPL.')
|
2020-11-20 12:59:38 -05:00
|
|
|
write("def hoge\n 3\nend")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
[0000]> def hoge
|
|
|
|
[0001]> 3
|
|
|
|
[0002]> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-01-05 04:29:09 -05:00
|
|
|
def test_broken_prompt_list
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --broken-dynamic-prompt}, startup_message: 'Multiline REPL.')
|
2021-01-05 04:29:09 -05:00
|
|
|
write("def hoge\n 3\nend")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
[0000]> def hoge
|
|
|
|
[0001]> 3
|
|
|
|
[0001]> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-11-26 05:13:34 -05:00
|
|
|
def test_enable_bracketed_paste
|
2020-12-17 05:57:44 -05:00
|
|
|
omit if Reline::IOGate.win?
|
2020-11-26 05:13:34 -05:00
|
|
|
write_inputrc <<~LINES
|
|
|
|
set enable-bracketed-paste on
|
|
|
|
LINES
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-11-26 05:13:34 -05:00
|
|
|
write("\e[200~,")
|
2020-11-27 09:11:46 -05:00
|
|
|
write("def hoge\n 3\nend")
|
2020-11-26 05:13:34 -05:00
|
|
|
write("\e[200~.")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
2020-11-27 09:11:46 -05:00
|
|
|
Multiline REPL.
|
2020-11-26 05:13:34 -05:00
|
|
|
prompt> def hoge
|
|
|
|
prompt> 3
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-12-06 03:45:05 -05:00
|
|
|
def test_backspace_until_returns_to_initial
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-12-06 03:45:05 -05:00
|
|
|
write("ABC")
|
|
|
|
write("\C-h\C-h\C-h")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-12-12 21:30:05 -05:00
|
|
|
def test_longer_than_screen_height
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-12-12 21:30:05 -05:00
|
|
|
write(<<~EOC.chomp)
|
|
|
|
def each_top_level_statement
|
|
|
|
initialize_input
|
|
|
|
catch(:TERM_INPUT) do
|
|
|
|
loop do
|
|
|
|
begin
|
|
|
|
prompt
|
|
|
|
unless l = lex
|
|
|
|
throw :TERM_INPUT if @line == ''
|
|
|
|
else
|
|
|
|
@line_no += l.count("\n")
|
|
|
|
next if l == "\n"
|
|
|
|
@line.concat l
|
|
|
|
if @code_block_open or @ltype or @continue or @indent > 0
|
|
|
|
next
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if @line != "\n"
|
|
|
|
@line.force_encoding(@io.encoding)
|
|
|
|
yield @line, @exp_line_no
|
|
|
|
end
|
|
|
|
break if @io.eof?
|
|
|
|
@line = ''
|
|
|
|
@exp_line_no = @line_no
|
|
|
|
#
|
|
|
|
@indent = 0
|
|
|
|
rescue TerminateLineInput
|
|
|
|
initialize_input
|
|
|
|
prompt
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
EOC
|
2021-01-13 18:34:30 -05:00
|
|
|
sleep 1
|
2020-12-12 21:30:05 -05:00
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
prompt> prompt
|
|
|
|
prompt> end
|
|
|
|
prompt> end
|
|
|
|
prompt> end
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_longer_than_screen_height_with_scroll_back
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-12-12 21:30:05 -05:00
|
|
|
write(<<~EOC.chomp)
|
|
|
|
def each_top_level_statement
|
|
|
|
initialize_input
|
|
|
|
catch(:TERM_INPUT) do
|
|
|
|
loop do
|
|
|
|
begin
|
|
|
|
prompt
|
|
|
|
unless l = lex
|
|
|
|
throw :TERM_INPUT if @line == ''
|
|
|
|
else
|
|
|
|
@line_no += l.count("\n")
|
|
|
|
next if l == "\n"
|
|
|
|
@line.concat l
|
|
|
|
if @code_block_open or @ltype or @continue or @indent > 0
|
|
|
|
next
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if @line != "\n"
|
|
|
|
@line.force_encoding(@io.encoding)
|
|
|
|
yield @line, @exp_line_no
|
|
|
|
end
|
|
|
|
break if @io.eof?
|
|
|
|
@line = ''
|
|
|
|
@exp_line_no = @line_no
|
|
|
|
#
|
|
|
|
@indent = 0
|
|
|
|
rescue TerminateLineInput
|
|
|
|
initialize_input
|
|
|
|
prompt
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
EOC
|
2021-01-13 18:34:30 -05:00
|
|
|
sleep 1
|
2020-12-12 21:30:05 -05:00
|
|
|
write("\C-p" * 6)
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
prompt> rescue Terminate
|
|
|
|
LineInput
|
|
|
|
prompt> initialize_inp
|
|
|
|
ut
|
|
|
|
prompt> prompt
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_longer_than_screen_height_with_complex_scroll_back
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(4, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-12-12 21:30:05 -05:00
|
|
|
write(<<~EOC.chomp)
|
|
|
|
def each_top_level_statement
|
|
|
|
initialize_input
|
|
|
|
catch(:TERM_INPUT) do
|
|
|
|
loop do
|
|
|
|
begin
|
|
|
|
prompt
|
|
|
|
unless l = lex
|
|
|
|
throw :TERM_INPUT if @line == ''
|
|
|
|
else
|
|
|
|
@line_no += l.count("\n")
|
|
|
|
next if l == "\n"
|
|
|
|
@line.concat l
|
|
|
|
if @code_block_open or @ltype or @continue or @indent > 0
|
|
|
|
next
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if @line != "\n"
|
|
|
|
@line.force_encoding(@io.encoding)
|
|
|
|
yield @line, @exp_line_no
|
|
|
|
end
|
|
|
|
break if @io.eof?
|
|
|
|
@line = ''
|
|
|
|
@exp_line_no = @line_no
|
|
|
|
#
|
|
|
|
@indent = 0
|
|
|
|
rescue TerminateLineInput
|
|
|
|
initialize_input
|
|
|
|
prompt
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
EOC
|
2021-01-13 18:34:30 -05:00
|
|
|
sleep 1
|
2020-12-12 21:30:05 -05:00
|
|
|
write("\C-p" * 5)
|
|
|
|
write("\C-n" * 3)
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
ut
|
|
|
|
prompt> prompt
|
|
|
|
prompt> end
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2020-12-27 04:37:16 -05:00
|
|
|
def test_update_cursor_correctly_when_just_cursor_moving
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2020-12-27 04:37:16 -05:00
|
|
|
write("def hoge\n 01234678")
|
|
|
|
write("\C-p")
|
|
|
|
write("\C-b")
|
|
|
|
write("\C-n")
|
|
|
|
write('5')
|
|
|
|
write("\C-e")
|
|
|
|
write('9')
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def hoge
|
|
|
|
prompt> 0123456789
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-01-05 04:22:00 -05:00
|
|
|
def test_suppress_auto_indent_just_after_pasted
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --auto-indent}, startup_message: 'Multiline REPL.')
|
2021-01-05 04:22:00 -05:00
|
|
|
write("def hoge\n [[\n 3]]\ned")
|
|
|
|
write("\C-bn")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def hoge
|
|
|
|
prompt> [[
|
|
|
|
prompt> 3]]
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-01-05 13:50:19 -05:00
|
|
|
def test_suppress_auto_indent_for_adding_newlines_in_pasting
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --auto-indent}, startup_message: 'Multiline REPL.')
|
2021-01-05 13:50:19 -05:00
|
|
|
write("<<~Q\n")
|
|
|
|
write("{\n #\n}")
|
|
|
|
write("#")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> <<~Q
|
|
|
|
prompt> {
|
|
|
|
prompt> #
|
|
|
|
prompt> }#
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-02-03 03:56:49 -05:00
|
|
|
def test_autowrap_in_the_middle_of_a_line
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2021-02-03 03:56:49 -05:00
|
|
|
write("def abcdefg; end\C-b\C-b\C-b\C-b\C-b")
|
|
|
|
%w{h i}.each do |c|
|
|
|
|
write(c)
|
|
|
|
end
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def abcdefgh
|
|
|
|
i; end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-02-05 07:39:29 -05:00
|
|
|
def test_terminate_in_the_middle_of_lines
|
2021-02-15 10:30:30 -05:00
|
|
|
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2021-02-05 07:39:29 -05:00
|
|
|
write("def hoge\n 1\n 2\n 3\n 4\nend\n")
|
|
|
|
write("\C-p\C-p\C-p\C-e\n")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
prompt> 3
|
|
|
|
prompt> 4
|
|
|
|
prompt> end
|
|
|
|
=> :hoge
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-02-15 11:46:53 -05:00
|
|
|
def test_dynamic_prompt_returns_empty
|
|
|
|
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dynamic-prompt-returns-empty}, startup_message: 'Multiline REPL.')
|
|
|
|
write("def hoge\nend\n")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def hoge
|
|
|
|
prompt> end
|
|
|
|
=> :hoge
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-04-02 04:18:37 -04:00
|
|
|
def test_reset_rest_height_when_clear_screen
|
|
|
|
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
|
|
|
write("\n\n\n\C-l3\n")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
prompt> 3
|
|
|
|
=> 3
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-04-16 06:59:36 -04:00
|
|
|
def test_meta_key
|
2021-10-04 09:46:03 -04:00
|
|
|
start_terminal(30, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2021-04-16 06:59:36 -04:00
|
|
|
write("def ge\M-bho")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def hoge
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_force_enter
|
2021-10-04 09:46:03 -04:00
|
|
|
start_terminal(30, 120, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
2021-04-16 06:59:36 -04:00
|
|
|
write("def hoge\nend\C-p\C-e")
|
|
|
|
write("\M-\x0D")
|
|
|
|
close
|
|
|
|
assert_screen(<<~EOC)
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def hoge
|
|
|
|
prompt>
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-05-16 09:50:59 -04:00
|
|
|
def test_with_newline
|
|
|
|
omit if Reline::IOGate.win?
|
|
|
|
cmd = %Q{ruby -e 'print(%Q{abc def \\e\\r})' | ruby -I#{@pwd}/lib -rreline -e 'p Reline.readline(%{> })'}
|
2021-10-04 09:46:03 -04:00
|
|
|
start_terminal(40, 50, ['bash', '-c', cmd])
|
2021-05-16 09:50:59 -04:00
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
> abc def
|
|
|
|
"abc def "
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-05-31 04:20:34 -04:00
|
|
|
def test_em_set_mark_and_em_exchange_mark
|
|
|
|
start_terminal(10, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
|
|
|
write("aaa bbb ccc ddd\M-b\M-b\M-\x20\M-b\C-x\C-xX\C-x\C-xY")
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> aaa Ybbb Xccc ddd
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-01 15:31:01 -04:00
|
|
|
def test_completion_journey_2nd_line
|
|
|
|
write_inputrc <<~LINES
|
|
|
|
set editing-mode vi
|
|
|
|
LINES
|
|
|
|
start_terminal(10, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --complete}, startup_message: 'Multiline REPL.')
|
|
|
|
write("def hoge\n S\C-n")
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def hoge
|
|
|
|
prompt> String
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-01 15:43:36 -04:00
|
|
|
def test_completion_journey_with_empty_line
|
|
|
|
write_inputrc <<~LINES
|
|
|
|
set editing-mode vi
|
|
|
|
LINES
|
|
|
|
start_terminal(10, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --complete}, startup_message: 'Multiline REPL.')
|
|
|
|
write("\C-n\C-p")
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt>
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 15:36:55 -04:00
|
|
|
def test_simple_dialog
|
2021-09-09 15:58:35 -04:00
|
|
|
start_terminal(20, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog simple}, startup_message: 'Multiline REPL.')
|
2021-09-09 15:36:55 -04:00
|
|
|
write('a')
|
|
|
|
write('b')
|
|
|
|
write('c')
|
|
|
|
write("\C-h")
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> ab
|
|
|
|
Ruby is...
|
|
|
|
A dynamic, open source programming
|
|
|
|
language with a focus on simplicity
|
|
|
|
and productivity. It has an elegant
|
|
|
|
syntax that is natural to read and
|
|
|
|
easy to write.
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 17:42:58 -04:00
|
|
|
def test_simple_dialog_at_right_edge
|
|
|
|
start_terminal(20, 40, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog simple}, startup_message: 'Multiline REPL.')
|
|
|
|
write('a')
|
|
|
|
write('b')
|
|
|
|
write('c')
|
|
|
|
write("\C-h")
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> ab
|
2021-10-09 10:19:59 -04:00
|
|
|
Ruby is...
|
|
|
|
A dynamic, open source programming
|
|
|
|
language with a focus on simplicity
|
|
|
|
and productivity. It has an elegant
|
|
|
|
syntax that is natural to read and
|
|
|
|
easy to write.
|
2021-09-09 17:42:58 -04:00
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 17:57:41 -04:00
|
|
|
def test_autocomplete_at_bottom
|
|
|
|
start_terminal(15, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
|
|
|
|
write('def hoge' + "\C-m" * 10 + "end\C-p ")
|
|
|
|
write('S')
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def hoge
|
|
|
|
prompt>
|
|
|
|
prompt>
|
|
|
|
prompt> String
|
|
|
|
prompt> Struct
|
|
|
|
prompt> Symbol
|
|
|
|
prompt> ScriptError
|
|
|
|
prompt> SyntaxError
|
|
|
|
prompt> Signal
|
|
|
|
prompt> S
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 19:08:56 -04:00
|
|
|
def test_autocomplete_return_to_original
|
|
|
|
start_terminal(20, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
|
|
|
|
write('S')
|
|
|
|
write('t')
|
|
|
|
write('r')
|
|
|
|
3.times{ write("\C-i") }
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> Str
|
|
|
|
String
|
|
|
|
Struct
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 18:37:12 -04:00
|
|
|
def test_autocomplete_target_is_wrapped
|
|
|
|
start_terminal(20, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
|
|
|
|
write(' ')
|
|
|
|
write('S')
|
|
|
|
write('t')
|
|
|
|
write('r')
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> St
|
2021-10-09 10:19:59 -04:00
|
|
|
r String
|
|
|
|
Struct
|
2021-09-09 18:37:12 -04:00
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 15:58:35 -04:00
|
|
|
def test_simple_dialog_with_scroll_key
|
|
|
|
start_terminal(20, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog long,scrollkey}, startup_message: 'Multiline REPL.')
|
|
|
|
write('a')
|
|
|
|
5.times{ write('j') }
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> a
|
|
|
|
A dynamic, open
|
|
|
|
source programming
|
|
|
|
language with a
|
|
|
|
focus on simplicity
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 19:54:24 -04:00
|
|
|
def test_simple_dialog_scrollbar_with_moving_to_right
|
|
|
|
start_terminal(20, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog long,scrollkey,scrollbar}, startup_message: 'Multiline REPL.')
|
|
|
|
6.times{ write('j') }
|
|
|
|
write('a')
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> a
|
|
|
|
source programming ▄
|
|
|
|
language with a █
|
|
|
|
focus on simplicity
|
|
|
|
and productivity.
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_simple_dialog_scrollbar_with_moving_to_left
|
|
|
|
start_terminal(20, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog long,scrollkey,scrollbar}, startup_message: 'Multiline REPL.')
|
|
|
|
write('a')
|
|
|
|
6.times{ write('j') }
|
|
|
|
write("\C-h")
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt>
|
|
|
|
source programming ▄
|
|
|
|
language with a █
|
|
|
|
focus on simplicity
|
|
|
|
and productivity.
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-10-10 05:58:46 -04:00
|
|
|
def test_dialog_with_fullwidth_chars
|
|
|
|
ENV['RELINE_TEST_PROMPT'] = '> '
|
|
|
|
start_terminal(30, 5, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog fullwidth,scrollkey,scrollbar}, startup_message: 'Multiline REPL.')
|
|
|
|
6.times{ write('j') }
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multi
|
|
|
|
line
|
|
|
|
REPL.
|
|
|
|
>
|
|
|
|
オー
|
|
|
|
グ言▄
|
|
|
|
備え█
|
|
|
|
ち、█
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_dialog_with_fullwidth_chars_split
|
|
|
|
ENV['RELINE_TEST_PROMPT'] = '> '
|
|
|
|
start_terminal(30, 6, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog fullwidth,scrollkey,scrollbar}, startup_message: 'Multiline REPL.')
|
|
|
|
6.times{ write('j') }
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multil
|
|
|
|
ine RE
|
|
|
|
PL.
|
|
|
|
>
|
|
|
|
オー
|
|
|
|
グ言 ▄
|
|
|
|
備え █
|
|
|
|
ち、 █
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 18:57:53 -04:00
|
|
|
def test_autocomplete_empty
|
|
|
|
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
|
|
|
|
write('Street')
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> Street
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-08 18:22:53 -04:00
|
|
|
def test_autocomplete
|
|
|
|
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
|
2021-09-09 18:58:34 -04:00
|
|
|
write('Str')
|
2021-09-08 18:22:53 -04:00
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
2021-09-09 18:34:33 -04:00
|
|
|
prompt> Str
|
2021-09-08 18:22:53 -04:00
|
|
|
String
|
|
|
|
Struct
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 19:24:37 -04:00
|
|
|
def test_autocomplete_after_2nd_line
|
|
|
|
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
|
|
|
|
write("def hoge\n Str")
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def hoge
|
|
|
|
prompt> Str
|
|
|
|
String
|
|
|
|
Struct
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 19:29:01 -04:00
|
|
|
def test_autocomplete_rerender_under_dialog
|
|
|
|
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
|
|
|
|
write("def hoge\n\n 123456\n 456789\nend\C-p\C-p\C-p a = Str")
|
|
|
|
write('i')
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> def hoge
|
|
|
|
prompt> a = Stri
|
|
|
|
prompt> 1234String
|
|
|
|
prompt> 456789
|
|
|
|
prompt> end
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 15:37:19 -04:00
|
|
|
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.')
|
2021-09-09 18:58:34 -04:00
|
|
|
write('S')
|
2021-09-09 15:37:19 -04:00
|
|
|
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.')
|
2021-09-09 18:58:34 -04:00
|
|
|
write('S' + "\C-i" * 16)
|
2021-09-09 15:37:19 -04:00
|
|
|
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
|
|
|
|
|
2021-10-03 05:25:26 -04:00
|
|
|
def test_autocomplete_super_long_and_backspace
|
|
|
|
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete-super-long}, startup_message: 'Multiline REPL.')
|
|
|
|
shift_tab = [27, 91, 90]
|
|
|
|
write('S' + shift_tab.map(&:chr).join)
|
|
|
|
write("\C-h")
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> Str_BX
|
|
|
|
Str_BX
|
|
|
|
Str_BXA
|
|
|
|
Str_BXB
|
|
|
|
Str_BXC
|
|
|
|
Str_BXD
|
|
|
|
Str_BXE
|
|
|
|
Str_BXF
|
|
|
|
Str_BXG
|
|
|
|
Str_BXH
|
|
|
|
Str_BXI
|
|
|
|
Str_BXJ
|
|
|
|
Str_BXK
|
|
|
|
Str_BXL
|
|
|
|
Str_BXM
|
|
|
|
Str_BXN
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-09-09 19:15:00 -04:00
|
|
|
def test_dialog_callback_returns_nil
|
|
|
|
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog nil}, startup_message: 'Multiline REPL.')
|
|
|
|
write('a')
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> a
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-10-05 13:56:14 -04:00
|
|
|
def test_dialog_narrower_than_screen
|
2021-10-05 14:25:53 -04:00
|
|
|
start_terminal(20, 11, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog simple}, startup_message: 'Multiline REPL.')
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline R
|
|
|
|
EPL.
|
|
|
|
prompt>
|
|
|
|
Ruby is...
|
|
|
|
A dynamic,
|
|
|
|
language wi
|
|
|
|
and product
|
|
|
|
syntax that
|
|
|
|
easy to wri
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_dialog_narrower_than_screen_with_scrollbar
|
2021-10-05 13:56:14 -04:00
|
|
|
start_terminal(20, 11, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete-long}, startup_message: 'Multiline REPL.')
|
|
|
|
write('S' + "\C-i" * 3)
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline R
|
|
|
|
EPL.
|
|
|
|
prompt> Sym
|
|
|
|
String
|
|
|
|
Struct █
|
|
|
|
Symbol █
|
|
|
|
StopIterat█
|
|
|
|
SystemCall█
|
|
|
|
SystemExit█
|
|
|
|
SystemStac█
|
|
|
|
ScriptErro█
|
|
|
|
SyntaxErro█
|
|
|
|
Signal █
|
|
|
|
SizedQueue█
|
|
|
|
Set
|
|
|
|
SecureRand
|
|
|
|
Socket
|
|
|
|
StringIO
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-10-09 10:07:18 -04:00
|
|
|
def test_dialog_with_fullwidth_scrollbar
|
|
|
|
start_terminal(20, 40, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dialog simple,scrollkey,alt-scrollbar}, startup_message: 'Multiline REPL.')
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt>
|
|
|
|
Ruby is... ::
|
|
|
|
A dynamic, open source programming ::
|
|
|
|
language with a focus on simplicity''
|
|
|
|
and productivity. It has an elegant
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-10-01 01:16:42 -04:00
|
|
|
def test_rerender_argument_prompt_after_pasting
|
|
|
|
start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl}, startup_message: 'Multiline REPL.')
|
|
|
|
write('abcdef')
|
|
|
|
write("\M-3\C-h")
|
|
|
|
close
|
|
|
|
assert_screen(<<~'EOC')
|
|
|
|
Multiline REPL.
|
|
|
|
prompt> abc
|
|
|
|
EOC
|
|
|
|
end
|
|
|
|
|
2021-08-13 00:44:08 -04:00
|
|
|
def write_inputrc(content)
|
2020-10-06 10:55:33 -04:00
|
|
|
File.open(@inputrc_file, 'w') do |f|
|
|
|
|
f.write content
|
|
|
|
end
|
|
|
|
end
|
2020-03-21 05:31:20 -04:00
|
|
|
end
|
2020-03-21 05:41:14 -04:00
|
|
|
rescue LoadError, NameError
|
|
|
|
# On Ruby repository, this test suit doesn't run because Ruby repo doesn't
|
|
|
|
# have the yamatanooroti gem.
|
2020-03-21 05:31:20 -04:00
|
|
|
end
|