comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java @ 11467:43eab069ca9b

Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
author Christian Humer <christian.humer@gmail.com>
date Thu, 29 Aug 2013 19:19:00 +0200
parents
children 88316d1c4644
comparison
equal deleted inserted replaced
11466:4830676526e3 11467:43eab069ca9b
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
27 public class TypeSystemErrorsTest {
28
29 @TypeSystem({int.class, boolean.class})
30 static class Types0 {
31
32 }
33
34 @ExpectError("Invalid type order. The type(s) [java.lang.String] are inherited from a earlier defined type java.lang.CharSequence.")
35 @TypeSystem({CharSequence.class, String.class})
36 static class Types1 {
37
38 }
39
40 @TypeSystem({int.class, boolean.class})
41 static class Types2 {
42
43 @TypeCast
44 @ExpectError("The provided return type \"String\" does not match expected return type \"int\".%")
45 String asInteger(Object value) {
46 return (String) value;
47 }
48
49 }
50
51 @TypeSystem({int.class, boolean.class})
52 static class Types3 {
53
54 @TypeCast
55 @ExpectError("The provided return type \"boolean\" does not match expected return type \"int\".%")
56 boolean asInteger(Object value) {
57 return (boolean) value;
58 }
59
60 }
61
62 }