comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java @ 20938:18c0f02fa4d2

Truffle-DSL: make type systems optional.
author Christian Humer <christian.humer@gmail.com>
date Tue, 14 Apr 2015 15:12:48 +0200
parents 7d67a33e1bbb
children
comparison
equal deleted inserted replaced
20937:37ea76052733 20938:18c0f02fa4d2
100 public static boolean asInteger(Object value) { 100 public static boolean asInteger(Object value) {
101 return (boolean) value; 101 return (boolean) value;
102 } 102 }
103 } 103 }
104 104
105 @TypeSystem({boolean.class})
106 public static class CastError3 {
107 @ExpectError("The type 'int' is not declared in the @TypeSystem.")
108 @TypeCast(int.class)
109 public static int asInt(Object value) {
110 return (int) value;
111 }
112 }
113
114 @TypeSystem({int.class}) 105 @TypeSystem({int.class})
115 public static class CastError4 { 106 public static class CastError4 {
116 @ExpectError("@TypeCast annotated method asInt must be public and static.") 107 @ExpectError("@TypeCast annotated method asInt must be public and static.")
117 @TypeCast(int.class) 108 @TypeCast(int.class)
118 public int asInt(Object value) { 109 public int asInt(Object value) {
124 public static class CastError5 { 115 public static class CastError5 {
125 @ExpectError("@TypeCast annotated method asInt must be public and static.") 116 @ExpectError("@TypeCast annotated method asInt must be public and static.")
126 @TypeCast(int.class) 117 @TypeCast(int.class)
127 static int asInt(Object value) { 118 static int asInt(Object value) {
128 return (int) value; 119 return (int) value;
129 }
130 }
131
132 @TypeSystem({boolean.class})
133 public static class CheckError1 {
134 @ExpectError("The type 'int' is not declared in the @TypeSystem.")
135 @TypeCheck(int.class)
136 public static boolean isInt(Object value) {
137 return value instanceof Integer;
138 } 120 }
139 } 121 }
140 122
141 @TypeSystem({int.class}) 123 @TypeSystem({int.class})
142 public static class CheckError2 { 124 public static class CheckError2 {