Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.codegen.test/src/com/oracle/truffle/api/codegen/test/AssumptionsTest.java @ 9390:c8be66a66fcf
Fix left-over debug output.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 28 Apr 2013 18:42:42 +0200 |
parents | 8e3a1635cc9e |
children |
rev | line source |
---|---|
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.codegen.test; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import org.junit.*; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.*; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import com.oracle.truffle.api.codegen.*; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.codegen.test.AssumptionsTestFactory.DerivedAssumptionNodeFactory; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.api.codegen.test.AssumptionsTestFactory.DerivedAssumptionRedeclaredNodeFactory; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 import com.oracle.truffle.api.codegen.test.AssumptionsTestFactory.MultipleAssumptionsNodeFactory; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 import com.oracle.truffle.api.codegen.test.AssumptionsTestFactory.SingleAssumptionNodeFactory; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 import com.oracle.truffle.api.codegen.test.TypeSystemTest.TestRootNode; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 import com.oracle.truffle.api.codegen.test.TypeSystemTest.ValueNode; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 public class AssumptionsTest { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 @Test |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 public void testSingleAssumption() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 Assumption assumption = Truffle.getRuntime().createAssumption(); |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
41 TestRootNode<?> root = TestHelper.createRoot(SingleAssumptionNodeFactory.getInstance(), assumption); |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 Assert.assertEquals(42, TestHelper.executeWith(root)); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 assumption.invalidate(); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 Assert.assertEquals("42", TestHelper.executeWith(root)); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 @NodeAssumptions("assumption") |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 abstract static class SingleAssumptionNode extends ValueNode { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 @Specialization(order = 0, assumptions = "assumption") |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 int doInt() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 return 42; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 @Specialization |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 Object doObject() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 return "42"; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 @Test |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 public void testMultipleAssumption() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 Assumption assumption1 = Truffle.getRuntime().createAssumption(); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
65 Assumption assumption2 = Truffle.getRuntime().createAssumption(); |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
66 TestRootNode<?> root = TestHelper.createRoot(MultipleAssumptionsNodeFactory.getInstance(), assumption1, assumption2); |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 Assert.assertEquals(42, TestHelper.executeWith(root)); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 assumption2.invalidate(); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 Assert.assertEquals("42", TestHelper.executeWith(root)); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 assumption1.invalidate(); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
72 Assert.assertEquals("43", TestHelper.executeWith(root)); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
73 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 @NodeAssumptions({"assumption1", "assumption2"}) |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
76 abstract static class MultipleAssumptionsNode extends ValueNode { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
77 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
78 @Specialization(assumptions = {"assumption1", "assumption2"}) |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
79 int doInt() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 return 42; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
82 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
83 @Specialization(assumptions = "assumption1") |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
84 Object doObject() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
85 return "42"; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
87 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
88 @Generic |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 Object doGeneric() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
90 return "43"; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
92 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 @Test |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 public void testDerivedAssumption() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
96 Assumption additionalAssumption = Truffle.getRuntime().createAssumption(); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
97 Assumption assumption = Truffle.getRuntime().createAssumption(); |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
98 TestRootNode<?> root = TestHelper.createRoot(DerivedAssumptionNodeFactory.getInstance(), assumption, additionalAssumption); |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
99 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
100 Assert.assertEquals(42, TestHelper.executeWith(root)); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
101 assumption.invalidate(); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
102 Assert.assertEquals(43, TestHelper.executeWith(root)); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
103 additionalAssumption.invalidate(); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
104 Assert.assertEquals("42", TestHelper.executeWith(root)); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
105 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
106 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
107 @NodeAssumptions({"additionalAssumption"}) |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
108 abstract static class DerivedAssumptionNode extends SingleAssumptionNode { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
109 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
110 @Specialization(order = 1, assumptions = "additionalAssumption") |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
111 int doIntDerived() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
112 return 43; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
113 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
114 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
115 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
116 @Test |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
117 public void testDerivedAssumptionRedeclared() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
118 Assumption additionalAssumption = Truffle.getRuntime().createAssumption(); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
119 Assumption assumption = Truffle.getRuntime().createAssumption(); |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
120 TestRootNode<?> root = TestHelper.createRoot(DerivedAssumptionRedeclaredNodeFactory.getInstance(), additionalAssumption, assumption); |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
121 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
122 Assert.assertEquals(42, TestHelper.executeWith(root)); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
123 assumption.invalidate(); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
124 Assert.assertEquals(43, TestHelper.executeWith(root)); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
125 additionalAssumption.invalidate(); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
126 Assert.assertEquals("42", TestHelper.executeWith(root)); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
127 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
128 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
129 @NodeAssumptions({"additionalAssumption", "assumption"}) |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
130 abstract static class DerivedAssumptionRedeclaredNode extends SingleAssumptionNode { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
131 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
132 @Specialization(order = 1, assumptions = "additionalAssumption") |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
133 int doIntDerived() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
134 return 43; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
135 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
136 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
137 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
138 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
139 } |