Skip to content

Commit

Permalink
Merge pull request #12 in G/truffle from eregon-dsl-bug to master
Browse files Browse the repository at this point in the history
* commit '3ca08c7bb8628665580317807776648d5504d6db':
  Add failing test for DSL processor bug with negated guard + @cached.
  • Loading branch information
eregon committed Jul 11, 2016
2 parents a5e8309 + 3ca08c7 commit ed80f7f
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ed80f7f

Please sign in to comment.