From 7bfa1146e298acb72d9ee0301fcf37acb4699197 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 24 Jul 2010 20:37:31 +0000 Subject: * numeric.c (flo_cmp): honor the result of infinite? method of the other. [ruby-core:31470] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_float.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/ruby/test_float.rb') diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 5f3e98a6fd..a8ce76edbc 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -242,6 +242,20 @@ class TestFloat < Test::Unit::TestCase assert_equal(-1, (Float::MAX.to_i*2) <=> inf) assert_equal(1, (-Float::MAX.to_i*2) <=> -inf) + bug3609 = '[ruby-core:31470]' + def (pinf = Object.new).infinite?; +1 end + def (ninf = Object.new).infinite?; -1 end + def (fin = Object.new).infinite?; nil end + nonum = Object.new + assert_equal(0, inf <=> pinf, bug3609) + assert_equal(1, inf <=> fin, bug3609) + assert_equal(1, inf <=> ninf, bug3609) + assert_nil(inf <=> nonum, bug3609) + assert_equal(-1, -inf <=> pinf, bug3609) + assert_equal(-1, -inf <=> fin, bug3609) + assert_equal(0, -inf <=> ninf, bug3609) + assert_nil(-inf <=> nonum, bug3609) + assert_raise(ArgumentError) { 1.0 > nil } assert_raise(ArgumentError) { 1.0 >= nil } assert_raise(ArgumentError) { 1.0 < nil } -- cgit v1.2.3