Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest.java @ 11320:80de3bbfa8b9
Truffle-DSL: fixed inconsistent children for polymorphic -> generic rewrites. (GRAAL-425)
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 16 Aug 2013 14:00:17 +0200 |
parents | 79041ab43660 |
children | e5b5a5cb0ac7 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest.java Thu Aug 15 19:46:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/PolymorphicTest.java Fri Aug 16 14:00:17 2013 +0200 @@ -31,6 +31,7 @@ import com.oracle.truffle.api.dsl.test.BinaryNodeTest.BinaryNode; import com.oracle.truffle.api.dsl.test.PolymorphicTestFactory.Node1Factory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; +import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; import com.oracle.truffle.api.nodes.*; import com.oracle.truffle.api.nodes.NodeInfo.Kind; @@ -44,6 +45,8 @@ assertEquals("(int,boolean)", executeWith(node, 42, false)); assertEquals("(boolean,int)", executeWith(node, false, 42)); assertEquals(Kind.SPECIALIZED, node.getNode().getClass().getAnnotation(NodeInfo.class).kind()); + assertEquals(node.getNode(), node.getNode().getLeft().getParent()); + assertEquals(node.getNode(), node.getNode().getRight().getParent()); } @Test @@ -52,6 +55,8 @@ assertEquals("(int,boolean)", executeWith(node, 42, false)); assertEquals("(int,int)", executeWith(node, 42, 42)); assertEquals(Kind.POLYMORPHIC, node.getNode().getClass().getAnnotation(NodeInfo.class).kind()); + assertEquals(node.getNode(), node.getNode().getLeft().getParent()); + assertEquals(node.getNode(), node.getNode().getRight().getParent()); } @Test @@ -61,6 +66,8 @@ assertEquals("(boolean,boolean)", executeWith(node, true, false)); assertEquals("(int,int)", executeWith(node, 42, 42)); assertEquals(Kind.POLYMORPHIC, node.getNode().getClass().getAnnotation(NodeInfo.class).kind()); + assertEquals(node.getNode(), node.getNode().getLeft().getParent()); + assertEquals(node.getNode(), node.getNode().getRight().getParent()); } @Test @@ -71,6 +78,8 @@ assertEquals("(boolean,boolean)", executeWith(node, true, false)); assertEquals("(int,int)", executeWith(node, 42, 42)); assertEquals(Kind.GENERIC, node.getNode().getClass().getAnnotation(NodeInfo.class).kind()); + assertEquals(node.getNode(), node.getNode().getLeft().getParent()); + assertEquals(node.getNode(), node.getNode().getRight().getParent()); } @Test @@ -78,21 +87,30 @@ TestRootNode<Node1> node = TestHelper.createRoot(Node1Factory.getInstance()); assertEquals("(generic,generic)", executeWith(node, "", "")); assertEquals(Kind.GENERIC, node.getNode().getClass().getAnnotation(NodeInfo.class).kind()); + assertEquals(node.getNode(), node.getNode().getLeft().getParent()); + assertEquals(node.getNode(), node.getNode().getRight().getParent()); } @Test - public void testGenericPolymorphic() { + public void testGenericPolymorphic1() { TestRootNode<Node1> node = TestHelper.createRoot(Node1Factory.getInstance()); assertEquals("(boolean,int)", executeWith(node, false, 42)); - assertEquals("(int,boolean)", executeWith(node, 42, false)); + assertEquals("(boolean,boolean)", executeWith(node, false, false)); assertEquals("(generic,generic)", executeWith(node, "", "")); assertEquals(Kind.GENERIC, node.getNode().getClass().getAnnotation(NodeInfo.class).kind()); + /* Assertions for bug GRAAL-425 */ + assertEquals(node.getNode(), node.getNode().getLeft().getParent()); + assertEquals(node.getNode(), node.getNode().getRight().getParent()); } @SuppressWarnings("unused") @PolymorphicLimit(3) abstract static class Node1 extends BinaryNode { + public abstract ValueNode getLeft(); + + public abstract ValueNode getRight(); + @Specialization(order = 1) String add(int left, int right) { return "(int,int)";