summaryrefslogtreecommitdiff
path: root/test/reline
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2020-10-09 21:46:22 +0900
committeraycabta <aycabta@gmail.com>2020-12-05 02:58:58 +0900
commitdd87d639e9ce71be474a9a5eb014875c88e2ae6b (patch)
tree50da050ec2fcf72c4d19ae2f73bb43017d48cd2f /test/reline
parent87f51c7e66f9e92242621dda526c668071c315be (diff)
[ruby/reline] Test prompt with escape sequence
https://github.com/ruby/reline/commit/c7c1d5f5d1
Diffstat (limited to 'test/reline')
-rw-r--r--test/reline/yamatanooroti/test_rendering.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index 7b32f0aed0..87af9c5155 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -23,6 +23,7 @@ begin
Dir.chdir(@pwd)
FileUtils.rm_rf(@tmpdir)
ENV['INPUTRC'] = @inputrc_backup
+ ENV.delete('RELINE_TEST_PROMPT') if ENV['RELINE_TEST_PROMPT']
end
def test_history_back
@@ -197,6 +198,33 @@ begin
EOC
end
+ def test_prompt_with_escape_sequence
+ ENV['RELINE_TEST_PROMPT'] = "\1\e[30m\2prompt> \1\e[m\2"
+ start_terminal(5, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
+ 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"
+ start_terminal(5, 15, %W{ruby -I#{@pwd}/lib #{@pwd}/bin/multiline_repl}, startup_message: 'Multiline REPL.')
+ write("12345678\n")
+ close
+ assert_screen(<<~EOC)
+ Multiline REPL.
+ prompt> 1234567
+ 8
+ => 12345678
+ prompt>
+ EOC
+ end
+
private def write_inputrc(content)
File.open(@inputrc_file, 'w') do |f|
f.write content