summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-22 08:36:25 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-22 08:36:25 +0000
commit31d8a976575d38bd912b7e4aa5204fd88b5a97fc (patch)
tree623244c547597f05e0a3e17faa1546b9d4b6d3f2 /test/ruby
parent873b56fd50e12294601bbe96b1bef3b2c2428010 (diff)
* io.c (rb_io_s_foreach): argument check before making Enumerator.
[ruby-dev:31525] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_io.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb
index 54253c1f99..a08c003403 100644
--- a/test/ruby/test_io.rb
+++ b/test/ruby/test_io.rb
@@ -1605,6 +1605,13 @@ End
IO.foreach(t.path, "b", 3) {|x| a << x }
assert_equal(["foo", "\nb", "ar\n", "b", "az\n"], a)
+ bug = '[ruby-dev:31525]'
+ assert_raise(ArgumentError, bug) {IO.foreach}
+
+ a = nil
+ assert_nothing_raised(ArgumentError, bug) {a = IO.foreach(t.path).to_a}
+ assert_equal(["foo\n", "bar\n", "baz\n"], a, bug)
+
bug6054 = '[ruby-dev:45267]'
e = assert_raise(IOError, bug6054) {IO.foreach(t.path, mode:"w").next}
assert_match(/not opened for reading/, e.message, bug6054)