comparison 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
comparison
equal deleted inserted replaced
11468:79d4c4b2d6db 11469:88316d1c4644
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 package com.oracle.truffle.api.dsl.test; 23 package com.oracle.truffle.api.dsl.test;
24
25 import static com.oracle.truffle.api.dsl.test.TestHelper.*;
26 import static org.junit.Assert.*;
24 27
25 import java.util.*; 28 import java.util.*;
26 29
27 import com.oracle.truffle.api.*; 30 import com.oracle.truffle.api.*;
28 import com.oracle.truffle.api.dsl.*; 31 import com.oracle.truffle.api.dsl.*;
113 } 116 }
114 117
115 return output; 118 return output;
116 } 119 }
117 120
121 /* Methods tests all test values in combinational order. */
122 static void assertRuns(NodeFactory<? extends ValueNode> factory, Object result, Object... testValues) {
123 // test each run by its own.
124 for (int i = 0; i < testValues.length; i++) {
125 assertValue(createRoot(factory), result, testValues);
126 }
127
128 // test all combinations of the test values
129 List<List<Object>> permuts = permutations(Arrays.asList(testValues));
130 for (List<Object> list : permuts) {
131 TestRootNode<?> root = createRoot(factory);
132 for (Object object : list) {
133 assertValue(root, result, object);
134 }
135 }
136 }
137
138 static void assertValue(TestRootNode<? extends ValueNode> root, Object result, Object testValues) {
139 if (testValues instanceof Object[]) {
140 assertEquals(result, executeWith(root, (Object[]) testValues));
141 } else {
142 assertEquals(result, executeWith(root, testValues));
143 }
144 }
145
118 } 146 }