Skip to content

Commit

Permalink
Fix keyword argument sepration issues when IO#open calls #to_open
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Sep 26, 2019
1 parent 5b9d646 commit 0aa267f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/ruby/test_io.rb
Expand Up @@ -2279,6 +2279,19 @@ def o.to_open; self; end
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'"
Expand Down

0 comments on commit 0aa267f

Please sign in to comment.