Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/InsertBeforeTest.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 | |
children | f9fff060dc41 |
comparison
equal
deleted
inserted
replaced
16755:bd28da642eea | 16756:5148aab962af |
---|---|
1 /* | |
2 * Copyright (c) 2012, 2012, 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.TypeSystemTest.ValueNode; | |
27 | |
28 public class InsertBeforeTest { | |
29 | |
30 @NodeChild("a") | |
31 static class InsertBefore1Base extends ValueNode { | |
32 | |
33 boolean g1(int a) { | |
34 return a == 1; | |
35 } | |
36 | |
37 boolean g2(int a) { | |
38 return a == 2; | |
39 } | |
40 | |
41 @Specialization(guards = "g1") | |
42 int f1(int a) { | |
43 return a; | |
44 } | |
45 | |
46 @Specialization(guards = "g2") | |
47 int f3(int a) { | |
48 return a; | |
49 } | |
50 | |
51 } | |
52 | |
53 @NodeChild("a") | |
54 static class InsertBefore1T1 extends InsertBefore1Base { | |
55 | |
56 @Specialization | |
57 int f0(int a) { | |
58 return a; | |
59 } | |
60 | |
61 } | |
62 | |
63 @NodeChild("a") | |
64 static class InsertBefore1T2 extends InsertBefore1Base { | |
65 | |
66 boolean g0(int a) { | |
67 return a == 0; | |
68 } | |
69 | |
70 @Specialization(guards = "g0", insertBefore = "f1") | |
71 int f0(int a) { | |
72 return a; | |
73 } | |
74 | |
75 } | |
76 | |
77 @NodeChild("a") | |
78 static class InsertBefore1T3 extends InsertBefore1Base { | |
79 | |
80 boolean g0(int a) { | |
81 return a == 0; | |
82 } | |
83 | |
84 @Specialization(guards = "g0", insertBefore = "f3") | |
85 int f0(int a) { | |
86 return a; | |
87 } | |
88 | |
89 } | |
90 | |
91 @NodeChild("a") | |
92 @ExpectError({"Element int f3(int) at annotation @Specialization is erroneous: Specialization is not reachable. It is shadowed by f0(int).", | |
93 "Element int f1(int) at annotation @Specialization is erroneous: Specialization is not reachable. It is shadowed by f0(int)."}) | |
94 static class InsertBefore1T4 extends InsertBefore1Base { | |
95 | |
96 boolean g0(int a) { | |
97 return a == 0; | |
98 } | |
99 | |
100 @Specialization(insertBefore = "f1") | |
101 int f0(int a) { | |
102 return a; | |
103 } | |
104 | |
105 } | |
106 | |
107 @NodeChild("a") | |
108 @ExpectError({"Element int f3(int) at annotation @Specialization is erroneous: Specialization is not reachable. It is shadowed by f0(int)."}) | |
109 static class InsertBefore1T5 extends InsertBefore1Base { | |
110 | |
111 boolean g0(int a) { | |
112 return a == 0; | |
113 } | |
114 | |
115 @Specialization(insertBefore = "f3") | |
116 int f0(int a) { | |
117 return a; | |
118 } | |
119 | |
120 } | |
121 | |
122 @NodeChild("a") | |
123 static class InsertBefore1Error1 extends InsertBefore1Base { | |
124 | |
125 @ExpectError("Specializations can only be inserted before specializations in superclasses.") | |
126 @Specialization(insertBefore = "f0") | |
127 int f0(int a) { | |
128 return a; | |
129 } | |
130 | |
131 } | |
132 | |
133 @NodeChild("a") | |
134 static class InsertBefore1Error2 extends InsertBefore1Base { | |
135 | |
136 @ExpectError("The referenced specialization 'asdf' could not be found.") | |
137 @Specialization(insertBefore = "asdf") | |
138 int f0(int a) { | |
139 return a; | |
140 } | |
141 | |
142 } | |
143 | |
144 } |