Skip to content

Commit

Permalink
Merge pull request #182 from aycabta/add-tests-about-complicated-rend…
Browse files Browse the repository at this point in the history
…ering

Add tests about complicated rendering
  • Loading branch information
aycabta authored Oct 10, 2020
2 parents 6c98c9a + f4683b7 commit 26388b8
Showing 1 changed file with 135 additions and 0 deletions.
135 changes: 135 additions & 0 deletions test/reline/yamatanooroti/test_rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,141 @@ def test_prompt_with_escape_sequence_and_autowrap
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
Expand Down

0 comments on commit 26388b8

Please sign in to comment.