| 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 | 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
| 5 | 5 |
| 6 import 'package:observatory/service_io.dart'; | 6 import 'package:observatory/service_io.dart'; |
| 7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
| 8 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 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 const LINE_A = 29; | 12 const LINE_A = 29; |
| 13 | 13 |
| 14 class Foo {} | 14 class Foo { |
| 15 |
| 16 } |
| 15 | 17 |
| 16 doThrow() { | 18 doThrow() { |
| 17 throw "TheException"; // Line 13. | 19 throw "TheException"; // Line 13. |
| 18 return "end of doThrow"; | 20 return "end of doThrow"; |
| 19 } | 21 } |
| 20 | 22 |
| 21 asyncThrower() async { | 23 asyncThrower() async { |
| 22 doThrow(); | 24 doThrow(); |
| 23 } | 25 } |
| 24 | 26 |
| 25 testeeMain() async { | 27 testeeMain() async { |
| 26 // No try ... catch. | 28 // No try ... catch. |
| 27 await asyncThrower(); | 29 await asyncThrower(); |
| 28 } | 30 } |
| 29 | 31 |
| 30 var tests = [ | 32 var tests = [ |
| 31 hasStoppedWithUnhandledException, | 33 hasStoppedWithUnhandledException, |
| 34 |
| 32 (Isolate isolate) async { | 35 (Isolate isolate) async { |
| 33 print("We stoppped!"); | 36 print("We stoppped!"); |
| 34 var stack = await isolate.getStack(); | 37 var stack = await isolate.getStack(); |
| 35 expect(stack['asyncCausalFrames'], isNotNull); | 38 expect(stack['asyncCausalFrames'], isNotNull); |
| 36 var asyncStack = stack['asyncCausalFrames']; | 39 var asyncStack = stack['asyncCausalFrames']; |
| 37 expect(asyncStack[0].toString(), contains('doThrow')); | 40 expect(asyncStack[0].toString(), contains('doThrow')); |
| 38 expect(asyncStack[1].toString(), contains('asyncThrower')); | 41 expect(asyncStack[1].toString(), contains('asyncThrower')); |
| 39 expect(asyncStack[2].kind, equals(M.FrameKind.asyncSuspensionMarker)); | 42 expect(asyncStack[2].kind, equals(M.FrameKind.asyncSuspensionMarker)); |
| 40 expect(asyncStack[3].toString(), contains('testeeMain')); | 43 expect(asyncStack[3].toString(), contains('testeeMain')); |
| 41 // We've stopped at LINE_A. | 44 // We've stopped at LINE_A. |
| 42 expect( | 45 expect(await asyncStack[3].location.toUserString(), |
| 43 await asyncStack[3].location.toUserString(), contains('.dart:$LINE_A')); | 46 contains('.dart:$LINE_A')); |
| 44 } | 47 } |
| 45 ]; | 48 ]; |
| 46 | 49 |
| 47 main(args) => runIsolateTests(args, tests, | 50 main(args) => runIsolateTests(args, |
| 48 pause_on_unhandled_exceptions: true, testeeConcurrent: testeeMain); | 51 tests, |
| 52 pause_on_unhandled_exceptions: true, |
| 53 testeeConcurrent: testeeMain); |
| OLD | NEW |