summaryrefslogtreecommitdiff
path: root/test/test_set.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-22 12:25:34 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-22 12:25:34 +0000
commit8c90432af72a59d8934b2c94a1bc847449e1f393 (patch)
tree2c50ce486548899b86a3cb114c93c1333de18be2 /test/test_set.rb
parent6693e3e7230ca64b01ffb24d2693af1c77bd2998 (diff)
Add `Set#reset`
This method resets the internal state of a set after modification to existing elements, reindexing and deduplicating them. [Feature #6589] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_set.rb')
-rw-r--r--test/test_set.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test_set.rb b/test/test_set.rb
index 33802410af..37b781c5ca 100644
--- a/test/test_set.rb
+++ b/test/test_set.rb
@@ -761,6 +761,19 @@ class TC_Set < Test::Unit::TestCase
assert_equal(3, set.size)
assert_equal(array.uniq.sort, set.sort)
end
+
+ def test_reset
+ [Set, Class.new(Set)].each { |klass|
+ a = [1, 2]
+ b = [1]
+ set = klass.new([a, b])
+
+ b << 2
+ set.reset
+
+ assert_equal(klass.new([a]), set, klass.name)
+ }
+ end
end
class TC_SortedSet < Test::Unit::TestCase