# HG changeset patch # User Christian Humer # Date 1420485802 -3600 # Node ID eecda5abf62764e490c913013066f234d7383d23 # Parent 93016f2f3f162748e2d011cf2c4d847db7155829 Truffle-DSL: simplify bad overflow test. The issue is fixed by the new generated node layout. (GRAAL-885 #resolve) diff -r 93016f2f3f16 -r eecda5abf627 graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BadLongOverflowSpecializationTest.java --- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BadLongOverflowSpecializationTest.java Mon Jan 05 20:23:22 2015 +0100 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/BadLongOverflowSpecializationTest.java Mon Jan 05 20:23:22 2015 +0100 @@ -25,59 +25,36 @@ import static com.oracle.truffle.api.dsl.test.TestHelper.*; import static org.junit.Assert.*; -import java.math.*; - import org.junit.*; -import com.oracle.truffle.api.*; import com.oracle.truffle.api.dsl.*; -import com.oracle.truffle.api.dsl.test.BadLongOverflowSpecializationTestFactory.AddNodeFactory; +import com.oracle.truffle.api.dsl.test.BadLongOverflowSpecializationTestFactory.ImplicitCastExclusionFactory; import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; public class BadLongOverflowSpecializationTest { - @NodeChildren({@NodeChild("left"), @NodeChild("right")}) - abstract static class BinaryNode extends ValueNode { - } + /* Regression test for */ - abstract static class AddNode extends BinaryNode { - @Specialization(rewriteOn = ArithmeticException.class) - int add(int left, int right) { - return ExactMath.addExact(left, right); + @NodeChild + @SuppressWarnings("unused") + abstract static class ImplicitCastExclusion extends ValueNode { + + @Specialization(rewriteOn = RuntimeException.class) + String f1(long a) { + return "triggered1"; } @Specialization - long addIntWithOverflow(int left, int right) { - return (long) left + (long) right; - } - - @Specialization(rewriteOn = ArithmeticException.class) - Object add(long left, long right) { - return ExactMath.addExact(left, right); - } - - @Specialization - BigInteger addSlow(long left, long right) { - return BigInteger.valueOf(left).add(BigInteger.valueOf(right)); + String f2(long a) { + return "triggered2"; } } @Test - @Ignore public void testAdd() { - TestRootNode node = createRoot(AddNodeFactory.getInstance()); - - long index = -1; - int baseStep = 0; - Object r1 = executeWith(node, index, baseStep); - assertEquals(-1L, r1); - - long err = 5000; - long errStep = 2000; - Object r2 = executeWith(node, err, errStep); - - assertEquals(Long.class, r2.getClass()); - assertEquals(7000L, r2); + TestRootNode node = createRoot(ImplicitCastExclusionFactory.getInstance()); + assertEquals("triggered1", executeWith(node, -1)); + assertEquals("triggered1", executeWith(node, 5000L)); } }