changeset 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 79d4c4b2d6db
children b010fd3de42d
files graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TestHelper.java graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java
diffstat 2 files changed, 32 insertions(+), 4 deletions(-) [+]
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));
+        }
+    }
+
 }
--- 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\".%")