comparison truffle/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/LineToProbesMapTest.java @ 21951:9c8c0937da41

Moving all sources into truffle subdirectory
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 17 Jun 2015 10:58:08 +0200
parents graal/com.oracle.truffle.tools.test/src/com/oracle/truffle/tools/test/LineToProbesMapTest.java@3b8bbf51d320
children dc83cc1f94f2 3aad794eec0e
comparison
equal deleted inserted replaced
21950:2a5011c7e641 21951:9c8c0937da41
1 /*
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package com.oracle.truffle.tools.test;
26
27 import static com.oracle.truffle.tools.test.TestNodes.*;
28 import static org.junit.Assert.*;
29
30 import org.junit.*;
31
32 import com.oracle.truffle.api.instrument.*;
33 import com.oracle.truffle.api.nodes.*;
34 import com.oracle.truffle.api.source.*;
35 import com.oracle.truffle.tools.*;
36
37 public class LineToProbesMapTest {
38
39 @Test
40 public void testToolCreatedTooLate() {
41 final RootNode expr13rootNode = createExpr13TestRootNode();
42 final Node addNode = expr13rootNode.getChildren().iterator().next();
43 final Probe probe = addNode.probe();
44 final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation();
45 assertEquals(lineLocation, expr13Line2);
46
47 final LineToProbesMap tool = new LineToProbesMap();
48 tool.install();
49
50 assertNull(tool.findFirstProbe(expr13Line1));
51 assertNull(tool.findFirstProbe(expr13Line2));
52 tool.dispose();
53 }
54
55 @Test
56 public void testToolInstalledTooLate() {
57 final LineToProbesMap tool = new LineToProbesMap();
58
59 final RootNode expr13rootNode = createExpr13TestRootNode();
60 final Node addNode = expr13rootNode.getChildren().iterator().next();
61 final Probe probe = addNode.probe();
62 final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation();
63 assertEquals(lineLocation, expr13Line2);
64
65 tool.install();
66
67 assertNull(tool.findFirstProbe(expr13Line1));
68 assertNull(tool.findFirstProbe(expr13Line2));
69 tool.dispose();
70 }
71
72 @Test
73 public void testMapping() {
74 final LineToProbesMap tool = new LineToProbesMap();
75 tool.install();
76
77 final RootNode expr13rootNode = createExpr13TestRootNode();
78 final Node addNode = expr13rootNode.getChildren().iterator().next();
79 final Probe probe = addNode.probe();
80 final LineLocation lineLocation = probe.getProbedSourceSection().getLineLocation();
81 assertEquals(lineLocation, expr13Line2);
82
83 assertNull(tool.findFirstProbe(expr13Line1));
84 assertEquals(tool.findFirstProbe(expr13Line2), probe);
85 tool.dispose();
86 }
87
88 }