annotate truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/LineToProbesMapTest.java @ 22548:6b76a24fffbd default tip

Use all variables: a, b, u,v and x, y
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Thu, 14 Jan 2016 14:20:57 +0100
parents 906a5f6e07cc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 /*
21568
3b8bbf51d320 Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18988
diff changeset
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
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
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
21568
3b8bbf51d320 Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18988
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
3b8bbf51d320 Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18988
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
3b8bbf51d320 Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18988
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
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
10 *
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 * 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
12 * 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
13 * 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
14 * 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
15 * 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
16 *
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 * 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
18 * 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
19 * 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
20 *
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 * 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
22 * 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
23 * 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
24 */
21568
3b8bbf51d320 Truffle/Debugging: add the Truffle DebugEngine and supporting code, as well as add a crude command-line debugging tool used mainly to test the DebugEngine. Migrate the small tols out of project com.oracle.truffle.api into the new project com.oracle.truffle.tools.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 18988
diff changeset
25 package com.oracle.truffle.tools.test;
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
26
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
27 import static org.junit.Assert.assertEquals;
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
28 import static org.junit.Assert.assertNotNull;
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
29 import static org.junit.Assert.assertNull;
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
30 import static org.junit.Assert.assertTrue;
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
31
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
32 import java.io.IOException;
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
33 import java.lang.reflect.Field;
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
34
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
35 import org.junit.Test;
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
36
22219
1c0f490984d5 Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157 22214
diff changeset
37 import com.oracle.truffle.api.instrument.Instrumenter;
1c0f490984d5 Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157 22214
diff changeset
38 import com.oracle.truffle.api.instrument.Probe;
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
39 import com.oracle.truffle.api.source.Source;
22266
0d36601f233e Merge revised Instrumentation framework into the Polyglot API
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22264
diff changeset
40 import com.oracle.truffle.api.vm.PolyglotEngine;
22219
1c0f490984d5 Merge with f47b601edbc626dcfe8b3636933b4834c89f7779
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157 22214
diff changeset
41 import com.oracle.truffle.tools.LineToProbesMap;
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
42 import com.oracle.truffle.tools.test.ToolTestUtil.ToolTestTag;
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
43
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 public class LineToProbesMapTest {
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
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 @Test
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
47 public void testNoExecution() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
22335
906a5f6e07cc Giving the PolyglotEngine builder factory method more sensible name.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22266
diff changeset
48 final PolyglotEngine vm = PolyglotEngine.newBuilder().build();
22266
0d36601f233e Merge revised Instrumentation framework into the Polyglot API
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22264
diff changeset
49 final Field field = PolyglotEngine.class.getDeclaredField("instrumenter");
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
50 field.setAccessible(true);
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
51 final Instrumenter instrumenter = (Instrumenter) field.get(vm);
22264
c7b6dae6d1fa Truffle/Instrumentation: update two instrumentation-related tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22233
diff changeset
52 instrumenter.registerASTProber(new ToolTestUtil.TestASTProber());
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
53 final Source source = ToolTestUtil.createTestSource("testNoExecution");
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
54 final LineToProbesMap probesMap = new LineToProbesMap();
22233
1f19e3cada3d Truffle/Instrumentation: change the installation sequence for instances of Intrumenter.Tool
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22223
diff changeset
55 instrumenter.install(probesMap);
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
56 assertNull(probesMap.findFirstProbe(source.createLineLocation(1)));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
57 assertNull(probesMap.findFirstProbe(source.createLineLocation(2)));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
58 assertNull(probesMap.findFirstProbe(source.createLineLocation(3)));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
59 probesMap.dispose();
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
60 }
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
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 @Test
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
63 public void testMapping1() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, IOException {
22335
906a5f6e07cc Giving the PolyglotEngine builder factory method more sensible name.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22266
diff changeset
64 final PolyglotEngine vm = PolyglotEngine.newBuilder().build();
22266
0d36601f233e Merge revised Instrumentation framework into the Polyglot API
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22264
diff changeset
65 final Field field = PolyglotEngine.class.getDeclaredField("instrumenter");
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
66 field.setAccessible(true);
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
67 final Instrumenter instrumenter = (Instrumenter) field.get(vm);
22264
c7b6dae6d1fa Truffle/Instrumentation: update two instrumentation-related tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22233
diff changeset
68 instrumenter.registerASTProber(new ToolTestUtil.TestASTProber());
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
69 final Source source = ToolTestUtil.createTestSource("testMapping1");
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
70 final LineToProbesMap probesMap = new LineToProbesMap();
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
71
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
72 assertNull(probesMap.findFirstProbe(source.createLineLocation(1)));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
73 assertNull(probesMap.findFirstProbe(source.createLineLocation(2)));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
74 assertNull(probesMap.findFirstProbe(source.createLineLocation(3)));
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
75
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
76 // Map installed before AST gets created
22233
1f19e3cada3d Truffle/Instrumentation: change the installation sequence for instances of Intrumenter.Tool
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22223
diff changeset
77 instrumenter.install(probesMap);
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
78 assertEquals(vm.eval(source).get(), 13);
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
79
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
80 final Probe probe1 = probesMap.findFirstProbe(source.createLineLocation(1));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
81 assertNotNull(probe1);
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
82 assertTrue(probe1.isTaggedAs(ToolTestTag.VALUE_TAG));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
83 final Probe probe2 = probesMap.findFirstProbe(source.createLineLocation(2));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
84 assertNotNull(probe2);
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
85 assertTrue(probe2.isTaggedAs(ToolTestTag.ADD_TAG));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
86 final Probe probe3 = probesMap.findFirstProbe(source.createLineLocation(3));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
87 assertNotNull(probe3);
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
88 assertTrue(probe3.isTaggedAs(ToolTestTag.VALUE_TAG));
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
89
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
90 probesMap.dispose();
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
91 }
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
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 @Test
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
94 public void testMapping2() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, IOException {
22335
906a5f6e07cc Giving the PolyglotEngine builder factory method more sensible name.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22266
diff changeset
95 final PolyglotEngine vm = PolyglotEngine.newBuilder().build();
22266
0d36601f233e Merge revised Instrumentation framework into the Polyglot API
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22264
diff changeset
96 final Field field = PolyglotEngine.class.getDeclaredField("instrumenter");
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
97 field.setAccessible(true);
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
98 final Instrumenter instrumenter = (Instrumenter) field.get(vm);
22264
c7b6dae6d1fa Truffle/Instrumentation: update two instrumentation-related tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22233
diff changeset
99 instrumenter.registerASTProber(new ToolTestUtil.TestASTProber());
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
100 final Source source = ToolTestUtil.createTestSource("testMapping2");
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
101 final LineToProbesMap probesMap = new LineToProbesMap();
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
102
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
103 assertNull(probesMap.findFirstProbe(source.createLineLocation(1)));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
104 assertNull(probesMap.findFirstProbe(source.createLineLocation(2)));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
105 assertNull(probesMap.findFirstProbe(source.createLineLocation(3)));
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
106
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
107 // Map installed after AST gets created
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
108 assertEquals(vm.eval(source).get(), 13);
22233
1f19e3cada3d Truffle/Instrumentation: change the installation sequence for instances of Intrumenter.Tool
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22223
diff changeset
109 instrumenter.install(probesMap);
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
110
22223
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
111 final Probe probe1 = probesMap.findFirstProbe(source.createLineLocation(1));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
112 assertNotNull(probe1);
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
113 assertTrue(probe1.isTaggedAs(ToolTestTag.VALUE_TAG));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
114 final Probe probe2 = probesMap.findFirstProbe(source.createLineLocation(2));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
115 assertNotNull(probe2);
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
116 assertTrue(probe2.isTaggedAs(ToolTestTag.ADD_TAG));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
117 final Probe probe3 = probesMap.findFirstProbe(source.createLineLocation(3));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
118 assertNotNull(probe3);
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
119 assertTrue(probe3.isTaggedAs(ToolTestTag.VALUE_TAG));
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
120
964e789e17f7 Truffle/Tools; rewrite tests for simple counting tools, e.g. CoverageTracker
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22219
diff changeset
121 probesMap.dispose();
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
122 }
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 }