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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 // Get the Debug object exposed from the debug context global object. | 58 // Get the Debug object exposed from the debug context global object. |
59 Debug = debug.Debug | 59 Debug = debug.Debug |
60 | 60 |
61 // This is the number of comment lines above the first test function. | 61 // This is the number of comment lines above the first test function. |
62 var comment_lines = 28; | 62 var comment_lines = 28; |
63 | 63 |
64 // This is the last position in the entire file (note: this equals | 64 // This is the last position in the entire file (note: this equals |
65 // file size of <debug-sourceinfo.js> - 1, since starting at 0). | 65 // file size of <debug-sourceinfo.js> - 1, since starting at 0). |
66 var last_position = 11337; | 66 var last_position = 11519; |
67 // This is the last line of entire file (note: starting at 0). | 67 // This is the last line of entire file (note: starting at 0). |
68 var last_line = 265; | 68 var last_line = 269; |
69 // This is the last column of last line (note: starting at 0 and +1, due | 69 // This is the last column of last line (note: starting at 0 and +1, due |
70 // to trailing <LF>). | 70 // to trailing <LF>). |
71 var last_column = 1; | 71 var last_column = 1; |
72 | 72 |
73 // This magic number is the length or the first line comment (actually number | 73 // This magic number is the length or the first line comment (actually number |
74 // of characters before 'function a(...'. | 74 // of characters before 'function a(...'. |
75 var comment_line_length = 1633; | 75 var comment_line_length = 1633; |
76 var start_a = 9 + comment_line_length; | 76 var start_a = 9 + comment_line_length; |
77 var start_b = 35 + comment_line_length; | 77 var start_b = 35 + comment_line_length; |
78 var start_c = 66 + comment_line_length; | 78 var start_c = 66 + comment_line_length; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 assertEquals(0 + start_c, Debug.findFunctionSourceLocation(c, 0, 0).position); | 237 assertEquals(0 + start_c, Debug.findFunctionSourceLocation(c, 0, 0).position); |
238 assertEquals(6 + start_c, Debug.findFunctionSourceLocation(c, 1, 0).position); | 238 assertEquals(6 + start_c, Debug.findFunctionSourceLocation(c, 1, 0).position); |
239 assertEquals(19 + start_c, Debug.findFunctionSourceLocation(c, 2, 0).position); | 239 assertEquals(19 + start_c, Debug.findFunctionSourceLocation(c, 2, 0).position); |
240 assertEquals(35 + start_c, Debug.findFunctionSourceLocation(c, 3, 0).position); | 240 assertEquals(35 + start_c, Debug.findFunctionSourceLocation(c, 3, 0).position); |
241 assertEquals(48 + start_c, Debug.findFunctionSourceLocation(c, 4, 0).position); | 241 assertEquals(48 + start_c, Debug.findFunctionSourceLocation(c, 4, 0).position); |
242 assertEquals(64 + start_c, Debug.findFunctionSourceLocation(c, 5, 0).position); | 242 assertEquals(64 + start_c, Debug.findFunctionSourceLocation(c, 5, 0).position); |
243 assertEquals(70 + start_c, Debug.findFunctionSourceLocation(c, 6, 0).position); | 243 assertEquals(70 + start_c, Debug.findFunctionSourceLocation(c, 6, 0).position); |
244 assertEquals(0 + start_d, Debug.findFunctionSourceLocation(d, 0, 0).position); | 244 assertEquals(0 + start_d, Debug.findFunctionSourceLocation(d, 0, 0).position); |
245 assertEquals(6 + start_d, Debug.findFunctionSourceLocation(d, 1, 0).position); | 245 assertEquals(6 + start_d, Debug.findFunctionSourceLocation(d, 1, 0).position); |
246 for (i = 1; i <= num_lines_d; i++) { | 246 for (i = 1; i <= num_lines_d; i++) { |
247 assertEquals(6 + (i * line_length_d) + start_d, Debug.findFunctionSourceLocati
on(d, (i + 1), 0).position); | 247 assertEquals(6 + (i * line_length_d) + start_d, |
| 248 Debug.findFunctionSourceLocation(d, (i + 1), 0).position); |
248 } | 249 } |
249 assertEquals(158 + start_d, Debug.findFunctionSourceLocation(d, 17, 0).position)
; | 250 assertEquals(158 + start_d, Debug.findFunctionSourceLocation(d, 17, 0).position)
; |
250 | 251 |
251 // Make sure invalid inputs work properly. | 252 // Make sure invalid inputs work properly. |
252 assertEquals(0, script.locationFromPosition(-1).line); | 253 assertEquals(0, script.locationFromPosition(-1).line); |
253 assertEquals(null, script.locationFromPosition(last_position + 1)); | 254 assertEquals(null, script.locationFromPosition(last_position + 2)); |
254 | 255 |
255 // Test last position. | 256 // Test last position. |
256 assertEquals(last_position, script.locationFromPosition(last_position).position)
; | 257 assertEquals(last_position, script.locationFromPosition(last_position).position)
; |
257 assertEquals(last_line, script.locationFromPosition(last_position).line); | 258 assertEquals(last_line, script.locationFromPosition(last_position).line); |
258 assertEquals(last_column, script.locationFromPosition(last_position).column); | 259 assertEquals(last_column, script.locationFromPosition(last_position).column); |
| 260 assertEquals(last_line + 1, |
| 261 script.locationFromPosition(last_position + 1).line); |
| 262 assertEquals(0, script.locationFromPosition(last_position + 1).column); |
259 | 263 |
260 // Test that script.sourceLine(line) works. | 264 // Test that script.sourceLine(line) works. |
261 var location; | 265 var location; |
262 | 266 |
263 for (line = 0; line < num_lines_d; line++) { | 267 for (line = 0; line < num_lines_d; line++) { |
264 var line_content_regexp = new RegExp(" x = " + (line + 1)); | 268 var line_content_regexp = new RegExp(" x = " + (line + 1)); |
265 assertTrue(line_content_regexp.test(script.sourceLine(start_line_d + line))); | 269 assertTrue(line_content_regexp.test(script.sourceLine(start_line_d + line))); |
266 } | 270 } |
OLD | NEW |