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); |