OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 'dart:developer'; | 6 import 'dart:developer'; |
7 import 'package:observatory/service_io.dart'; | 7 import 'package:observatory/service_io.dart'; |
8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
9 import 'service_test_common.dart'; | 9 import 'service_test_common.dart'; |
10 import 'test_helper.dart'; | 10 import 'test_helper.dart'; |
11 | 11 |
12 const LINE_A = 25; | 12 const LINE_A = 25; |
13 const LINE_B = 18; | 13 const LINE_B = 18; |
14 const LINE_C = 20; | 14 const LINE_C = 20; |
15 | 15 |
16 foobar() async* { | 16 foobar() async* { |
17 debugger(); | 17 debugger(); |
18 yield 1; // LINE_B. | 18 yield 1; // LINE_B. |
19 debugger(); | 19 debugger(); |
20 yield 2; // LINE_C. | 20 yield 2; // LINE_C. |
21 } | 21 } |
22 | 22 |
23 helper() async { | 23 helper() async { |
24 debugger(); | 24 debugger(); |
25 print('helper'); // LINE_A. | 25 print('helper'); // LINE_A. |
26 await for (var i in foobar()) { | 26 await for (var i in foobar()) { |
27 print('helper $i'); | 27 print('helper $i'); |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 testMain() { | 31 testMain() { |
32 helper(); | 32 helper(); |
33 } | 33 } |
34 | 34 |
35 var tests = [ | 35 var tests = [ |
36 hasStoppedAtBreakpoint, | 36 hasStoppedAtBreakpoint, |
37 stoppedAtLine(LINE_A), | 37 stoppedAtLine(LINE_A), |
38 (Isolate isolate) async { | 38 (Isolate isolate) async { |
39 ServiceMap stack = await isolate.getStack(); | 39 ServiceMap stack = await isolate.getStack(); |
40 // No causal frames because we are in a completely synchronous stack. | 40 // No causal frames because we are in a completely synchronous stack. |
41 expect(stack['asyncCausalFrames'], isNotNull); | 41 expect(stack['asyncCausalFrames'], isNotNull); |
42 }, | 42 }, |
43 resumeIsolate, | 43 resumeIsolate, |
44 hasStoppedAtBreakpoint, | 44 hasStoppedAtBreakpoint, |
45 stoppedAtLine(LINE_B), | 45 stoppedAtLine(LINE_B), |
46 | |
47 (Isolate isolate) async { | 46 (Isolate isolate) async { |
48 ServiceMap stack = await isolate.getStack(); | 47 ServiceMap stack = await isolate.getStack(); |
49 // Has causal frames (we are inside an async function) | 48 // Has causal frames (we are inside an async function) |
50 expect(stack['asyncCausalFrames'], isNotNull); | 49 expect(stack['asyncCausalFrames'], isNotNull); |
51 }, | 50 }, |
52 | |
53 resumeIsolate, | 51 resumeIsolate, |
54 hasStoppedAtBreakpoint, | 52 hasStoppedAtBreakpoint, |
55 stoppedAtLine(LINE_C), | 53 stoppedAtLine(LINE_C), |
56 | |
57 (Isolate isolate) async { | 54 (Isolate isolate) async { |
58 ServiceMap stack = await isolate.getStack(); | 55 ServiceMap stack = await isolate.getStack(); |
59 // Has causal frames (we are inside a function called by an async function) | 56 // Has causal frames (we are inside a function called by an async function) |
60 expect(stack['asyncCausalFrames'], isNotNull); | 57 expect(stack['asyncCausalFrames'], isNotNull); |
61 }, | 58 }, |
62 ]; | 59 ]; |
63 | 60 |
64 main(args) => runIsolateTestsSynchronous(args, | 61 main(args) => |
65 tests, | 62 runIsolateTestsSynchronous(args, tests, testeeConcurrent: testMain); |
66 testeeConcurrent: testMain); | |
OLD | NEW |