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

Side by Side Diff: pkg/unittest/lib/unittest.dart

Issue 12366004: When we have excess callbacks, throw instead of calling error() so that we (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/unittest/test/unittest_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * A library for writing dart unit tests. 6 * A library for writing dart unit tests.
7 * 7 *
8 * To import this library, use the pub package manager. 8 * To import this library, use the pub package manager.
9 * Create a pubspec.yaml file in your project and add 9 * Create a pubspec.yaml file in your project and add
10 * a dependency on unittest with the following lines: 10 * a dependency on unittest with the following lines:
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 return guardAsync( 425 return guardAsync(
426 () { 426 () {
427 ++_actualCalls; 427 ++_actualCalls;
428 if (_shouldCallBack()) { 428 if (_shouldCallBack()) {
429 return _callback(arg1, arg2); 429 return _callback(arg1, arg2);
430 } 430 }
431 }, 431 },
432 _after, _testNum); 432 _after, _testNum);
433 } 433 }
434 434
435 /** Returns false if we exceded the number of expected calls. */ 435 /** Returns true if we have not exceeded the number of expected calls. */
436 bool _checkCallCount() { 436 bool _checkCallCount() {
437 if (_actualCalls > _expectedCalls) { 437 if (_actualCalls > _expectedCalls) {
438 _testCase.error('Callback ${_id}called more times than expected ' 438 throw new TestFailure('Callback ${_id}called more times than expected '
439 '($_actualCalls > $_expectedCalls).', ''); 439 '($_actualCalls > $_expectedCalls).');
440 return false; 440 return false;
Jennifer Messerly 2013/02/27 22:42:55 remove?
441 } 441 }
442 return true; 442 return true;
443 } 443 }
444 } 444 }
445 445
446 /** 446 /**
447 * Indicate that [callback] is expected to be called a [count] number of times 447 * Indicate that [callback] is expected to be called a [count] number of times
448 * (by default 1). The unittest framework will wait for the callback to run the 448 * (by default 1). The unittest framework will wait for the callback to run the
449 * specified [count] times before it continues with the following test. Using 449 * specified [count] times before it continues with the following test. Using
450 * [_expectAsync] will also ensure that errors that occur within [callback] are 450 * [_expectAsync] will also ensure that errors that occur within [callback] are
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 } 881 }
882 882
883 /** Enable a test by ID. */ 883 /** Enable a test by ID. */
884 void enableTest(int testId) => _setTestEnabledState(testId, true); 884 void enableTest(int testId) => _setTestEnabledState(testId, true);
885 885
886 /** Disable a test by ID. */ 886 /** Disable a test by ID. */
887 void disableTest(int testId) => _setTestEnabledState(testId, false); 887 void disableTest(int testId) => _setTestEnabledState(testId, false);
888 888
889 /** Signature for a test function. */ 889 /** Signature for a test function. */
890 typedef dynamic TestFunction(); 890 typedef dynamic TestFunction();
OLDNEW
« no previous file with comments | « no previous file | pkg/unittest/test/unittest_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698