Skip to content
Snippets Groups Projects
Commit a3834e5b authored by Mick Jordan's avatar Mick Jordan
Browse files

Handle builtins in identical(RFunction)

parent d2b95ac0
Branches
No related tags found
No related merge requests found
......@@ -204,6 +204,17 @@ public abstract class Identical extends RBuiltinNode {
// trivial case
return RRuntime.LOGICAL_TRUE;
} else {
boolean xb = x.isBuiltin();
boolean yb = y.isBuiltin();
if ((xb && !yb) || (yb && !xb)) {
return RRuntime.LOGICAL_FALSE;
}
if (xb && yb) {
// equal if the factories are
return RRuntime.asLogical(x.getRBuiltin() == y.getRBuiltin());
}
// compare the structure
if (!new IdenticalVisitor().accept((RSyntaxNode) x.getRootNode(), (RSyntaxNode) y.getRootNode())) {
return RRuntime.LOGICAL_FALSE;
......
......@@ -217,7 +217,6 @@ public class TestBuiltin_identical extends TestBase {
assertEval("{ identical(quote(if(x) 42), quote(if(x) 7)) }");
assertEval("{ identical(quote(if(x) 42), quote(if(x) 42)) }");
assertEval("{ identical(function() 42, function() 42) }");
assertEval("{ setClass(\"foo\", representation(j=\"numeric\")); x<-new(\"foo\", j=42); y<-new(\"foo\", j=42); identical(x,y) }");
assertEval("{ setClass(\"foo\", representation(j=\"numeric\")); x<-new(\"foo\", j=42); y<-new(\"foo\", j=7); identical(x,y) }");
......@@ -256,6 +255,7 @@ public class TestBuiltin_identical extends TestBase {
// GnuR adds a srcref attribute, FastR does not, so we really can't do any comparative
// tests.
assertEval(Ignored.ImplementationError, "{ f1 <- function() {}; f2 <- function() {}; identical(f1, f2) }");
assertEval(Ignored.ImplementationError, "{ identical(function() 42, function() 42) }");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment