summaryrefslogtreecommitdiff
path: root/test/ruby/test_io.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2024-05-25 19:15:25 +0900
committerNobuyoshi Nakada <[email protected]>2024-05-25 19:15:25 +0900
commit0bae2f00025b6b51a9e0c9e3348d5f5d16c2aae4 (patch)
treeddc7f328efdafc77ce3491dff3c05a68090a4c3b /test/ruby/test_io.rb
parent4d0c5486a2773f0474a51033d4f685e5c766ec30 (diff)
[Bug #20510] Do not count optional hash argument for `IO.new`
Since `IO.new` accepts one or two positional arguments except for the optional hash argument, exclude the optional hash argument from the check for delegation to `IO.new`.
Diffstat (limited to 'test/ruby/test_io.rb')
-rw-r--r--test/ruby/test_io.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 476d9f882f..ce81286c4d 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -2929,6 +2929,15 @@ class TestIO < Test::Unit::TestCase
f.close
assert_equal("FOO\n", File.read(t.path))
+
+ fd = IO.sysopen(t.path)
+ %w[w r+ w+ a+].each do |mode|
+ assert_raise(Errno::EINVAL, "#{mode} [ruby-dev:38571]") {IO.new(fd, mode)}
+ end
+ f = IO.new(fd, "r")
+ data = f.read
+ f.close
+ assert_equal("FOO\n", data)
}
end