Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: runtime/observatory/tests/service/smart_next_test.dart

Issue 1299083002: Automagically change the meaning of 'next' to 'async-next' when paused at an async function at awai… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/service_io.dart';
7 import 'test_helper.dart';
8 import 'dart:async';
9 import 'dart:developer';
10
11 foo() async { }
12 bar() { }
13
14 doAsync(stop) async {
15 if (stop) debugger();
16 await foo(); // Line 16.
17 bar(); // Line 17.
18 bar(); // Line 18.
19 await foo(); // Line 19.
20 await foo(); // Line 20.
21 bar(); // Line 21.
22 return null;
23 }
24
25 testMain() {
26 // With two runs of doAsync floating around, async step should only cause
27 // us to stop in the run we started in.
28 doAsync(false);
29 doAsync(true);
30 }
31
32 stepOverAwaitingResume(Isolate isolate) async {
33 Completer completer = new Completer();
34 await isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
35 var subscription;
36 subscription = stream.listen((ServiceEvent event) {
37 if (event.kind == ServiceEvent.kResume) {
38 subscription.cancel();
39 completer.complete();
40 }
41 });
42 });
43 isolate.stepOver();
44 return completer.future;
45 }
46
47 smartNext(Isolate isolate) async {
48 if (isolate.pauseEvent.atAsyncJump) {
49 print("next-async");
50 return isolate.asyncStepOver()[Isolate.kSecondResume];
51 } else {
52 print("next-sync");
53 return stepOverAwaitingResume(isolate);
54 }
55 }
56
57 var tests = [
58 hasStoppedAtBreakpoint, stoppedAtLine(16), // foo()
59 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(16), // await
60 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(17), // bar()
61 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(18), // bar()
62 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(19), // foo()
63 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(19), // await
64 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(20), // foo()
65 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(20), // await
66 smartNext, hasStoppedAtBreakpoint, stoppedAtLine(21), // bar()
67 resumeIsolate,
68 ];
69
70 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain);
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/service/object.dart ('k') | runtime/observatory/tests/service/test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698