Project

General

Profile

Bug #1219 » test_ostruct.patch

The patch for test/ostruct/test_ostruct.rb - RobertDober (Robert Dober), 02/27/2009 06:11 AM

View differences:

test_ostruct-new.rb 2009-02-26 22:04:10.000000000 +0100
foo.bar.foo = foo
assert_equal('#<OpenStruct bar=#<OpenStruct foo=#<OpenStruct ...>>>', foo.inspect)
end
def test_frozen
o = OpenStruct::new :a => 42
o.freeze
assert_raise TypeError do
o.b = 1
end
assert_raise TypeError do
o.a = 1764
end
assert_equal 42, o.a
assert_equal nil, o.b
end
def test_really_frozen
o1 = OpenStruct::new :a => 42
o2 = o1.dup
class << o1; def frozen?; nil end end
o1.freeze
o2.b = 42
assert_equal 42, o2.b
assert_raise TypeError do
o1.b = 1
end
assert_raise TypeError do
o1.a = 1806
end
assert_equal 42, o1.a
OpenStruct.module_eval do def frozen?; nil end end
o2.freeze
assert_raise TypeError do
o2.b = 1
end
assert_equal 42, o2.b
end
end
(2-2/2)