| OLD | NEW |
| 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, specify the relative path to | 8 * To import this library, specify the relative path to |
| 9 * pkg/unittest/unittest.dart. | 9 * pkg/unittest/unittest.dart. |
| 10 * | 10 * |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } catch (e) { | 231 } catch (e) { |
| 232 threw = true; | 232 threw = true; |
| 233 | 233 |
| 234 // Also let the callback look at it. | 234 // Also let the callback look at it. |
| 235 if (callback != null) { | 235 if (callback != null) { |
| 236 var result = callback(e); | 236 var result = callback(e); |
| 237 | 237 |
| 238 // If the callback explicitly returned false, treat that like an | 238 // If the callback explicitly returned false, treat that like an |
| 239 // expectation too. (If it returns null, though, don't.) | 239 // expectation too. (If it returns null, though, don't.) |
| 240 if (result == false) { | 240 if (result == false) { |
| 241 _fail('Exception:\n$e\ndid not match expectation.'); | 241 fail('Exception:\n$e\ndid not match expectation.'); |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 if (threw != true) _fail('An expected exception was not thrown.'); | 246 if (threw != true) fail('An expected exception was not thrown.'); |
| 247 } | 247 } |
| 248 | 248 |
| 249 /** | 249 /** |
| 250 * Creates a new test case with the given description and body. The | 250 * Creates a new test case with the given description and body. The |
| 251 * description will include the descriptions of any surrounding group() | 251 * description will include the descriptions of any surrounding group() |
| 252 * calls. | 252 * calls. |
| 253 */ | 253 */ |
| 254 void test(String spec, TestFunction body) { | 254 void test(String spec, TestFunction body) { |
| 255 ensureInitialized(); | 255 ensureInitialized(); |
| 256 _tests.add(new TestCase(_tests.length + 1, _fullSpec(spec), body, 0)); | 256 _tests.add(new TestCase(_tests.length + 1, _fullSpec(spec), body, 0)); |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 } | 871 } |
| 872 | 872 |
| 873 /** Enable a test by ID. */ | 873 /** Enable a test by ID. */ |
| 874 void enableTest(int testId) => _setTestEnabledState(testId, true); | 874 void enableTest(int testId) => _setTestEnabledState(testId, true); |
| 875 | 875 |
| 876 /** Disable a test by ID. */ | 876 /** Disable a test by ID. */ |
| 877 void disableTest(int testId) => _setTestEnabledState(testId, false); | 877 void disableTest(int testId) => _setTestEnabledState(testId, false); |
| 878 | 878 |
| 879 /** Signature for a test function. */ | 879 /** Signature for a test function. */ |
| 880 typedef void TestFunction(); | 880 typedef void TestFunction(); |
| OLD | NEW |