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

ruby-changes:22780

From: nobu <ko1@a...>
Date: Mon, 27 Feb 2012 17:03:38 +0900 (JST)
Subject: [ruby-changes:22780] nobu:r34829 (trunk): * ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec): since methods

nobu	2012-02-27 17:03:24 +0900 (Mon, 27 Feb 2012)

  New Revision: 34829

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

  Log:
    * ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec): since methods
      can be overridden, so should not make an assumption on the type
      of results.  [ruby-core:42969][Bug #6093]

  Modified files:
    trunk/ChangeLog
    trunk/ext/bigdecimal/bigdecimal.c
    trunk/test/bigdecimal/test_bigdecimal.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 34828)
+++ ChangeLog	(revision 34829)
@@ -1,3 +1,9 @@
+Mon Feb 27 17:03:20 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec): since methods
+	  can be overridden, so should not make an assumption on the type
+	  of results.  [ruby-core:42969][Bug #6093]
+
 Mon Feb 27 10:54:20 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/mkmf.rb (try_cppflags, try_cflags, try_ldflags): replace the
Index: ext/bigdecimal/bigdecimal.c
===================================================================
--- ext/bigdecimal/bigdecimal.c	(revision 34828)
+++ ext/bigdecimal/bigdecimal.c	(revision 34829)
@@ -209,7 +209,7 @@
 	if (prec < 0) goto unable_to_coerce_without_prec;
 	if (prec > DBL_DIG+1)goto SomeOneMayDoIt;
 	v = rb_funcall(v, id_to_r, 0);
-	/* fall through */
+	goto again;
       case T_RATIONAL:
 	if (prec < 0) goto unable_to_coerce_without_prec;
 
Index: test/bigdecimal/test_bigdecimal.rb
===================================================================
--- test/bigdecimal/test_bigdecimal.rb	(revision 34828)
+++ test/bigdecimal/test_bigdecimal.rb	(revision 34829)
@@ -1,4 +1,5 @@
 require_relative "testbase"
+require_relative "../ruby/envutil"
 
 require 'thread'
 
@@ -1303,4 +1304,10 @@
     assert_equal(1, y)
     assert_kind_of(c, y)
   end
+
+  def test_to_d
+    bug6093 = '[ruby-core:42969]'
+    code = "exit(BigDecimal.new('10.0') == 10.0.to_d)"
+    assert_ruby_status(%w[-rbigdecimal -rbigdecimal/util -rmathn -], code, bug6093)
+  end
 end

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

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