summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-09-27 01:13:10 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-09-27 01:13:10 +0900
commit81191afe8a9b40e6dd6cc8e0d1a9899938840073 (patch)
treeca16f18d09ebdd141f016c3f4bf761c9b38d84c2 /test
parent617fa3049a151d773bb26151ae774a8f6a60bc2a (diff)
Kernel#open may be redefined
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 280d11f786..6a27b5dc93 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2283,13 +2283,24 @@ class TestIO < Test::Unit::TestCase
o = Object.new
def o.to_open(**kw); kw; end
assert_equal({:a=>1}, open(o, a: 1))
- assert_warn(/The last argument is used as the keyword parameter.*for `to_open'/m) do
+
+ w = /The last argument is used as the keyword parameter.*for `(to_)?open'/m
+ redefined = nil
+ w.singleton_class.define_method(:===) do |s|
+ match = super(s)
+ redefined = !$1
+ match
+ end
+
+ assert_warn(w) do
assert_equal({:a=>1}, open(o, {a: 1}))
end
def o.to_open(kw); kw; end
assert_equal({:a=>1}, open(o, a: 1))
- assert_equal({:a=>1}, open(o, {a: 1}))
+ unless redefined
+ assert_equal({:a=>1}, open(o, {a: 1}))
+ end
end
def test_open_pipe