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:
parent
cf74755921
commit
b33caa5bbc
1 changed files with 29 additions and 0 deletions
|
@ -509,6 +509,29 @@ module TestIRB
|
||||||
assert_match(%r[/irb\.rb], out)
|
assert_match(%r[/irb\.rb], out)
|
||||||
end
|
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
|
def test_whereami
|
||||||
input = TestInputMethod.new([
|
input = TestInputMethod.new([
|
||||||
"whereami\n",
|
"whereami\n",
|
||||||
|
@ -525,5 +548,11 @@ module TestIRB
|
||||||
assert_empty err
|
assert_empty err
|
||||||
assert_match(/^From: .+ @ line \d+ :\n/, out)
|
assert_match(/^From: .+ @ line \d+ :\n/, out)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This method is used for testing show_source command
|
||||||
|
def show_source_test_method
|
||||||
|
unless true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue