OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug | 4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug |
5 | 5 |
6 import 'package:observatory/service_io.dart'; | 6 import 'package:observatory/service_io.dart'; |
7 import 'test_helper.dart'; | 7 import 'test_helper.dart'; |
8 import 'dart:developer'; | 8 import 'dart:developer'; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 | 10 |
11 import 'service_test_common.dart'; | 11 import 'service_test_common.dart'; |
12 | 12 |
13 const int LINE_A = 30; | 13 const int LINE_A = 29; |
14 const int LINE_B = 34; | 14 const int LINE_B = 33; |
15 | 15 |
16 foo(param) { | 16 foo(param) { |
17 return param; | 17 return param; |
18 } | 18 } |
19 | 19 |
20 fooClosure() { | 20 fooClosure() { |
21 theClosureFunction(param) { | 21 theClosureFunction(param) { |
22 return param; | 22 return param; |
23 } | 23 } |
24 | |
25 return theClosureFunction; | 24 return theClosureFunction; |
26 } | 25 } |
27 | 26 |
28 testMain() { | 27 testMain() { |
29 debugger(); | 28 debugger(); |
30 foo("in-scope"); // Line A. | 29 foo("in-scope"); // Line A. |
31 | 30 |
32 var f = fooClosure(); | 31 var f = fooClosure(); |
33 debugger(); | 32 debugger(); |
34 f("in-scope"); // Line B. | 33 f("in-scope"); // Line B. |
35 } | 34 } |
36 | 35 |
37 var tests = [ | 36 var tests = [ |
38 hasStoppedAtBreakpoint, | 37 hasStoppedAtBreakpoint, |
39 stoppedAtLine(LINE_A), | 38 stoppedAtLine(LINE_A), |
40 (isolate) => isolate.stepInto(), | 39 (isolate) => isolate.stepInto(), |
41 hasStoppedAtBreakpoint, | 40 hasStoppedAtBreakpoint, |
42 (isolate) async { | 41 (isolate) async { |
43 var stack = await isolate.getStack(); | 42 var stack = await isolate.getStack(); |
44 Frame top = stack['frames'][0]; | 43 Frame top = stack['frames'][0]; |
45 print(top); | 44 print(top); |
46 expect(top.function.name, equals("foo")); | 45 expect(top.function.name, equals("foo")); |
47 print(top.variables); | 46 print(top.variables); |
48 expect(top.variables.length, equals(1)); | 47 expect(top.variables.length, equals(1)); |
49 var param = top.variables[0]; | 48 var param = top.variables[0]; |
50 expect(param['name'], equals("param")); | 49 expect(param['name'], equals("param")); |
51 expect(param['value'].valueAsString, equals("in-scope")); | 50 expect(param['value'].valueAsString, equals("in-scope")); |
52 }, | 51 }, |
53 resumeIsolate, | 52 resumeIsolate, |
| 53 |
54 hasStoppedAtBreakpoint, | 54 hasStoppedAtBreakpoint, |
55 stoppedAtLine(LINE_B), | 55 stoppedAtLine(LINE_B), |
56 (isolate) => isolate.stepInto(), | 56 (isolate) => isolate.stepInto(), |
57 hasStoppedAtBreakpoint, | 57 hasStoppedAtBreakpoint, |
58 (isolate) async { | 58 (isolate) async { |
59 var stack = await isolate.getStack(); | 59 var stack = await isolate.getStack(); |
60 Frame top = stack['frames'][0]; | 60 Frame top = stack['frames'][0]; |
61 print(top); | 61 print(top); |
62 expect(top.function.name, equals("theClosureFunction")); | 62 expect(top.function.name, equals("theClosureFunction")); |
63 print(top.variables); | 63 print(top.variables); |
64 expect(top.variables.length, equals(1)); | 64 expect(top.variables.length, equals(1)); |
65 var param = top.variables[0]; | 65 var param = top.variables[0]; |
66 expect(param['name'], equals("param")); | 66 expect(param['name'], equals("param")); |
67 expect(param['value'].valueAsString, equals("in-scope")); | 67 expect(param['value'].valueAsString, equals("in-scope")); |
68 }, | 68 }, |
69 resumeIsolate, | 69 resumeIsolate, |
70 ]; | 70 ]; |
71 | 71 |
72 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain); | 72 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain); |
OLD | NEW |