summaryrefslogtreecommitdiff
path: root/test/ruby/test_enum.rb
diff options
context:
space:
mode:
authorsorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-14 10:42:42 +0000
committersorah <sorah@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-14 10:42:42 +0000
commit71588d17e5f3fe1f27ff0ae01b56e9d98abdd0ef (patch)
tree68ebeff0ceb975f03986333e12407868bb2e6629 /test/ruby/test_enum.rb
parent180293ac8995922355e84939ee7449dbc0353b1b (diff)
* enum.c (enum_grep_v, grep_i, grep_iter_i, Init_enum):
Implement Enumerable#grep_v. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_enum.rb')
-rw-r--r--test/ruby/test_enum.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index 6961187471..f774c4260b 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -33,6 +33,18 @@ class TestEnumerable < Test::Unit::TestCase
$VERBOSE = @verbose
end
+ def test_grep_v
+ assert_equal([3], @obj.grep_v(1..2))
+ a = []
+ @obj.grep_v(2) {|x| a << x }
+ assert_equal([1, 3, 1], a)
+
+ a = []
+ lambda = ->(x, i) {a << [x, i]}
+ @obj.each_with_index.grep_v(proc{|x,i|x!=2}, &lambda)
+ assert_equal([[2, 1], [2, 4]], a)
+ end
+
def test_grep
assert_equal([1, 2, 1, 2], @obj.grep(1..2))
a = []