[前][次][番号順一覧][スレッド一覧]

ruby-changes:57949

From: Nobuyoshi <ko1@a...>
Date: Fri, 27 Sep 2019 01:14:25 +0900 (JST)
Subject: [ruby-changes:57949] 81191afe8a (master): Kernel#open may be redefined

https://git.ruby-lang.org/ruby.git/commit/?id=81191afe8a

From 81191afe8a9b40e6dd6cc8e0d1a9899938840073 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Fri, 27 Sep 2019 01:13:10 +0900
Subject: Kernel#open may be redefined


diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 280d11f..6a27b5d 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2283,13 +2283,24 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2283
     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
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]