1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test_enum.rb: add tests

* test/ruby/test_enum.rb (test_each_slice, test_each_cons): add
  missing tests for Enumerable#each_slice and Enumerable#each_cons.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-04-16 14:44:46 +00:00
parent 4c98e1a2c7
commit fcbd13b10a

View file

@ -338,6 +338,18 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal([1, 2, 3, 1, 2], a)
end
def test_each_slice
ary = []
(1..10).each_slice(3) {|a| ary << a}
assert_equal([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]], ary)
end
def test_each_cons
ary = []
(1..5).each_cons(3) {|a| ary << a}
assert_equal([[1, 2, 3], [2, 3, 4], [3, 4, 5]], ary)
end
def test_zip
assert_equal([[1,1],[2,2],[3,3],[1,1],[2,2]], @obj.zip(@obj))
a = []