From e8b1c9d099ea4c40985cac0ce1c8b97079122376 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Mon, 7 Nov 2022 09:26:05 -0800 Subject: [PATCH] Test show_source as a method --- test/irb/test_cmd.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index 22ee5eaaa..a48b2c116 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -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",