mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* hash.c, object.c, struct.c, lib/ostruct.rb: add to_h methods.
[Feature #6276] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b05c95d93f
commit
770ddcdfe0
10 changed files with 156 additions and 2 deletions
|
@ -263,4 +263,10 @@ class TestStruct < Test::Unit::TestCase
|
|||
end
|
||||
assert_equal("Insecure: can't modify #{st}::S", error.message, bug5036)
|
||||
end
|
||||
|
||||
def test_to_h
|
||||
klass = Struct.new(:a, :b, :c, :d, :e, :f)
|
||||
o = klass.new(1, 2, 3, 4, 5, 6)
|
||||
assert_equal({a:1, b:2, c:3, d:4, e:5, f:6}, o.to_h)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue