mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/ostruct.rb (modifiable): check if really frozen.
[ruby-core:22559] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
770f854176
commit
1942710d42
3 changed files with 13 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Feb 27 14:23:09 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/ostruct.rb (modifiable): check if really frozen.
|
||||
[ruby-core:22559]
|
||||
|
||||
Thu Feb 26 23:14:46 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/lib/socket.rb (BasicSocket#connect_address): new method.
|
||||
|
|
|
@ -68,8 +68,10 @@ class OpenStruct
|
|||
end
|
||||
|
||||
def modifiable
|
||||
if self.frozen?
|
||||
raise TypeError, "can't modify frozen #{self.class}", caller(2)
|
||||
begin
|
||||
@modifiable = true
|
||||
rescue
|
||||
raise TypeError, "can't modify frozen #{self.class}", caller(3)
|
||||
end
|
||||
@table
|
||||
end
|
||||
|
|
|
@ -43,5 +43,9 @@ class TC_OpenStruct < Test::Unit::TestCase
|
|||
assert_not_respond_to(o, :b)
|
||||
assert_raise(TypeError) {o.a = 'z'}
|
||||
assert_equal('a', o.a)
|
||||
o = OpenStruct.new :a => 42
|
||||
def o.frozen?; nil end
|
||||
o.freeze
|
||||
assert_raise(TypeError, '[ruby-core:22559]') {o.a = 1764}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue