From 559b717567e61206294a310cdeedea9f28426e22 Mon Sep 17 00:00:00 2001 From: mrkn Date: Wed, 17 Aug 2011 01:32:16 +0000 Subject: Merge commit r32994 from trunk: * rational.c (nurat_coerce): Rational#coerce should converts itself into Complex if the argument is a Complex with non-zero imaginary part. [Bug #5020] [ruby-dev:44088] * test/ruby/test_rational.rb (test_coerce): test for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- rational.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'rational.c') diff --git a/rational.c b/rational.c index 8dac978ca7..40b480df6e 100644 --- a/rational.c +++ b/rational.c @@ -1108,6 +1108,8 @@ nurat_coerce(VALUE self, VALUE other) if (k_exact_zero_p(RCOMPLEX(other)->imag)) return rb_assoc_new(f_rational_new_bang1 (CLASS_OF(self), RCOMPLEX(other)->real), self); + else + return rb_assoc_new(other, rb_Complex(self, INT2FIX(0))); } rb_raise(rb_eTypeError, "%s can't be coerced into %s", -- cgit v1.2.3