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

Unified Diff: pkg/unittest/lib/unittest.dart

Issue 12377055: pkg/unittest: simplify guardAsync (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/unittest.dart
diff --git a/pkg/unittest/lib/unittest.dart b/pkg/unittest/lib/unittest.dart
index e96c9b20521f07f39dd665b06e4752297b98fef4..4b6e612b45a4101406daa1aace4de3daec448bd0 100644
--- a/pkg/unittest/lib/unittest.dart
+++ b/pkg/unittest/lib/unittest.dart
@@ -390,7 +390,7 @@ class _SpreadArgsHelper {
invoke([arg0 = sentinel, arg1 = sentinel, arg2 = sentinel,
arg3 = sentinel, arg4 = sentinel]) {
- return guardAsync(() {
+ return _guardAsync(() {
if (!shouldCallBack()) {
return;
} else if (arg0 == sentinel) {
@@ -414,7 +414,7 @@ class _SpreadArgsHelper {
}
invoke0() {
- return guardAsync(
+ return _guardAsync(
() {
if (shouldCallBack()) {
return callback();
@@ -424,7 +424,7 @@ class _SpreadArgsHelper {
}
invoke1(arg1) {
- return guardAsync(
+ return _guardAsync(
() {
if (shouldCallBack()) {
return callback(arg1);
@@ -434,7 +434,7 @@ class _SpreadArgsHelper {
}
invoke2(arg1, arg2) {
- return guardAsync(
+ return _guardAsync(
() {
if (shouldCallBack()) {
return callback(arg1, arg2);
@@ -723,8 +723,12 @@ void runTests() {
*
* The value returned by [tryBody] (if any) is returned by [guardAsync].
*/
-guardAsync(Function tryBody, [Function finallyBody, int testNum = -1]) {
- if (testNum < 0) testNum = _currentTest;
+guardAsync(Function tryBody) {
+ return _guardAsync(tryBody, null, _currentTest);
+}
+
+_guardAsync(Function tryBody, Function finallyBody, int testNum) {
+ assert(testNum >= 0);
try {
return tryBody();
} catch (e, trace) {
@@ -766,7 +770,7 @@ _nextBatch() {
break;
}
final testCase = _tests[_currentTest];
- var f = guardAsync(testCase.run, null, _currentTest);
+ var f = _guardAsync(testCase.run, null, _currentTest);
if (f != null) {
f.whenComplete(() {
_nextTestCase(); // Schedule the next test.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698