summaryrefslogtreecommitdiff
path: root/test/test_set.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-18 17:48:18 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-18 17:48:18 +0000
commit2849ee5d18360f26b55643a2643a1c597376865d (patch)
tree3e6b37ebb7b4576b78d4faf34d9e0f99ba006bb9 /test/test_set.rb
parent041224017c5a865ad0ea0d360bce1709b39d2255 (diff)
* lib/set.rb (Set#delete_if, Set#keep_if): Make Set#delete_if and
Set#keep_if more space and time efficient by avoiding to_a. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/test_set.rb')
-rw-r--r--test/test_set.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test_set.rb b/test/test_set.rb
index 1027cc1..9041182 100644
--- a/test/test_set.rb
+++ b/test/test_set.rb
@@ -368,6 +368,18 @@ class TC_Set < Test::Unit::TestCase
assert_equal(Set[1,2,4,5,7,8,10], set)
end
+ def test_keep_if
+ set = Set.new(1..10)
+ ret = set.keep_if { |i| i <= 10 }
+ assert_same(set, ret)
+ assert_equal(Set.new(1..10), set)
+
+ set = Set.new(1..10)
+ ret = set.keep_if { |i| i % 3 != 0 }
+ assert_same(set, ret)
+ assert_equal(Set[1,2,4,5,7,8,10], set)
+ end
+
def test_collect!
set = Set[1,2,3,'a','b','c',-1..1,2..4]