diff --git a/tests/language/async/return_throw_test.dart b/tests/language/async/return_throw_test.dart new file mode 100644 index 000000000000..43c9271c5d5c --- /dev/null +++ b/tests/language/async/return_throw_test.dart @@ -0,0 +1,23 @@ +// Copyright (c) 2020, 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 "package:expect/expect.dart"; + +Future f() async { + throw 'f'; +} + +Future g() async { + try { + // Should obtain the `Future`, await it, then throw. + return f(); + } catch (e) { + // Having caught the exception, we return a value. + return 'g'; + } +} + +void main() async { + Expect.equals('g', await g()); +} diff --git a/tests/language_2/async/return_throw_test.dart b/tests/language_2/async/return_throw_test.dart new file mode 100644 index 000000000000..43c9271c5d5c --- /dev/null +++ b/tests/language_2/async/return_throw_test.dart @@ -0,0 +1,23 @@ +// Copyright (c) 2020, 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 "package:expect/expect.dart"; + +Future f() async { + throw 'f'; +} + +Future g() async { + try { + // Should obtain the `Future`, await it, then throw. + return f(); + } catch (e) { + // Having caught the exception, we return a value. + return 'g'; + } +} + +void main() async { + Expect.equals('g', await g()); +}