Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsTest.java @ 21011:a84d57d27727
DSL: test for using a static field in a guard.
author | Chris Seaton <chris.seaton@oracle.com> |
---|---|
date | Sat, 18 Apr 2015 13:44:13 +0100 |
parents | 9ca538e3e46e |
children | b1530a6cce8c |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsTest.java Fri Apr 17 12:04:12 2015 +0200 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsTest.java Sat Apr 18 13:44:13 2015 +0100 @@ -50,6 +50,7 @@ import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardNotTestFactory; import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardOrTestFactory; import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardStaticFieldTestFactory; +import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardStaticFinalFieldCompareTestFactory; import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardUnboundMethodTestFactory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; @@ -385,6 +386,30 @@ } @Test + public void testGuardStaticFinalFieldCompare() { + CallTarget root = createCallTarget(GuardStaticFinalFieldCompareTestFactory.getInstance()); + GuardStaticFieldTest.field = true; + assertEquals("do1", root.call(1)); + assertEquals("do2", root.call(2)); + } + + @NodeChild + static class GuardStaticFinalFieldCompareTest extends ValueNode { + + protected static final int FIELD = 1; + + @Specialization(guards = "value == FIELD") + static String do1(int value) { + return "do1"; + } + + @Specialization(guards = "value != FIELD") + static String do2(int value) { + return "do2"; + } + } + + @Test public void testGuardMethod() { CallTarget root = createCallTarget(GuardMethodTestFactory.getInstance()); assertEquals("do1", root.call(1));