diff options
author | aycabta <aycabta@gmail.com> | 2020-04-28 17:06:43 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2020-04-29 19:13:14 +0900 |
commit | 3864fbc6d85b834be4567fa1d5bd0dccc4dfd808 (patch) | |
tree | a1ce65277028a5179104bb826af9424bd5580c97 /test/irb | |
parent | 98a346d065cc981d60ec0e45f7f15ba7328b6ad6 (diff) |
[ruby/irb] Check existence of rc files in irb_info command
https://github.com/ruby/irb/commit/cdbb9dfc9f
Diffstat (limited to 'test/irb')
-rw-r--r-- | test/irb/test_cmd.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb index 1f385512a6..7a9e7d79e1 100644 --- a/test/irb/test_cmd.rb +++ b/test/irb/test_cmd.rb @@ -60,5 +60,55 @@ module TestIRB }x assert_match expected, irb.context.main.irb_info.to_s end + + def test_irb_info_multiline_without_rc_files + inputrc_backup = ENV["INPUTRC"] + ENV["INPUTRC"] = "unkown_inpurc" + ext_backup = IRB::IRBRC_EXT + IRB.__send__(:remove_const, :IRBRC_EXT) + IRB.const_set(:IRBRC_EXT, "unkown_ext") + IRB.setup(__FILE__, argv: []) + IRB.conf[:USE_MULTILINE] = true + IRB.conf[:USE_SINGLELINE] = false + workspace = IRB::WorkSpace.new(self) + irb = IRB::Irb.new(workspace) + IRB.conf[:MAIN_CONTEXT] = irb.context + expected = %r{ + Ruby\sversion: .+\n + IRB\sversion:\sirb .+\n + InputMethod:\sReidlineInputMethod\swith\sReline\s[^ ]+(?!\sand\s.+)\n + \z + }x + assert_match expected, irb.context.main.irb_info.to_s + ensure + ENV["INPUTRC"] = inputrc_backup + IRB.__send__(:remove_const, :IRBRC_EXT) + IRB.const_set(:IRBRC_EXT, ext_backup) + end + + def test_irb_info_singleline_without_rc_files + inputrc_backup = ENV["INPUTRC"] + ENV["INPUTRC"] = "unkown_inpurc" + ext_backup = IRB::IRBRC_EXT + IRB.__send__(:remove_const, :IRBRC_EXT) + IRB.const_set(:IRBRC_EXT, "unkown_ext") + IRB.setup(__FILE__, argv: []) + IRB.conf[:USE_MULTILINE] = false + IRB.conf[:USE_SINGLELINE] = true + workspace = IRB::WorkSpace.new(self) + irb = IRB::Irb.new(workspace) + IRB.conf[:MAIN_CONTEXT] = irb.context + expected = %r{ + Ruby\sversion: .+\n + IRB\sversion:\sirb .+\n + InputMethod:\sReadlineInputMethod\swith\s[^ ]+\s[^ ]+(?!\sand\s.+)\n + \z + }x + assert_match expected, irb.context.main.irb_info.to_s + ensure + ENV["INPUTRC"] = inputrc_backup + IRB.__send__(:remove_const, :IRBRC_EXT) + IRB.const_set(:IRBRC_EXT, ext_backup) + end end end |