| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug --trac
e_service | 4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug --trac
e_service |
| 5 | 5 |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:developer'; | 7 import 'dart:developer'; |
| 8 | 8 |
| 9 import 'test_helper.dart'; | 9 import 'test_helper.dart'; |
| 10 import 'service_test_common.dart'; | 10 import 'service_test_common.dart'; |
| 11 | 11 |
| 12 import 'package:observatory/models.dart' as M; |
| 12 import 'package:observatory/service_io.dart'; | 13 import 'package:observatory/service_io.dart'; |
| 13 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
| 14 | 15 |
| 15 const int LINE_A = 24; | 16 const int LINE_A = 25; |
| 16 const int LINE_B = 26; | 17 const int LINE_B = 27; |
| 17 const int LINE_C = 28; | 18 const int LINE_C = 29; |
| 18 const int LINE_D = 29; | 19 const int LINE_D = 30; |
| 19 | 20 |
| 20 // This tests the low level synthetic breakpoint added / paused / removed | 21 // This tests the low level synthetic breakpoint added / paused / removed |
| 21 // machinery triggered by the step OverAwait command. | 22 // machinery triggered by the step OverAwait command. |
| 22 asyncWithoutAwait() async { | 23 asyncWithoutAwait() async { |
| 23 debugger(); | 24 debugger(); |
| 24 print('a'); // LINE_A | 25 print('a'); // LINE_A |
| 25 await new Future.delayed(new Duration(seconds: 2)); | 26 await new Future.delayed(new Duration(seconds: 2)); |
| 26 print('b'); // LINE_B | 27 print('b'); // LINE_B |
| 27 debugger(); // LINE_C | 28 debugger(); // LINE_C |
| 28 debugger(); // LINE_D | 29 debugger(); // LINE_D |
| 29 } | 30 } |
| 30 | 31 |
| 31 testMain() { | 32 testMain() { |
| 32 asyncWithoutAwait(); | 33 asyncWithoutAwait(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 Breakpoint syntheticBreakpoint; | 36 Breakpoint syntheticBreakpoint; |
| 36 | 37 |
| 37 Future<Isolate> testLowLevelAwaitOver( | 38 Future<Isolate> testLowLevelAwaitOver( |
| 38 Isolate isolate) { | 39 Isolate isolate) { |
| 39 assert(isolate.pauseEvent.atAsyncSuspension); | 40 assert(M.isAtAsyncSuspension(isolate.pauseEvent)); |
| 40 | 41 |
| 41 int state = 0; | 42 int state = 0; |
| 42 bool firstResume = true; | 43 bool firstResume = true; |
| 43 handleBreakpointAdded(ServiceEvent event) { | 44 handleBreakpointAdded(ServiceEvent event) { |
| 44 expect(syntheticBreakpoint, isNull); | 45 expect(syntheticBreakpoint, isNull); |
| 45 expect(state, 0); | 46 expect(state, 0); |
| 46 if (!event.breakpoint.isSyntheticAsyncContinuation) { | 47 if (!event.breakpoint.isSyntheticAsyncContinuation) { |
| 47 // Not a synthetic async breakpoint. | 48 // Not a synthetic async breakpoint. |
| 48 return; | 49 return; |
| 49 } | 50 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 155 } |
| 155 | 156 |
| 156 | 157 |
| 157 var tests = [ | 158 var tests = [ |
| 158 hasStoppedAtBreakpoint, | 159 hasStoppedAtBreakpoint, |
| 159 stoppedAtLine(LINE_A), | 160 stoppedAtLine(LINE_A), |
| 160 stepOver, | 161 stepOver, |
| 161 stepOver, | 162 stepOver, |
| 162 stepOver, | 163 stepOver, |
| 163 (Isolate isolate) async { | 164 (Isolate isolate) async { |
| 164 expect(isolate.pauseEvent.atAsyncSuspension, isTrue); | 165 expect(M.isAtAsyncSuspension(isolate.pauseEvent), isTrue); |
| 165 expect(syntheticBreakpoint, isNull); | 166 expect(syntheticBreakpoint, isNull); |
| 166 }, | 167 }, |
| 167 testLowLevelAwaitOver, | 168 testLowLevelAwaitOver, |
| 168 hasStoppedAtBreakpoint, | 169 hasStoppedAtBreakpoint, |
| 169 stoppedAtLine(LINE_C), | 170 stoppedAtLine(LINE_C), |
| 170 resumeIsolate, | 171 resumeIsolate, |
| 171 hasStoppedAtBreakpoint, | 172 hasStoppedAtBreakpoint, |
| 172 stoppedAtLine(LINE_D), | 173 stoppedAtLine(LINE_D), |
| 173 resumeIsolate, | 174 resumeIsolate, |
| 174 ]; | 175 ]; |
| 175 | 176 |
| 176 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain); | 177 main(args) => runIsolateTests(args, tests, testeeConcurrent: testMain); |
| OLD | NEW |