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 = 29; | 13 const int LINE_A = 29; |
14 const int LINE_B = 33; | 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 |
24 return theClosureFunction; | 25 return theClosureFunction; |
25 } | 26 } |
26 | 27 |
27 testMain() { | 28 testMain() { |
28 debugger(); | 29 debugger(); |
29 foo("in-scope"); // Line A. | 30 foo("in-scope"); // Line A. |
30 | 31 |
31 var f = fooClosure(); | 32 var f = fooClosure(); |
32 debugger(); | 33 debugger(); |
33 f("in-scope"); // Line B. | 34 f("in-scope"); // Line B. |
34 } | 35 } |
35 | 36 |
36 var tests = [ | 37 var tests = [ |
37 hasStoppedAtBreakpoint, | 38 hasStoppedAtBreakpoint, |
38 stoppedAtLine(LINE_A), | 39 stoppedAtLine(LINE_A), |
39 (isolate) => isolate.stepInto(), | 40 (isolate) => isolate.stepInto(), |
40 hasStoppedAtBreakpoint, | 41 hasStoppedAtBreakpoint, |
41 (isolate) async { | 42 (isolate) async { |
42 var stack = await isolate.getStack(); | 43 var stack = await isolate.getStack(); |
43 Frame top = stack['frames'][0]; | 44 Frame top = stack['frames'][0]; |
44 print(top); | 45 print(top); |
45 expect(top.function.name, equals("foo")); | 46 expect(top.function.name, equals("foo")); |
46 print(top.variables); | 47 print(top.variables); |
47 expect(top.variables.length, equals(1)); | 48 expect(top.variables.length, equals(1)); |
48 var param = top.variables[0]; | 49 var param = top.variables[0]; |
49 expect(param['name'], equals("param")); | 50 expect(param['name'], equals("param")); |
50 expect(param['value'].valueAsString, equals("in-scope")); | 51 expect(param['value'].valueAsString, equals("in-scope")); |
51 }, | 52 }, |
52 resumeIsolate, | 53 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 |