| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 | 4 // VMOptions=--error_on_bad_type --error_on_bad_override --verbose_debug |
| 5 | 5 |
| 6 import 'dart:developer'; | 6 import 'dart:developer'; |
| 7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
| 8 import 'package:observatory/service_io.dart'; | 8 import 'package:observatory/service_io.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 import 'service_test_common.dart'; | 10 import 'service_test_common.dart'; |
| 11 import 'test_helper.dart'; | 11 import 'test_helper.dart'; |
| 12 | 12 |
| 13 const LINE_C = 19; | 13 const LINE_C = 19; |
| 14 const LINE_A = 24; | 14 const LINE_A = 24; |
| 15 const LINE_B = 30; | 15 const LINE_B = 30; |
| 16 | 16 |
| 17 foobar() { | 17 foobar() { |
| 18 debugger(); | 18 debugger(); |
| 19 print('foobar'); // LINE_C. | 19 print('foobar'); // LINE_C. |
| 20 } | 20 } |
| 21 | 21 |
| 22 helper() async { | 22 helper() async { |
| 23 debugger(); | 23 debugger(); |
| 24 print('helper'); // LINE_A. | 24 print('helper'); // LINE_A. |
| 25 foobar(); | 25 foobar(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 testMain() { | 28 testMain() { |
| 29 debugger(); | 29 debugger(); |
| 30 helper(); // LINE_B. | 30 helper(); // LINE_B. |
| 31 } | 31 } |
| 32 | 32 |
| 33 var tests = [ | 33 var tests = [ |
| 34 hasStoppedAtBreakpoint, | 34 hasStoppedAtBreakpoint, |
| 35 stoppedAtLine(LINE_B), | 35 stoppedAtLine(LINE_B), |
| 36 (Isolate isolate) async { | 36 (Isolate isolate) async { |
| 37 ServiceMap stack = await isolate.getStack(); | 37 ServiceMap stack = await isolate.getStack(); |
| 38 // No causal frames because we are in a completely synchronous stack. | 38 // No causal frames because we are in a completely synchronous stack. |
| 39 expect(stack['asyncCausalFrames'], isNull); | 39 expect(stack['asyncCausalFrames'], isNull); |
| 40 }, | 40 }, |
| 41 resumeIsolate, | 41 resumeIsolate, |
| 42 hasStoppedAtBreakpoint, | 42 hasStoppedAtBreakpoint, |
| 43 stoppedAtLine(LINE_A), | 43 stoppedAtLine(LINE_A), |
| 44 | |
| 45 (Isolate isolate) async { | 44 (Isolate isolate) async { |
| 46 ServiceMap stack = await isolate.getStack(); | 45 ServiceMap stack = await isolate.getStack(); |
| 47 // Has causal frames (we are inside an async function) | 46 // Has causal frames (we are inside an async function) |
| 48 expect(stack['asyncCausalFrames'], isNotNull); | 47 expect(stack['asyncCausalFrames'], isNotNull); |
| 49 var asyncStack = stack['asyncCausalFrames']; | 48 var asyncStack = stack['asyncCausalFrames']; |
| 50 expect(asyncStack[0].toString(), contains('helper')); | 49 expect(asyncStack[0].toString(), contains('helper')); |
| 51 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker)); | 50 expect(asyncStack[1].kind, equals(M.FrameKind.asyncSuspensionMarker)); |
| 52 expect(asyncStack[2].toString(), contains('testMain')); | 51 expect(asyncStack[2].toString(), contains('testMain')); |
| 53 }, | 52 }, |
| 54 | |
| 55 resumeIsolate, | 53 resumeIsolate, |
| 56 hasStoppedAtBreakpoint, | 54 hasStoppedAtBreakpoint, |
| 57 stoppedAtLine(LINE_C), | 55 stoppedAtLine(LINE_C), |
| 58 | |
| 59 (Isolate isolate) async { | 56 (Isolate isolate) async { |
| 60 ServiceMap stack = await isolate.getStack(); | 57 ServiceMap stack = await isolate.getStack(); |
| 61 // Has causal frames (we are inside a function called by an async function) | 58 // Has causal frames (we are inside a function called by an async function) |
| 62 expect(stack['asyncCausalFrames'], isNotNull); | 59 expect(stack['asyncCausalFrames'], isNotNull); |
| 63 var asyncStack = stack['asyncCausalFrames']; | 60 var asyncStack = stack['asyncCausalFrames']; |
| 64 expect(asyncStack[0].toString(), contains('foobar')); | 61 expect(asyncStack[0].toString(), contains('foobar')); |
| 65 expect(asyncStack[1].toString(), contains('helper')); | 62 expect(asyncStack[1].toString(), contains('helper')); |
| 66 expect(asyncStack[2].kind, equals(M.FrameKind.asyncSuspensionMarker)); | 63 expect(asyncStack[2].kind, equals(M.FrameKind.asyncSuspensionMarker)); |
| 67 expect(asyncStack[3].toString(), contains('testMain')); | 64 expect(asyncStack[3].toString(), contains('testMain')); |
| 68 // Line 19. | 65 // Line 19. |
| 69 expect(await asyncStack[0].location.toUserString(), contains('.dart:19')); | 66 expect(await asyncStack[0].location.toUserString(), contains('.dart:19')); |
| 70 // Line 25. | 67 // Line 25. |
| 71 expect(await asyncStack[1].location.toUserString(), contains('.dart:25')); | 68 expect(await asyncStack[1].location.toUserString(), contains('.dart:25')); |
| 72 // Line 30. | 69 // Line 30. |
| 73 expect(await asyncStack[3].location.toUserString(), contains('.dart:30')); | 70 expect(await asyncStack[3].location.toUserString(), contains('.dart:30')); |
| 74 }, | 71 }, |
| 75 ]; | 72 ]; |
| 76 | 73 |
| 77 main(args) => runIsolateTestsSynchronous(args, | 74 main(args) => |
| 78 tests, | 75 runIsolateTestsSynchronous(args, tests, testeeConcurrent: testMain); |
| 79 testeeConcurrent: testMain); | |
| OLD | NEW |