From da1ba13714f0a1025e4e60ef50d477a2603c1a3a Mon Sep 17 00:00:00 2001 From: k0kubun Date: Tue, 12 Dec 2017 11:25:16 +0000 Subject: irb.rb: preserve ARGV on binding.irb This is not perfectly good solution (at least we don't want to have ARGV as default value of `argv` argument), but unfortunately IRB.setup and IRB.parse_opts are public methods and we can't make breaking change to those methods. We may deprecate using them and then make them private in the future, but the removal should not be in Ruby 2.5. So I kept their interface for now. [Bug #14162] [close GH-1770] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/irb/test_init.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/irb/test_init.rb (limited to 'test') diff --git a/test/irb/test_init.rb b/test/irb/test_init.rb new file mode 100644 index 0000000000..f2022253f9 --- /dev/null +++ b/test/irb/test_init.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: false +require "test/unit" +require "irb" + +module TestIRB + class TestInit < Test::Unit::TestCase + def test_setup_with_argv_preserves_global_argv + argv = ["foo", "bar"] + with_argv(argv) do + IRB.setup(eval("__FILE__"), argv: []) + assert_equal argv, ARGV + end + end + + private + + def with_argv(argv) + orig = ARGV.dup + ARGV.replace(argv) + yield + ensure + ARGV.replace(orig) + end + end +end -- cgit v1.2.3