Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/tools/NodeExecCounterTest.java @ 18988:cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 27 Jan 2015 20:27:25 -0800 |
parents | |
children |
rev | line source |
---|---|
18988
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
1 /* |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
4 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
8 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
14 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
18 * |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
21 * questions. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
22 */ |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.test.tools; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
24 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
25 import static com.oracle.truffle.api.test.tools.TestNodes.*; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
26 import static org.junit.Assert.*; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
27 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
28 import org.junit.*; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
29 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.api.*; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.truffle.api.instrument.*; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.truffle.api.nodes.*; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.truffle.api.test.tools.TestNodes.TestAddNode; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.truffle.api.test.tools.TestNodes.TestValueNode; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.truffle.api.tools.*; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.truffle.api.tools.NodeExecCounter.NodeExecutionCount; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
37 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
38 public class NodeExecCounterTest { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
39 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
40 @Test |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
41 public void testNoExecution() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
42 final NodeExecCounter tool = new NodeExecCounter(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
43 assertEquals(tool.getCounts().length, 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
44 tool.install(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
45 assertEquals(tool.getCounts().length, 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
46 tool.setEnabled(false); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
47 assertEquals(tool.getCounts().length, 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
48 tool.setEnabled(true); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
49 assertEquals(tool.getCounts().length, 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
50 tool.reset(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
51 assertEquals(tool.getCounts().length, 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
52 tool.dispose(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
53 assertEquals(tool.getCounts().length, 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
54 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
55 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
56 @Test |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
57 public void testToolCreatedTooLate() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
58 final CallTarget expr13callTarget = createExpr13TestCallTarget(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
59 final NodeExecCounter tool = new NodeExecCounter(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
60 tool.install(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
61 assertEquals(13, expr13callTarget.call()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
62 assertEquals(tool.getCounts().length, 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
63 tool.dispose(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
64 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
65 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
66 @Test |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
67 public void testToolInstalledcTooLate() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
68 final NodeExecCounter tool = new NodeExecCounter(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
69 final CallTarget expr13callTarget = createExpr13TestCallTarget(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
70 tool.install(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
71 assertEquals(13, expr13callTarget.call()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
72 assertEquals(tool.getCounts().length, 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
73 tool.dispose(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
74 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
75 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
76 @Test |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
77 public void testCountingAll() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
78 final NodeExecCounter tool = new NodeExecCounter(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
79 tool.install(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
80 final CallTarget expr13callTarget = createExpr13TestCallTarget(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
81 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
82 // execute once |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
83 assertEquals(13, expr13callTarget.call()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
84 final NodeExecutionCount[] count1 = tool.getCounts(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
85 assertNotNull(count1); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
86 assertEquals(count1.length, 2); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
87 for (NodeExecutionCount count : count1) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
88 final Class<?> class1 = count.nodeClass(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
89 final long executionCount = count.executionCount(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
90 if (class1 == TestAddNode.class) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
91 assertEquals(executionCount, 1); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
92 } else if (class1 == TestValueNode.class) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
93 assertEquals(executionCount, 2); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
94 } else { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
95 fail(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
96 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
97 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
98 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
99 // Execute 99 more times |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
100 for (int i = 0; i < 99; i++) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
101 assertEquals(13, expr13callTarget.call()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
102 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
103 final NodeExecutionCount[] counts100 = tool.getCounts(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
104 assertNotNull(counts100); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
105 assertEquals(counts100.length, 2); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
106 for (NodeExecutionCount count : counts100) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
107 final Class<?> class1 = count.nodeClass(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
108 final long executionCount = count.executionCount(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
109 if (class1 == TestAddNode.class) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
110 assertEquals(executionCount, 100); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
111 } else if (class1 == TestValueNode.class) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
112 assertEquals(executionCount, 200); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
113 } else { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
114 fail(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
115 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
116 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
117 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
118 tool.dispose(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
119 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
120 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
121 @Test |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
122 public void testCountingTagged() { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
123 final NodeExecCounter tool = new NodeExecCounter(StandardSyntaxTag.STATEMENT); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
124 tool.install(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
125 final RootNode expr13rootNode = createExpr13TestRootNode(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
126 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
127 // Not probed yet. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
128 assertEquals(13, expr13rootNode.execute(null)); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
129 assertEquals(tool.getCounts().length, 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
130 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
131 final Node addNode = expr13rootNode.getChildren().iterator().next(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
132 final Probe probe = addNode.probe(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
133 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
134 // Probed but not tagged yet. |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
135 assertEquals(13, expr13rootNode.execute(null)); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
136 assertEquals(tool.getCounts().length, 0); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
137 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
138 probe.tagAs(StandardSyntaxTag.STATEMENT, "fake statement for testing"); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
139 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
140 // Counting now; execute once |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
141 assertEquals(13, expr13rootNode.execute(null)); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
142 final NodeExecutionCount[] counts1 = tool.getCounts(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
143 assertNotNull(counts1); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
144 assertEquals(counts1.length, 1); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
145 final NodeExecutionCount count1 = counts1[0]; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
146 assertNotNull(count1); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
147 assertEquals(count1.nodeClass(), addNode.getClass()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
148 assertEquals(count1.executionCount(), 1); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
149 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
150 // Execute 99 more times |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
151 for (int i = 0; i < 99; i++) { |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
152 assertEquals(13, expr13rootNode.execute(null)); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
153 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
154 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
155 final NodeExecutionCount[] counts100 = tool.getCounts(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
156 assertNotNull(counts100); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
157 assertEquals(counts100.length, 1); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
158 final NodeExecutionCount count100 = counts100[0]; |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
159 assertNotNull(count100); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
160 assertEquals(count100.nodeClass(), addNode.getClass()); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
161 assertEquals(count100.executionCount(), 100); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
162 |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
163 tool.dispose(); |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
164 } |
cca166aa28c0
Truffle/Tools: unit tests for new framework and tool instances
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
165 } |