Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IntegerLiteralGuardsTest.java @ 21951:9c8c0937da41
Moving all sources into truffle subdirectory
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 17 Jun 2015 10:58:08 +0200 |
parents | graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/IntegerLiteralGuardsTest.java@65d29fa81397 |
children | dc83cc1f94f2 |
comparison
equal
deleted
inserted
replaced
21950:2a5011c7e641 | 21951:9c8c0937da41 |
---|---|
1 /* | |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.truffle.api.dsl.test; | |
24 | |
25 import static com.oracle.truffle.api.dsl.test.TestHelper.*; | |
26 import static org.junit.Assert.*; | |
27 | |
28 import org.junit.*; | |
29 | |
30 import com.oracle.truffle.api.*; | |
31 import com.oracle.truffle.api.dsl.*; | |
32 import com.oracle.truffle.api.dsl.test.IntegerLiteralGuardsTestFactory.BinaryLiteralTestFactory; | |
33 import com.oracle.truffle.api.dsl.test.IntegerLiteralGuardsTestFactory.DecimalLiteralTestFactory; | |
34 import com.oracle.truffle.api.dsl.test.IntegerLiteralGuardsTestFactory.HexLiteralTestFactory; | |
35 import com.oracle.truffle.api.dsl.test.IntegerLiteralGuardsTestFactory.OctalLiteralTestFactory; | |
36 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; | |
37 | |
38 @SuppressWarnings("unused") | |
39 public class IntegerLiteralGuardsTest { | |
40 | |
41 @Test | |
42 public void testDecimalLiteral() { | |
43 CallTarget root = createCallTarget(DecimalLiteralTestFactory.getInstance()); | |
44 assertEquals("do1", root.call(14)); | |
45 } | |
46 | |
47 @NodeChild | |
48 static class DecimalLiteralTest extends ValueNode { | |
49 @Specialization(guards = "value == 14") | |
50 static String do1(int value) { | |
51 return "do1"; | |
52 } | |
53 | |
54 @Specialization | |
55 static String do2(int value) { | |
56 return "do2"; | |
57 } | |
58 } | |
59 | |
60 @Test | |
61 public void testHexLiteral() { | |
62 CallTarget root = createCallTarget(HexLiteralTestFactory.getInstance()); | |
63 assertEquals("do1", root.call(20)); | |
64 } | |
65 | |
66 @NodeChild | |
67 static class HexLiteralTest extends ValueNode { | |
68 @Specialization(guards = "value == 0x14") | |
69 static String do1(int value) { | |
70 return "do1"; | |
71 } | |
72 | |
73 @Specialization | |
74 static String do2(int value) { | |
75 return "do2"; | |
76 } | |
77 } | |
78 | |
79 @Test | |
80 public void testOctalLiteral() { | |
81 CallTarget root = createCallTarget(OctalLiteralTestFactory.getInstance()); | |
82 assertEquals("do1", root.call(12)); | |
83 } | |
84 | |
85 @NodeChild | |
86 static class OctalLiteralTest extends ValueNode { | |
87 @Specialization(guards = "value == 014") | |
88 static String do1(int value) { | |
89 return "do1"; | |
90 } | |
91 | |
92 @Specialization | |
93 static String do2(int value) { | |
94 return "do2"; | |
95 } | |
96 } | |
97 | |
98 @Test | |
99 public void testBinaryLiteral() { | |
100 CallTarget root = createCallTarget(BinaryLiteralTestFactory.getInstance()); | |
101 assertEquals("do1", root.call(50)); | |
102 } | |
103 | |
104 @NodeChild | |
105 static class BinaryLiteralTest extends ValueNode { | |
106 @Specialization(guards = "value == 0b110010") | |
107 static String do1(int value) { | |
108 return "do1"; | |
109 } | |
110 | |
111 @Specialization | |
112 static String do2(int value) { | |
113 return "do2"; | |
114 } | |
115 } | |
116 | |
117 } |