Project

General

Profile

Bug #13062 ยป fix_13062_string_to_d.patch

Esse (Piotr Szmielew), 12/25/2016 12:16 AM

View differences:

ext/bigdecimal/lib/bigdecimal/util.rb
# # => 0.5e0
#
def to_d
BigDecimal(self)
begin
BigDecimal(self)
rescue ArgumentError
BigDecimal(0)
end
end
end
test/bigdecimal/test_bigdecimal_util.rb
def test_Rational_to_d_with_negative_precision
assert_raise(ArgumentError) { 355.quo(113).to_d(-42) }
end
def test_String_to_d
assert_equal("2.5".to_d, BigDecimal.new('2.5'))
end
def test_invalid_String_to_d
assert_equal("invalid".to_d, BigDecimal.new('0.0'))
end
end
    (1-1/1)