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: b1d0cc0580e7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d08501a4e596
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 12, 2018

  1. Copy the full SHA
    917d159 View commit details
  2. Copy the full SHA
    e64b94a View commit details
  3. Copy the full SHA
    d08501a View commit details
Showing with 14 additions and 9 deletions.
  1. +13 −9 core/src/main/java/org/jruby/RubyEnumerable.java
  2. +1 −0 test/mri/excludes/TestBeginEndBlock.rb
22 changes: 13 additions & 9 deletions core/src/main/java/org/jruby/RubyEnumerable.java
Original file line number Diff line number Diff line change
@@ -48,6 +48,7 @@
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.InternalVariables;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.callsite.NormalCachingCallSite;
import org.jruby.util.ArraySupport;
import org.jruby.util.TypeConverter;

@@ -261,27 +262,29 @@ private static SizeFn cycleSizeFn(final ThreadContext context, final IRubyObject
@Override
public IRubyObject size(IRubyObject[] args) {
Ruby runtime = context.runtime;
long mul = 0;
IRubyObject n = runtime.getNil();
IRubyObject size = enumSizeFn(context, self).size(args);

if (size == null || size.isNil()) {
return runtime.getNil();
}

if (args != null && args.length > 0) {
n = args[0];
if (!n.isNil()) mul = n.convertToInteger().getLongValue();
}

IRubyObject size = enumSizeFn(context, self).size(args);
if (size == null || size.isNil() || size.equals(RubyFixnum.zero(runtime))) {
return size;
}

if (n == null || n.isNil()) {
return RubyFloat.newFloat(runtime, RubyFloat.INFINITY);
}

long multiple = RubyNumeric.num2long(n);
if (multiple <= 0) {
if (mul <= 0) {
return RubyFixnum.zero(runtime);
}

return size.callMethod(context, "*", RubyFixnum.newFixnum(runtime, multiple));
n = RubyFixnum.newFixnum(runtime, mul);
return size.callMethod(context, "*", n);
}
};
}
@@ -1055,9 +1058,10 @@ public static IRubyObject inject(ThreadContext context, IRubyObject self, IRubyO
final IRubyObject result[] = new IRubyObject[] { init };

callEach(runtime, context, self, Signature.OPTIONAL, new BlockCallback() {
final NormalCachingCallSite site = new NormalCachingCallSite(methodId);
public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
IRubyObject larg = packEnumValues(ctx, largs);
result[0] = result[0] == null ? larg : result[0].callMethod(ctx, methodId, larg);
result[0] = result[0] == null ? larg : site.call(ctx, self, result[0], larg);
return ctx.nil;
}
});
1 change: 1 addition & 0 deletions test/mri/excludes/TestBeginEndBlock.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
exclude :test_begininclass, "needs investigation"
exclude :test_begininmethod, "needs investigation"
exclude :test_beginendblock, "needs investigation"
exclude :test_callcc_at_exit, "requires callcc"
exclude :test_propagate_signaled, "needs investigation"
exclude :test_raise_in_at_exit, "need to run multiple -e as separate top-level scripts (#3674)"