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

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

Issue 187323003: pkg/unittest: much cleaner support for arbitrary args in expectAsync functions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixed status Created 6 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
Index: pkg/unittest/lib/src/spread_args_helper.dart
diff --git a/pkg/unittest/lib/src/spread_args_helper.dart b/pkg/unittest/lib/src/spread_args_helper.dart
index 41411b93780f4f2d68f4f6941dad6186b668f4f4..b0224df862d555ed7daa706edb3c31fd1e380cf8 100644
--- a/pkg/unittest/lib/src/spread_args_helper.dart
+++ b/pkg/unittest/lib/src/spread_args_helper.dart
@@ -1,9 +1,15 @@
part of unittest;
+const _PLACE_HOLDER = const _ArgPlaceHolder();
+
+class _ArgPlaceHolder {
+ const _ArgPlaceHolder();
+}
+
/** Simulates spread arguments using named arguments. */
// TODO(sigmund): remove this class and simply use a closure with named
// arguments (if still applicable).
-class _SpreadArgsHelper {
+class _SpreadArgsHelper implements Function {
final Function callback;
final int minExpectedCalls;
final int maxExpectedCalls;
@@ -90,31 +96,16 @@ class _SpreadArgsHelper {
}
}
- invoke0() {
- return _guardAsync(
- () {
- if (shouldCallBack()) {
- return callback();
- }
- },
- after, testCase);
- }
+ call([a0 = _PLACE_HOLDER, a1 = _PLACE_HOLDER, a2 = _PLACE_HOLDER,
+ a3 = _PLACE_HOLDER, a4 = _PLACE_HOLDER, a5 = _PLACE_HOLDER]) {
- invoke1(arg1) {
- return _guardAsync(
- () {
- if (shouldCallBack()) {
- return callback(arg1);
- }
- },
- after, testCase);
- }
+ var args = [a0, a1, a2, a3, a4, a5];
+ args.removeWhere((a) => a == _PLACE_HOLDER);
- invoke2(arg1, arg2) {
return _guardAsync(
() {
if (shouldCallBack()) {
- return callback(arg1, arg2);
+ return Function.apply(callback, args);
}
},
after, testCase);

Powered by Google App Engine
This is Rietveld 408576698