From 3ca08c7bb8628665580317807776648d5504d6db Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 12 Apr 2016 16:06:12 +0200 Subject: [PATCH] Add failing test for DSL processor bug with negated guard + @Cached. --- .../truffle/api/dsl/test/CachedTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java index a3459ffd71ee..f7c05a3b0700 100644 --- a/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java +++ b/truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CachedTest.java @@ -27,6 +27,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; +import org.junit.Ignore; import org.junit.Test; import com.oracle.truffle.api.CallTarget; @@ -43,6 +44,7 @@ import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestCacheMethodFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestCacheNodeFieldFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestCachesOrderFactory; +import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestCodeGenerationPosNegGuardFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestGuardWithCachedAndDynamicParameterFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestGuardWithJustCachedParameterFactory; import com.oracle.truffle.api.dsl.test.CachedTestFactory.TestMultipleCachesFactory; @@ -362,6 +364,38 @@ public void testCachesOrder() { assertEquals(42, root.call(23)); } + @NodeChild + static class TestCodeGenerationPosNegGuard extends ValueNode { + + @Specialization(guards = "guard(value)") + static int do0(int value) { + return value; + } + + // @Specialization(guards = {"!guard(value)", "value != cachedValue"}) + // static int do1(int value, @Cached("get(value)") int cachedValue) { + // return cachedValue; + // } + + protected static boolean guard(int i) { + return i == 0; + } + + protected int get(int i) { + return i * 2; + } + + } + + @Ignore("Code above (uncommented) produces invalid code") + @Test + public void testCodeGenerationPosNegGuard() { + CallTarget root = createCallTarget(TestCodeGenerationPosNegGuardFactory.getInstance()); + assertEquals(0, root.call(0)); + assertEquals(2, root.call(1)); + assertEquals(2, root.call(2)); + } + @NodeChild static class CachedError1 extends ValueNode { @Specialization