# HG changeset patch # User Christian Humer # Date 1377855462 -7200 # Node ID 88316d1c464468962c61429789a29f920019c460 # Parent 79d4c4b2d6dbca3ca6737c5fa093996c11dbf268 Truffle-DSL: preparations for implicit casts diff -r 79d4c4b2d6db -r 88316d1c4644 graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java --- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java Thu Aug 29 19:19:33 2013 +0200 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java Fri Aug 30 11:37:42 2013 +0200 @@ -22,6 +22,9 @@ */ package com.oracle.truffle.api.dsl.test; +import static com.oracle.truffle.api.dsl.test.TestHelper.*; +import static org.junit.Assert.*; + import java.util.*; import com.oracle.truffle.api.*; @@ -115,4 +118,29 @@ return output; } + /* Methods tests all test values in combinational order. */ + static void assertRuns(NodeFactory factory, Object result, Object... testValues) { + // test each run by its own. + for (int i = 0; i < testValues.length; i++) { + assertValue(createRoot(factory), result, testValues); + } + + // test all combinations of the test values + List> permuts = permutations(Arrays.asList(testValues)); + for (List list : permuts) { + TestRootNode root = createRoot(factory); + for (Object object : list) { + assertValue(root, result, object); + } + } + } + + static void assertValue(TestRootNode root, Object result, Object testValues) { + if (testValues instanceof Object[]) { + assertEquals(result, executeWith(root, (Object[]) testValues)); + } else { + assertEquals(result, executeWith(root, testValues)); + } + } + } diff -r 79d4c4b2d6db -r 88316d1c4644 graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java --- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java Thu Aug 29 19:19:33 2013 +0200 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java Fri Aug 30 11:37:42 2013 +0200 @@ -27,18 +27,18 @@ public class TypeSystemErrorsTest { @TypeSystem({int.class, boolean.class}) - static class Types0 { + public static class Types0 { } @ExpectError("Invalid type order. The type(s) [java.lang.String] are inherited from a earlier defined type java.lang.CharSequence.") @TypeSystem({CharSequence.class, String.class}) - static class Types1 { + public static class Types1 { } @TypeSystem({int.class, boolean.class}) - static class Types2 { + public static class Types2 { @TypeCast @ExpectError("The provided return type \"String\" does not match expected return type \"int\".%") @@ -49,7 +49,7 @@ } @TypeSystem({int.class, boolean.class}) - static class Types3 { + public static class Types3 { @TypeCast @ExpectError("The provided return type \"boolean\" does not match expected return type \"int\".%")