| 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 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 // Build source by putting all lines together | 42 // Build source by putting all lines together |
| 43 var source = ''; | 43 var source = ''; |
| 44 for (var i = 0; i < lines.length; i++) { | 44 for (var i = 0; i < lines.length; i++) { |
| 45 source += lines[i]; | 45 source += lines[i]; |
| 46 } | 46 } |
| 47 eval(source); | 47 eval(source); |
| 48 | 48 |
| 49 // Flags: --expose-debug-as debug | 49 // Flags: --expose-debug-as debug |
| 50 // Get the Debug object exposed from the debug context global object. | 50 // Get the Debug object exposed from the debug context global object. |
| 51 Debug = debug.Debug | 51 Debug = debug.Debug; |
| 52 | 52 |
| 53 // Get the script object from one of the functions in the source. | 53 // Get the script object from one of the functions in the source. |
| 54 var script = Debug.findScript(a); | 54 var script = Debug.findScript(a); |
| 55 | 55 |
| 56 // Make sure that the source is as expected. | 56 // Make sure that the source is as expected. |
| 57 assertEquals(source, script.source); | 57 assertEquals(source, script.source); |
| 58 assertEquals(source, script.sourceSlice().sourceText()); | 58 assertEquals(source, script.sourceSlice().sourceText()); |
| 59 | 59 |
| 60 // Try all possible line interval slices. | 60 // Try all possible line interval slices. |
| 61 for (var slice_size = 0; slice_size < lines.length; slice_size++) { | 61 for (var slice_size = 0; slice_size < lines.length; slice_size++) { |
| 62 for (var n = 0; n < lines.length - slice_size; n++) { | 62 for (var n = 0; n < lines.length - slice_size; n++) { |
| 63 var slice = script.sourceSlice(n, n + slice_size); | 63 var slice = script.sourceSlice(n, n + slice_size); |
| 64 assertEquals(n, slice.from_line); | 64 assertEquals(n, slice.from_line); |
| 65 assertEquals(n + slice_size, slice.to_line); | 65 assertEquals(n + slice_size, slice.to_line); |
| 66 | 66 |
| 67 var text = slice.sourceText(); | 67 var text = slice.sourceText(); |
| 68 var expected = ''; | 68 var expected = ''; |
| 69 for (var i = 0; i < slice_size; i++) { | 69 for (var i = 0; i < slice_size; i++) { |
| 70 expected += lines[n + i]; | 70 expected += lines[n + i]; |
| 71 } | 71 } |
| 72 assertEquals(expected, text); | 72 assertEquals(expected, text); |
| 73 } | 73 } |
| 74 } | 74 } |
| OLD | NEW |