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

ruby-changes:49099

From: mrkn <ko1@a...>
Date: Thu, 14 Dec 2017 00:28:35 +0900 (JST)
Subject: [ruby-changes:49099] mrkn:r61213 (trunk): bigdecimal: version 1.3.3

mrkn	2017-12-14 00:28:30 +0900 (Thu, 14 Dec 2017)

  New Revision: 61213

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61213

  Log:
    bigdecimal: version 1.3.3
    
    Import bigdecimal version 1.3.3.  The full commit log is here:
    
      https://github.com/ruby/bigdecimal/compare/v1.3.2...v1.3.3

  Modified files:
    trunk/ext/bigdecimal/bigdecimal.c
    trunk/ext/bigdecimal/bigdecimal.gemspec
    trunk/ext/bigdecimal/bigdecimal.h
    trunk/ext/bigdecimal/extconf.rb
    trunk/ext/bigdecimal/lib/bigdecimal/math.rb
    trunk/ext/bigdecimal/lib/bigdecimal/util.rb
    trunk/test/bigdecimal/test_bigdecimal.rb
    trunk/test/bigdecimal/test_bigdecimal_util.rb
Index: ext/bigdecimal/bigdecimal.c
===================================================================
--- ext/bigdecimal/bigdecimal.c	(revision 61212)
+++ ext/bigdecimal/bigdecimal.c	(revision 61213)
@@ -141,12 +141,16 @@ rb_rational_den(VALUE rat) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L141
 static VALUE
 BigDecimal_version(VALUE self)
 {
-    /*
-     * 1.0.0: Ruby 1.8.0
-     * 1.0.1: Ruby 1.8.1
-     * 1.1.0: Ruby 1.9.3
-    */
-    return rb_str_new2("1.1.0");
+  /*
+   * 1.0.0: Ruby 1.8.0
+   * 1.0.1: Ruby 1.8.1
+   * 1.1.0: Ruby 1.9.3
+   */
+#ifndef RUBY_BIGDECIMAL_VERSION
+# error RUBY_BIGDECIMAL_VERSION is not defined
+#endif
+  rb_warning("BigDecimal.ver is deprecated; use BigDecimal::VERSION instead.");
+  return rb_str_new2(RUBY_BIGDECIMAL_VERSION);
 }
 
 /*
@@ -393,7 +397,7 @@ BigDecimal_hash(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L397
  *
  * Method used to provide marshalling support.
  *
- *      inf = BigDecimal.new('Infinity')
+ *      inf = BigDecimal('Infinity')
  *        #=> Infinity
  *      BigDecimal._load(inf._dump)
  *        #=> Infinity
@@ -646,12 +650,12 @@ GetAddSubPrec(Real *a, Real *b) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L650
 }
 
 static SIGNED_VALUE
-GetPositiveInt(VALUE v)
+GetPrecisionInt(VALUE v)
 {
     SIGNED_VALUE n;
     n = NUM2INT(v);
     if (n < 0) {
-	rb_raise(rb_eArgError, "argument must be positive");
+	rb_raise(rb_eArgError, "negative precision");
     }
     return n;
 }
@@ -876,7 +880,7 @@ BigDecimal_to_r(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L880
  * be coerced into a BigDecimal value.
  *
  * e.g.
- *   a = BigDecimal.new("1.0")
+ *   a = BigDecimal("1.0")
  *   b = a / 2.0 #=> 0.5
  *
  * Note that coercing a String to a BigDecimal is not supported by default;
@@ -1165,7 +1169,7 @@ BigDecimal_comp(VALUE self, VALUE r) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1169
  *
  * Values may be coerced to perform the comparison:
  *
- *   BigDecimal.new('1.0') == 1.0  #=> true
+ *   BigDecimal('1.0') == 1.0  #=> true
  */
 static VALUE
 BigDecimal_eq(VALUE self, VALUE r)
@@ -1527,8 +1531,8 @@ BigDecimal_remainder(VALUE self, VALUE r https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1531
  *
  *   require 'bigdecimal'
  *
- *   a = BigDecimal.new("42")
- *   b = BigDecimal.new("9")
+ *   a = BigDecimal("42")
+ *   b = BigDecimal("9")
  *
  *   q, m = a.divmod(b)
  *
@@ -1571,7 +1575,7 @@ BigDecimal_div2(VALUE self, VALUE b, VAL https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1575
     }
 
     /* div in BigDecimal sense */
-    ix = GetPositiveInt(n);
+    ix = GetPrecisionInt(n);
     if (ix == 0) {
         return BigDecimal_div(self, b);
     }
@@ -1640,7 +1644,7 @@ BigDecimal_add2(VALUE self, VALUE b, VAL https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1644
 {
     ENTER(2);
     Real *cv;
-    SIGNED_VALUE mx = GetPositiveInt(n);
+    SIGNED_VALUE mx = GetPrecisionInt(n);
     if (mx == 0) return BigDecimal_add(self, b);
     else {
 	size_t pl = VpSetPrecLimit(0);
@@ -1670,7 +1674,7 @@ BigDecimal_sub2(VALUE self, VALUE b, VAL https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1674
 {
     ENTER(2);
     Real *cv;
-    SIGNED_VALUE mx = GetPositiveInt(n);
+    SIGNED_VALUE mx = GetPrecisionInt(n);
     if (mx == 0) return BigDecimal_sub(self, b);
     else {
 	size_t pl = VpSetPrecLimit(0);
@@ -1688,7 +1692,7 @@ BigDecimal_mult2(VALUE self, VALUE b, VA https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1692
 {
     ENTER(2);
     Real *cv;
-    SIGNED_VALUE mx = GetPositiveInt(n);
+    SIGNED_VALUE mx = GetPrecisionInt(n);
     if (mx == 0) return BigDecimal_mult(self, b);
     else {
 	size_t pl = VpSetPrecLimit(0);
@@ -1742,7 +1746,7 @@ BigDecimal_sqrt(VALUE self, VALUE nFig) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L1746
     GUARD_OBJ(a, GetVpValue(self, 1));
     mx = a->Prec * (VpBaseFig() + 1);
 
-    n = GetPositiveInt(nFig) + VpDblFig() + BASE_FIG;
+    n = GetPrecisionInt(nFig) + VpDblFig() + BASE_FIG;
     if (mx <= n) mx = n;
     GUARD_OBJ(c, VpCreateRbObject(mx, "0"));
     VpSqrt(c, a);
@@ -2012,26 +2016,27 @@ BigDecimal_ceil(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2016
  *
  * Examples:
  *
- *   BigDecimal.new('-123.45678901234567890').to_s('5F')
+ *   BigDecimal('-123.45678901234567890').to_s('5F')
  *     #=> '-123.45678 90123 45678 9'
  *
- *   BigDecimal.new('123.45678901234567890').to_s('+8F')
+ *   BigDecimal('123.45678901234567890').to_s('+8F')
  *     #=> '+123.45678901 23456789'
  *
- *   BigDecimal.new('123.45678901234567890').to_s(' F')
+ *   BigDecimal('123.45678901234567890').to_s(' F')
  *     #=> ' 123.4567890123456789'
  */
 static VALUE
 BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
 {
     ENTER(5);
-    int   fmt = 0;   /* 0:E format */
-    int   fPlus = 0; /* =0:default,=1: set ' ' before digits ,set '+' before digits. */
+    int   fmt = 0;   /* 0: E format, 1: F format */
+    int   fPlus = 0; /* 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
     Real  *vp;
     volatile VALUE str;
     char  *psz;
     char   ch;
     size_t nc, mc = 0;
+    SIGNED_VALUE m;
     VALUE  f;
 
     GUARD_OBJ(vp, GetVpValue(self, 1));
@@ -2062,7 +2067,11 @@ BigDecimal_to_s(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2067
 	    }
 	}
 	else {
-	    mc = (size_t)GetPositiveInt(f);
+	    m = NUM2INT(f);
+	    if (m <= 0) {
+		rb_raise(rb_eArgError, "argument must be positive");
+	    }
+	    mc = (size_t)m;
 	}
     }
     if (fmt) {
@@ -2159,7 +2168,7 @@ BigDecimal_exponent(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2168
 /* Returns debugging information about the value as a string of comma-separated
  * values in angle brackets with a leading #:
  *
- *   BigDecimal.new("1234.5678").inspect
+ *   BigDecimal("1234.5678").inspect
  *     #=> "0.12345678e4"
  *
  * The first part is the address, the second is the value as a string, and
@@ -2591,6 +2600,13 @@ static Real *BigDecimal_new(int argc, VA https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2600
  *                 value is omitted, this exception is raised.
  */
 static VALUE
+BigDecimal_s_new(int argc, VALUE *argv, VALUE self)
+{
+  rb_warning("BigDecimal.new is deprecated");
+  return rb_call_super(argc, argv);
+}
+
+static VALUE
 BigDecimal_initialize(int argc, VALUE *argv, VALUE self)
 {
     ENTER(1);
@@ -2626,6 +2642,20 @@ BigDecimal_initialize_copy(VALUE self, V https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2642
     return self;
 }
 
+static VALUE
+BigDecimal_clone(VALUE self)
+{
+  rb_warning("BigDecimal#clone is deprecated.");
+  return rb_call_super(0, NULL);
+}
+
+static VALUE
+BigDecimal_dup(VALUE self)
+{
+  rb_warning("BigDecimal#dup is deprecated.");
+  return rb_call_super(0, NULL);
+}
+
 static Real *
 BigDecimal_new(int argc, VALUE *argv)
 {
@@ -2638,7 +2668,7 @@ BigDecimal_new(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2668
         mf = 0;
     }
     else {
-        mf = GetPositiveInt(nFig);
+        mf = GetPrecisionInt(nFig);
     }
 
     switch (TYPE(iniValue)) {
@@ -2758,9 +2788,9 @@ BigDecimal_sign(VALUE self) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2788
  *       BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
  *       BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
  *
- *       BigDecimal.new(BigDecimal('Infinity'))
- *       BigDecimal.new(BigDecimal('-Infinity'))
- *       BigDecimal(BigDecimal.new('NaN'))
+ *       BigDecimal(BigDecimal('Infinity'))
+ *       BigDecimal(BigDecimal('-Infinity'))
+ *       BigDecimal(BigDecimal('NaN'))
  *     end
  *
  * For use with the BigDecimal::EXCEPTION_*
@@ -3147,15 +3177,15 @@ get_vp_value: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3177
  *
  *   require 'bigdecimal'
  *
- *   sum = BigDecimal.new("0")
+ *   sum = BigDecimal("0")
  *   10_000.times do
- *     sum = sum + BigDecimal.new("0.0001")
+ *     sum = sum + BigDecimal("0.0001")
  *   end
  *   print sum #=> 0.1E1
  *
  * Similarly:
  *
- *	(BigDecimal.new("1.2") - BigDecimal("1.0")) == BigDecimal("0.2") #=> true
+ *	(BigDecimal("1.2") - BigDecimal("1.0")) == BigDecimal("0.2") #=> true
  *
  *	(1.2 - 1.0) == 0.2 #=> false
  *
@@ -3169,8 +3199,8 @@ get_vp_value: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3199
  * BigDecimal sometimes needs to return infinity, for example if you divide
  * a value by zero.
  *
- *	BigDecimal.new("1.0") / BigDecimal.new("0.0")  #=> Infinity
- *	BigDecimal.new("-1.0") / BigDecimal.new("0.0")  #=> -Infinity
+ *	BigDecimal("1.0") / BigDecimal("0.0")  #=> Infinity
+ *	BigDecimal("-1.0") / BigDecimal("0.0")  #=> -Infinity
  *
  * You can represent infinite numbers to BigDecimal using the strings
  * <code>'Infinity'</code>, <code>'+Infinity'</code> and
@@ -3183,13 +3213,13 @@ get_vp_value: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3213
  *
  * Example:
  *
- *	BigDecimal.new("0.0") / BigDecimal.new("0.0") #=> NaN
+ *	BigDecimal("0.0") / BigDecimal("0.0") #=> NaN
  *
  * You can also create undefined values.
  *
  * NaN is never considered to be the same as any other value, even NaN itself:
  *
- *	n = BigDecimal.new('NaN')
+ *	n = BigDecimal('NaN')
  *	n == 0.0 #=> false
  *	n == n #=> false
  *
@@ -3202,11 +3232,11 @@ get_vp_value: https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3232
  * If the value which is too small to be represented is negative, a BigDecimal
  * value of negative zero is returned.
  *
- *	BigDecimal.new("1.0") / BigDecimal.new("-Infinity") #=> -0.0
+ *	BigDecimal("1.0") / BigDecimal("-Infinity") #=> -0.0
  *
  * If the value is positive, a value of positive zero is returned.
  *
- *	BigDecimal.new("1.0") / BigDecimal.new("Infinity") #=> 0.0
+ *	BigDecimal("1.0") / BigDecimal("Infinity") #=> 0.0
  *
  * (See BigDecimal.mode for how to specify limits of precision.)
  *
@@ -3261,6 +3291,7 @@ Init_bigdecimal(void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3291
     rb_define_global_function("BigDecimal", BigDecimal_global_new, -1);
 
     /* Class methods */
+    rb_define_singleton_method(rb_cBigDecimal, "new", BigDecimal_s_new, -1);
     rb_define_singleton_method(rb_cBigDecimal, "mode", BigDecimal_mode, -1);
     rb_define_singleton_method(rb_cBigDecimal, "limit", BigDecimal_limit, -1);
     rb_define_singleton_method(rb_cBigDecimal, "double_fig", BigDecimal_double_fig, 0);
@@ -3273,6 +3304,14 @@ Init_bigdecimal(void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3304
 
     /* Constants definition */
 
+#ifndef RUBY_BIGDECIMAL_VERSION
+# error RUBY_BIGDECIMAL_VERSION is not defined
+#endif
+    /*
+     * The version of bigdecimal library
+     */
+    rb_define_const(rb_cBigDecimal, "VERSION", rb_str_new2(RUBY_BIGDECIMAL_VERSION));
+
     /*
      * Base value used in internal calculations.  On a 32 bit system, BASE
      * is 10000, indicating that calculation is done in groups of 4 digits.
@@ -3409,7 +3448,8 @@ Init_bigdecimal(void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3448
     rb_define_method(rb_cBigDecimal, "modulo", BigDecimal_mod, 1);
     rb_define_method(rb_cBigDecimal, "remainder", BigDecimal_remainder, 1);
     rb_define_method(rb_cBigDecimal, "divmod", BigDecimal_divmod, 1);
-    /* rb_define_method(rb_cBigDecimal, "dup", BigDecimal_dup, 0); */
+    rb_define_method(rb_cBigDecimal, "clone", BigDecimal_clone, 0);
+    rb_define_method(rb_cBigDecimal, "dup", BigDecimal_dup, 0);
     rb_define_method(rb_cBigDecimal, "to_f", BigDecimal_to_f, 0);
     rb_define_method(rb_cBigDecimal, "abs", BigDecimal_abs, 0);
     rb_define_method(rb_cBigDecimal, "sqrt", BigDecimal_sqrt, 1);
@@ -5348,7 +5388,7 @@ VpSzMantissa(Real *a,char *psz) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L5388
 
 VP_EXPORT int
 VpToSpecialString(Real *a,char *psz,int fPlus)
-    /* fPlus =0:default, =1: set ' ' before digits , =2: set '+' before digits. */
+/* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
 {
     if (VpIsNaN(a)) {
 	sprintf(psz,SZ_NaN);
@@ -5383,7 +5423,7 @@ VpToSpecialString(Real *a,char *psz,int https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L5423
 
 VP_EXPORT void
 VpToString(Real *a, char *psz, size_t fFmt, int fPlus)
-/* fPlus =0:default, =1: set ' ' before digits , =2:set '+' before digits. */
+/* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
 {
     size_t i, n, ZeroSup;
     BDIGIT shift, m, e, nn;
@@ -5431,7 +5471,7 @@ VpToString(Real *a, char *psz, size_t fF https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L5471
 
 VP_EXPORT void
 VpToFString(Real *a, char *psz, size_t fFmt, int fPlus)
-/* fPlus =0:default,=1: set ' ' before digits ,set '+' before digits. */
+/* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
 {
     size_t i, n;
     BDIGIT m, e, nn;
Index: ext/bigdecimal/bigdecimal.gemspec
===================================================================
--- ext/bigdecimal/bigdecimal.gemspec	(revision 61212)
+++ ext/bigdecimal/bigdecimal.gemspec	(revision 61213)
@@ -1,9 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.gemspec#L1
 # coding: utf-8
-_VERSION = '1.3.2'
+
+bigdecimal_version = '1.3.3'
 
 Gem::Specification.new do |s|
   s.name          = "bigdecimal"
-  s.version       = _VERSION
+  s.version       = bigdecimal_version
   s.authors       = ["Kenta Murata", "Zachary Scott", "Shigeo Kobayashi"]
   s.email         = ["mrkn@m..."]
 
@@ -31,7 +32,8 @@ Gem::Specification.new do |s| https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.gemspec#L32
   ]
 
   s.add_development_dependency "rake", "~> 10.0"
-  s.add_development_dependency "rake-compiler", "~> 0.9"
+  s.add_development_dependency "rake-compiler", ">= 0.9"
+  s.add_development_dependency "rake-compiler-dock", ">= 0.6.1"
   s.add_development_dependency "minitest", "~> 4.7.5"
   s.add_development_dependency "pry"
 end
Index: ext/bigdecimal/bigdecimal.h
===================================================================
--- ext/bigdecimal/bigdecimal.h	(revision 61212)
+++ ext/bigdecimal/bigdecimal.h	(revision 61213)
@@ -142,6 +142,12 @@ rb_sym2str(VALUE sym) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.h#L142
 }
 #endif
 
+#ifndef ST2FIX
+# undef RB_ST2FIX
+# define RB_ST2FIX(h) LONG2FIX((long)(h))
+# define ST2FIX(h) RB_ST2FIX(h)
+#endif
+
 #ifdef vabs
 # undef vabs
 #endif
Index: ext/bigdecimal/lib/bigdecimal/math.rb
===================================================================
--- ext/bigdecimal/lib/bigdecimal/math.rb	(revision 61212)
+++ ext/bigdecimal/lib/bigdecimal/math.rb	(revision 61213)
@@ -37,7 +37,7 @@ module BigMath https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/math.rb#L37
   # Computes the square root of +decimal+ to the specified number of digits of
   # precision, +numeric+.
   #
-  #   BigMath.sqrt(BigDecimal.new('2'), 16).to_s
+  #   BigMath.sqrt(BigDecimal('2'), 16).to_s
   #   #=> "0.1414213562373095048801688724e1"
   #
   def sqrt(x, prec)
@@ -140,7 +140,7 @@ module BigMath https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/math.rb#L140
   #
   # If +decimal+ is NaN, returns NaN.
   #
-  #   BigMath.atan(BigDecimal.new('-1'), 16).to_s
+  #   BigMath.atan(BigDecimal('-1'), 16).to_s
   #   #=> "-0.785398163397448309615660845819878471907514682065e0"
   #
   def atan(x, prec)
Index: ext/bigdecimal/lib/bigdecimal/util.rb
===================================================================
--- ext/bigdecimal/lib/bigdecimal/util.rb	(revision 61212)
+++ ext/bigdecimal/lib/bigdecimal/util.rb	(revision 61213)
@@ -83,7 +83,7 @@ class BigDecimal < Numeric https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/util.rb#L83
   #
   #     require 'bigdecimal/util'
   #
-  #     d = BigDecimal.new("3.14")
+  #     d = BigDecimal("3.14")
   #     d.to_digits                  # => "3.14"
   #
   def to_digits
@@ -103,7 +103,7 @@ class BigDecimal < Numeric https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/util.rb#L103
   #
   #     require 'bigdecimal/util'
   #
-  #     d = BigDecimal.new("3.14")
+  #     d = BigDecimal("3.14")
   #     d.to_d                       # => 0.314e1
   #
   def to_d
Index: ext/bigdecimal/extconf.rb
===================================================================
--- ext/bigdecimal/extconf.rb	(revision 61212)
+++ ext/bigdecimal/extconf.rb	(revision 61213)
@@ -1,6 +1,22 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/extconf.rb#L1
 # frozen_string_literal: false
 require 'mkmf'
 
+case
+when File.file?(File.expand_path('../bigdecimal.gemspec', __FILE__))
+  gemspec_path = File.expand_path('../bigdecimal.gemspec', __FILE__)
+when File.file?(File.expand_path('../../../bigdecimal.gemspec', __FILE__))
+  gemspec_path = File.expand_path('../../../bigdecimal.gemspec', __FILE__)
+else
+  $stderr.puts "Unable to find bigdecimal.gemspec"
+  abort
+end
+
+bigdecimal_version =
+  IO.readlines(gemspec_path)
+    .grep(/\Abigdecimal_version\s+=\s+/)[0][/\'([\d\.]+)\'/, 1]
+
+$defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"]
+
 alias __have_macro__ have_macro
 
 have_func("labs", "stdlib.h")
Index: test/bigdecimal/test_bigdecimal_util.rb
===================================================================
--- test/bigdecimal/test_bigdecimal_util.rb	(revision 61212)
+++ test/bigdecimal/test_bigdecimal_util.rb	(revision 61213)
@@ -50,11 +50,11 @@ class TestBigDecimalUtil < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal_util.rb#L50
   end
 
   def test_String_to_d
-    assert_equal("2.5".to_d, BigDecimal.new('2.5'))
+    assert_equal("2.5".to_d, BigDecimal('2.5'))
   end
 
   def test_invalid_String_to_d
-    assert_equal("invalid".to_d, BigDecimal.new('0.0'))
+    assert_equal("invalid".to_d, BigDecimal('0.0'))
   end
 
 end
Index: test/bigdecimal/test_bigdecimal.rb
===================================================================
--- test/bigdecimal/test_bigdecimal.rb	(revision 61212)
+++ test/bigdecimal/test_bigdecimal.rb	(revision 61213)
@@ -2,6 +2,8 @@ https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L2
 require_relative "testbase"
 require 'bigdecimal/math'
 
+require 'thread'
+
 class TestBigDecimal < Test::Unit::TestCase
   include TestBigDecimalBase
 
@@ -127,61 +129,73 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L129
     }.join
   end
 
+  def test_s_ver
+    assert_warning(/BigDecimal\.ver is deprecated; use BigDecimal::VERSION instead/) do
+      BigDecimal.ver
+    end
+  end
+
+  def test_s_new
+    assert_warning(/BigDecimal.new is deprecated/) do
+      BigDecimal.new("1")
+    end
+  end
+
   def test_new
-    assert_equal(1, BigDecimal.new("1"))
-    assert_equal(1, BigDecimal.new("1", 1))
-    assert_equal(1, BigDecimal.new(" 1 "))
-    assert_equal(111, BigDecimal.new("1_1_1_"))
-    assert_equal(10**(-1), BigDecimal.new("1E-1"), '#4825')
+    assert_equal(1, BigDecimal("1"))
+    assert_equal(1, BigDecimal("1", 1))
+    assert_equal(1, BigDecimal(" 1 "))
+    assert_equal(111, BigDecimal("1_1_1_"))
+    assert_equal(10**(-1), BigDecimal("1E-1"), '#4825')
 
-    assert_raise(ArgumentError, /"_1_1_1"/) { BigDecimal.new("_1_1_1") }
+    assert_raise(ArgumentError, /"_1_1_1"/) { BigDecimal("_1_1 (... truncated)

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

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