aboutsummaryrefslogtreecommitdiffstats
path: root/test/ostruct
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-24 12:16:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-24 12:16:54 +0000
commitf34e8df1f19076b02dd6f79119f76954252b4263 (patch)
treefa125974976f9dfbbbe414de8072489b6419148c /test/ostruct
parentd5c28c8a21c3d72d88e318f3213b78d1aa61466d (diff)
downloadruby-f34e8df1f19076b02dd6f79119f76954252b4263.tar.gz
ostruct.rb: fix OpenStruct.allocate
* lib/ostruct.rb (OpenStruct.allocate): initialize an instance variable directly, without calling `intialize` method which may be overridden in a subclass. [ruby-core:80292] [Bug #13358] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ostruct')
-rw-r--r--test/ostruct/test_ostruct.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index 7df5200ca1..b9bbaace55 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -183,4 +183,13 @@ class TC_OpenStruct < Test::Unit::TestCase
os.foo = 44
assert_equal(43, os.foo)
end
+
+ def test_allocate_subclass
+ bug = '[ruby-core:80292] [Bug #13358] allocate should not call initialize'
+ c = Class.new(OpenStruct) {
+ def initialize(x,y={})super(y);end
+ }
+ os = assert_nothing_raised(ArgumentError, bug) {c.allocate}
+ assert_instance_of(c, os)
+ end
end