Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LazyClassLoadingTest.java @ 18761:a665483c3881
Truffle-DSL: new node layout implementation.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 29 Dec 2014 23:38:54 +0100 |
parents | dd95dff835f9 |
children | 15fe16c45d64 |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LazyClassLoadingTest.java Mon Dec 29 23:38:50 2014 +0100 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/LazyClassLoadingTest.java Mon Dec 29 23:38:54 2014 +0100 @@ -28,28 +28,45 @@ import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.dsl.test.LazyClassLoadingTestFactory.TestNodeFactory; -import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; +import com.oracle.truffle.api.dsl.test.TypeSystemTest.*; public class LazyClassLoadingTest { @Test public void test() { - String testClassName = getClass().getName(); - String factoryClassName = testClassName + "Factory"; - String nodeFactoryClassName = factoryClassName + "$TestNodeFactory"; - - Assert.assertFalse(isLoaded(factoryClassName + "$TestNode")); - Assert.assertFalse(isLoaded(nodeFactoryClassName)); + String factoryName = TestNodeFactory.class.getName(); + String nodeName = factoryName + "$" + TestNode.class.getSimpleName() + "Gen"; + Assert.assertTrue(isLoaded(factoryName)); + Assert.assertFalse(isLoaded(nodeName)); NodeFactory<TestNode> factory = TestNodeFactory.getInstance(); + Assert.assertTrue(isLoaded(factoryName)); + Assert.assertTrue(isLoaded(nodeName)); - Assert.assertTrue(isLoaded(nodeFactoryClassName)); - Assert.assertFalse(isLoaded(nodeFactoryClassName + "$TestBaseNode")); + Assert.assertFalse(isLoaded(nodeName + "$UninitializedNode")); + Assert.assertFalse(isLoaded(nodeName + "$BaseNode")); + Assert.assertFalse(isLoaded(nodeName + "$IntNode")); + Assert.assertFalse(isLoaded(nodeName + "$BooleanNode")); + Assert.assertFalse(isLoaded(nodeName + "$PolymorphicNode")); + + TestRootNode<TestNode> root = TestHelper.createRoot(factory); - TestHelper.createRoot(factory); + Assert.assertTrue(isLoaded(nodeName + "$BaseNode")); + Assert.assertTrue(isLoaded(nodeName + "$UninitializedNode")); + Assert.assertFalse(isLoaded(nodeName + "$IntNode")); + Assert.assertFalse(isLoaded(nodeName + "$BooleanNode")); + Assert.assertFalse(isLoaded(nodeName + "$PolymorphicNode")); + + Assert.assertEquals(42, TestHelper.executeWith(root, 42)); - Assert.assertTrue(isLoaded(nodeFactoryClassName + "$TestBaseNode")); - Assert.assertTrue(isLoaded(nodeFactoryClassName + "$TestUninitializedNode")); - Assert.assertFalse(isLoaded(nodeFactoryClassName + "$TestGenericNode")); + Assert.assertTrue(isLoaded(nodeName + "$IntNode")); + Assert.assertFalse(isLoaded(nodeName + "$BooleanNode")); + Assert.assertFalse(isLoaded(nodeName + "$PolymorphicNode")); + + Assert.assertEquals(true, TestHelper.executeWith(root, true)); + + Assert.assertTrue(isLoaded(nodeName + "$IntNode")); + Assert.assertTrue(isLoaded(nodeName + "$BooleanNode")); + Assert.assertTrue(isLoaded(nodeName + "$PolymorphicNode")); } private boolean isLoaded(String className) { @@ -64,22 +81,18 @@ } } - @SuppressWarnings("unused") - @NodeChildren({@NodeChild("left"), @NodeChild("right")}) + @NodeChild("a") abstract static class TestNode extends ValueNode { - @Specialization(order = 1) - int add(int left, int right) { - return 42; + + @Specialization + int s(int a) { + return a; } - @Specialization(order = 2) - int add(boolean left, boolean right) { - return 21; + @Specialization + boolean s(boolean a) { + return a; } - @Specialization(order = 4) - String add(boolean left, int right) { - return "(boolean,int)"; - } } }