Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java @ 11469:88316d1c4644
Truffle-DSL: preparations for implicit casts
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 30 Aug 2013 11:37:42 +0200 |
parents | e55e24cc3e7b |
children | 1ccb36a32f87 |
line wrap: on
line diff
--- 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<? extends ValueNode> 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<List<Object>> permuts = permutations(Arrays.asList(testValues)); + for (List<Object> list : permuts) { + TestRootNode<?> root = createRoot(factory); + for (Object object : list) { + assertValue(root, result, object); + } + } + } + + static void assertValue(TestRootNode<? extends ValueNode> root, Object result, Object testValues) { + if (testValues instanceof Object[]) { + assertEquals(result, executeWith(root, (Object[]) testValues)); + } else { + assertEquals(result, executeWith(root, testValues)); + } + } + }