Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IntegerLiteralGuardsTest.java @ 22241:14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
- Caused by lack of a "vm" known to the Accessor during most testing, making the Instrumenter unavailable, which is now required to create a CallTarget
- Modified the Instrumenter/Accessor with a static field that can be reflectively "poked" with a vm value for testing
- Create a pair of methods to globally enable/disable testing mode to modify that static field and restore it when tests complete.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 22 Sep 2015 20:31:19 -0700 |
parents | dc83cc1f94f2 |
children | 5309cc9668e3 |
rev | line source |
---|---|
20169
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
1 /* |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
4 * |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
8 * |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
14 * |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
18 * |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
21 * questions. |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
22 */ |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
24 |
22241
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
25 import static com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
26 import static org.junit.Assert.assertEquals; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
27 |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
28 import org.junit.After; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
29 import org.junit.Before; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
30 import org.junit.Test; |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
31 |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
32 import com.oracle.truffle.api.CallTarget; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
33 import com.oracle.truffle.api.dsl.NodeChild; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
34 import com.oracle.truffle.api.dsl.Specialization; |
20169
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.truffle.api.dsl.test.IntegerLiteralGuardsTestFactory.BinaryLiteralTestFactory; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.truffle.api.dsl.test.IntegerLiteralGuardsTestFactory.DecimalLiteralTestFactory; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
37 import com.oracle.truffle.api.dsl.test.IntegerLiteralGuardsTestFactory.HexLiteralTestFactory; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
38 import com.oracle.truffle.api.dsl.test.IntegerLiteralGuardsTestFactory.OctalLiteralTestFactory; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
39 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
22241
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
40 import com.oracle.truffle.api.dsl.test.utilities.InstrumentationTestMode; |
20169
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
41 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
42 @SuppressWarnings("unused") |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
43 public class IntegerLiteralGuardsTest { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
44 |
22241
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
45 @Before |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
46 public void before() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
47 InstrumentationTestMode.set(true); |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
48 } |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
49 |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
50 @After |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
51 public void after() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
52 InstrumentationTestMode.set(false); |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
53 } |
14e6dfb1ef05
Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
54 |
20169
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
55 @Test |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
56 public void testDecimalLiteral() { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
57 CallTarget root = createCallTarget(DecimalLiteralTestFactory.getInstance()); |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
58 assertEquals("do1", root.call(14)); |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
59 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
60 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
61 @NodeChild |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
62 static class DecimalLiteralTest extends ValueNode { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
63 @Specialization(guards = "value == 14") |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
64 static String do1(int value) { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
65 return "do1"; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
66 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
67 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
68 @Specialization |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
69 static String do2(int value) { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
70 return "do2"; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
71 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
72 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
73 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
74 @Test |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
75 public void testHexLiteral() { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
76 CallTarget root = createCallTarget(HexLiteralTestFactory.getInstance()); |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
77 assertEquals("do1", root.call(20)); |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
78 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
79 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
80 @NodeChild |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
81 static class HexLiteralTest extends ValueNode { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
82 @Specialization(guards = "value == 0x14") |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
83 static String do1(int value) { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
84 return "do1"; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
85 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
86 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
87 @Specialization |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
88 static String do2(int value) { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
89 return "do2"; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
90 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
91 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
92 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
93 @Test |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
94 public void testOctalLiteral() { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
95 CallTarget root = createCallTarget(OctalLiteralTestFactory.getInstance()); |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
96 assertEquals("do1", root.call(12)); |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
97 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
98 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
99 @NodeChild |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
100 static class OctalLiteralTest extends ValueNode { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
101 @Specialization(guards = "value == 014") |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
102 static String do1(int value) { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
103 return "do1"; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
104 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
105 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
106 @Specialization |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
107 static String do2(int value) { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
108 return "do2"; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
109 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
110 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
111 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
112 @Test |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
113 public void testBinaryLiteral() { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
114 CallTarget root = createCallTarget(BinaryLiteralTestFactory.getInstance()); |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
115 assertEquals("do1", root.call(50)); |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
116 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
117 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
118 @NodeChild |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
119 static class BinaryLiteralTest extends ValueNode { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
120 @Specialization(guards = "value == 0b110010") |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
121 static String do1(int value) { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
122 return "do1"; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
123 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
124 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
125 @Specialization |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
126 static String do2(int value) { |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
127 return "do2"; |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
128 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
129 } |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
130 |
65d29fa81397
DSL: add support for hex, oct and binary integer literals.
Chris Seaton <chris.seaton@oracle.com>
parents:
diff
changeset
|
131 } |