| 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 = 34; | 12 const LINE_A = 37; |
| 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 try { | 28 try { |
| 27 // caught. | 29 // caught. |
| 28 try { | 30 try { |
| 29 await asyncThrower(); | 31 await asyncThrower(); |
| 30 } catch (e) {} | 32 } catch (e) { |
| 33 } |
| 31 | 34 |
| 32 // uncaught. | 35 // uncaught. |
| 33 try { | 36 try { |
| 34 await asyncThrower(); // LINE_A. | 37 await asyncThrower(); // LINE_A. |
| 35 } on double catch (e) {} | 38 } on double catch (e) { |
| 36 } on Foo catch (e) {} | 39 } |
| 40 } on Foo catch (e) { |
| 41 } |
| 37 } | 42 } |
| 38 | 43 |
| 39 var tests = [ | 44 var tests = [ |
| 40 hasStoppedWithUnhandledException, | 45 hasStoppedWithUnhandledException, |
| 46 |
| 41 (Isolate isolate) async { | 47 (Isolate isolate) async { |
| 42 print("We stoppped!"); | 48 print("We stoppped!"); |
| 43 var stack = await isolate.getStack(); | 49 var stack = await isolate.getStack(); |
| 44 expect(stack['asyncCausalFrames'], isNotNull); | 50 expect(stack['asyncCausalFrames'], isNotNull); |
| 45 var asyncStack = stack['asyncCausalFrames']; | 51 var asyncStack = stack['asyncCausalFrames']; |
| 46 expect(asyncStack[0].toString(), contains('doThrow')); | 52 expect(asyncStack[0].toString(), contains('doThrow')); |
| 47 expect(asyncStack[1].toString(), contains('asyncThrower')); | 53 expect(asyncStack[1].toString(), contains('asyncThrower')); |
| 48 expect(asyncStack[2].kind, equals(M.FrameKind.asyncSuspensionMarker)); | 54 expect(asyncStack[2].kind, equals(M.FrameKind.asyncSuspensionMarker)); |
| 49 expect(asyncStack[3].toString(), contains('testeeMain')); | 55 expect(asyncStack[3].toString(), contains('testeeMain')); |
| 50 // We've stopped at LINE_A. | 56 // We've stopped at LINE_A. |
| 51 expect( | 57 expect(await asyncStack[3].location.toUserString(), |
| 52 await asyncStack[3].location.toUserString(), contains('.dart:$LINE_A')); | 58 contains('.dart:$LINE_A')); |
| 53 } | 59 } |
| 54 ]; | 60 ]; |
| 55 | 61 |
| 56 main(args) => runIsolateTests(args, tests, | 62 main(args) => runIsolateTests(args, |
| 57 pause_on_unhandled_exceptions: true, testeeConcurrent: testeeMain); | 63 tests, |
| 64 pause_on_unhandled_exceptions: true, |
| 65 testeeConcurrent: testeeMain); |
| OLD | NEW |