From a4eb3395643835b87c504701f2964ae461a5727c Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 15 Feb 2009 12:43:46 +0000 Subject: * lib/ostruct.rb (OpenStruct#new_ostruct_member): checks if frozen. [ruby-talk:328195], [ruby-core:22142] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ostruct/test_ostruct.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/ostruct') diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index 79662c6437..37b7cd137e 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -34,4 +34,12 @@ class TC_OpenStruct < Test::Unit::TestCase foo.bar.foo = foo assert_equal('#>>', foo.inspect) end + + def test_frozen + o = OpenStruct.new + o.a = 'a' + o.freeze + assert_raise(TypeError) {o.b = 'b'} + assert_not_respond_to(o, :b) + end end -- cgit v1.2.3