From edea151a4bae78a57efdb67d73a22ba52421952c Mon Sep 17 00:00:00 2001 From: normal Date: Sun, 27 Dec 2015 06:15:06 +0000 Subject: IO#readpartial rejects bad args Sometimes a sleepy developer will want to swap read_nonblock for readpartial forget to remove "exception: false" * io.c (io_getpartial): remove unused kwarg from template * test/ruby/test_io.rb (test_readpartial_bad_args): new [Bug #11885] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/ruby/test_io.rb') diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index 766804eb2e..2b79acea09 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -3186,6 +3186,17 @@ End } end + def test_readpartial_bad_args + IO.pipe do |r, w| + w.write '.' + buf = String.new + assert_raise(ArgumentError) { r.readpartial(1, buf, exception: false) } + assert_raise(TypeError) { r.readpartial(1, exception: false) } + assert_equal [[r],[],[]], IO.select([r], nil, nil, 1) + assert_equal '.', r.readpartial(1) + end + end + def test_sysread_unlocktmp_ensure bug8669 = '[ruby-core:56121] [Bug #8669]' -- cgit v1.2.3