| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 // VMOptions=--error_on_bad_type --error_on_bad_override | |
| 5 | |
| 6 import 'package:observatory/models.dart' as M; | |
| 7 import 'package:observatory/service_io.dart'; | |
| 8 import 'test_helper.dart'; | |
| 9 import 'dart:async'; | |
| 10 import 'dart:developer'; | |
| 11 import 'service_test_common.dart'; | |
| 12 | |
| 13 const int LINE_A = 20; | |
| 14 | |
| 15 foo() async {} | |
| 16 bar() {} | |
| 17 | |
| 18 doAsync(stop) async { | |
| 19 if (stop) debugger(); | |
| 20 await foo(); // Line A. | |
| 21 bar(); // Line A + 1. | |
| 22 bar(); // Line A + 2. | |
| 23 await foo(); // Line A + 3. | |
| 24 await foo(); // Line A + 4. | |
| 25 bar(); // Line A + 5. | |
| 26 return null; | |
| 27 } | |
| 28 | |
| 29 testMain() { | |
| 30 // With two runs of doAsync floating around, async step should only cause | |
| 31 // us to stop in the run we started in. | |
| 32 doAsync(false); | |
| 33 doAsync(true); | |
| 34 } | |
| 35 | |
| 36 stepOverAwaitingResume(Isolate isolate) async { | |
| 37 Completer completer = new Completer(); | |
| 38 await isolate.vm.getEventStream(VM.kDebugStream).then((stream) { | |
| 39 var subscription; | |
| 40 subscription = stream.listen((ServiceEvent event) { | |
| 41 if (event.kind == ServiceEvent.kResume) { | |
| 42 subscription.cancel(); | |
| 43 completer.complete(); | |
| 44 } | |
| 45 }); | |
| 46 }); | |
| 47 isolate.stepOver(); | |
| 48 return completer.future; | |
| 49 } | |
| 50 | |
| 51 smartNext(Isolate isolate) async { | |
| 52 if (M.isAtAsyncSuspension(isolate.pauseEvent)) { | |
| 53 print("next-async"); | |
| 54 return asyncStepOver(isolate); | |
| 55 } else { | |
| 56 print("next-sync"); | |
| 57 return stepOverAwaitingResume(isolate); | |
| 58 } | |
| 59 } | |
| 60 | |
| 61 var tests = [ | |
| 62 hasStoppedAtBreakpoint, stoppedAtLine(LINE_A), // foo() | |
| 63 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(LINE_A), // await | |
| 64 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(LINE_A + 1), // bar() | |
| 65 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(LINE_A + 2), // bar() | |
| 66 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(LINE_A + 3), // foo() | |
| 67 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(LINE_A + 3), // await | |
| 68 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(LINE_A + 4), // foo() | |
| 69 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(LINE_A + 4), // await | |
| 70 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(LINE_A + 5), // bar() | |
| 71 resumeIsolate, | |
| 72 ]; | |
| 73 | |
| 74 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain); | |
| OLD | NEW |