ruby-changes:68370
From: Takashi <ko1@a...>
Date: Mon, 11 Oct 2021 15:24:25 +0900 (JST)
Subject: [ruby-changes:68370] b33caa5bbc (master): [ruby/irb] Add a test of find_end for show_source command
https://git.ruby-lang.org/ruby.git/commit/?id=b33caa5bbc From b33caa5bbc1ff6cb2ea1656419e1fa09e3e60690 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Sun, 10 Oct 2021 23:02:50 -0700 Subject: [ruby/irb] Add a test of find_end for show_source command https://github.com/ruby/irb/commit/68e6ca95a0 --- test/irb/test_cmd.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index e6bb587b5c..f3e1d44358 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -509,6 +509,29 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_cmd.rb#L509 assert_match(%r[/irb\.rb], out) end + def test_show_source_end_finder + code = <<~EOS.gsub(/^/, ' ' * 4); eval(code, binding, __FILE__, __LINE__ + 1) unless respond_to?(:show_source_test_method) + def show_source_test_method + unless true + end + end + EOS + input = TestInputMethod.new([ + "show_source 'TestIRB::ExtendCommand#show_source_test_method'\n", + ]) + IRB.init_config(nil) + workspace = IRB::WorkSpace.new(self) + IRB.conf[:VERBOSE] = false + irb = IRB::Irb.new(workspace, input) + IRB.conf[:MAIN_CONTEXT] = irb.context + irb.context.return_format = "=> %s\n" + out, err = capture_output do + irb.eval_input + end + assert_empty err + assert_include(out, code) + end + def test_whereami input = TestInputMethod.new([ "whereami\n", @@ -525,5 +548,11 @@ module TestIRB https://github.com/ruby/ruby/blob/trunk/test/irb/test_cmd.rb#L548 assert_empty err assert_match(/^From: .+ @ line \d+ :\n/, out) end + + # This method is used for testing show_source command + def show_source_test_method + unless true + end + end end end -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/