Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/MethodGuardsTest.java @ 22157:dc83cc1f94f2
Using fully qualified imports
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 16 Sep 2015 11:33:22 +0200 |
parents | 9c8c0937da41 |
children | 14e6dfb1ef05 |
rev | line source |
---|---|
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test; |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
25 import com.oracle.truffle.api.CallTarget; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
26 import com.oracle.truffle.api.dsl.NodeChild; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
27 import com.oracle.truffle.api.dsl.Specialization; |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
28 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardCompareWithFieldTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
29 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardComplexTestFactory; |
20171
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
30 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardEqualByteIntTestFactory; |
20170
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
31 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardEqualIntLongTestFactory; |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
32 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardEqualLongIntTestFactory; |
20171
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
33 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardEqualShortIntTestFactory; |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
34 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardEqualTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
35 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardFieldTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
36 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardGreaterEqualTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
37 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardGreaterTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
38 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardLessEqualTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
39 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardLessTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
40 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardMethodTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
41 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardMultipleAndMethodTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
42 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardMultipleOrMethodTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
43 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardNotTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
44 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardOrTestFactory; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
45 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardStaticFieldTestFactory; |
21011
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
46 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardStaticFinalFieldCompareTestFactory; |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
47 import com.oracle.truffle.api.dsl.test.MethodGuardsTestFactory.GuardUnboundMethodTestFactory; |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
48 import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
49 import static com.oracle.truffle.api.dsl.test.TestHelper.getNode; |
18784
3c7d543d758d
Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents:
16851
diff
changeset
|
50 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
51 import static org.junit.Assert.assertEquals; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
52 import static org.junit.Assert.fail; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
53 import org.junit.Test; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 @SuppressWarnings("unused") |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 public class MethodGuardsTest { |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
58 @Test |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
59 public void testGuardEqual() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
60 CallTarget root = createCallTarget(GuardEqualTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
61 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
62 assertEquals("do2", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
63 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
64 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
65 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
66 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
67 static class GuardEqualTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
68 @Specialization(guards = "value == 1") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
69 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
70 return "do1"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
71 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
72 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
73 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
74 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
75 return "do2"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
76 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
77 } |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
78 |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 @Test |
20170
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
80 public void testGuardEqualIntLong() { |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
81 CallTarget root = createCallTarget(GuardEqualIntLongTestFactory.getInstance()); |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
82 assertEquals("do1", root.call(1)); |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
83 assertEquals("do2", root.call(2)); |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
84 assertEquals("do1", root.call(1)); |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
85 } |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
86 |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
87 @NodeChild |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
88 static class GuardEqualIntLongTest extends ValueNode { |
20171
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
89 @Specialization(guards = "1 == value") |
20170
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
90 static String do1(long value) { |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
91 return "do1"; |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
92 } |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
93 |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
94 @Specialization |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
95 static String do2(long value) { |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
96 return "do2"; |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
97 } |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
98 } |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
99 |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
100 @Test |
20171
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
101 public void testGuardEqualByteInt() { |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
102 CallTarget root = createCallTarget(GuardEqualByteIntTestFactory.getInstance()); |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
103 assertEquals("do1", root.call((byte) 1)); |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
104 assertEquals("do2", root.call((byte) 2)); |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
105 assertEquals("do1", root.call((byte) 1)); |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
106 } |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
107 |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
108 @NodeChild |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
109 static class GuardEqualByteIntTest extends ValueNode { |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
110 @Specialization(guards = "value == 1") |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
111 static String do1(byte value) { |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
112 return "do1"; |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
113 } |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
114 |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
115 @Specialization |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
116 static String do2(byte value) { |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
117 return "do2"; |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
118 } |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
119 } |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
120 |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
121 @Test |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
122 public void testGuardEqualShortInt() { |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
123 CallTarget root = createCallTarget(GuardEqualShortIntTestFactory.getInstance()); |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
124 assertEquals("do1", root.call((short) 1)); |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
125 assertEquals("do2", root.call((short) 2)); |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
126 assertEquals("do1", root.call((short) 1)); |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
127 } |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
128 |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
129 @NodeChild |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
130 static class GuardEqualShortIntTest extends ValueNode { |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
131 @Specialization(guards = "value == 1") |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
132 static String do1(short value) { |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
133 return "do1"; |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
134 } |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
135 |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
136 @Specialization |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
137 static String do2(short value) { |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
138 return "do2"; |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
139 } |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
140 } |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
141 |
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
142 @Test |
20170
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
143 public void testGuardEqualLongInt() { |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
144 CallTarget root = createCallTarget(GuardEqualLongIntTestFactory.getInstance()); |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
145 assertEquals("do1", root.call(1)); |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
146 assertEquals("do2", root.call(2)); |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
147 assertEquals("do1", root.call(1)); |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
148 } |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
149 |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
150 @NodeChild |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
151 static class GuardEqualLongIntTest extends ValueNode { |
20171
9ca538e3e46e
DSL: add tests for comparing against a byte and a short in guards.
Chris Seaton <chris.seaton@oracle.com>
parents:
20170
diff
changeset
|
152 @Specialization(guards = "value == 1") |
20170
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
153 static String do1(long value) { |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
154 return "do1"; |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
155 } |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
156 |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
157 @Specialization |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
158 static String do2(long value) { |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
159 return "do2"; |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
160 } |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
161 } |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
162 |
953c813b8e7a
DSL: allow comparison of different integral types.
Chris Seaton <chris.seaton@oracle.com>
parents:
19289
diff
changeset
|
163 @Test |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
164 public void testGuardLessEqual() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
165 CallTarget root = createCallTarget(GuardLessEqualTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
166 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
167 assertEquals("do1", root.call(0)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
168 assertEquals("do2", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
169 assertEquals("do1", root.call(0)); |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
170 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
171 |
18784
3c7d543d758d
Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents:
16851
diff
changeset
|
172 @NodeChild |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
173 static class GuardLessEqualTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
174 @Specialization(guards = "value <= 1") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
175 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
176 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
177 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
178 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
179 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
180 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
181 return "do2"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
182 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
183 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
184 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
185 @Test |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
186 public void testGuardLess() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
187 CallTarget root = createCallTarget(GuardLessTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
188 assertEquals("do1", root.call(0)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
189 assertEquals("do2", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
190 assertEquals("do2", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
191 assertEquals("do1", root.call(-1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
192 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
193 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
194 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
195 static class GuardLessTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
196 @Specialization(guards = "value < 1") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
197 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
198 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
199 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
200 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
201 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
202 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
203 return "do2"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
204 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
205 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
206 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
207 @Test |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
208 public void testGuardGreaterEqual() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
209 CallTarget root = createCallTarget(GuardGreaterEqualTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
210 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
211 assertEquals("do2", root.call(0)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
212 assertEquals("do1", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
213 assertEquals("do2", root.call(0)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
214 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
215 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
216 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
217 static class GuardGreaterEqualTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
218 @Specialization(guards = "value >= 1") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
219 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
220 return "do1"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
221 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
222 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
223 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
224 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
225 return "do2"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
226 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
227 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
228 |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
229 @Test |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
230 public void testGuardGreater() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
231 CallTarget root = createCallTarget(GuardGreaterTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
232 assertEquals("do1", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
233 assertEquals("do2", root.call(0)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
234 assertEquals("do2", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
235 assertEquals("do2", root.call(0)); |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
236 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
237 |
18784
3c7d543d758d
Truffle-DSL: minor cleanup to the guard test.
Christian Humer <christian.humer@gmail.com>
parents:
16851
diff
changeset
|
238 @NodeChild |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
239 static class GuardGreaterTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
240 @Specialization(guards = "value > 1") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
241 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
242 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
243 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
244 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
245 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
246 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
247 return "do2"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
248 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
249 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
250 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
251 @Test |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
252 public void testGuardOr() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
253 CallTarget root = createCallTarget(GuardOrTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
254 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
255 assertEquals("do1", root.call(0)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
256 assertEquals("do2", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
257 assertEquals("do2", root.call(-1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
258 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
259 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
260 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
261 static class GuardOrTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
262 @Specialization(guards = "value == 1 || value == 0") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
263 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
264 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
265 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
266 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
267 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
268 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
269 return "do2"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
270 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
271 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
272 |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
273 @Test |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
274 public void testGuardNot() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
275 CallTarget root = createCallTarget(GuardNotTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
276 assertEquals("do1", root.call(0)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
277 assertEquals("do1", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
278 assertEquals("do2", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
279 assertEquals("do1", root.call(0)); |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
280 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
281 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
282 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
283 static class GuardNotTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
284 @Specialization(guards = "!(value == 1)") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
285 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
286 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
287 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
288 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
289 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
290 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
291 return "do2"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
292 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
293 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
294 |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
295 @Test |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
296 public void testGuardField() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
297 CallTarget root = createCallTarget(GuardFieldTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
298 GuardFieldTest node = getNode(root); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
299 node.field = true; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
300 assertEquals("do1", root.call(0)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
301 assertEquals("do1", root.call(2)); |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
302 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
303 node.field = false; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
304 try { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
305 root.call(2); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
306 fail("expected Assertion failed"); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
307 } catch (AssertionError e) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
308 } |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
309 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
310 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
311 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
312 static class GuardFieldTest extends ValueNode { |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
313 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
314 boolean field; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
315 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
316 @Specialization(guards = "field") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
317 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
318 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
319 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
320 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
321 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
322 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
323 return "do2"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
324 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
325 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
326 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
327 @Test |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
328 public void testGuardCompareWithField() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
329 CallTarget root = createCallTarget(GuardCompareWithFieldTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
330 GuardCompareWithFieldTest node = getNode(root); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
331 node.field = 1; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
332 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
333 assertEquals("do2", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
334 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
335 node.field = 2; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
336 assertEquals("do2", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
337 assertEquals("do1", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
338 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
339 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
340 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
341 static class GuardCompareWithFieldTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
342 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
343 int field; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
344 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
345 @Specialization(guards = "value == field") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
346 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
347 return "do1"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
348 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
349 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
350 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
351 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
352 return "do2"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
353 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
354 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
355 |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
356 @Test |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
357 public void testGuardStaticField() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
358 CallTarget root = createCallTarget(GuardStaticFieldTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
359 GuardStaticFieldTest.field = true; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
360 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
361 assertEquals("do1", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
362 GuardStaticFieldTest.field = false; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
363 try { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
364 root.call(2); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
365 fail("expected Assertion failed"); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
366 } catch (AssertionError e) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
367 } |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
368 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
369 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
370 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
371 static class GuardStaticFieldTest extends ValueNode { |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
372 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
373 static boolean field; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
374 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
375 @Specialization(guards = "field") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
376 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
377 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
378 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
379 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
380 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
381 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
382 return "do2"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
383 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
384 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
385 |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
386 @Test |
21011
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
387 public void testGuardStaticFinalFieldCompare() { |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
388 CallTarget root = createCallTarget(GuardStaticFinalFieldCompareTestFactory.getInstance()); |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
389 GuardStaticFieldTest.field = true; |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
390 assertEquals("do1", root.call(1)); |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
391 assertEquals("do2", root.call(2)); |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
392 } |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
393 |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
394 @NodeChild |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
395 static class GuardStaticFinalFieldCompareTest extends ValueNode { |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
396 |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
397 protected static final int FIELD = 1; |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
398 |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
399 @Specialization(guards = "value == FIELD") |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
400 static String do1(int value) { |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
401 return "do1"; |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
402 } |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
403 |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
404 @Specialization(guards = "value != FIELD") |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
405 static String do2(int value) { |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
406 return "do2"; |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
407 } |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
408 } |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
409 |
a84d57d27727
DSL: test for using a static field in a guard.
Chris Seaton <chris.seaton@oracle.com>
parents:
20171
diff
changeset
|
410 @Test |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
411 public void testGuardMethod() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
412 CallTarget root = createCallTarget(GuardMethodTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
413 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
414 assertEquals("do2", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
415 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
416 assertEquals("do2", root.call(0)); |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
417 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
418 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
419 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
420 static class GuardMethodTest extends ValueNode { |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
421 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
422 @Specialization(guards = "method(value)") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
423 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
424 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
425 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
426 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
427 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
428 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
429 return "do2"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
430 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
431 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
432 boolean method(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
433 return value == 1; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
434 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
435 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
436 |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
437 @Test |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
438 public void testGuardUnboundMethodField() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
439 CallTarget root = createCallTarget(GuardUnboundMethodTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
440 GuardUnboundMethodTest node = getNode(root); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
441 node.hiddenValue = true; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
442 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
443 assertEquals("do1", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
444 node.hiddenValue = false; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
445 try { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
446 root.call(2); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
447 fail("expected Assertion failed"); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
448 } catch (AssertionError e) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
449 } |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
450 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
451 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
452 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
453 static class GuardUnboundMethodTest extends ValueNode { |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
454 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
455 private boolean hiddenValue; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
456 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
457 @Specialization(guards = "method()") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
458 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
459 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
460 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
461 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
462 boolean method() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
463 return hiddenValue; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
464 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
465 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
466 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
467 @Test |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
468 public void testStaticGuardMethod() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
469 CallTarget root = createCallTarget(GuardMethodTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
470 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
471 assertEquals("do2", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
472 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
473 assertEquals("do2", root.call(0)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
474 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
475 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
476 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
477 static class StaticGuardMethodTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
478 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
479 @Specialization(guards = "method(value)") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
480 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
481 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
482 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
483 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
484 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
485 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
486 return "do2"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
487 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
488 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
489 static boolean method(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
490 return value == 1; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
491 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
492 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
493 |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
494 @Test |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
495 public void testMultipleGuardAndMethod() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
496 CallTarget root = createCallTarget(GuardMultipleAndMethodTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
497 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
498 assertEquals("do1", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
499 assertEquals("do2", root.call(3)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
500 assertEquals("do2", root.call(0)); |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
501 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
502 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
503 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
504 static class GuardMultipleAndMethodTest extends ValueNode { |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
505 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
506 @Specialization(guards = {"method1(value)", "method2(value)"}) |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
507 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
508 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
509 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
510 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
511 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
512 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
513 return "do2"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
514 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
515 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
516 boolean method1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
517 return value >= 1; |
16830
c3c07046a74b
Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
518 } |
c3c07046a74b
Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
519 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
520 boolean method2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
521 return value <= 2; |
16830
c3c07046a74b
Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
522 } |
c3c07046a74b
Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
523 } |
c3c07046a74b
Truffle-DSL: fixed guard solve of guards for interfaces.
Christian Humer <christian.humer@gmail.com>
parents:
16760
diff
changeset
|
524 |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
525 @Test |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
526 public void testMultipleGuardOrMethod() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
527 CallTarget root = createCallTarget(GuardMultipleOrMethodTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
528 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
529 assertEquals("do1", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
530 assertEquals("do2", root.call(3)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
531 assertEquals("do2", root.call(0)); |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
532 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
533 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
534 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
535 static class GuardMultipleOrMethodTest extends ValueNode { |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
536 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
537 @Specialization(guards = {"method1(value) || method2(value)"}) |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
538 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
539 return "do1"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
540 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
541 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
542 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
543 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
544 return "do2"; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
545 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
546 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
547 boolean method1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
548 return value == 1; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
549 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
550 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
551 boolean method2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
552 return value == 2; |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
553 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
554 } |
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
555 |
19289
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
556 @Test |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
557 public void testComplexGuard() { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
558 CallTarget root = createCallTarget(GuardComplexTestFactory.getInstance()); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
559 assertEquals("do1", root.call(1)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
560 assertEquals("do1", root.call(2)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
561 assertEquals("do2", root.call(3)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
562 assertEquals("do1", root.call(0)); |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
563 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
564 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
565 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
566 static class GuardComplexTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
567 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
568 int field1 = 1; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
569 static int field2 = 2; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
570 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
571 @Specialization(guards = {"method2(method1(field1 == 1), value <= 2)", "field2 == 2"}) |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
572 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
573 return "do1"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
574 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
575 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
576 @Specialization |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
577 static String do2(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
578 return "do2"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
579 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
580 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
581 static boolean method1(boolean value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
582 return value; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
583 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
584 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
585 boolean method2(boolean value1, boolean value2) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
586 return value1 && value2; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
587 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
588 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
589 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
590 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
591 static class ErrorGuardNotTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
592 @ExpectError("Error parsing expression '!value == 1': The operator ! is undefined for the argument type int.") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
593 @Specialization(guards = "!value == 1") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
594 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
595 return "do1"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
596 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
597 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
598 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
599 @NodeChild |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
600 static class ErrorIncompatibleReturnTypeTest extends ValueNode { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
601 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
602 @ExpectError("Incompatible return type int. Guards must return boolean.") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
603 @Specialization(guards = "1") |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
604 static String do1(int value) { |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
605 return "do1"; |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
606 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
607 |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
608 } |
62c43fcf5be2
Truffle-DSL: implement @Cached and fixes for the new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents:
19283
diff
changeset
|
609 |
16756
5148aab962af
Truffle-DSL: updated tests for the new generation layout.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
610 } |