aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2021-10-10 23:02:50 -0700
committerTakashi Kokubun <takashikkbn@gmail.com>2021-10-10 23:23:47 -0700
commitb33caa5bbc1ff6cb2ea1656419e1fa09e3e60690 (patch)
tree331fd27750331623da9ee9ef78642a7f5e3dd78f
parentcf74755921623225b30d592a83792c43677b9f52 (diff)
downloadruby-b33caa5bbc1ff6cb2ea1656419e1fa09e3e60690.tar.gz
[ruby/irb] Add a test of find_end for show_source command
https://github.com/ruby/irb/commit/68e6ca95a0
-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