Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NullTest.java @ 21591:6c5327245831
LinearScan: fix intervals context.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Fri, 29 May 2015 10:59:03 +0200 |
parents | 6fa3999631d8 |
children |
rev | line source |
---|---|
18760
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.dsl.test; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import static com.oracle.truffle.api.dsl.test.TestHelper.*; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 import static org.junit.Assert.*; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import org.junit.*; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.api.dsl.*; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 import com.oracle.truffle.api.dsl.test.NullTestFactory.NullTest1Factory; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 public class NullTest { |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 @Test |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 public void testGuardInvocations() { |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 TestRootNode<NullTest1> root = createRoot(NullTest1Factory.getInstance()); |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 assertEquals("fallback", executeWith(root, (Object) null)); |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 assertEquals(true, executeWith(root, true)); |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 assertEquals(42L, executeWith(root, 42)); |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 assertEquals("string", executeWith(root, "s")); |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 assertEquals("fallback", executeWith(root, (Object) null)); |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 } |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 @SuppressWarnings("unused") |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 @NodeChild("a") |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 abstract static class NullTest1 extends ValueNode { |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 @Specialization |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 long s(long a) { |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 return a; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 } |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 @Specialization |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 boolean s(boolean a) { |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 return a; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 } |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 @Specialization |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 String s(String a) { |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 return "string"; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 } |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 @Fallback |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 Object s(Object a) { |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 return "fallback"; |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 } |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
72 } |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
73 |
6fa3999631d8
Truffle-DSL: added test for null
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 } |