Skip to content

Commit

Permalink
Merge branch 'jruby-1_7'
Browse files Browse the repository at this point in the history
Conflicts:
	core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java
	test/test_base64_strangeness.rb
  • Loading branch information
mkristian committed Mar 20, 2015
2 parents d663235 + 9b8aa73 commit 8421673
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -520,7 +520,10 @@ private static RubyBigDecimal newInstance(ThreadContext context, IRubyObject rec

BigDecimal decimal;
try {
System.err.println("newInstance " + strValue );

This comment has been minimized.

Copy link
@bjfish

bjfish Mar 20, 2015

Contributor

@mkristian just curious, are these needed here?

This comment has been minimized.

Copy link
@mkristian

mkristian Mar 20, 2015

Author Member

9b8aa73

:)

System.err.println("newInstance " + mathContext );
decimal = new BigDecimal(strValue, mathContext);
System.err.println("newInstance " + decimal );
} catch (NumberFormatException e) {
if (isOverflowExceptionMode(context.runtime)) throw context.runtime.newFloatDomainError("exponent overflow");

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

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

MathContext mathContext = new MathContext(digits);
Expand Down
8 changes: 7 additions & 1 deletion test/jruby/test_bignum.rb
@@ -1,4 +1,5 @@
require 'test/unit'
require 'bigdecimal'

class TestBignum < Test::Unit::TestCase
# others tested in FixnumBignumAutoconversion test
Expand Down Expand Up @@ -41,6 +42,11 @@ def test_bignum_should_respond_to_array_operator
def test_bignum_aref_with_bignum_arg_no_exception
assert_equal(0, (2**64)[2**32])
end

def test_GH_2650
assert_equal(BigDecimal.new("10.91231", 1).to_f, 10.91231)
assert_equal(BigDecimal.new("10.9", 2).to_f, 10.9)
end
# more to come

end
end

0 comments on commit 8421673

Please sign in to comment.