Skip to content

Commit 8421673

Browse files
committed
Merge branch 'jruby-1_7'
Conflicts: core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java test/test_base64_strangeness.rb
2 parents d663235 + 9b8aa73 commit 8421673

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,10 @@ private static RubyBigDecimal newInstance(ThreadContext context, IRubyObject rec
520520

521521
BigDecimal decimal;
522522
try {
523+
System.err.println("newInstance " + strValue );
524+
System.err.println("newInstance " + mathContext );
523525
decimal = new BigDecimal(strValue, mathContext);
526+
System.err.println("newInstance " + decimal );
524527
} catch (NumberFormatException e) {
525528
if (isOverflowExceptionMode(context.runtime)) throw context.runtime.newFloatDomainError("exponent overflow");
526529

@@ -545,7 +548,9 @@ public static RubyBigDecimal newInstance(ThreadContext context, IRubyObject recv
545548

546549
@JRubyMethod(name = "new", meta = true)
547550
public static RubyBigDecimal newInstance(ThreadContext context, IRubyObject recv, IRubyObject arg, IRubyObject mathArg) {
551+
System.err.println( "margs" + mathArg);
548552
int digits = (int) mathArg.convertToInteger().getLongValue();
553+
System.err.println( "margs" + digits);
549554
if (digits < 0) throw context.runtime.newArgumentError("argument must be positive");
550555

551556
MathContext mathContext = new MathContext(digits);

test/jruby/test_bignum.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'test/unit'
2+
require 'bigdecimal'
23

34
class TestBignum < Test::Unit::TestCase
45
# others tested in FixnumBignumAutoconversion test
@@ -41,6 +42,11 @@ def test_bignum_should_respond_to_array_operator
4142
def test_bignum_aref_with_bignum_arg_no_exception
4243
assert_equal(0, (2**64)[2**32])
4344
end
45+
46+
def test_GH_2650
47+
assert_equal(BigDecimal.new("10.91231", 1).to_f, 10.91231)
48+
assert_equal(BigDecimal.new("10.9", 2).to_f, 10.9)
49+
end
4450
# more to come
4551

46-
end
52+
end

0 commit comments

Comments
 (0)