Index: runtime/observatory/tests/service/smart_next_test.dart |
diff --git a/runtime/observatory/tests/service/smart_next_test.dart b/runtime/observatory/tests/service/smart_next_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..aeb819ff471fab77345fb10f4a1ffabad0641656 |
--- /dev/null |
+++ b/runtime/observatory/tests/service/smart_next_test.dart |
@@ -0,0 +1,70 @@ |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+// VMOptions=--error_on_bad_type --error_on_bad_override |
+ |
+import 'package:observatory/service_io.dart'; |
+import 'test_helper.dart'; |
+import 'dart:async'; |
+import 'dart:developer'; |
+ |
+foo() async { } |
+bar() { } |
+ |
+doAsync(stop) async { |
+ if (stop) debugger(); |
+ await foo(); // Line 16. |
+ bar(); // Line 17. |
+ bar(); // Line 18. |
+ await foo(); // Line 19. |
+ await foo(); // Line 20. |
+ bar(); // Line 21. |
+ return null; |
+} |
+ |
+testMain() { |
+ // With two runs of doAsync floating around, async step should only cause |
+ // us to stop in the run we started in. |
+ doAsync(false); |
+ doAsync(true); |
+} |
+ |
+stepOverAwaitingResume(Isolate isolate) async { |
+ Completer completer = new Completer(); |
+ await isolate.vm.getEventStream(VM.kDebugStream).then((stream) { |
+ var subscription; |
+ subscription = stream.listen((ServiceEvent event) { |
+ if (event.kind == ServiceEvent.kResume) { |
+ subscription.cancel(); |
+ completer.complete(); |
+ } |
+ }); |
+ }); |
+ isolate.stepOver(); |
+ return completer.future; |
+} |
+ |
+smartNext(Isolate isolate) async { |
+ if (isolate.pauseEvent.atAsyncJump) { |
+ print("next-async"); |
+ return isolate.asyncStepOver()[Isolate.kSecondResume]; |
+ } else { |
+ print("next-sync"); |
+ return stepOverAwaitingResume(isolate); |
+ } |
+} |
+ |
+var tests = [ |
+ hasStoppedAtBreakpoint, stoppedAtLine(16), // foo() |
+ smartNext, hasStoppedAtBreakpoint, stoppedAtLine(16), // await |
+ smartNext, hasStoppedAtBreakpoint, stoppedAtLine(17), // bar() |
+ smartNext, hasStoppedAtBreakpoint, stoppedAtLine(18), // bar() |
+ smartNext, hasStoppedAtBreakpoint, stoppedAtLine(19), // foo() |
+ smartNext, hasStoppedAtBreakpoint, stoppedAtLine(19), // await |
+ smartNext, hasStoppedAtBreakpoint, stoppedAtLine(20), // foo() |
+ smartNext, hasStoppedAtBreakpoint, stoppedAtLine(20), // await |
+ smartNext, hasStoppedAtBreakpoint, stoppedAtLine(21), // bar() |
+ resumeIsolate, |
+]; |
+ |
+main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain); |