Skip to content

Commit 073acc7

Browse files
eernstgcommit-bot@chromium.org
authored andcommitted
Add tests for throwing async return
Cf. #44395. Change-Id: I753a6a4fae65c50267d8cf1575d2ce87e7ac345b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175064 Reviewed-by: Lasse R.H. Nielsen <[email protected]> Commit-Queue: Erik Ernst <[email protected]>
1 parent 224351b commit 073acc7

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2020, 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 "package:expect/expect.dart";
6+
7+
Future<String> f() async {
8+
throw 'f';
9+
}
10+
11+
Future<String> g() async {
12+
try {
13+
// Should obtain the `Future<String>`, await it, then throw.
14+
return f();
15+
} catch (e) {
16+
// Having caught the exception, we return a value.
17+
return 'g';
18+
}
19+
}
20+
21+
void main() async {
22+
Expect.equals('g', await g());
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2020, 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 "package:expect/expect.dart";
6+
7+
Future<String> f() async {
8+
throw 'f';
9+
}
10+
11+
Future<String> g() async {
12+
try {
13+
// Should obtain the `Future<String>`, await it, then throw.
14+
return f();
15+
} catch (e) {
16+
// Having caught the exception, we return a value.
17+
return 'g';
18+
}
19+
}
20+
21+
void main() async {
22+
Expect.equals('g', await g());
23+
}

0 commit comments

Comments
 (0)