From c68596aef1c03678b196c3ee1269df09710dbdbf Mon Sep 17 00:00:00 2001 From: knu Date: Mon, 2 Sep 2013 22:54:58 +0000 Subject: Retain behavior of Numeric#step when nil is given as second argument. * numeric.c (NUM_STEP_SCAN_ARGS): On sencond thought, keep Numeral#step backward compatible in that it raises TypeError when nil is given as second argument. * test/ruby/test_float.rb (TestFloat#test_num2dbl): Revert. * test/ruby/test_numeric.rb (TestNumeric#test_step): Fix test cases for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_float.rb | 3 +++ test/ruby/test_numeric.rb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index c55b051832..f011c2b062 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -561,6 +561,9 @@ class TestFloat < Test::Unit::TestCase assert_raise(TypeError) do 1.0.step(2.0, "0.5") {} end + assert_raise(TypeError) do + 1.0.step(2.0, nil) {} + end end def test_sleep_with_Float diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb index d2f211245d..4e7aef2777 100644 --- a/test/ruby/test_numeric.rb +++ b/test/ruby/test_numeric.rb @@ -229,8 +229,8 @@ class TestNumeric < Test::Unit::TestCase assert_raise(ArgumentError) { 1.step(10, 0).size } assert_raise(TypeError) { 1.step(10, "1") { } } assert_raise(TypeError) { 1.step(10, "1").size } - assert_nothing_raised { 1.step(10, nil) { } } - assert_nothing_raised { 1.step(10, nil).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) } assert_nothing_raised { 1.step(by: 0, to: nil).size } assert_nothing_raised { 1.step(by: 0) } -- cgit v1.2.3