diff options
Diffstat (limited to 'test/test_set.rb')
-rw-r--r-- | test/test_set.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_set.rb b/test/test_set.rb index 9439974fea..07c404ab79 100644 --- a/test/test_set.rb +++ b/test/test_set.rb @@ -715,6 +715,25 @@ class TC_Set < Test::Unit::TestCase set1.add(set2) assert_equal(true, set1.inspect.include?('#<Set: {...}>')) end + + def test_compare_by_identity + a1, a2 = "a", "a" + b1, b2 = "b", "b" + c = "c" + array = [a1, b1, c, a2, b2] + + iset = Set.new.compare_by_identity + assert_send([iset, :compare_by_identity?]) + iset.merge(array) + assert_equal(5, iset.size) + assert_equal(array.map(&:object_id).sort, iset.map(&:object_id).sort) + + set = Set.new + assert_not_send([set, :compare_by_identity?]) + set.merge(array) + assert_equal(3, set.size) + assert_equal(array.uniq.sort, set.sort) + end end class TC_SortedSet < Test::Unit::TestCase |