Skip to content
Snippets Groups Projects
Commit 738d19bd authored by Natalie Weizenbaum's avatar Natalie Weizenbaum Committed by GitHub
Browse files

Throw a better error for async groups. (#486)

Closes #485
parent c97a3b08
No related branches found
Tags 0.12.17+3
No related merge requests found
## 0.12.15+10
* Throw a better error if a group body is asynchronous.
## 0.12.15+9
* Widen version constraint on `analyzer`.
......
......@@ -129,7 +129,13 @@ class Declarer {
var declarer = new Declarer._(
this, _prefix(name), metadata, _collectTraces, trace);
declarer.declare(body);
declarer.declare(() {
// Cast to dynamic to avoid the analyzer complaining about us using the
// result of a void method.
var result = (body as dynamic)();
if (result is! Future) return;
throw new ArgumentError("Groups may not be async.");
});
_entries.add(declarer.build());
}
......
name: test
version: 0.12.15+9
version: 0.12.15+10
author: Dart Team <misc@dartlang.org>
description: A library for writing dart unit tests.
homepage: https://github.com/dart-lang/test
......
......@@ -354,6 +354,12 @@ void main() {
equals(new Duration(seconds: 15)));
});
test("disallows asynchronous groups", () async {
declare(() {
expect(() => group("group", () async {}), throwsArgumentError);
});
});
group(".setUp()", () {
test("is scoped to the group", () async {
var setUpRun = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment