diff options
author | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-12 11:25:16 +0000 |
---|---|---|
committer | k0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-12 11:25:16 +0000 |
commit | da1ba13714f0a1025e4e60ef50d477a2603c1a3a (patch) | |
tree | 04b8046c765f7d1cec10db66cf45945211422459 /test/irb | |
parent | 8d1d4e3164a095ed488fd07c2eb75fa084378ab7 (diff) |
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
Diffstat (limited to 'test/irb')
-rw-r--r-- | test/irb/test_init.rb | 25 |
1 files changed, 25 insertions, 0 deletions
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 |