Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 import "dart:async"; | |
| 6 import "package:expect/expect.dart"; | |
| 7 import "package:async_helper/async_helper.dart"; | |
| 8 | |
| 9 bool finallyRun = false; | |
| 10 | |
| 11 foo() async { | |
| 12 try { | |
| 13 await new Future.value(3); | |
| 14 throw "Error"; | |
| 15 } catch (e) { | |
| 16 throw "Error2"; | |
|
floitsch
2015/02/13 15:30:07
Add boolean to make sure we entered this catch.
Or
floitsch
2015/02/13 15:30:07
before this line.
Expect.isFalse(finallyRun);
sigurdm
2015/02/17 08:43:10
Done.
sigurdm
2015/02/17 08:43:10
Done.
| |
| 17 } finally { | |
| 18 finallyRun = true; | |
| 19 } | |
| 20 } | |
| 21 | |
| 22 bool finallyRun2 = false; | |
| 23 | |
| 24 foo2() async { | |
| 25 print("start"); | |
| 26 try { | |
| 27 await new Future.value(3); | |
| 28 throw "Error"; | |
| 29 } catch (e) { | |
| 30 await new Future.error("Error2"); | |
| 31 } finally { | |
| 32 finallyRun2 = true; | |
| 33 } | |
| 34 } | |
| 35 | |
| 36 bool finallyRun3 = false; | |
| 37 | |
| 38 foo3() async* { | |
| 39 try { | |
| 40 await new Future.value(3); | |
| 41 throw "Error"; | |
| 42 } catch (e) { | |
| 43 yield 1; | |
| 44 yield 2; | |
| 45 await new Future.error("Error2"); | |
| 46 } finally { | |
| 47 finallyRun3 = true; | |
| 48 } | |
| 49 } | |
| 50 | |
| 51 test() async { | |
| 52 print("start"); | |
| 53 try { | |
| 54 await foo(); | |
| 55 } catch (e) { | |
| 56 Expect.equals("Error2", e); | |
|
floitsch
2015/02/13 15:30:07
indentation.
ditto for the others.
floitsch
2015/02/13 15:30:07
Make sure this 'catch' is executed.
ditto for the
sigurdm
2015/02/17 08:43:10
Done.
| |
| 57 } | |
| 58 Expect.isTrue(finallyRun); | |
| 59 print("done"); | |
| 60 try { | |
| 61 await foo2(); | |
| 62 } catch (e) { | |
| 63 Expect.equals("Error2", e); | |
| 64 } | |
| 65 Expect.isTrue(finallyRun2); | |
| 66 var subscription; | |
| 67 subscription = foo3().listen((event) { | |
| 68 subscription.cancel(); | |
| 69 }, onDone: () { | |
| 70 Expect.isTrue(finallyRun3); | |
| 71 }); | |
| 72 } | |
|
floitsch
2015/02/13 15:30:07
Add a few more tests:
try {
try {
throw;
sigurdm
2015/02/17 08:43:10
Done.
| |
| 73 | |
| 74 void main() { | |
| 75 asyncTest(test); | |
| 76 } | |
| OLD | NEW |