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