ruby-changes:54172
From: mrkn <ko1@a...>
Date: Fri, 14 Dec 2018 12:34:03 +0900 (JST)
Subject: [ruby-changes:54172] mrkn:r66393 (trunk): Import bigdecimal-1.4.0.pre.20181214a
mrkn 2018-12-14 12:33:53 +0900 (Fri, 14 Dec 2018) New Revision: 66393 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66393 Log: Import bigdecimal-1.4.0.pre.20181214a * https://github.com/ruby/bigdecimal/compare/v1.4.0.pre.20181205a..v1.4.0.pre.20181214a Added files: trunk/ext/bigdecimal/lib/bigdecimal.rb Modified files: trunk/ext/bigdecimal/bigdecimal.gemspec trunk/test/bigdecimal/test_bigdecimal.rb Index: test/bigdecimal/test_bigdecimal.rb =================================================================== --- test/bigdecimal/test_bigdecimal.rb (revision 66392) +++ test/bigdecimal/test_bigdecimal.rb (revision 66393) @@ -56,8 +56,8 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L56 assert_equal(1234, BigDecimal(" \t\n\r \r1234 \t\n\r \r")) assert_raise(ArgumentError) { BigDecimal("1", -1) } - assert_raise(ArgumentError, /"1__1_1"/) { BigDecimal("1__1_1") } - assert_raise(ArgumentError, /"_1_1_1"/) { BigDecimal("_1_1_1") } + assert_raise_with_message(ArgumentError, /"1__1_1"/) { BigDecimal("1__1_1") } + assert_raise_with_message(ArgumentError, /"_1_1_1"/) { BigDecimal("_1_1_1") } BigDecimal.save_exception_mode do BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false) @@ -88,10 +88,10 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L88 BigDecimal.save_exception_mode do BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false) BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false) - assert_raise(ArgumentError, /"Infinity_"/) { BigDecimal("Infinity_") } - assert_raise(ArgumentError, /"+Infinity_"/) { BigDecimal("+Infinity_") } - assert_raise(ArgumentError, /"-Infinity_"/) { BigDecimal("-Infinity_") } - assert_raise(ArgumentError, /"NaN_"/) { BigDecimal("NaN_") } + assert_raise_with_message(ArgumentError, /"Infinity_"/) { BigDecimal("Infinity_") } + assert_raise_with_message(ArgumentError, /"\+Infinity_"/) { BigDecimal("+Infinity_") } + assert_raise_with_message(ArgumentError, /"-Infinity_"/) { BigDecimal("-Infinity_") } + assert_raise_with_message(ArgumentError, /"NaN_"/) { BigDecimal("NaN_") } end end @@ -209,15 +209,21 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L209 end def test_s_ver - assert_raise(NoMethodError, /undefined method `ver`/) { BigDecimal.ver } + assert_raise_with_message(NoMethodError, /undefined method `ver'/) { BigDecimal.ver } end def test_s_allocate - assert_raise(NoMethodError, /undefined method `allocate`/) { BigDecimal.allocate } + assert_raise_with_message(NoMethodError, /undefined method `allocate'/) { BigDecimal.allocate } end def test_s_new - assert_raise(NoMethodError, /undefined method `new`/) { BigDecimal.new("1") } + # TODO: BigDecimal.new will be removed on 1.5 + # assert_raise_with_message(NoMethodError, /undefined method `new'/) { BigDecimal.new("1") } + assert_equal(BigDecimal(1), BigDecimal.new(1)) + assert_raise(ArgumentError) { BigDecimal.new(',', exception: true) } + assert_nothing_raised { assert_equal(nil, BigDecimal.new(',', exception: false)) } + assert_raise(TypeError) { BigDecimal.new(nil, exception: true) } + assert_nothing_raised { assert_equal(nil, BigDecimal.new(nil, exception: false)) } end def _test_mode(type) @@ -1821,7 +1827,13 @@ class TestBigDecimal < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L1827 def test_dup_subclass c = Class.new(BigDecimal) - assert_raise(NoMethodError, /undefined method `new`/) { c.new(1) } + # TODO: BigDecimal.new will be removed on 1.5 + # assert_raise_with_message(NoMethodError, /undefined method `new'/) { c.new(1) } + assert_equal(BigDecimal(1), c.new(1)) + assert_raise(ArgumentError) { c.new(',', exception: true) } + assert_nothing_raised { assert_equal(nil, c.new(',', exception: false)) } + assert_raise(TypeError) { c.new(nil, exception: true) } + assert_nothing_raised { assert_equal(nil, c.new(nil, exception: false)) } end def test_to_d Index: ext/bigdecimal/lib/bigdecimal.rb =================================================================== --- ext/bigdecimal/lib/bigdecimal.rb (nonexistent) +++ ext/bigdecimal/lib/bigdecimal.rb (revision 66393) @@ -0,0 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal.rb#L1 +require 'bigdecimal.so' + +def BigDecimal.new(*args, **kwargs) + warn "BigDecimal.new is deprecated; use BigDecimal() method instead.", uplevel: 1 + BigDecimal(*args, **kwargs) +end Index: ext/bigdecimal/bigdecimal.gemspec =================================================================== --- ext/bigdecimal/bigdecimal.gemspec (revision 66392) +++ ext/bigdecimal/bigdecimal.gemspec (revision 66393) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.gemspec#L1 # coding: utf-8 -bigdecimal_version = '1.4.0.pre.20181204a' +bigdecimal_version = '1.4.0.pre.20181214a' Gem::Specification.new do |s| s.name = "bigdecimal" -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/