[前][次][番号順一覧][スレッド一覧]

ruby-changes:63912

From: aycabta <ko1@a...>
Date: Sat, 5 Dec 2020 03:09:07 +0900 (JST)
Subject: [ruby-changes:63912] dd87d639e9 (master): [ruby/reline] Test prompt with escape sequence

https://git.ruby-lang.org/ruby.git/commit/?id=dd87d639e9

From dd87d639e9ce71be474a9a5eb014875c88e2ae6b Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Fri, 9 Oct 2020 21:46:22 +0900
Subject: [ruby/reline] Test prompt with escape sequence

https://github.com/ruby/reline/commit/c7c1d5f5d1

diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index 7b32f0a..87af9c5 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -23,6 +23,7 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L23
       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 https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L198
       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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]