Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemErrorsTest.java @ 17199:88012c1750a0
Move bit logic nodes into the arithmetic node hierarchies.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Wed, 24 Sep 2014 14:29:43 +0200 |
parents | 64dcb92ee75a |
children | 3ea386a1036f |
rev | line source |
---|---|
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test; |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import com.oracle.truffle.api.dsl.*; |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
11479
diff
changeset
|
26 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 public class TypeSystemErrorsTest { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 @TypeSystem({int.class, boolean.class}) |
11469
88316d1c4644
Truffle-DSL: preparations for implicit casts
Christian Humer <christian.humer@gmail.com>
parents:
11467
diff
changeset
|
31 public static class Types0 { |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 @ExpectError("Invalid type order. The type(s) [java.lang.String] are inherited from a earlier defined type java.lang.CharSequence.") |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 @TypeSystem({CharSequence.class, String.class}) |
11469
88316d1c4644
Truffle-DSL: preparations for implicit casts
Christian Humer <christian.humer@gmail.com>
parents:
11467
diff
changeset
|
37 public static class Types1 { |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 @TypeSystem({int.class, boolean.class}) |
11469
88316d1c4644
Truffle-DSL: preparations for implicit casts
Christian Humer <christian.humer@gmail.com>
parents:
11467
diff
changeset
|
42 public static class Types2 { |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 @TypeCast |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 @ExpectError("The provided return type \"String\" does not match expected return type \"int\".%") |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 String asInteger(Object value) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 return (String) value; |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 @TypeSystem({int.class, boolean.class}) |
11469
88316d1c4644
Truffle-DSL: preparations for implicit casts
Christian Humer <christian.humer@gmail.com>
parents:
11467
diff
changeset
|
53 public static class Types3 { |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 @TypeCast |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 @ExpectError("The provided return type \"boolean\" does not match expected return type \"int\".%") |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 boolean asInteger(Object value) { |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 return (boolean) value; |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 } |
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 |
11479
fce94b1d46f0
Truffle-DSL: fixed the @TypeSystem of child nodes were not checked for equality.
Christian Humer <christian.humer@gmail.com>
parents:
11469
diff
changeset
|
63 @TypeSystemReference(Types0.class) |
fce94b1d46f0
Truffle-DSL: fixed the @TypeSystem of child nodes were not checked for equality.
Christian Humer <christian.humer@gmail.com>
parents:
11469
diff
changeset
|
64 @NodeChild |
fce94b1d46f0
Truffle-DSL: fixed the @TypeSystem of child nodes were not checked for equality.
Christian Humer <christian.humer@gmail.com>
parents:
11469
diff
changeset
|
65 @ExpectError("The @TypeSystem of the node and the @TypeSystem of the @NodeChild does not match. Types0 != SimpleTypes. ") |
fce94b1d46f0
Truffle-DSL: fixed the @TypeSystem of child nodes were not checked for equality.
Christian Humer <christian.humer@gmail.com>
parents:
11469
diff
changeset
|
66 abstract static class ErrorNode1 extends ValueNode { |
fce94b1d46f0
Truffle-DSL: fixed the @TypeSystem of child nodes were not checked for equality.
Christian Humer <christian.humer@gmail.com>
parents:
11469
diff
changeset
|
67 |
fce94b1d46f0
Truffle-DSL: fixed the @TypeSystem of child nodes were not checked for equality.
Christian Humer <christian.humer@gmail.com>
parents:
11469
diff
changeset
|
68 } |
fce94b1d46f0
Truffle-DSL: fixed the @TypeSystem of child nodes were not checked for equality.
Christian Humer <christian.humer@gmail.com>
parents:
11469
diff
changeset
|
69 |
11467
43eab069ca9b
Truffle-DSL: improved error recovery of type systems and improved error testability infrastructure.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 } |