comparison truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java @ 21951:9c8c0937da41

Moving all sources into truffle subdirectory
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 17 Jun 2015 10:58:08 +0200
parents graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java@18c0f02fa4d2
children dc83cc1f94f2
comparison
equal deleted inserted replaced
21950:2a5011c7e641 21951:9c8c0937da41
1 /*
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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
21 * questions.
22 */
23 package com.oracle.truffle.api.dsl.test;
24
25 import com.oracle.truffle.api.dsl.*;
26 import com.oracle.truffle.api.dsl.test.TypeSystemErrorsTest.Types1.Type1;
27 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
28
29 public class TypeSystemErrorsTest {
30
31 @TypeSystem({int.class, boolean.class})
32 public static class ErrorTypes0 {
33
34 }
35
36 @ExpectError("Invalid type order. The type(s) [java.lang.String] are inherited from a earlier defined type java.lang.CharSequence.")
37 @TypeSystem({CharSequence.class, String.class})
38 public static class ErrorTypes1 {
39
40 }
41
42 public static class Types1 {
43 public static class Type1 {
44 }
45 }
46
47 public static class Types2 {
48 public static class Type1 {
49 }
50 }
51
52 // verify boxed type overlay
53 @ExpectError("Two types result in the same boxed name: Type1.")
54 @TypeSystem({Type1.class, com.oracle.truffle.api.dsl.test.TypeSystemErrorsTest.Types2.Type1.class})
55 public static class ErrorTypes2 {
56
57 }
58
59 public static class Types3 {
60 public static class Object {
61 }
62 }
63
64 // verify Object name cannot appear
65 @ExpectError("Two types result in the same boxed name: Object.")
66 @TypeSystem({com.oracle.truffle.api.dsl.test.TypeSystemErrorsTest.Types3.Object.class})
67 public static class ErrorTypes3 {
68 }
69
70 public static class Types4 {
71 public static class Integer {
72 }
73 }
74
75 // verify int boxed name
76 @ExpectError("Two types result in the same boxed name: Integer.")
77 @TypeSystem({int.class, com.oracle.truffle.api.dsl.test.TypeSystemErrorsTest.Types4.Integer.class})
78 public static class ErrorTypes4 {
79 }
80
81 @TypeSystemReference(ErrorTypes0.class)
82 @NodeChild
83 @ExpectError("The @TypeSystem of the node and the @TypeSystem of the @NodeChild does not match. Types0 != SimpleTypes. ")
84 abstract static class ErrorNode1 extends ValueNode {
85 }
86
87 @TypeSystem({int.class})
88 public static class CastError1 {
89 @TypeCast(int.class)
90 @ExpectError("The provided return type \"String\" does not match expected return type \"int\".%")
91 public static String asInteger(Object value) {
92 return (String) value;
93 }
94 }
95
96 @TypeSystem({int.class})
97 public static class CastError2 {
98 @TypeCast(int.class)
99 @ExpectError("The provided return type \"boolean\" does not match expected return type \"int\".%")
100 public static boolean asInteger(Object value) {
101 return (boolean) value;
102 }
103 }
104
105 @TypeSystem({int.class})
106 public static class CastError4 {
107 @ExpectError("@TypeCast annotated method asInt must be public and static.")
108 @TypeCast(int.class)
109 public int asInt(Object value) {
110 return (int) value;
111 }
112 }
113
114 @TypeSystem({int.class})
115 public static class CastError5 {
116 @ExpectError("@TypeCast annotated method asInt must be public and static.")
117 @TypeCast(int.class)
118 static int asInt(Object value) {
119 return (int) value;
120 }
121 }
122
123 @TypeSystem({int.class})
124 public static class CheckError2 {
125 @ExpectError("@TypeCheck annotated method isInt must be public and static.")
126 @TypeCheck(int.class)
127 public boolean isInt(Object value) {
128 return value instanceof Integer;
129 }
130 }
131
132 @TypeSystem({int.class})
133 public static class CheckError3 {
134 @ExpectError("@TypeCheck annotated method isInt must be public and static.")
135 @TypeCheck(int.class)
136 static boolean isInt(Object value) {
137 return value instanceof Integer;
138 }
139 }
140
141 }