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

Unified Diff: lib/src/frontend/expect.dart

Issue 1148723005: Make expect* throw useful errors outside tests. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/frontend/expect_async.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/frontend/expect.dart
diff --git a/lib/src/frontend/expect.dart b/lib/src/frontend/expect.dart
index d39986b40231df2599403430c43909ff703e40e5..8d73ea308b71ede696e0a94fe04d548548fcc120 100644
--- a/lib/src/frontend/expect.dart
+++ b/lib/src/frontend/expect.dart
@@ -39,6 +39,10 @@ typedef String ErrorFormatter(
/// [verbose] should be specified as `true`.
void expect(actual, matcher,
{String reason, bool verbose: false, ErrorFormatter formatter}) {
+ if (Invoker.current == null) {
+ throw new StateError("extend() may only be called within a test.");
+ }
+
if (Invoker.current.closed) throw new ClosedException();
matcher = wrapMatcher(matcher);
« no previous file with comments | « CHANGELOG.md ('k') | lib/src/frontend/expect_async.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698