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

ruby-changes:67680

From: aycabta <ko1@a...>
Date: Fri, 10 Sep 2021 09:04:46 +0900 (JST)
Subject: [ruby-changes:67680] 364e646317 (master): [ruby/reline] Add a test for simple dialog

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

From 364e646317fb9bf0f284532ad8a1c1e707bcbb21 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Fri, 10 Sep 2021 04:36:55 +0900
Subject: [ruby/reline] Add a test for simple dialog

https://github.com/ruby/reline/commit/d70f507e2c
---
 test/reline/yamatanooroti/multiline_repl    | 13 +++++++++++++
 test/reline/yamatanooroti/test_rendering.rb | 19 +++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/test/reline/yamatanooroti/multiline_repl b/test/reline/yamatanooroti/multiline_repl
index b21ad4b..4de3f81 100755
--- a/test/reline/yamatanooroti/multiline_repl
+++ b/test/reline/yamatanooroti/multiline_repl
@@ -30,6 +30,19 @@ opt.on('--dynamic-prompt-returns-empty') { https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/multiline_repl#L30
 opt.on('--auto-indent') {
   AutoIndent.new
 }
+opt.on('--simple-dialog') {
+  Reline.add_dialog_proc(:simple_dialog, lambda {
+    contents = <<~RUBY.split("\n")
+      Ruby is...
+      A dynamic, open source programming
+      language with a focus on simplicity
+      and productivity. It has an elegant
+      syntax that is natural to read and
+      easy to write.
+    RUBY
+    Reline::DialogRenderInfo.new(pos: cursor_pos, contents: contents)
+  })
+}
 opt.on('--complete') {
   Reline.completion_proc = lambda { |target, preposing = nil, postposing = nil|
     %w{String ScriptError SyntaxError Signal}
diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb
index 55b122e..2ae0b81 100644
--- a/test/reline/yamatanooroti/test_rendering.rb
+++ b/test/reline/yamatanooroti/test_rendering.rb
@@ -835,6 +835,25 @@ begin https://github.com/ruby/ruby/blob/trunk/test/reline/yamatanooroti/test_rendering.rb#L835
       EOC
     end
 
+    def test_simple_dialog
+      start_terminal(20, 50, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --simple-dialog}, startup_message: 'Multiline REPL.')
+      write('a')
+      write('b')
+      write('c')
+      write("\C-h")
+      close
+      assert_screen(<<~'EOC')
+        Multiline REPL.
+        prompt> ab
+                  Ruby is...
+                  A dynamic, open source programming
+                  language with a focus on simplicity
+                  and productivity. It has an elegant
+                  syntax that is natural to read and
+                  easy to write.
+      EOC
+    end
+
     def test_autocomplete
       start_terminal(20, 30, %W{ruby -I#{@pwd}/lib #{@pwd}/test/reline/yamatanooroti/multiline_repl --autocomplete}, startup_message: 'Multiline REPL.')
       write("Stri")
-- 
cgit v1.1


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

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