Skip to content

Commit

Permalink
Test show_source as a method
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Nov 7, 2022
1 parent e31bd8d commit e8b1c9d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/irb/test_cmd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,23 @@ def test_show_source
assert_match(%r[/irb\.rb], out)
end

def test_show_source_method
input = TestInputMethod.new([
"p show_source('IRB.conf')\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_match(%r[/irb\.rb], out)
end

def test_show_source_string
input = TestInputMethod.new([
"show_source 'IRB.conf'\n",
Expand Down

0 comments on commit e8b1c9d

Please sign in to comment.