1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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/trunk@32994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mrkn 2011-08-17 01:24:22 +00:00
parent 783fb0881f
commit b30d203fed
3 changed files with 21 additions and 0 deletions

View file

@ -1,3 +1,11 @@
Wed Aug 17 10:16:00 2011 Kenta Murata <mrkn@mrkn.jp>
* 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.
Wed Aug 17 06:33:19 2011 Martin Bosslet <Martin.Bosslet@googlemail.com>
* ext/openssl/ossl_x509cert.c: Add class documentation for
@ -38,6 +46,7 @@ Tue Aug 16 08:00:15 2011 Eric Hodel <drbrain@segment7.net>
Mon Aug 15 09:58:55 2011 Martin Bosslet <Martin.Bosslet@googlemail.com>
* ext/openssl/ossl_ssl.c: Support disabling OpenSSL compression.
* test/openssl/test_ssl.rb: Add a test for it.
Thanks to Eric Wong for the patch.
[Ruby 1.9 - Feature #5183] [ruby-core:38911]
@ -70,12 +79,14 @@ Sat Aug 13 09:26:24 2011 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/core_ext.rb: Make Kernel#y private.
[ruby-core:38913]
* test/psych/test_yaml.rb: corresponding test.
Sat Aug 13 09:05:16 2011 Tadayoshi Funaba <tadf@dotrb.org>
* ext/date/date_core.c (date_strftime_alloc): followed the change
of r32885.
* doc/NEWS-1.9.3: followed the above change.
Sat Aug 13 08:55:38 2011 Aaron Patterson <aaron@tenderlovemaking.com>
@ -228,7 +239,9 @@ Tue Aug 9 12:20:33 2011 Naohisa Goto <ngotogenome@gmail.com>
Tue Aug 9 09:18:04 2011 Eric Hodel <drbrain@segment7.net>
* ext/zlib/zlib.c (gzfile_wrap): Document encoding options.
* ext/zlib/zlib.c (rb_gzwriter_s_open): ditto
* ext/zlib/zlib.c (rb_gzreader_s_open): ditto
Sun Aug 7 23:31:32 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
@ -243,7 +256,9 @@ Sun Aug 7 22:51:45 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
* ext/openssl/ossl_asn1.c (decode_eoc): remove unused variables.
Patch by Eric Wong. [Feature #5157] [ruby-core:38798]
* ext/openssl/ossl_asn1.c (ossl_asn1_decode): ditto.
* ext/openssl/ossl_pkey.c (ossl_pkey_new_from_data): ditto.
Sun Aug 7 22:37:08 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>

View file

@ -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",

View file

@ -721,6 +721,10 @@ class Rational_Test < Test::Unit::TestCase
assert_equal([Rational(2),Rational(1)], Rational(1).coerce(2))
assert_equal([Rational(2.2),Rational(1)], Rational(1).coerce(2.2))
assert_equal([Rational(2),Rational(1)], Rational(1).coerce(Rational(2)))
assert_nothing_raised(TypeError, '[Bug #5020] [ruby-devl:44088]') do
Rational(1,2).coerce(Complex(1,1))
end
end
class ObjectX