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 --- ChangeLog | 19 ++++++++++++++++++- rational.c | 2 ++ test/ruby/test_rational.rb | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8f385d8051..d5bb1ec979 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Wed Aug 17 10:16:00 2011 Kenta Murata + + * backport 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. + Wed Aug 17 06:33:19 2011 Martin Bosslet * backport r32992 from trunk. @@ -30,6 +40,7 @@ Tue Aug 16 09:38:37 2011 Eric Hodel [Ruby 1.9 - Bug #5192] * ext/.document (fiddle): Remove duplicate entry + * ext/fiddle: Complete documentation of Fiddle. Patch by Vincent Batts. [#5192] @@ -45,6 +56,7 @@ Mon Aug 15 10:16:55 2011 Martin Bosslet * backport r32973 from trunk. * 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] @@ -72,12 +84,14 @@ Sat Aug 13 09:26:24 2011 Aaron Patterson * 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:15:16 2011 Tadayoshi Funaba * ext/date/date_core.c (date_strftime_alloc): followed the change of r32885. + * NEWS: followed the above change. Sat Aug 13 08:49:05 2011 Tadayoshi Funaba @@ -300,6 +314,7 @@ Fri Aug 5 07:35:00 2011 Luis Lavena * lib/rubygems/installer.rb (class Gem): Correct path check on Windows Possible fix for [Ruby 1.9 - Bug #5111] + * test/rubygems/test_gem_installer.rb (load Gem): ditto Backported from trunk r32804 @@ -312,7 +327,7 @@ Fri Aug 5 07:00:31 2011 Nobuyoshi Nakada Wed Aug 4 02:35:00 2011 Kenta Murata * configure.in: use build_os variable for checking C and C++ compilers - matching. + matching. * configure.in: use clang++ if clang is used. @@ -422,6 +437,7 @@ Sat Jul 30 23:51:44 2011 Tadayoshi Funaba Sat Jul 30 23:48:04 2011 Tadayoshi Funaba * ext/date/date_core.c: an issue that is same as [ruby-dev:44071]. + * ext/date/date_strftime.c: identical to [ruby-dev:44112]. Sat Jul 30 23:19:09 2011 Nobuyoshi Nakada @@ -467,6 +483,7 @@ Sat Jul 30 10:58:10 2011 KOSAKI Motohiro * signal.c (rb_register_sigaltstack): ditto. * vm_core.h: moved ALT_STACK_SIZE definition from signal.c. + * vm.c (thread_free): use xfree() instead of free(). Sat Jul 30 07:20:49 2011 Tanaka Akira 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", diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index 3d9709517f..70aab03c38 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -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 -- cgit v1.2.3