summaryrefslogtreecommitdiff
path: root/test/ostruct/test_ostruct.rb
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 21:19:50 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 21:19:50 +0000
commit3785d2675abf2e4aca07e89596ea6f12b4c474a5 (patch)
tree9932e8e24868b0bb49ba2e8f7be7bbf1312d519c /test/ostruct/test_ostruct.rb
parent22115ec87e5c805711762eac46cc5332bf2afb16 (diff)
* lib/ostruct.rb: Also accept {Open}Struct as argument to new
[ruby-core:47476] [Feature #7007] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ostruct/test_ostruct.rb')
-rw-r--r--test/ostruct/test_ostruct.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index a7cfbe9..491f950 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -2,6 +2,13 @@ require 'test/unit'
require 'ostruct'
class TC_OpenStruct < Test::Unit::TestCase
+ def test_initialize
+ h = {name: "John Smith", age: 70, pension: 300}
+ assert_equal h, OpenStruct.new(h).to_h
+ assert_equal h, OpenStruct.new(OpenStruct.new(h)).to_h
+ assert_equal h, OpenStruct.new(Struct.new(*h.keys).new(*h.values)).to_h
+ end
+
def test_equality
o1 = OpenStruct.new
o2 = OpenStruct.new