Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug | |
| 5 | |
| 6 import 'dart:developer'; | |
| 7 import 'package:observatory/models.dart' as M; | |
| 8 import 'package:observatory/service_io.dart'; | |
| 9 import 'package:unittest/unittest.dart'; | |
| 10 import 'service_test_common.dart'; | |
| 11 import 'test_helper.dart'; | |
| 12 | |
|
siva
2017/02/08 18:46:28
Ditto comment here.
| |
| 13 const LINE_A = 26; | |
| 14 const LINE_B = 19; | |
| 15 const LINE_C = 21; | |
| 16 | |
| 17 foobar() async* { | |
| 18 debugger(); | |
| 19 yield 1; // LINE_B. | |
| 20 debugger(); | |
| 21 yield 2; // LINE_C. | |
| 22 } | |
| 23 | |
| 24 helper() async { | |
| 25 debugger(); | |
| 26 print('helper'); // LINE_A. | |
| 27 await for (var i in foobar()) { | |
| 28 print('helper $i'); | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 testMain() { | |
| 33 helper(); | |
| 34 } | |
| 35 | |
| 36 var tests = [ | |
| 37 hasStoppedAtBreakpoint, | |
| 38 stoppedAtLine(LINE_A), | |
| 39 (Isolate isolate) async { | |
| 40 ServiceMap stack = await isolate.getStack(); | |
| 41 // No causal frames because we are in a completely synchronous stack. | |
| 42 expect(stack['asyncCausalFrames'], isNotNull); | |
| 43 var asyncStack = stack['asyncCausalFrames']; | |
| 44 expect(asyncStack[0].toString(), contains('helper_async_body')); | |
| 45 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker)); | |
| 46 expect(asyncStack[2].toString(), contains('helper')); | |
|
siva
2017/02/08 18:46:29
expect(asyncStack[3].toString(), contains('testMai
Cutch
2017/02/09 22:45:51
Done.
| |
| 47 }, | |
| 48 resumeIsolate, | |
| 49 hasStoppedAtBreakpoint, | |
| 50 stoppedAtLine(LINE_B), | |
| 51 | |
| 52 (Isolate isolate) async { | |
| 53 ServiceMap stack = await isolate.getStack(); | |
| 54 // Has causal frames (we are inside an async function) | |
| 55 expect(stack['asyncCausalFrames'], isNotNull); | |
| 56 var asyncStack = stack['asyncCausalFrames']; | |
| 57 expect(asyncStack[0].toString(), contains('foobar_async_gen_body')); | |
| 58 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker)); | |
| 59 expect(asyncStack[2].toString(), contains('foobar')); | |
| 60 expect(asyncStack[3].toString(), contains('helper_async_body')); | |
| 61 expect(asyncStack[4].kind, equals(M.FrameKind.asyncSuspensionMarker)); | |
| 62 expect(asyncStack[5].toString(), contains('helper')); | |
| 63 expect(asyncStack[6].toString(), contains('testMain')); | |
| 64 }, | |
| 65 | |
| 66 resumeIsolate, | |
| 67 hasStoppedAtBreakpoint, | |
| 68 stoppedAtLine(LINE_C), | |
| 69 | |
| 70 (Isolate isolate) async { | |
| 71 ServiceMap stack = await isolate.getStack(); | |
| 72 // Has causal frames (we are inside a function called by an async function) | |
| 73 expect(stack['asyncCausalFrames'], isNotNull); | |
| 74 var asyncStack = stack['asyncCausalFrames']; | |
| 75 expect(asyncStack[0].toString(), contains('foobar_async_gen_body')); | |
| 76 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker)); | |
| 77 expect(asyncStack[2].toString(), contains('foobar')); | |
| 78 expect(asyncStack[3].toString(), contains('helper_async_body')); | |
| 79 expect(asyncStack[4].kind, equals(M.FrameKind.asyncSuspensionMarker)); | |
| 80 expect(asyncStack[5].toString(), contains('helper')); | |
| 81 expect(asyncStack[6].toString(), contains('testMain')); | |
| 82 }, | |
| 83 ]; | |
| 84 | |
| 85 main(args) => runIsolateTestsSynchronous(args, | |
| 86 tests, | |
| 87 testeeConcurrent: testMain); | |
| OLD | NEW |