summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/irb/test_cmd.rb29
1 files changed, 29 insertions, 0 deletions
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
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
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