OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 assertEquals(2, script.locationFromLine(1, 11, start_b).line - comment_lines); | 168 assertEquals(2, script.locationFromLine(1, 11, start_b).line - comment_lines); |
169 assertEquals(11, script.locationFromLine(1, 11, start_b).column); | 169 assertEquals(11, script.locationFromLine(1, 11, start_b).column); |
170 | 170 |
171 // Test second line column 12 offset function b. Second line in b is 11 long | 171 // Test second line column 12 offset function b. Second line in b is 11 long |
172 // using column 12 wraps to next line. | 172 // using column 12 wraps to next line. |
173 assertEquals(start_b + 6 + 12, script.locationFromLine(1, 12, start_b).position)
; | 173 assertEquals(start_b + 6 + 12, script.locationFromLine(1, 12, start_b).position)
; |
174 assertEquals(3, script.locationFromLine(1, 12, start_b).line - comment_lines); | 174 assertEquals(3, script.locationFromLine(1, 12, start_b).line - comment_lines); |
175 assertEquals(0, script.locationFromLine(1, 12, start_b).column); | 175 assertEquals(0, script.locationFromLine(1, 12, start_b).column); |
176 | 176 |
177 // Test the Debug.findSourcePosition which wraps SourceManager. | 177 // Test the Debug.findSourcePosition which wraps SourceManager. |
178 assertEquals(0 + start_a, Debug.findFunctionSourcePosition(a, 0, 0)); | 178 assertEquals(0 + start_a, Debug.findFunctionSourceLocation(a, 0, 0).position); |
179 assertEquals(0 + start_b, Debug.findFunctionSourcePosition(b, 0, 0)); | 179 assertEquals(0 + start_b, Debug.findFunctionSourceLocation(b, 0, 0).position); |
180 assertEquals(6 + start_b, Debug.findFunctionSourcePosition(b, 1, 0)); | 180 assertEquals(6 + start_b, Debug.findFunctionSourceLocation(b, 1, 0).position); |
181 assertEquals(8 + start_b, Debug.findFunctionSourcePosition(b, 1, 2)); | 181 assertEquals(8 + start_b, Debug.findFunctionSourceLocation(b, 1, 2).position); |
182 assertEquals(18 + start_b, Debug.findFunctionSourcePosition(b, 2, 0)); | 182 assertEquals(18 + start_b, Debug.findFunctionSourceLocation(b, 2, 0).position); |
183 assertEquals(0 + start_c, Debug.findFunctionSourcePosition(c, 0, 0)); | 183 assertEquals(0 + start_c, Debug.findFunctionSourceLocation(c, 0, 0).position); |
184 assertEquals(7 + start_c, Debug.findFunctionSourcePosition(c, 1, 0)); | 184 assertEquals(7 + start_c, Debug.findFunctionSourceLocation(c, 1, 0).position); |
185 assertEquals(21 + start_c, Debug.findFunctionSourcePosition(c, 2, 0)); | 185 assertEquals(21 + start_c, Debug.findFunctionSourceLocation(c, 2, 0).position); |
186 assertEquals(38 + start_c, Debug.findFunctionSourcePosition(c, 3, 0)); | 186 assertEquals(38 + start_c, Debug.findFunctionSourceLocation(c, 3, 0).position); |
187 assertEquals(52 + start_c, Debug.findFunctionSourcePosition(c, 4, 0)); | 187 assertEquals(52 + start_c, Debug.findFunctionSourceLocation(c, 4, 0).position); |
188 assertEquals(69 + start_c, Debug.findFunctionSourcePosition(c, 5, 0)); | 188 assertEquals(69 + start_c, Debug.findFunctionSourceLocation(c, 5, 0).position); |
189 assertEquals(76 + start_c, Debug.findFunctionSourcePosition(c, 6, 0)); | 189 assertEquals(76 + start_c, Debug.findFunctionSourceLocation(c, 6, 0).position); |
190 | 190 |
191 // Test source line and restriction. All the following tests start from line 1 | 191 // Test source line and restriction. All the following tests start from line 1 |
192 // column 2 in function b, which is the call to c. | 192 // column 2 in function b, which is the call to c. |
193 // c(true); | 193 // c(true); |
194 // ^ | 194 // ^ |
195 | 195 |
196 var location; | 196 var location; |
197 | 197 |
198 location = script.locationFromLine(1, 0, start_b); | 198 location = script.locationFromLine(1, 0, start_b); |
199 assertEquals(' c(true);', location.sourceText()); | 199 assertEquals(' c(true);', location.sourceText()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 location.restrict(5, 4); | 267 location.restrict(5, 4); |
268 assertEquals(' c(t', location.sourceText()); | 268 assertEquals(' c(t', location.sourceText()); |
269 | 269 |
270 location = script.locationFromLine(1, 0, start_b); | 270 location = script.locationFromLine(1, 0, start_b); |
271 location.restrict(7, 0); | 271 location.restrict(7, 0); |
272 assertEquals(' c(tru', location.sourceText()); | 272 assertEquals(' c(tru', location.sourceText()); |
273 | 273 |
274 location = script.locationFromLine(1, 0, start_b); | 274 location = script.locationFromLine(1, 0, start_b); |
275 location.restrict(7, 6); | 275 location.restrict(7, 6); |
276 assertEquals(' c(tru', location.sourceText()); | 276 assertEquals(' c(tru', location.sourceText()); |
OLD | NEW |