diff --git a/ChangeLog b/ChangeLog index 374c8247cc..b1483efbe6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Jun 27 16:56:33 2009 Tadayoshi Funaba + + * rational.c (nurat_cmp): use rb_num_coerce_cmp. + Sat Jun 27 16:45:10 2009 Tadayoshi Funaba * complex.c: revised rdoc. diff --git a/rational.c b/rational.c index 218a14883c..5a490d48c7 100644 --- a/rational.c +++ b/rational.c @@ -979,7 +979,7 @@ nurat_cmp(VALUE self, VALUE other) return f_cmp(f_sub(num1, num2), ZERO); } default: - return rb_num_coerce_bin(self, other, id_cmp); + return rb_num_coerce_cmp(self, other, id_cmp); } } diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index b43db9c982..bbea2da83c 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -692,6 +692,9 @@ class Rational_Test < Test::Unit::TestCase assert_equal(true, Rational(0) <= Rational(0)) assert_equal(true, Rational(0) >= Rational(0)) assert_equal(false, Rational(0) > Rational(0)) + + assert_equal(nil, Rational(0) <=> nil) + assert_equal(nil, Rational(0) <=> 'foo') end def test_equal