ruby-changes:57940
From: Jeremy <ko1@a...>
Date: Fri, 27 Sep 2019 00:02:16 +0900 (JST)
Subject: [ruby-changes:57940] 0aa267f985 (master): Fix keyword argument sepration issues when IO#open calls #to_open
https://git.ruby-lang.org/ruby.git/commit/?id=0aa267f985 From 0aa267f985084e69c3e45cc3e94698eaacab5c36 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Wed, 25 Sep 2019 11:02:40 -0700 Subject: Fix keyword argument sepration issues when IO#open calls #to_open diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index a610b60..280d11f 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2279,6 +2279,19 @@ class TestIO < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_io.rb#L2279 assert_equal(o, o2) end + def test_open_redirect_keyword + 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 + 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})) + end + def test_open_pipe open("|" + EnvUtil.rubybin, "r+") do |f| f.puts "puts 'foo'" -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/