diff graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java @ 16756:5148aab962af

Truffle-DSL: updated tests for the new generation layout.
author Christian Humer <christian.humer@gmail.com>
date Mon, 11 Aug 2014 15:53:05 +0200
parents 5f5e2711dc24
children 3912400fc33a
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java	Mon Aug 11 15:53:05 2014 +0200
+++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ImplicitCastTest.java	Mon Aug 11 15:53:05 2014 +0200
@@ -34,7 +34,7 @@
 
 public class ImplicitCastTest {
 
-    @TypeSystem({int.class, boolean.class, String.class})
+    @TypeSystem({int.class, String.class, boolean.class})
     static class ImplicitCast0Types {
 
         @ImplicitCast
@@ -55,12 +55,12 @@
 
         public abstract Object executeEvaluated(VirtualFrame frame, Object value2);
 
-        @Specialization(order = 1)
+        @Specialization
         public String op1(String value) {
             return value;
         }
 
-        @Specialization(order = 2)
+        @Specialization
         public boolean op1(boolean value) {
             return value;
         }
@@ -81,22 +81,21 @@
 
     @TypeSystemReference(ImplicitCast0Types.class)
     @NodeChild(value = "operand", type = ImplicitCast1Node.class)
-    // TODO temporary workaround
     abstract static class ImplicitCast1Node extends ValueNode {
 
         public abstract Object executeEvaluated(VirtualFrame frame, Object operand);
 
-        @Specialization(order = 0)
+        @Specialization
         public String op0(String value) {
             return value;
         }
 
-        @Specialization(order = 1, rewriteOn = RuntimeException.class)
+        @Specialization(rewriteOn = RuntimeException.class)
         public boolean op1(@SuppressWarnings("unused") boolean value) throws RuntimeException {
             throw new RuntimeException();
         }
 
-        @Specialization(order = 2)
+        @Specialization(contains = "op1")
         public boolean op2(boolean value) {
             return value;
         }
@@ -120,18 +119,18 @@
     // TODO temporary workaround
     abstract static class ImplicitCast2Node extends ValueNode {
 
-        @Specialization(order = 0)
+        @Specialization
         public String op0(String v0, String v1) {
             return v0 + v1;
         }
 
         @SuppressWarnings("unused")
-        @Specialization(order = 1, rewriteOn = RuntimeException.class)
+        @Specialization(rewriteOn = RuntimeException.class)
         public boolean op1(boolean v0, boolean v1) throws RuntimeException {
             throw new RuntimeException();
         }
 
-        @Specialization(order = 2)
+        @Specialization(contains = "op1")
         public boolean op2(boolean v0, boolean v1) {
             return v0 && v1;
         }
@@ -156,4 +155,15 @@
         Assert.assertEquals(true, root.getNode().executeEvaluated(null, true, true));
     }
 
+    @TypeSystem({String.class, boolean.class})
+    static class ImplicitCastError1 {
+
+        @ImplicitCast
+        @ExpectError("Target type and source type of an @ImplicitCast must not be the same type.")
+        String castInvalid(@SuppressWarnings("unused") String value) {
+            throw new AssertionError();
+        }
+
+    }
+
 }