summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2022-11-07 09:29:24 -0800
committergit <svn-admin@ruby-lang.org>2022-11-07 17:29:28 +0000
commit9001e53e68d282493f513ed67824e4014fd01d57 (patch)
tree1b8070f10aa422b2d6510c56f93e924c0bb4abbf /test
parent7442cb461b32de2eec3b37f52d80752d30627de0 (diff)
[ruby/irb] Support non-string input in show_source
(https://github.com/ruby/irb/pull/430) * Support non-string input in show_source * Test show_source as a method
Diffstat (limited to 'test')
-rw-r--r--test/irb/test_cmd.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb
index 2728aa656a..531ea519f3 100644
--- a/test/irb/test_cmd.rb
+++ b/test/irb/test_cmd.rb
@@ -548,6 +548,40 @@ module TestIRB
def test_show_source
input = TestInputMethod.new([
+ "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_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",
])
IRB.init_config(nil)