OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 // This test forks a second vm process that runs this dart script as | 5 // This test forks a second vm process that runs this dart script as |
6 // a debug target. | 6 // a debug target. |
7 // Run this test with option --wire to see the json messages sent | 7 // Run this test with option --wire to see the json messages sent |
8 // between the processes. | 8 // between the processes. |
9 // Run this test with option --verbose to see the stdout and stderr output | 9 // Run this test with option --verbose to see the stdout and stderr output |
10 // of the debug target process. | 10 // of the debug target process. |
11 | 11 |
12 import "debug_lib.dart"; | 12 import "debug_lib.dart"; |
13 | 13 |
14 // Check that if a breakpoint is requested on the line containing the | 14 // Check that if a breakpoint is requested on the line containing the |
15 // one-liner with a local function below, the breakpoint gets set in | 15 // one-liner with a local function below, the breakpoint gets set in |
16 // the outer function. | 16 // the outer function. |
17 foo(x) => (n) => x * n; | 17 foo(x) => (n) => x * n; // Breakpoint 1 on this line. |
18 | 18 |
19 // Check that if a breakpoint is requested on the line "return n*x" | 19 // Check that if a breakpoint is requested on the line "return n*x" |
20 // below, the breakpoint is set in the local function (closure). | 20 // below, the breakpoint is set in the local function (closure). |
21 bar(x) { | 21 bar(x) { |
22 return (n) { | 22 return (n) { |
23 return n * x; | 23 return n * x; // Breakpoint 2 on this line. |
24 }; | 24 }; |
25 } | 25 } |
26 | 26 |
| 27 // Check that setting a breakpoint works in the case where the |
| 28 // class has not been parsed yet. |
| 29 // No reference to class C must appear in main(), so that the class is not |
| 30 // yet parsed when the breakpoint in the closure nested in the constructor |
| 31 // is set. |
| 32 class C { |
| 33 var closure; |
| 34 C() { |
| 35 closure = () { |
| 36 var z = 10; // Breakpoint 3 on this line. |
| 37 z = z * 2; |
| 38 return z; |
| 39 }; |
| 40 } |
| 41 } |
| 42 |
| 43 checkBpInLazilyParsedClass() { |
| 44 var c = new C(); |
| 45 c.closure(); // Expected to hit breakpoint. |
| 46 } |
| 47 |
| 48 |
27 main(List<String> arguments) { | 49 main(List<String> arguments) { |
28 if (RunScript(testScript, arguments)) return; | 50 if (RunScript(testScript, arguments)) return; |
29 print("Hello from debuggee"); | 51 print("Hello from debuggee"); |
30 var f = foo(10); // Hits breakpoint. | 52 var f = foo(10); // Hits breakpoint. |
31 print(f(5)); | 53 print(f(5)); |
32 var b = bar(10); | 54 var b = bar(10); |
33 print(b(10)); // Hits breakpoint. | 55 print(b(10)); // Hits breakpoint. |
| 56 checkBpInLazilyParsedClass(); |
34 } | 57 } |
35 | 58 |
36 // Expected debugger events and commands. | 59 // Expected debugger events and commands. |
37 var testScript = [ | 60 var testScript = [ |
38 MatchFrame(0, "main"), // Top frame in trace is function "main". | 61 MatchFrame(0, "main"), // Top frame in trace is function "main". |
39 SetBreakpoint(17), // Set breakpoint in function foo. | 62 SetBreakpoint(17), // Breakpoint 1 in function foo. |
40 SetBreakpoint(23), // Set breakpoint in local function inside bar. | 63 SetBreakpoint(23), // Breakpoint 2 in local function inside bar. |
| 64 SetBreakpoint(36), // Breakpoint 3 in local function inside constructor C
. |
41 Resume(), | 65 Resume(), |
42 MatchFrames(["foo", "main"]), | 66 MatchFrames(["foo", "main"]), |
43 Resume(), | 67 Resume(), |
44 MatchFrames(["<anonymous closure>", "main"]), | 68 MatchFrames(["<anonymous closure>", "main"]), |
45 Resume() | 69 Resume(), |
| 70 MatchFrames(["C.<anonymous closure>", "checkBpInLazilyParsedClass"]), |
| 71 Resume(), |
46 ]; | 72 ]; |
OLD | NEW |