[前][次][番号順一覧][スレッド一覧]

ruby-changes:33521

From: nobu <ko1@a...>
Date: Wed, 16 Apr 2014 23:44:52 +0900 (JST)
Subject: [ruby-changes:33521] nobu:r45602 (trunk): test_enum.rb: add tests

nobu	2014-04-16 23:44:46 +0900 (Wed, 16 Apr 2014)

  New Revision: 45602

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45602

  Log:
    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.

  Modified files:
    trunk/test/ruby/test_enum.rb
Index: test/ruby/test_enum.rb
===================================================================
--- test/ruby/test_enum.rb	(revision 45601)
+++ test/ruby/test_enum.rb	(revision 45602)
@@ -338,6 +338,18 @@ class TestEnumerable < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enum.rb#L338
     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 = []

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]