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:
parent
4c98e1a2c7
commit
fcbd13b10a
1 changed files with 12 additions and 0 deletions
|
@ -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 = []
|
||||
|
|
Loading…
Reference in a new issue