From cd453f16b42ea9b68993631b27773165b24ee9b2 Mon Sep 17 00:00:00 2001 From: glass Date: Thu, 27 Dec 2012 11:43:02 +0000 Subject: * ext/stringio/stringio.c (strio_ungetc): raise IOError instead of RuntimeError if the string is frozen. [Bug #7231] [ruby-core:48530] * ext/stringio/stringio.c (strio_ungetbyte): ditto. * test/stringio/test_stringio.rb: a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/stringio/test_stringio.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test') diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb index 417a53b383..0ea3e4f961 100644 --- a/test/stringio/test_stringio.rb +++ b/test/stringio/test_stringio.rb @@ -504,6 +504,14 @@ class TestStringIO < Test::Unit::TestCase assert_raise(RuntimeError, bug) {s.reopen("")} end + def test_frozen_string + s = StringIO.new("".freeze) + bug = '[ruby-core:48530]' + assert_raise(IOError, bug) {s.write("foo")} + assert_raise(IOError, bug) {s.ungetc("a")} + assert_raise(IOError, bug) {s.ungetbyte("a")} + end + def test_readlines_limit_0 assert_raise(ArgumentError, "[ruby-dev:43392]") { StringIO.new.readlines(0) } end -- cgit v1.2.3