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

Unified Diff: pkg/unittest/unittest.dart

Issue 10948005: Reverting 12485 and 12480 just for the sake of mocking, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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/mock.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/unittest.dart
===================================================================
--- pkg/unittest/unittest.dart (revision 12486)
+++ pkg/unittest/unittest.dart (working copy)
@@ -293,6 +293,15 @@
_tests.add(_soloTest);
}
+/** Sentinel value for [_SpreadArgsHelper]. */
+class _Sentinel {
+ const _Sentinel();
+}
+
+// TODO(sigmund): make a singleton const field when frog supports passing those
+// as default values to named arguments.
+const _sentinel = const _Sentinel();
+
/** Simulates spread arguments using named arguments. */
// TODO(sigmund): remove this class and simply use a closure with named
// arguments (if still applicable).
@@ -356,21 +365,30 @@
}
}
- invoke([arg0, arg1, arg2, arg3, arg4]) {
+ invoke([arg0 = _sentinel, arg1 = _sentinel, arg2 = _sentinel,
+ arg3 = _sentinel, arg4 = _sentinel]) {
return guardAsync(() {
++_actualCalls;
- if (!_shouldCallBack()) return;
- if (!?arg0) return _callback();
- if (!?arg1) return _callback(arg0);
- if (!?arg2) return _callback(arg0, arg1);
- if (!?arg3) return _callback(arg0, arg1, arg2);
- if (!?arg4) return _callback(arg0, arg1, arg2, arg3);
- _testCase.error(
- 'unittest lib does not support callbacks with more than'
- ' 4 arguments.',
- '');
- },
- _after, _testNum);
+ if (!_shouldCallBack()) {
+ return;
+ } else if (arg0 == _sentinel) {
+ return _callback();
+ } else if (arg1 == _sentinel) {
+ return _callback(arg0);
+ } else if (arg2 == _sentinel) {
+ return _callback(arg0, arg1);
+ } else if (arg3 == _sentinel) {
+ return _callback(arg0, arg1, arg2);
+ } else if (arg4 == _sentinel) {
+ return _callback(arg0, arg1, arg2, arg3);
+ } else {
+ _testCase.error(
+ 'unittest lib does not support callbacks with more than'
+ ' 4 arguments.',
+ '');
+ }
+ },
+ _after, _testNum);
}
invoke0() {
« no previous file with comments | « pkg/unittest/mock.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698