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