Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceSectionTest.java @ 22292:0e13cbebc04c
Truffle/Source: remove two previously @Ignored tests that are inconsistent with the current text model being used.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Thu, 08 Oct 2015 10:07:07 -0400 |
parents | dc83cc1f94f2 |
children | f56fa795a5a5 |
rev | line source |
---|---|
21647
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
1 /* |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
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. |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
4 * |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
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 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
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 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
8 * |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
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 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
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 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
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 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
14 * |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
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 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
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, |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
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. |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
18 * |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
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 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
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 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
21 * questions. |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
22 */ |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.test.source; |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
24 |
22292
0e13cbebc04c
Truffle/Source: remove two previously @Ignored tests that are inconsistent with the current text model being used.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
25 import static org.junit.Assert.assertEquals; |
0e13cbebc04c
Truffle/Source: remove two previously @Ignored tests that are inconsistent with the current text model being used.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
26 import static org.junit.Assert.assertNotNull; |
0e13cbebc04c
Truffle/Source: remove two previously @Ignored tests that are inconsistent with the current text model being used.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
27 |
0e13cbebc04c
Truffle/Source: remove two previously @Ignored tests that are inconsistent with the current text model being used.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
28 import org.junit.Test; |
0e13cbebc04c
Truffle/Source: remove two previously @Ignored tests that are inconsistent with the current text model being used.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
22157
diff
changeset
|
29 |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
30 import com.oracle.truffle.api.source.Source; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21951
diff
changeset
|
31 import com.oracle.truffle.api.source.SourceSection; |
21647
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
32 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
33 public class SourceSectionTest { |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
34 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
35 private final Source emptySource = Source.fromText("", null); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
36 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
37 private final Source emptyLineSource = Source.fromText("\n", null); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
38 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
39 private final Source shortSource = Source.fromText("01", null); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
40 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
41 private final Source longSource = Source.fromText("01234\n67\n9\n", null); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
42 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
43 public void emptySourceTest0() { |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
44 SourceSection section = emptySource.createSection("test", 0, 0); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
45 assertNotNull(section); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
46 assertEquals(section.getCode(), ""); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
47 } |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
48 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
49 @Test |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
50 public void emptyLineTest0() { |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
51 SourceSection section = emptyLineSource.createSection("test", 0, 0); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
52 assertNotNull(section); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
53 assertEquals(section.getCode(), ""); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
54 assertEquals(section.getCharIndex(), 0); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
55 assertEquals(section.getCharLength(), 0); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
56 assertEquals(section.getStartLine(), 1); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
57 assertEquals(section.getStartColumn(), 1); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
58 } |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
59 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
60 @Test |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
61 public void emptyLineTest1() { |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
62 SourceSection section = emptyLineSource.createSection("test", 0, 1); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
63 assertNotNull(section); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
64 assertEquals(section.getCode(), "\n"); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
65 assertEquals(section.getCharIndex(), 0); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
66 assertEquals(section.getCharLength(), 1); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
67 assertEquals(section.getStartLine(), 1); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
68 assertEquals(section.getStartColumn(), 1); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
69 assertEquals(section.getEndLine(), 1); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
70 assertEquals(section.getEndColumn(), 1); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
71 } |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
72 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
73 @Test |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
74 public void emptySectionTest2() { |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
75 SourceSection section = shortSource.createSection("test", 0, 0); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
76 assertNotNull(section); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
77 assertEquals(section.getCode(), ""); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
78 } |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
79 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
80 @Test |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
81 public void emptySectionTest3() { |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
82 SourceSection section = longSource.createSection("test", 0, 0); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
83 assertNotNull(section); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
84 assertEquals(section.getCode(), ""); |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
85 } |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
86 |
ae601ad0b023
Truffle/Source: add some tests for SourceSections, including a reported design issue with empty Soruces.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
87 } |