1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/irb] Add a test of find_end for show_source command

https://github.com/ruby/irb/commit/68e6ca95a0
This commit is contained in:
Takashi Kokubun 2021-10-10 23:02:50 -07:00
parent cf74755921
commit b33caa5bbc

View file

@ -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