summaryrefslogtreecommitdiff
path: root/test/bigdecimal/test_bigdecimal.rb
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-08-07 09:01:33 -0700
committerJeremy Evans <code@jeremyevans.net>2019-09-21 16:10:37 -0700
commit2e551356a7a6e74ba07283e000ff16f5d1ea6506 (patch)
tree99c123bb12c43346d9b1748cd73c42b883c6bb0a /test/bigdecimal/test_bigdecimal.rb
parent7470f965650bf17875632f0c5f9e5a4d9de9fc3f (diff)
Make Kernel#{Pathname,BigDecimal,Complex} return argument if given correct type
This is how Kernel#{Array,String,Float,Integer,Hash,Rational} work. BigDecimal and Complex instances are always frozen, so this should not cause backwards compatibility issues for those. Pathname instances are not frozen, so potentially this could cause backwards compatibility issues by not returning a new object. Based on a patch from Joshua Ballanco, some minor changes by me. Fixes [Bug #7522]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2473
Diffstat (limited to 'test/bigdecimal/test_bigdecimal.rb')
-rw-r--r--test/bigdecimal/test_bigdecimal.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb
index e4f1444..b3368b4 100644
--- a/test/bigdecimal/test_bigdecimal.rb
+++ b/test/bigdecimal/test_bigdecimal.rb
@@ -54,6 +54,11 @@ class TestBigDecimal < Test::Unit::TestCase
assert_equal(111, BigDecimal("1_1_1_"))
assert_equal(10**(-1), BigDecimal("1E-1"), '#4825')
assert_equal(1234, BigDecimal(" \t\n\r \r1234 \t\n\r \r"))
+ bd = BigDecimal.new("1.12", 1)
+ assert_same(bd, BigDecimal(bd))
+ assert_same(bd, BigDecimal(bd, exception: false))
+ assert_not_same(bd, BigDecimal(bd, 1))
+ assert_not_same(bd, BigDecimal(bd, 1, exception: false))
assert_raise(ArgumentError) { BigDecimal("1", -1) }
assert_raise_with_message(ArgumentError, /"1__1_1"/) { BigDecimal("1__1_1") }