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

ruby-changes:74235

From: st0012 <ko1@a...>
Date: Mon, 24 Oct 2022 22:37:16 +0900 (JST)
Subject: [ruby-changes:74235] 5a86155249 (master): [ruby/irb] Add a test case to cover rdoc unintalled scenario

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

From 5a86155249d0cba9135327bce8f5d3f6f69721d8 Mon Sep 17 00:00:00 2001
From: st0012 <stan001212@g...>
Date: Fri, 21 Oct 2022 21:36:13 +0100
Subject: [ruby/irb] Add a test case to cover rdoc unintalled scenario

---
 test/irb/test_input_method.rb | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/test/irb/test_input_method.rb b/test/irb/test_input_method.rb
index 5b2d35aeab..77f10774e9 100644
--- a/test/irb/test_input_method.rb
+++ b/test/irb/test_input_method.rb
@@ -53,6 +53,37 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_input_method.rb#L53
     ensure
       Reline.add_dialog_proc(:show_doc, original_show_doc_proc, Reline::DEFAULT_DIALOG_CONTEXT)
     end
+
+    def test_initialization_with_use_autocomplete_but_without_rdoc
+      original_show_doc_proc = Reline.dialog_proc(:show_doc)&.dialog_proc
+      empty_proc = Proc.new {}
+      Reline.add_dialog_proc(:show_doc, empty_proc)
+
+      IRB.conf[:USE_AUTOCOMPLETE] = true
+
+      without_rdoc do
+        IRB::RelineInputMethod.new
+      end
+
+      assert Reline.autocompletion
+      # doesn't register show_doc dialog
+      assert_equal empty_proc, Reline.dialog_proc(:show_doc).dialog_proc
+    ensure
+      Reline.add_dialog_proc(:show_doc, original_show_doc_proc, Reline::DEFAULT_DIALOG_CONTEXT)
+    end
+
+    def without_rdoc(&block)
+      ::Kernel.send(:alias_method, :old_require, :require)
+
+      ::Kernel.define_method(:require) do |name|
+        raise LoadError, "cannot load such file -- rdoc (test)" if name == "rdoc"
+        original_require(name)
+      end
+
+      yield
+    ensure
+      ::Kernel.send(:alias_method, :require, :old_require)
+    end
   end
 end
 
-- 
cgit v1.2.3


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

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