aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_numeric.rb
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-13 19:17:49 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-13 19:17:49 +0000
commitded94d1c8ca7b318aad0c92ca290d1b6b2f3814d (patch)
tree8fd11b6fa8f8dde6d21c2ac5c4a6b13e12b7370c /test/ruby/test_numeric.rb
parentb238a3f3fdb575749121f35bbf37bfc1baed050c (diff)
downloadruby-ded94d1c8ca7b318aad0c92ca290d1b6b2f3814d.tar.gz
* numeric.c (ruby_float_step): fix Numeric#step with infinity unit
doesn't works well. [ruby-core:32779] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_numeric.rb')
-rw-r--r--test/ruby/test_numeric.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb
index f4fbea4ce9..9667046916 100644
--- a/test/ruby/test_numeric.rb
+++ b/test/ruby/test_numeric.rb
@@ -27,6 +27,7 @@ class TestNumeric < Test::Unit::TestCase
assert_raise(ArgumentError) { 1 <= a }
DummyNumeric.class_eval do
+ remove_method :coerce
def coerce(x); 1.coerce(x); end
end
assert_equal(2, 1 + a)
@@ -34,6 +35,7 @@ class TestNumeric < Test::Unit::TestCase
assert(1 <= a)
DummyNumeric.class_eval do
+ remove_method :coerce
def coerce(x); [x, 1]; end
end
assert_equal(-1, -a)
@@ -95,6 +97,7 @@ class TestNumeric < Test::Unit::TestCase
assert_equal(:ok, a.abs)
DummyNumeric.class_eval do
+ remove_method :<
def <(x); false; end
end
@@ -150,6 +153,7 @@ class TestNumeric < Test::Unit::TestCase
assert_equal(1, a.truncate)
DummyNumeric.class_eval do
+ remove_method :to_f
def to_f; 1.4; end
end
@@ -160,6 +164,7 @@ class TestNumeric < Test::Unit::TestCase
assert_equal(1, a.truncate)
DummyNumeric.class_eval do
+ remove_method :to_f
def to_f; -1.5; end
end
@@ -202,6 +207,14 @@ class TestNumeric < Test::Unit::TestCase
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)
end
def test_num2long