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

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

Issue 193643003: pkg/unittest: support up to 6 arguments in expectAsync[Until] (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: doc comments Created 6 years, 9 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 | « pkg/unittest/lib/src/spread_args_helper.dart ('k') | pkg/unittest/test/missing_tick_test.dart » ('j') | 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 da95faecc9f03ca1ef539d431f88a8372c0f7b85..9add42c8b1bb6928ae3d3ebb81d4c20faac0975c 100644
--- a/pkg/unittest/lib/unittest.dart
+++ b/pkg/unittest/lib/unittest.dart
@@ -325,22 +325,8 @@ void solo_test(String spec, TestFunction body) {
* bound.
*/
Function expectAsync(Function callback,
- {int count: 1, int max: 0, String id}) {
- var minArgs = _minArgs(callback);
-
- switch(minArgs) {
- case 0:
- return new _SpreadArgsHelper(callback, count, max, null, id).invoke0;
- case 1:
- return new _SpreadArgsHelper(callback, count, max, null, id).invoke1;
- case 2:
- return new _SpreadArgsHelper(callback, count, max, null, id).invoke2;
- default:
- // _minArgs throws an argument exception if the arg count is > 2.
- // this is just for paranoia
- throw new StateError('Should never get here');
- }
-}
+ {int count: 1, int max: 0, String id}) =>
+ new _SpreadArgsHelper(callback, count, max, id).func;
/**
* *Deprecated*
@@ -382,22 +368,8 @@ Function expectAsync2(Function callback,
* identify the callback in error messages (for example if it is called
* after the test case is complete).
*/
-Function expectAsyncUntil(Function callback, Function isDone, {String id}) {
- var minArgs = _minArgs(callback);
-
- switch(minArgs) {
- case 0:
- return new _SpreadArgsHelper(callback, 0, -1, isDone, id).invoke0;
- case 1:
- return new _SpreadArgsHelper(callback, 0, -1, isDone, id).invoke1;
- case 2:
- return new _SpreadArgsHelper(callback, 0, -1, isDone, id).invoke2;
- default:
- // _minArgs throws an argument exception if the arg count is > 2.
- // this is just for paranoia
- throw new StateError('Should never get here');
- }
-}
+Function expectAsyncUntil(Function callback, bool isDone(), {String id}) =>
+ new _SpreadArgsHelper(callback, 0, -1, id, isDone: isDone).func;
/**
* *Deprecated*
@@ -770,18 +742,3 @@ Trace _getTrace(stack) {
return frame.package != 'unittest' || frame.member != 'TestCase._runTest';
})).terse.foldFrames((frame) => frame.package == 'unittest' || frame.isCore);
}
-
-typedef _Func0();
-typedef _Func1(a);
-typedef _Func2(a, b);
-
-/**
- * Throws an [ArgumentError] if the callback has more than 2 required arguments.
- */
-int _minArgs(Function callback) {
- if (callback is _Func0) return 0;
- if (callback is _Func1) return 1;
- if (callback is _Func2) return 2;
- throw new ArgumentError(
- 'The callback argument has more than 2 required arguments.');
-}
« no previous file with comments | « pkg/unittest/lib/src/spread_args_helper.dart ('k') | pkg/unittest/test/missing_tick_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698