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

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

Issue 12217142: Unit test improvements: (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 unified diff | Download patch | Annotate | Revision Log
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:
11 * dependencies: 11 * dependencies:
12 * unittest: 12 * unittest: any
13 * sdk: unittest
14 * 13 *
15 * Then run 'pub install' from your project directory or using 14 * Then run 'pub install' from your project directory or using
16 * the DartEditor. 15 * the DartEditor.
17 * 16 *
18 * Please see [Pub Getting Started](http://pub.dartlang.org/doc) 17 * Please see [Pub Getting Started](http://pub.dartlang.org/doc)
19 * for more details about the pub package manager. 18 * for more details about the pub package manager.
20 * 19 *
21 * ##Concepts## 20 * ##Concepts##
22 * 21 *
23 * * Tests: Tests are specified via the top-level function [test], they can be 22 * * Tests: Tests are specified via the top-level function [test], they can be
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 _callback = callback; 346 _callback = callback;
348 _shouldCallBack = shouldCallBack; 347 _shouldCallBack = shouldCallBack;
349 _isDone = isDone; 348 _isDone = isDone;
350 _expectedCalls = expectedCalls; 349 _expectedCalls = expectedCalls;
351 _testNum = _currentTest; 350 _testNum = _currentTest;
352 _testCase = _tests[_currentTest]; 351 _testCase = _tests[_currentTest];
353 if (expectedCalls > 0) { 352 if (expectedCalls > 0) {
354 _testCase.callbackFunctionsOutstanding++; 353 _testCase.callbackFunctionsOutstanding++;
355 } 354 }
356 _id = ''; 355 _id = '';
356 // If the callback is not an anonymous closure, try to get the
357 // name.
358 var fname = callback.toString();
359 var prefix = "Function '";
360 var pos = fname.indexOf(prefix);
361 if (pos > 0) {
362 pos += prefix.length;
363 var epos = fname.indexOf("'", pos);
364 if (epos > 0) {
365 _id = "${fname.substring(pos, epos)} ";
366 }
367 }
357 } 368 }
358 369
359 _SpreadArgsHelper(callback, shouldCallBack, isDone) { 370 _SpreadArgsHelper(callback, shouldCallBack, isDone) {
360 _init(callback, shouldCallBack, isDone); 371 _init(callback, shouldCallBack, isDone);
361 } 372 }
362 373
363 _SpreadArgsHelper.fixedCallCount(callback, expectedCalls, id) { 374 _SpreadArgsHelper.fixedCallCount(callback, expectedCalls, id) {
364 _init(callback, _checkCallCount, _allCallsDone, expectedCalls); 375 _init(callback, _checkCallCount, _allCallsDone, expectedCalls);
365 if (id != null) { 376 if (id != null) {
366 _id = "$id "; 377 _id = "$id ";
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 } 923 }
913 924
914 /** Enable a test by ID. */ 925 /** Enable a test by ID. */
915 void enableTest(int testId) => _setTestEnabledState(testId, true); 926 void enableTest(int testId) => _setTestEnabledState(testId, true);
916 927
917 /** Disable a test by ID. */ 928 /** Disable a test by ID. */
918 void disableTest(int testId) => _setTestEnabledState(testId, false); 929 void disableTest(int testId) => _setTestEnabledState(testId, false);
919 930
920 /** Signature for a test function. */ 931 /** Signature for a test function. */
921 typedef void TestFunction(); 932 typedef void TestFunction();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698