mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/ostruct.rb: Fix case of frozen object with initializer.
Bug revealed by RubySpec [ruby-core:72639] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
428fe14f5e
commit
9543908c9f
3 changed files with 8 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat Jan 2 02:27:22 2016 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||
|
||||
* lib/ostruct.rb: Fix case of frozen object with initializer.
|
||||
Bug revealed by RubySpec [ruby-core:72639]
|
||||
|
||||
Fri Jan 1 22:01:52 2016 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||
|
||||
* NEWS: mention about CSV's liberal_parsing option.
|
||||
|
|
|
@ -195,7 +195,7 @@ class OpenStruct
|
|||
modifiable[new_ostruct_member(mname)] = args[0]
|
||||
elsif len == 0
|
||||
if @table.key?(mid)
|
||||
new_ostruct_member(mid)
|
||||
new_ostruct_member(mid) unless frozen?
|
||||
@table[mid]
|
||||
end
|
||||
else
|
||||
|
|
|
@ -61,13 +61,14 @@ class TC_OpenStruct < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_frozen
|
||||
o = OpenStruct.new
|
||||
o = OpenStruct.new(foo: 42)
|
||||
o.a = 'a'
|
||||
o.freeze
|
||||
assert_raise(RuntimeError) {o.b = 'b'}
|
||||
assert_not_respond_to(o, :b)
|
||||
assert_raise(RuntimeError) {o.a = 'z'}
|
||||
assert_equal('a', o.a)
|
||||
assert_equal(42, o.foo)
|
||||
o = OpenStruct.new :a => 42
|
||||
def o.frozen?; nil end
|
||||
o.freeze
|
||||
|
|
Loading…
Reference in a new issue