Skip to content

Use a new future instead of a cached future from another zone #831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions lib/src/frontend/expect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ import '../backend/invoker.dart';
import '../utils.dart';
import 'async_matcher.dart';

/// A future that emits `null`.
///
/// We cache and re-use this value to avoid adding a new microtask hit for each
/// call to `expect()`.
final _emptyFuture = new Future.value();

/// An exception thrown when a test assertion fails.
class TestFailure {
final String message;
Expand Down Expand Up @@ -120,7 +114,7 @@ Future _expect(actual, matcher,
}

Invoker.current.skip(message);
return _emptyFuture;
return new Future.sync(() {});
}

if (matcher is AsyncMatcher) {
Expand Down Expand Up @@ -151,12 +145,12 @@ Future _expect(actual, matcher,
});
}

return _emptyFuture;
return new Future.sync(() {});
}

var matchState = {};
try {
if (matcher.matches(actual, matchState)) return _emptyFuture;
if (matcher.matches(actual, matchState)) return new Future.sync(() {});
} catch (e, trace) {
reason ??= '$e at $trace';
}
Expand Down