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

Commits on Dec 13, 2016

  1. Copy the full SHA
    47a6d2d View commit details
  2. Copy the full SHA
    bead3f3 View commit details
  3. [Truffle] Fix equal? for (int,long) if the different class specializa…

    …tion is taken first.
    
    * Primitives of different classes are usually not equal?, except for int/long.
    eregon committed Dec 13, 2016
    2
    Copy the full SHA
    b4541e3 View commit details
7 changes: 7 additions & 0 deletions spec/ruby/shared/kernel/equal.rb
Original file line number Diff line number Diff line change
@@ -44,4 +44,11 @@
true.__send__(@method, false).should == false
false.__send__(@method, true).should == false
end

it "returns true for integers of initially different ranges" do
big42 = (bignum_value * 42 / bignum_value)
42.__send__(@method, big42).should == true
long42 = (1 << 35) * 42 / (1 << 35)
42.__send__(@method, long42).should == true
end
end
Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ public boolean equal(VirtualFrame frame, Object a, Object b) {

}

@CoreMethod(names = { "equal?", "==" }, required = 1)
@CoreMethod(names = {"equal?", "=="}, required = 1)
public abstract static class ReferenceEqualNode extends CoreMethodArrayArgumentsNode {

public static ReferenceEqualNode create() {
@@ -132,8 +132,8 @@ public boolean equal(DynamicObject a, DynamicObject b) {
return a == b;
}

@Specialization(guards = { "isNotDynamicObject(a)", "isNotDynamicObject(b)", "notSameClass(a, b)" })
public boolean equal(Object a, Object b) {
@Specialization(guards = {"isNotDynamicObject(a)", "isNotDynamicObject(b)", "notSameClass(a, b)", "isNotIntLong(a) || isNotIntLong(b)"})
public boolean equalIncompatiblePrimitiveTypes(Object a, Object b) {
return false;
}

@@ -155,6 +155,10 @@ protected boolean notSameClass(Object a, Object b) {
return a.getClass() != b.getClass();
}

protected boolean isNotIntLong(Object v) {
return !(v instanceof Integer) && !(v instanceof Long);
}

}

@CoreMethod(names = "initialize", needsSelf = false)
Original file line number Diff line number Diff line change
@@ -1383,6 +1383,25 @@ public boolean isNil() {
}
}

// A basic Kernel#p for debugging core, overridden later in kernel.rb
@CoreMethod(names = "p", needsSelf = false, required = 1, unsafe = UnsafeGroup.IO)
public abstract static class DebugPrintNode extends CoreMethodArrayArgumentsNode {

@Child CallDispatchHeadNode callInspectNode = CallDispatchHeadNode.createMethodCall();

@Specialization
public Object p(VirtualFrame frame, Object value) {
Object inspected = callInspectNode.call(frame, value, "inspect");
print(inspected);
return value;
}

@TruffleBoundary
private void print(Object inspected) {
System.out.println(inspected.toString());
}
}

@CoreMethod(names = "private_methods", optional = 1)
@NodeChildren({
@NodeChild(type = RubyNode.class, value = "object"),
@@ -1976,7 +1995,7 @@ public String toHexString(DynamicObject value) {

}

@CoreMethod(names = "to_s")
@CoreMethod(names = {"to_s", "inspect"}) // Basic inspect, refined later in core
public abstract static class ToSNode extends CoreMethodArrayArgumentsNode {

@Child private LogicalClassNode classNode;