Chromium Code Reviews| 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=--compile_all --error_on_bad_type --error_on_bad_override --verbos e_debug | |
| 5 | |
| 6 import 'package:observatory/service_io.dart'; | |
| 7 import 'package:unittest/unittest.dart'; | |
| 8 import 'test_helper.dart'; | |
| 9 import 'dart:developer'; | |
| 10 | |
| 11 foo() async { } | |
| 12 | |
| 13 doAsync(stop) async { | |
| 14 if (stop) debugger(); | |
| 15 await foo(); // Line 15. | |
| 16 await foo(); // Line 16. | |
| 17 await foo(); // Line 17. | |
| 18 return null; | |
| 19 } | |
| 20 | |
| 21 testMain() { | |
| 22 // With two runs of doAsync floating around, async step should only cause | |
| 23 // us to stop in the run we started in. | |
| 24 doAsync(false); | |
| 25 doAsync(true); | |
| 26 } | |
| 27 | |
| 28 | |
| 29 asyncStep(Isolate isolate) async { | |
| 30 var event = isolate.pauseEvent; | |
| 31 expect(event, isNotNull); | |
| 32 | |
| 33 // 1. Set breakpoint for the continuation and resume the isolate. | |
| 34 Instance continuation = event.asyncContinuation; | |
| 35 print("Async continuation is $continuation"); | |
| 36 expect(continuation.isClosure, isTrue); | |
| 37 | |
| 38 var bpt = await isolate.addBreakOnActivation(continuation); | |
| 39 expect(bpt is Breakpoint, isTrue); | |
| 40 print("Async step to $bpt"); | |
| 41 | |
| 42 print("A"); | |
| 43 await isolate.resume(); | |
| 44 print("AA"); | |
| 45 await hasStoppedAtBreakpoint(isolate); | |
| 46 | |
| 47 // 2. Step past the state-machine dispatch. | |
| 48 print("AAA"); | |
| 49 await isolate.stepOver(); | |
| 50 print("AAAA"); | |
| 51 await hasStoppedAtBreakpoint(isolate); | |
| 52 } | |
| 53 | |
| 54 // Currying is your friend. | |
| 55 atLine(int line) { | |
|
Cutch
2015/07/15 17:04:23
Add a return type 'IsolateTest':
IsolateTest atLi
rmacnak
2015/07/16 19:42:17
Done.
| |
| 56 return (Isolate isolate) async { | |
| 57 ServiceMap stack = await isolate.getStack(); | |
| 58 expect(stack.type, equals('Stack')); | |
| 59 expect(stack['frames'].length, greaterThanOrEqualTo(1)); | |
| 60 | |
| 61 Script script = stack['frames'][0].location.script; | |
| 62 await script.load(); | |
| 63 expect(script.tokenToLine(stack['frames'][0].location.tokenPos), | |
| 64 equals(line)); | |
| 65 }; | |
| 66 } | |
| 67 | |
| 68 | |
| 69 var tests = [ | |
| 70 hasStoppedAtBreakpoint, | |
| 71 atLine(15), | |
| 72 asyncStep, | |
| 73 atLine(16), | |
| 74 asyncStep, | |
| 75 atLine(17), | |
| 76 resumeIsolate, | |
| 77 ]; | |
| 78 | |
| 79 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain); | |
| OLD | NEW |