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

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

Issue 12340082: pkg/unittest: fixed asserts around currentTestCase (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 | no next file » | 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 part of unittest; 5 part of unittest;
6 6
7 /** 7 /**
8 * Hooks to configure the unittest library for different platforms. This class 8 * Hooks to configure the unittest library for different platforms. This class
9 * implements the API in a platform-independent way. Tests that want to take 9 * implements the API in a platform-independent way. Tests that want to take
10 * advantage of the platform can create a subclass and override methods from 10 * advantage of the platform can create a subclass and override methods from
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 /** Called as soon as the unittest framework starts running. */ 47 /** Called as soon as the unittest framework starts running. */
48 void onStart() {} 48 void onStart() {}
49 49
50 /** 50 /**
51 * Called when each test starts. Useful to show intermediate progress on 51 * Called when each test starts. Useful to show intermediate progress on
52 * a test suite. 52 * a test suite.
53 */ 53 */
54 void onTestStart(TestCase testCase) { 54 void onTestStart(TestCase testCase) {
55 assert(testCase != null);
56 assert(_currentTestCase == null);
55 _currentTestCase = testCase; 57 _currentTestCase = testCase;
56 } 58 }
57 59
58 /** 60 /**
59 * Called when each test is completed. Useful to show intermediate progress on 61 * Called when each test is completed. Useful to show intermediate progress on
60 * a test suite. 62 * a test suite.
61 */ 63 */
62 void onTestResult(TestCase testCase) { 64 void onTestResult(TestCase testCase) {
63 _currentTestCase = null; 65 assert(testCase != null);
66 if(_currentTestCase != null) {
Siggi Cherem (dart-lang) 2013/02/26 19:37:37 nit: since this is just for assertions and nothing
67 assert(_currentTestCase == testCase);
68 _currentTestCase = null;
69 }
64 } 70 }
65 71
66 /** 72 /**
67 * Can be called by tests to log status. Tests should use this 73 * Can be called by tests to log status. Tests should use this
68 * instead of print. Subclasses should not override this; they 74 * instead of print. Subclasses should not override this; they
69 * should instead override logMessage which is passed the test case. 75 * should instead override logMessage which is passed the test case.
70 */ 76 */
71 void logMessage(String message) { 77 void logMessage(String message) {
72 if (currentTestCase == null || _currentTest >= _tests.length || 78 if (currentTestCase == null || _currentTest >= _tests.length ||
73 currentTestCase.id != _tests[_currentTest].id) { 79 currentTestCase.id != _tests[_currentTest].id) {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // Currently e.message works in dartium, but not in dartc. 163 // Currently e.message works in dartium, but not in dartc.
158 handleExternalError(e, String message) => 164 handleExternalError(e, String message) =>
159 _reportTestError('$message\nCaught $e', ''); 165 _reportTestError('$message\nCaught $e', '');
160 166
161 _postMessage(String message) { 167 _postMessage(String message) {
162 // In dart2js browser tests, the JavaScript-based test controller 168 // In dart2js browser tests, the JavaScript-based test controller
163 // intercepts calls to print and listens for "secret" messages. 169 // intercepts calls to print and listens for "secret" messages.
164 print(message); 170 print(message);
165 } 171 }
166 } 172 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698