summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_io.rb13
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'"