Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Unified Diff: test/utils.dart

Issue 1870543004: Add typed wrapper functions to delegate classes. (Closed) Base URL: git@github.com:dart-lang/async.git@master
Patch Set: Code review changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/src/lazy_stream.dart ('K') | « test/typed_wrapper/stream_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/utils.dart
diff --git a/test/utils.dart b/test/utils.dart
index c32ea2c1a6a550e49c22fc1ea9dfc6bad052fa4c..7b65bcb70e09fc2df0b14b163f54eeff39d84ac3 100644
--- a/test/utils.dart
+++ b/test/utils.dart
@@ -16,6 +16,29 @@ Future flushMicrotasks() => new Future.delayed(Duration.ZERO);
/// Returns a function that fails the test if it is ever called.
unreachable(String name) => ([a, b]) => fail("Unreachable: $name");
+// TODO(nweiz): Use the version of this in test when test#418 is fixed.
+/// A matcher that runs a callback in its own zone and asserts that that zone
+/// emits an error that matches [matcher].
+Matcher throwsZoned(matcher) => predicate((callback) {
+ var firstError = true;
+ runZoned(callback, onError: expectAsync((error, stackTrace) {
+ if (firstError) {
+ expect(error, matcher);
+ firstError = false;
+ } else {
+ registerException(error, stackTrace);
+ }
+ }, max: -1));
+ return true;
+});
+
+/// A matcher that runs a callback in its own zone and asserts that that zone
+/// emits a [CastError].
+final throwsZonedCastError = throwsZoned(new isInstanceOf<CastError>());
+
+/// A matcher that matches a callback or future that throws a [CastError].
+final throwsCastError = throwsA(new isInstanceOf<CastError>());
+
/// A badly behaved stream which throws if it's ever listened to.
///
/// Can be used to test cases where a stream should not be used.
« lib/src/lazy_stream.dart ('K') | « test/typed_wrapper/stream_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698