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

ruby-changes:30796

From: nobu <ko1@a...>
Date: Sun, 8 Sep 2013 04:04:46 +0900 (JST)
Subject: [ruby-changes:30796] nobu:r42876 (trunk): numeric.c: no extra checks

nobu	2013-09-08 04:04:28 +0900 (Sun, 08 Sep 2013)

  New Revision: 42876

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

  Log:
    numeric.c: no extra checks
    
    * numeric.c (NUM_STEP_SCAN_ARGS): remove extra class checks, which
      cause the incompatibilities.

  Modified files:
    trunk/numeric.c
    trunk/test/ruby/test_float.rb
    trunk/test/ruby/test_numeric.rb
Index: numeric.c
===================================================================
--- numeric.c	(revision 42875)
+++ numeric.c	(revision 42876)
@@ -1864,20 +1864,10 @@ ruby_num_interval_step_size(VALUE from, https://github.com/ruby/ruby/blob/trunk/numeric.c#L1864
     if (NIL_P(step)) {							\
         step = INT2FIX(1);						\
     }									\
-    else {								\
-        if (!rb_obj_is_kind_of(step, rb_cNumeric)) {			\
-            rb_raise(rb_eTypeError, "step must be numeric");		\
-        }								\
-    }									\
     desc = negative_int_p(step);					\
     if (NIL_P(to)) {							\
         to = desc ? DBL2NUM(-INFINITY) : DBL2NUM(INFINITY);		\
     }									\
-    else {								\
-        if (!rb_obj_is_kind_of(to, rb_cNumeric)) {			\
-            rb_raise(rb_eTypeError, "limit must be numeric");		\
-        }								\
-    }									\
 } while (0)
 
 #define NUM_STEP_GET_INF(to, desc, inf) do {				\
Index: test/ruby/test_float.rb
===================================================================
--- test/ruby/test_float.rb	(revision 42875)
+++ test/ruby/test_float.rb	(revision 42876)
@@ -558,7 +558,7 @@ class TestFloat < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_float.rb#L558
   end
 
   def test_num2dbl
-    assert_raise(TypeError) do
+    assert_raise(ArgumentError) do
       1.0.step(2.0, "0.5") {}
     end
     assert_raise(TypeError) do
Index: test/ruby/test_numeric.rb
===================================================================
--- test/ruby/test_numeric.rb	(revision 42875)
+++ test/ruby/test_numeric.rb	(revision 42876)
@@ -227,8 +227,8 @@ class TestNumeric < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_numeric.rb#L227
     assert_raise(ArgumentError) { 1.step(10, 1, 0).size }
     assert_raise(ArgumentError) { 1.step(10, 0) { } }
     assert_raise(ArgumentError) { 1.step(10, 0).size }
-    assert_raise(TypeError) { 1.step(10, "1") { } }
-    assert_raise(TypeError) { 1.step(10, "1").size }
+    assert_raise(ArgumentError) { 1.step(10, "1") { } }
+    assert_raise(ArgumentError) { 1.step(10, "1").size }
     assert_raise(TypeError) { 1.step(10, nil) { } }
     assert_raise(TypeError) { 1.step(10, nil).size }
     assert_nothing_raised { 1.step(by: 0, to: nil) }

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

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