* 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
This commit is contained in:
nobu 2009-02-15 12:43:46 +00:00
parent 8fc45476eb
commit a4eb339564
3 changed files with 25 additions and 8 deletions

View file

@ -34,4 +34,12 @@ class TC_OpenStruct < Test::Unit::TestCase
foo.bar.foo = foo
assert_equal('#<OpenStruct bar=#<OpenStruct foo=#<OpenStruct ...>>>', 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