Chromium Code Reviews| Index: tests/language/await_throw_in_catch_test.dart |
| diff --git a/tests/language/await_throw_in_catch_test.dart b/tests/language/await_throw_in_catch_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4f0e51a232d0cf37ecc982f37b433dec96ef59e3 |
| --- /dev/null |
| +++ b/tests/language/await_throw_in_catch_test.dart |
| @@ -0,0 +1,76 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +import "dart:async"; |
| +import "package:expect/expect.dart"; |
| +import "package:async_helper/async_helper.dart"; |
| + |
| +bool finallyRun = false; |
| + |
| +foo() async { |
| + try { |
| + await new Future.value(3); |
| + throw "Error"; |
| + } catch (e) { |
| + 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.
|
| + } finally { |
| + finallyRun = true; |
| + } |
| +} |
| + |
| +bool finallyRun2 = false; |
| + |
| +foo2() async { |
| + print("start"); |
| + try { |
| + await new Future.value(3); |
| + throw "Error"; |
| + } catch (e) { |
| + await new Future.error("Error2"); |
| + } finally { |
| + finallyRun2 = true; |
| + } |
| +} |
| + |
| +bool finallyRun3 = false; |
| + |
| +foo3() async* { |
| + try { |
| + await new Future.value(3); |
| + throw "Error"; |
| + } catch (e) { |
| + yield 1; |
| + yield 2; |
| + await new Future.error("Error2"); |
| + } finally { |
| + finallyRun3 = true; |
| + } |
| +} |
| + |
| +test() async { |
| + print("start"); |
| + try { |
| + await foo(); |
| + } catch (e) { |
| + 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.
|
| + } |
| + Expect.isTrue(finallyRun); |
| + print("done"); |
| + try { |
| + await foo2(); |
| + } catch (e) { |
| + Expect.equals("Error2", e); |
| + } |
| + Expect.isTrue(finallyRun2); |
| + var subscription; |
| + subscription = foo3().listen((event) { |
| + subscription.cancel(); |
| + }, onDone: () { |
| + Expect.isTrue(finallyRun3); |
| + }); |
| +} |
|
floitsch
2015/02/13 15:30:07
Add a few more tests:
try {
try {
throw;
sigurdm
2015/02/17 08:43:10
Done.
|
| + |
| +void main() { |
| + asyncTest(test); |
| +} |