diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-09-25 11:02:40 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-09-26 08:01:53 -0700 |
commit | 0aa267f985084e69c3e45cc3e94698eaacab5c36 (patch) | |
tree | bc7458be896fd043315e3e8bbf8fbc5e337baaec /test | |
parent | 5b9d646944fe3a2f92682be906b0e9c7beae323c (diff) |
Fix keyword argument sepration issues when IO#open calls #to_open
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2484
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_io.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index a610b608aa..280d11f786 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2279,6 +2279,19 @@ class TestIO < Test::Unit::TestCase 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'" |