| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'test_helper.dart'; | 8 import 'test_helper.dart'; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 t.complete(event); | 44 t.complete(event); |
| 45 } | 45 } |
| 46 if (event.kind == ServiceEvent.kResume) { | 46 if (event.kind == ServiceEvent.kResume) { |
| 47 if (onResume == null) throw "Unexpected resume event $event"; | 47 if (onResume == null) throw "Unexpected resume event $event"; |
| 48 var t = onResume; | 48 var t = onResume; |
| 49 onResume = null; | 49 onResume = null; |
| 50 t.complete(event); | 50 t.complete(event); |
| 51 } | 51 } |
| 52 }); | 52 }); |
| 53 | 53 |
| 54 test(String pauseInfo, | 54 test(String pauseMode, |
| 55 String expression, | 55 String expression, |
| 56 bool shouldPause, | 56 bool shouldPause, |
| 57 bool shouldBeCaught) async { | 57 bool shouldBeCaught) async { |
| 58 print("Evaluating $expression with pause on $pauseInfo exception"); | 58 print("Evaluating $expression with pause on $pauseMode exception"); |
| 59 | 59 |
| 60 expect((await isolate.setExceptionPauseInfo(pauseInfo)) is DartError, | 60 expect((await isolate.setExceptionPauseMode(pauseMode)) is DartError, |
| 61 isFalse); | 61 isFalse); |
| 62 | 62 |
| 63 var t; | 63 var t; |
| 64 if (shouldPause) { | 64 if (shouldPause) { |
| 65 t = new Completer(); | 65 t = new Completer(); |
| 66 onPaused = t; | 66 onPaused = t; |
| 67 } | 67 } |
| 68 var fres = lib.evaluate(expression); | 68 var fres = lib.evaluate(expression); |
| 69 if (shouldPause) { | 69 if (shouldPause) { |
| 70 await t.future; | 70 await t.future; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 87 expect(res.valueAsString, equals("end of doCaught")); | 87 expect(res.valueAsString, equals("end of doCaught")); |
| 88 } else { | 88 } else { |
| 89 expect(res.isError, isTrue); | 89 expect(res.isError, isTrue); |
| 90 await res.load(); // Weird? | 90 await res.load(); // Weird? |
| 91 expect(res.exception.isInstance, isTrue); | 91 expect(res.exception.isInstance, isTrue); |
| 92 expect(res.exception.isString, isTrue); | 92 expect(res.exception.isString, isTrue); |
| 93 expect(res.exception.valueAsString, equals("TheException")); | 93 expect(res.exception.valueAsString, equals("TheException")); |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 await test("all", "doCaught()", true, true); | 97 await test("All", "doCaught()", true, true); |
| 98 await test("all", "doUncaught()", true, false); | 98 await test("All", "doUncaught()", true, false); |
| 99 | 99 |
| 100 await test("unhandled", "doCaught()", false, true); | 100 await test("Unhandled", "doCaught()", false, true); |
| 101 await test("unhandled", "doUncaught()", true, false); | 101 await test("Unhandled", "doUncaught()", true, false); |
| 102 | 102 |
| 103 await test("none", "doCaught()", false, true); | 103 await test("None", "doCaught()", false, true); |
| 104 await test("none", "doUncaught()", false, false); | 104 await test("None", "doUncaught()", false, false); |
| 105 | 105 |
| 106 subscription.cancel(); | 106 subscription.cancel(); |
| 107 }, | 107 }, |
| 108 | 108 |
| 109 ]; | 109 ]; |
| 110 | 110 |
| 111 main(args) => runIsolateTests(args, tests); | 111 main(args) => runIsolateTests(args, tests); |
| OLD | NEW |