| 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/service_io.dart'; |
| 7 import 'package:unittest/unittest.dart'; |
| 8 import 'test_helper.dart'; |
| 9 import 'dart:async'; |
| 10 |
| 11 testMain() { |
| 12 var foo; // line 11 |
| 13 foo = 42; // line 12 |
| 14 print(foo); |
| 15 } |
| 16 |
| 17 var tests = [ |
| 18 hasPausedAtStart, |
| 19 |
| 20 // Add breakpoints at line 11 and line 12. |
| 21 (Isolate isolate) async { |
| 22 var rootLib = isolate.rootLibrary; |
| 23 await rootLib.load(); |
| 24 var script = rootLib.scripts[0]; |
| 25 |
| 26 var bpt1 = await isolate.addBreakpoint(script, 11); |
| 27 var bpt2 = await isolate.addBreakpoint(script, 12); |
| 28 expect(await bpt1.location.getLine(), equals(11)); |
| 29 expect(await bpt2.location.getLine(), equals(12)); |
| 30 |
| 31 var stream = await isolate.vm.getEventStream(VM.kDebugStream); |
| 32 Completer completer = new Completer(); |
| 33 var subscription; |
| 34 var breakCount = 0; |
| 35 subscription = stream.listen((ServiceEvent event) async { |
| 36 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
| 37 breakCount++; |
| 38 print('break count is $breakCount'); |
| 39 if (breakCount == 1) { |
| 40 // We are stopped at breakpoint 1. |
| 41 expect(event.breakpoint.number, equals(bpt1.number)); |
| 42 |
| 43 // Remove both breakpoints |
| 44 var result = await isolate.removeBreakpoint(bpt1); |
| 45 expect(result.type, equals("Success")); |
| 46 |
| 47 result = await isolate.removeBreakpoint(bpt2); |
| 48 expect(result.type, equals("Success")); |
| 49 |
| 50 isolate.stepOver(); |
| 51 } else { |
| 52 // No breakpoint. |
| 53 expect(event.breakpoint, isNull); |
| 54 |
| 55 // We expect the next step to take us to line 12. |
| 56 var stack = await isolate.getStack(); |
| 57 expect(await stack['frames'][0].location.getLine(), equals(12)); |
| 58 |
| 59 subscription.cancel(); |
| 60 completer.complete(null); |
| 61 } |
| 62 } |
| 63 }); |
| 64 isolate.resume(); |
| 65 await completer.future; |
| 66 }, |
| 67 ]; |
| 68 |
| 69 main(args) => runIsolateTests(args, tests, |
| 70 testeeConcurrent: testMain, |
| 71 pause_on_start: true); |
| OLD | NEW |