mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/reline] Add tests about complicated rendering
https://github.com/ruby/reline/commit/f4683b72eb
This commit is contained in:
parent
dd87d639e9
commit
da59f65178
1 changed files with 135 additions and 0 deletions
|
@ -225,6 +225,141 @@ begin
|
|||
EOC
|
||||
end
|
||||
|
||||
def test_multiline_and_autowrap
|
||||
start_terminal(10, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
write("def aaaaaa\n 33333333\n end\C-a\C-pputs\C-e\e\C-m88888888888")
|
||||
close
|
||||
assert_screen(<<~EOC)
|
||||
Multiline REPL.
|
||||
prompt> def aaa
|
||||
aaa
|
||||
prompt> puts 3
|
||||
3333333
|
||||
prompt> 8888888
|
||||
8888
|
||||
prompt>
|
||||
end
|
||||
EOC
|
||||
end
|
||||
|
||||
def test_clear
|
||||
start_terminal(10, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
write("3\C-l")
|
||||
close
|
||||
assert_screen(<<~EOC)
|
||||
prompt> 3
|
||||
EOC
|
||||
end
|
||||
|
||||
def test_clear_multiline_and_autowrap
|
||||
omit # FIXME clear logic is buggy
|
||||
start_terminal(10, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
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
|
||||
start_terminal(10, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
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
|
||||
start_terminal(10, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
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
|
||||
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
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
|
||||
start_terminal(5, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
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
|
||||
start_terminal(5, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
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
|
||||
start_terminal(3, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
write("3333333333\C-a\C-f\e\C-m")
|
||||
close
|
||||
assert_screen(<<~EOC)
|
||||
prompt> 3
|
||||
prompt> 3333333
|
||||
33
|
||||
EOC
|
||||
end
|
||||
|
||||
def test_insert_after_clear
|
||||
start_terminal(10, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
write("def a\n 01234\nend\C-l\C-p5678")
|
||||
close
|
||||
assert_screen(<<~EOC)
|
||||
prompt> def a
|
||||
prompt> 056781234
|
||||
prompt> end
|
||||
EOC
|
||||
end
|
||||
|
||||
def test_multiline_incremental_search
|
||||
start_terminal(5, 20, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
|
||||
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
|
||||
|
||||
private def write_inputrc(content)
|
||||
File.open(@inputrc_file, 'w') do |f|
|
||||
f.write content
|
||||
|
|
Loading…
Reference in a new issue