Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 3d0432e

Browse files
srujzscommit-bot@chromium.org
authored andcommitted
Add returnsNormally to async_minitest
Included change in fileapi_supported_throws_test to sanity test the change in async_minitest. Change-Id: I6e6b6b4eb0740ae695a85d4b3c1e2b4f8f63615a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138614 Commit-Queue: Srujan Gaddam <[email protected]> Reviewed-by: Bob Nystrom <[email protected]>
1 parent 6f47790 commit 3d0432e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

pkg/async_helper/lib/async_minitest.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ void _checkThrow<T>(dynamic v, void onError(error)) {
223223
});
224224
}
225225

226+
void returnsNormally(dynamic o) {
227+
try {
228+
Expect.type<Function()>(o);
229+
o();
230+
} catch (error, trace) {
231+
Expect.fail(
232+
"Expected function to return normally, but threw:\n$error\n\n$trace");
233+
}
234+
}
235+
226236
void throws(dynamic v) {
227237
_checkThrow<Object>(v, (_) {});
228238
}

tests/lib_2/html/fileapi_supported_throws_test.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import 'dart:html';
55

66
import 'package:async_helper/async_helper.dart';
77
import 'package:async_helper/async_minitest.dart';
8-
import 'package:expect/minitest.dart' as minitest;
98

109
main() {
1110
test('requestFileSystem', () async {
12-
var expectation = FileSystem.supported ? minitest.returnsNormally : throws;
13-
minitest.expect(() async {
11+
var expectation = FileSystem.supported ? returnsNormally : throws;
12+
expect(() async {
1413
await window.requestFileSystem(100);
1514
}, expectation);
1615
});

0 commit comments

Comments
 (0)