| 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 = 11591; | 66 var last_position = 11337; |
| 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 = 268; | 68 var last_line = 265; |
| 69 // This is the column of the last character (note: starting at 0) due to | 69 // This is the last column of last line (note: starting at 0 and +1, due |
| 70 // final line having a trailing newline that is conceptually part of that line. | 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; |
| 79 var start_d = 151 + comment_line_length; | 79 var start_d = 151 + comment_line_length; |
| 80 | 80 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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, Debug.findFunctionSourceLocati
on(d, (i + 1), 0).position); |
| 248 } | 248 } |
| 249 assertEquals(158 + start_d, Debug.findFunctionSourceLocation(d, 17, 0).position)
; | 249 assertEquals(158 + start_d, Debug.findFunctionSourceLocation(d, 17, 0).position)
; |
| 250 | 250 |
| 251 // Make sure invalid inputs work properly. | 251 // Make sure invalid inputs work properly. |
| 252 assertEquals(0, script.locationFromPosition(-1).line); | 252 assertEquals(0, script.locationFromPosition(-1).line); |
| 253 // We might expect last_position + 1 to be the first illegal position, but we | 253 assertEquals(null, script.locationFromPosition(last_position + 1)); |
| 254 // sometimes generate character positions that are one past the last character. | |
| 255 // See Rewriter::Rewrite for details. | |
| 256 assertEquals(null, script.locationFromPosition(last_position + 2)); | |
| 257 | 254 |
| 258 // Test last position. | 255 // Test last position. |
| 259 assertEquals(last_position, script.locationFromPosition(last_position).position)
; | 256 assertEquals(last_position, script.locationFromPosition(last_position).position)
; |
| 260 assertEquals(last_line, script.locationFromPosition(last_position).line); | 257 assertEquals(last_line, script.locationFromPosition(last_position).line); |
| 261 assertEquals(last_column, script.locationFromPosition(last_position).column); | 258 assertEquals(last_column, script.locationFromPosition(last_position).column); |
| 262 | 259 |
| 263 // Test that script.sourceLine(line) works. | 260 // Test that script.sourceLine(line) works. |
| 264 var location; | 261 var location; |
| 265 | 262 |
| 266 for (line = 0; line < num_lines_d; line++) { | 263 for (line = 0; line < num_lines_d; line++) { |
| 267 var line_content_regexp = new RegExp(" x = " + (line + 1)); | 264 var line_content_regexp = new RegExp(" x = " + (line + 1)); |
| 268 assertTrue(line_content_regexp.test(script.sourceLine(start_line_d + line))); | 265 assertTrue(line_content_regexp.test(script.sourceLine(start_line_d + line))); |
| 269 } | 266 } |
| OLD | NEW |