summaryrefslogtreecommitdiff
path: root/test/ostruct
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 21:19:15 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 21:19:15 +0000
commitb4300d25c941475db902ed2dc667ac23d36be992 (patch)
tree1505baa640a703a09b9dc89cb93cdb354d611a95 /test/ostruct
parent15d4862b913f6d555ce8a79075d69bba74b5b9bc (diff)
* lib/ostruct.rb: Add OpenStruct#eql? and OpenStruct#hash
[ruby-core:42651] [Bug #6029] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ostruct')
-rw-r--r--test/ostruct/test_ostruct.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index 9b125fc..a7cfbe9 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -92,4 +92,14 @@ class TC_OpenStruct < Test::Unit::TestCase
assert_equal '#<Enumerator: #<OpenStruct name="John Smith", age=70, pension=300>:each_pair>', os.each_pair.inspect
assert_equal [[:name, "John Smith"], [:age, 70], [:pension, 300]], os.each_pair.to_a
end
+
+ def test_eql_and_hash
+ os1 = OpenStruct.new age: 70
+ os2 = OpenStruct.new age: 70.0
+ assert_equal os1, os2
+ assert_equal false, os1.eql?(os2)
+ assert_not_equal os1.hash, os2.hash
+ assert_equal true, os1.eql?(os1.dup)
+ assert_equal os1.hash, os1.dup.hash
+ end
end