Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/TextMapTest.java @ 14628:a08b8694f556
Truffle: Node API changes
deprecate adoptChild, no longer needed in constructor
add Node#insert for inserting new nodes into the tree (previously adoptChild)
add Node#adoptChildren() helper method that adopts all (direct and indirect) children of a node, automatically called in TruffleRuntime#createCallTarget
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Wed, 19 Mar 2014 23:11:46 +0100 |
parents | 108ba3e82d3a |
children |
rev | line source |
---|---|
13474
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
1 /* |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
108ba3e82d3a
Truffle: add TextMap tests
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. |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
4 * |
108ba3e82d3a
Truffle: add TextMap tests
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 |
108ba3e82d3a
Truffle: add TextMap tests
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 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
8 * |
108ba3e82d3a
Truffle: add TextMap tests
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 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
108ba3e82d3a
Truffle: add TextMap tests
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 |
108ba3e82d3a
Truffle: add TextMap tests
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 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
14 * |
108ba3e82d3a
Truffle: add TextMap tests
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 |
108ba3e82d3a
Truffle: add TextMap tests
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, |
108ba3e82d3a
Truffle: add TextMap tests
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. |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
18 * |
108ba3e82d3a
Truffle: add TextMap tests
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 |
108ba3e82d3a
Truffle: add TextMap tests
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 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
21 * questions. |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
22 */ |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.api.test.utilities; |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
24 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
25 import static org.junit.Assert.*; |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
26 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
27 import org.junit.*; |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
28 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.api.source.*; |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
30 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
31 public class TextMapTest { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
32 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
33 final TextMap emptyTextMap = new TextMap(""); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
34 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
35 final TextMap emptyLineMap = new TextMap("\n"); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
36 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
37 private final TextMap shortMap = new TextMap("01"); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
38 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
39 private final TextMap longMap = new TextMap("01234\n67\n9\n"); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
40 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
41 @Test |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
42 public void emptyTextTest0() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
43 assertEquals(emptyTextMap.lineCount(), 0); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
44 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
45 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
46 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
47 public void emptyTextTest1() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
48 emptyTextMap.offsetToLine(0); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
49 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
50 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
51 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
52 public void emptyTextTest2() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
53 emptyTextMap.offsetToCol(0); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
54 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
55 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
56 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
57 public void emptyTextTest3() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
58 emptyTextMap.lineStartOffset(-1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
59 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
60 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
61 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
62 public void emptyTextTest4() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
63 emptyTextMap.lineStartOffset(0); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
64 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
65 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
66 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
67 public void emptyTextTest5() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
68 emptyTextMap.lineStartOffset(1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
69 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
70 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
71 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
72 public void emptyTextTest6() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
73 emptyTextMap.lineLength(1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
74 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
75 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
76 @Test |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
77 public void emptyLineTest0() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
78 assertEquals(emptyLineMap.lineCount(), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
79 assertEquals(emptyLineMap.offsetToLine(0), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
80 assertEquals(emptyLineMap.lineStartOffset(1), 0); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
81 assertEquals(emptyLineMap.offsetToCol(0), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
82 assertEquals(emptyLineMap.lineLength(1), 0); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
83 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
84 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
85 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
86 public void emptyLineTest1() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
87 emptyLineMap.offsetToLine(1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
88 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
89 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
90 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
91 public void emptyLineTest2() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
92 emptyLineMap.lineStartOffset(2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
93 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
94 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
95 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
96 public void emptyLineTest3() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
97 emptyLineMap.offsetToCol(1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
98 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
99 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
100 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
101 public void emptyLineTest4() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
102 emptyLineMap.lineLength(2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
103 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
104 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
105 @Test |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
106 public void shortTextTest0() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
107 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
108 assertEquals(shortMap.lineCount(), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
109 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
110 assertEquals(shortMap.offsetToLine(0), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
111 assertEquals(shortMap.lineStartOffset(1), 0); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
112 assertEquals(shortMap.offsetToCol(0), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
113 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
114 assertEquals(shortMap.offsetToLine(1), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
115 assertEquals(shortMap.offsetToCol(1), 2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
116 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
117 assertEquals(shortMap.lineLength(1), 2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
118 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
119 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
120 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
121 public void shortTextTest1() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
122 shortMap.offsetToLine(-1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
123 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
124 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
125 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
126 public void shortTextTest2() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
127 shortMap.offsetToCol(-1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
128 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
129 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
130 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
131 public void shortTextTest3() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
132 shortMap.offsetToLine(2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
133 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
134 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
135 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
136 public void shortTextTest4() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
137 shortMap.offsetToCol(2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
138 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
139 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
140 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
141 public void shortTextTest5() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
142 shortMap.lineStartOffset(2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
143 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
144 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
145 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
146 public void shortTextTest6() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
147 shortMap.lineLength(2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
148 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
149 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
150 @Test |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
151 public void longTextTest0() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
152 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
153 assertEquals(longMap.lineCount(), 3); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
154 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
155 assertEquals(longMap.offsetToLine(0), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
156 assertEquals(longMap.lineStartOffset(1), 0); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
157 assertEquals(longMap.offsetToCol(0), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
158 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
159 assertEquals(longMap.offsetToLine(4), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
160 assertEquals(longMap.offsetToCol(4), 5); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
161 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
162 assertEquals(longMap.offsetToLine(5), 1); // newline |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
163 assertEquals(longMap.offsetToCol(5), 6); // newline |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
164 assertEquals(longMap.lineLength(1), 5); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
165 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
166 assertEquals(longMap.offsetToLine(6), 2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
167 assertEquals(longMap.lineStartOffset(2), 6); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
168 assertEquals(longMap.offsetToCol(6), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
169 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
170 assertEquals(longMap.offsetToLine(7), 2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
171 assertEquals(longMap.offsetToCol(7), 2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
172 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
173 assertEquals(longMap.offsetToLine(8), 2); // newline |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
174 assertEquals(longMap.offsetToLine(8), 2); // newline |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
175 assertEquals(longMap.lineLength(2), 2); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
176 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
177 assertEquals(longMap.offsetToLine(9), 3); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
178 assertEquals(longMap.lineStartOffset(3), 9); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
179 assertEquals(longMap.offsetToCol(9), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
180 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
181 assertEquals(longMap.offsetToLine(10), 3); // newline |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
182 assertEquals(longMap.offsetToCol(10), 2); // newline |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
183 assertEquals(longMap.lineLength(3), 1); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
184 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
185 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
186 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
187 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
188 public void longTextTest1() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
189 longMap.offsetToLine(11); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
190 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
191 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
192 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
193 public void longTextTest2() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
194 longMap.offsetToCol(11); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
195 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
196 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
197 @Test(expected = IllegalArgumentException.class) |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
198 public void longTextTest3() { |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
199 longMap.lineStartOffset(4); |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
200 } |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
201 |
108ba3e82d3a
Truffle: add TextMap tests
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
diff
changeset
|
202 } |