Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsTest.java @ 20170:953c813b8e7a
DSL: allow comparison of different integral types.
author | Chris Seaton <chris.seaton@oracle.com> |
---|---|
date | Sun, 05 Apr 2015 20:40:52 +0100 |
parents | 62c43fcf5be2 |
children | 9ca538e3e46e |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsTest.java Sun Apr 05 19:51:46 2015 +0100 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsTest.java Sun Apr 05 20:40:52 2015 +0100 @@ -34,6 +34,8 @@ import com.oracle.truffle.api.dsl.test.LimitTestFactory.MethodLimitTestFactory; import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardCompareWithFieldTestFactory; import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardComplexTestFactory; +import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardEqualIntLongTestFactory; +import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardEqualLongIntTestFactory; import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardEqualTestFactory; import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardFieldTestFactory; import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardGreaterEqualTestFactory; @@ -74,6 +76,48 @@ } @Test + public void testGuardEqualIntLong() { + CallTarget root = createCallTarget(GuardEqualIntLongTestFactory.getInstance()); + assertEquals("do1", root.call(1)); + assertEquals("do2", root.call(2)); + assertEquals("do1", root.call(1)); + } + + @NodeChild + static class GuardEqualIntLongTest extends ValueNode { + @Specialization(guards = "value == 1") + static String do1(long value) { + return "do1"; + } + + @Specialization + static String do2(long value) { + return "do2"; + } + } + + @Test + public void testGuardEqualLongInt() { + CallTarget root = createCallTarget(GuardEqualLongIntTestFactory.getInstance()); + assertEquals("do1", root.call(1)); + assertEquals("do2", root.call(2)); + assertEquals("do1", root.call(1)); + } + + @NodeChild + static class GuardEqualLongIntTest extends ValueNode { + @Specialization(guards = "1 == value") + static String do1(long value) { + return "do1"; + } + + @Specialization + static String do2(long value) { + return "do2"; + } + } + + @Test public void testGuardLessEqual() { CallTarget root = createCallTarget(GuardLessEqualTestFactory.getInstance()); assertEquals("do1", root.call(1));