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

ruby-changes:33170

From: nagachika <ko1@a...>
Date: Mon, 3 Mar 2014 00:59:18 +0900 (JST)
Subject: [ruby-changes:33170] nagachika:r45249 (ruby_2_0_0): (merged partially from r42781)

nagachika	2014-03-03 00:59:13 +0900 (Mon, 03 Mar 2014)

  New Revision: 45249

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

  Log:
    (merged partially from r42781)
    * test/ruby/test_numeric.rb (assert_step): introduce assert_step.

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/test/ruby/test_numeric.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 45248)
+++ ruby_2_0_0/ChangeLog	(revision 45249)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Mar  3 00:43:33 2014  CHIKANAGA Tomoyuki  <nagachika@r...>
+
+	(merged partially from r42781)
+	* test/ruby/test_numeric.rb (assert_step): introduce assert_step.
+
 Mon Mar  3 00:24:38 2014  Zachary Scott  <e@z...>
 
 	* README.EXT.ja: [DOC] Fix typo "macro macro" @utenmiki [Fixes GH-551]
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 45248)
+++ ruby_2_0_0/version.h	(revision 45249)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-03-03"
-#define RUBY_PATCHLEVEL 452
+#define RUBY_PATCHLEVEL 453
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_0_0/test/ruby/test_numeric.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_numeric.rb	(revision 45248)
+++ ruby_2_0_0/test/ruby/test_numeric.rb	(revision 45249)
@@ -213,41 +213,50 @@ class TestNumeric < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_numeric.rb#L213
     end
   end
 
-  def test_step
-    a = []
-    1.step(10) {|x| a << x }
-    assert_equal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], a)
-
-    a = []
-    1.step(10, 2) {|x| a << x }
-    assert_equal([1, 3, 5, 7, 9], a)
+  def assert_step(expected, (from, *args), inf: false)
+    enum = from.step(*args)
+    size = enum.size
+    xsize = expected.size
+
+    if inf
+      assert_send [size, :infinite?], "step size: +infinity"
+      assert_send [size, :>, 0], "step size: +infinity"
+
+      a = []
+      from.step(*args) { |x| a << x; break if a.size == xsize }
+      assert_equal expected, a, "step"
+
+      a = []
+      enum.each { |x| a << x; break if a.size == xsize }
+      assert_equal expected, a, "step enumerator"
+    else
+      assert_equal expected.size, size, "step size"
+
+      a = []
+      from.step(*args) { |x| a << x }
+      assert_equal expected, a, "step"
+
+      a = []
+      enum.each { |x| a << x }
+      assert_equal expected, a, "step enumerator"
+    end
+  end
 
+  def test_step
     assert_raise(ArgumentError) { 1.step(10, 1, 0) { } }
     assert_raise(ArgumentError) { 1.step(10, 0) { } }
 
-    a = []
-    10.step(1, -2) {|x| a << x }
-    assert_equal([10, 8, 6, 4, 2], a)
-
-    a = []
-    1.0.step(10.0, 2.0) {|x| a << x }
-    assert_equal([1.0, 3.0, 5.0, 7.0, 9.0], a)
-
-    a = []
-    1.step(10, 2**32) {|x| a << x }
-    assert_equal([1], a)
-
-    a = []
-    10.step(1, -(2**32)) {|x| a << x }
-    assert_equal([10], a)
-
-    a = []
-    1.step(0, Float::INFINITY) {|x| a << x }
-    assert_equal([], a)
-
-    a = []
-    0.step(1, -Float::INFINITY) {|x| a << x }
-    assert_equal([], a)
+    assert_step [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 10]
+    assert_step [1, 3, 5, 7, 9], [1, 10, 2]
+
+    assert_step [10, 8, 6, 4, 2], [10, 1, -2]
+    assert_step [1.0, 3.0, 5.0, 7.0, 9.0], [1.0, 10.0, 2.0]
+    assert_step [1], [1, 10, 2**32]
+
+    assert_step [10], [10, 1, -(2**32)]
+
+    assert_step [], [1, 0, Float::INFINITY]
+    assert_step [], [0, 1, -Float::INFINITY]
   end
 
   def test_num2long

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r42781


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

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