From fcbd13b10ae48b326a573662f91b7b76e4da8334 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 16 Apr 2014 14:44:46 +0000 Subject: 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 --- test/ruby/test_enum.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/ruby/test_enum.rb') diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index 5668ce4de0..0fbfeebc2f 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -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 = [] -- cgit v1.2.3