summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/reline/helper.rb8
-rwxr-xr-xtest/reline/yamatanooroti/multiline_repl7
-rw-r--r--test/reline/yamatanooroti/test_rendering.rb12
3 files changed, 20 insertions, 7 deletions
diff --git a/test/reline/helper.rb b/test/reline/helper.rb
index c2a47a79d1..b8751ff16e 100644
--- a/test/reline/helper.rb
+++ b/test/reline/helper.rb
@@ -157,13 +157,7 @@ class Reline::TestCase < Test::Unit::TestCase
end
def assert_whole_lines(expected)
- previous_line_index = @line_editor.instance_variable_get(:@previous_line_index)
- if previous_line_index
- lines = @line_editor.whole_lines(index: previous_line_index)
- else
- lines = @line_editor.whole_lines
- end
- assert_equal(expected, lines)
+ assert_equal(expected, @line_editor.whole_lines)
end
def assert_key_binding(input, method_symbol, editing_modes = [:emacs, :vi_insert, :vi_command])
diff --git a/test/reline/yamatanooroti/multiline_repl b/test/reline/yamatanooroti/multiline_repl
index 7e58b602eb..73f5159ee2 100755
--- a/test/reline/yamatanooroti/multiline_repl
+++ b/test/reline/yamatanooroti/multiline_repl
@@ -52,6 +52,13 @@ opt.on('--color-bold') {
output.gsub(/./) { |c| "\e[1m#{c}\e[0m" }
}
}
+opt.on('--dynamic-prompt-show-line') {
+ Reline.prompt_proc = proc { |lines|
+ lines.map { |l|
+ '[%4.4s]> ' % l
+ }
+ }
+}
opt.on('--auto-indent') {
Reline.auto_indent_proc = lambda do |lines, line_index, byte_pointer, is_newline|
AutoIndent.calculate_indent(lines, line_index, byte_pointer, is_newline)
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index 90cd3b52c9..d02abc60bc 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -1335,6 +1335,18 @@ begin
EOC
end
+ def test_lines_passed_to_dynamic_prompt
+ start_terminal(5, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --dynamic-prompt-show-line}, startup_message: 'Multiline REPL.')
+ write("if true")
+ write("\n")
+ close
+ assert_screen(<<~EOC)
+ Multiline REPL.
+ [if t]> if true
+ [ ]>
+ EOC
+ end
+
def test_clear_dialog_when_just_move_cursor_at_last_line
start_terminal(10, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
write("class A\n 3\nend\n")