[前][次][番号順一覧][スレッド一覧]

ruby-changes:20946

From: mrkn <ko1@a...>
Date: Wed, 17 Aug 2011 10:32:26 +0900 (JST)
Subject: [ruby-changes:20946] mrkn:r32995 (ruby_1_9_3): Merge commit r32994 from trunk:

mrkn	2011-08-17 10:32:16 +0900 (Wed, 17 Aug 2011)

  New Revision: 32995

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32995

  Log:
    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.

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/rational.c
    branches/ruby_1_9_3/test/ruby/test_rational.rb

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 32994)
+++ ruby_1_9_3/ChangeLog	(revision 32995)
@@ -1,3 +1,13 @@
+Wed Aug 17 10:16:00 2011  Kenta Murata  <mrkn@m...>
+
+	* 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  <Martin.Bosslet@g...>
 
 	* backport r32992 from trunk.
@@ -30,6 +40,7 @@
 	  [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 @@
 	* 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 @@
 
 	* 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  <tadf@d...>
 
 	* 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  <tadf@d...>
@@ -300,6 +314,7 @@
 
 	* 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 @@
 Wed Aug  4 02:35:00 2011  Kenta Murata  <mrkn@m...>
 
 	* 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:48:04 2011  Tadayoshi Funaba  <tadf@d...>
 
 	* 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  <nobu@r...>
@@ -467,6 +483,7 @@
 	* 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  <akr@f...>
Index: ruby_1_9_3/test/ruby/test_rational.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_rational.rb	(revision 32994)
+++ ruby_1_9_3/test/ruby/test_rational.rb	(revision 32995)
@@ -721,6 +721,10 @@
     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
Index: ruby_1_9_3/rational.c
===================================================================
--- ruby_1_9_3/rational.c	(revision 32994)
+++ ruby_1_9_3/rational.c	(revision 32995)
@@ -1108,6 +1108,8 @@
 	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",

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]