Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c7dfe5c195fa
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ded24dbd61af
Choose a head ref
  • 2 commits
  • 3 files changed
  • 2 contributors

Commits on May 27, 2016

  1. Copy the full SHA
    3fba463 View commit details
  2. Merge pull request #3935 from MSNexploder/bignum_tests

    Fixed shift with negative distance on Bignum
    headius committed May 27, 2016
    Copy the full SHA
    ded24db View commit details
Showing with 3 additions and 18 deletions.
  1. +3 −15 core/src/main/java/org/jruby/RubyBignum.java
  2. +0 −1 test/mri/excludes/CGIMultipartTest.rb
  3. +0 −2 test/mri/excludes/TestBignum.rb
18 changes: 3 additions & 15 deletions core/src/main/java/org/jruby/RubyBignum.java
Original file line number Diff line number Diff line change
@@ -714,30 +714,24 @@ public IRubyObject op_neg() {
@JRubyMethod(name = "<<", required = 1)
public IRubyObject op_lshift(IRubyObject other) {
long shift;
boolean neg = false;

for (;;) {
if (other instanceof RubyFixnum) {
shift = ((RubyFixnum)other).getLongValue();
if (shift < 0) {
neg = true;
shift = -shift;
}
break;
} else if (other instanceof RubyBignum) {
RubyBignum otherBignum = (RubyBignum)other;
if (otherBignum.value.signum() < 0) {
IRubyObject tmp = otherBignum.checkShiftDown(this);
if (!tmp.isNil()) return tmp;
neg = true;
}
shift = big2long(otherBignum);
break;
}
other = other.convertToInteger();
}

return bignorm(getRuntime(), neg ? value.shiftRight((int)shift) : value.shiftLeft((int)shift));
return bignorm(getRuntime(), value.shiftLeft((int)shift));
}

/** rb_big_rshift
@@ -746,30 +740,24 @@ public IRubyObject op_lshift(IRubyObject other) {
@JRubyMethod(name = ">>", required = 1)
public IRubyObject op_rshift(IRubyObject other) {
long shift;
boolean neg = false;

for (;;) {
if (other instanceof RubyFixnum) {
shift = ((RubyFixnum)other).getLongValue();
if (shift < 0) {
neg = true;
shift = -shift;
}
break;
} else if (other instanceof RubyBignum) {
RubyBignum otherBignum = (RubyBignum)other;
if (otherBignum.value.signum() >= 0) {
IRubyObject tmp = otherBignum.checkShiftDown(this);
if (!tmp.isNil()) return tmp;
} else {
neg = true;
}
shift = big2long(otherBignum);
break;
}
other = other.convertToInteger();
}
return bignorm(getRuntime(), neg ? value.shiftLeft((int)shift) : value.shiftRight((int)shift));

return bignorm(getRuntime(), value.shiftRight((int)shift));
}

/** rb_big_aref
1 change: 0 additions & 1 deletion test/mri/excludes/CGIMultipartTest.rb

This file was deleted.

2 changes: 0 additions & 2 deletions test/mri/excludes/TestBignum.rb
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@
exclude :test_eq, "needs investigation"
exclude :test_fix_fdiv, "needs investigation"
exclude :test_float_fdiv, "needs investigation"
exclude :test_frozen, "needs investigation"
exclude :test_interrupt_during_bigdivrem, "slow and isn't testing interrupt well"
exclude :test_interrupt_during_to_s, "slow and isn't testing interrupt well"
exclude :test_pow, "needs investigation"
exclude :test_shift2, "needs investigation"