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 |
| 5 // VMOptions=--verbose-debug |
| 6 |
| 7 import 'package:observatory/service_io.dart'; |
| 8 import 'package:unittest/unittest.dart'; |
| 9 import 'test_helper.dart'; |
| 10 import 'dart:async'; |
| 11 |
| 12 printSync() { // Line 12 |
| 13 print('sync'); |
| 14 } |
| 15 printAsync() async { // Line 15 |
| 16 print('async'); |
| 17 } |
| 18 printAsyncStar() async* { // Line 18 |
| 19 print('async*'); |
| 20 } |
| 21 printSyncStar() sync* { // Line 21 |
| 22 print('sync*'); |
| 23 } |
| 24 |
| 25 var testerReady = false; |
| 26 testeeDo() { |
| 27 // We block here rather than allowing the isolate to enter the |
| 28 // paused-on-exit state before the tester gets a chance to set |
| 29 // the breakpoints because we need the event loop to remain |
| 30 // operational for the async bodies to run. |
| 31 print('testee waiting'); |
| 32 while(!testerReady); |
| 33 |
| 34 printSync(); |
| 35 var future = printAsync(); |
| 36 var stream = printAsyncStar(); |
| 37 var iterator = printSyncStar(); |
| 38 |
| 39 print('middle'); // Line 39. |
| 40 |
| 41 future.then((v) => print(v)); |
| 42 stream.toList(); |
| 43 iterator.toList(); |
| 44 } |
| 45 |
| 46 testAsync(Isolate isolate) async { |
| 47 await isolate.rootLib.load(); |
| 48 var script = isolate.rootLib.scripts[0]; |
| 49 |
| 50 var bp1 = await isolate.addBreakpoint(script, 12); |
| 51 expect(bp1, isNotNull); |
| 52 expect(bp1 is Breakpoint, isTrue); |
| 53 var bp2 = await isolate.addBreakpoint(script, 15); |
| 54 expect(bp2, isNotNull); |
| 55 expect(bp2 is Breakpoint, isTrue); |
| 56 var bp3 = await isolate.addBreakpoint(script, 18); |
| 57 expect(bp3, isNotNull); |
| 58 expect(bp3 is Breakpoint, isTrue); |
| 59 var bp4 = await isolate.addBreakpoint(script, 21); |
| 60 expect(bp4, isNotNull); |
| 61 expect(bp4 is Breakpoint, isTrue); |
| 62 var bp5 = await isolate.addBreakpoint(script, 39); |
| 63 expect(bp5, isNotNull); |
| 64 expect(bp5 is Breakpoint, isTrue); |
| 65 |
| 66 var hits = []; |
| 67 |
| 68 isolate.eval(isolate.rootLib, 'testerReady = true;') |
| 69 .then((ServiceObject result) { |
| 70 expect(result.valueAsString, equals('true')); |
| 71 }); |
| 72 |
| 73 await for (ServiceEvent event in isolate.vm.events.stream) { |
| 74 if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
| 75 var bp = event.breakpoint; |
| 76 print('Hit $bp'); |
| 77 hits.add(bp); |
| 78 isolate.resume(); |
| 79 |
| 80 if (hits.length == 5) break; |
| 81 } |
| 82 } |
| 83 |
| 84 expect(hits, equals([bp1, bp5, bp4, bp2, bp3])); |
| 85 } |
| 86 |
| 87 var tests = [testAsync]; |
| 88 |
| 89 main(args) => runIsolateTests(args, tests, testeeConcurrent: testeeDo); |
OLD | NEW |