summaryrefslogtreecommitdiff
path: root/test/reline/yamatanooroti/multiline_repl
diff options
context:
space:
mode:
authortomoya ishida <tomoyapenguin@gmail.com>2023-07-19 22:31:13 +0900
committergit <svn-admin@ruby-lang.org>2023-07-19 13:31:17 +0000
commit7380c73af410d33dc2d4a3d77871d2001531416f (patch)
tree5b84261ac5d78a6242a01403be8acaa7f382a061 /test/reline/yamatanooroti/multiline_repl
parentca561480eaf8aba3d1c7ac70725cb1a726b3a5ba (diff)
[ruby/reline] Add assertion to auto_indent_proc's parameter, add
Ctrl-d exit test (https://github.com/ruby/reline/pull/574) * Add auto_indent_proc's parameter assertion in multiline_repl * Add rendering test for Ctrl-d exit https://github.com/ruby/reline/commit/46db71132a
Diffstat (limited to 'test/reline/yamatanooroti/multiline_repl')
-rwxr-xr-xtest/reline/yamatanooroti/multiline_repl16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/reline/yamatanooroti/multiline_repl b/test/reline/yamatanooroti/multiline_repl
index 73f5159ee2..bdefc48faa 100755
--- a/test/reline/yamatanooroti/multiline_repl
+++ b/test/reline/yamatanooroti/multiline_repl
@@ -59,8 +59,24 @@ opt.on('--dynamic-prompt-show-line') {
}
}
}
+
+def assert_auto_indent_params(lines, line_index, byte_pointer, is_newline)
+ raise 'Wrong lines type' unless lines.all?(String)
+
+ line = lines[line_index]
+ raise 'Wrong line_index value' unless line
+
+ # The condition `byte_pointer <= line.bytesize` is not satisfied. Maybe bug.
+ # Instead, loose constraint `byte_pointer <= line.bytesize + 1` seems to be satisfied when is_newline is false.
+ return if is_newline
+
+ raise 'byte_pointer out of bounds' unless byte_pointer <= line.bytesize + 1
+ raise 'Invalid byte_pointer' unless line.byteslice(0, byte_pointer).valid_encoding?
+end
+
opt.on('--auto-indent') {
Reline.auto_indent_proc = lambda do |lines, line_index, byte_pointer, is_newline|
+ assert_auto_indent_params(lines, line_index, byte_pointer, is_newline)
AutoIndent.calculate_indent(lines, line_index, byte_pointer, is_newline)
end
}