Chromium Code Reviews| Index: lib/unittest/unittest.dart |
| diff --git a/lib/unittest/unittest.dart b/lib/unittest/unittest.dart |
| index 8d4d0171dd143217f092d02d7ffbc71eef569439..4844269dd694243c0863de9f16fb62888d9d9e2a 100644 |
| --- a/lib/unittest/unittest.dart |
| +++ b/lib/unittest/unittest.dart |
| @@ -143,6 +143,7 @@ final _RUNNING_TEST = 2; |
| final _UNCAUGHT_ERROR = 3; |
| int _state = _UNINITIALIZED; |
| +String _uncaughtErrorMessage = null; |
| final _PASS = 'pass'; |
| final _FAIL = 'fail'; |
| @@ -168,7 +169,7 @@ void expectThrow(function) { |
| * calls. |
| */ |
| void test(String spec, TestFunction body) { |
| - _ensureInitialized(); |
| + ensureInitialized(); |
| _tests.add(new TestCase(_tests.length + 1, _fullSpec(spec), body, 0)); |
| } |
| @@ -180,7 +181,7 @@ void test(String spec, TestFunction body) { |
| */ |
| // TODO(sigmund): deprecate this API |
| void asyncTest(String spec, int callbacks, TestFunction body) { |
| - _ensureInitialized(); |
| + ensureInitialized(); |
| final testCase = new TestCase( |
| _tests.length + 1, _fullSpec(spec), body, callbacks); |
| @@ -201,7 +202,7 @@ void asyncTest(String spec, int callbacks, TestFunction body) { |
| * reported by the unittest framework. |
| */ |
| // TODO(sigmund): expose this functionality |
| -Function _later0(Function callback) { |
| +Function later0(Function callback) { |
|
Bob Nystrom
2012/04/20 22:31:36
I remember discussing it, but I don't remember the
Siggi Cherem (dart-lang)
2012/04/21 00:03:43
I tried the approach that conflates them in a sing
|
| Expect.isTrue(_currentTest < _tests.length); |
| var testCase = _tests[_currentTest]; |
| testCase.callbacks++; |
| @@ -211,8 +212,8 @@ Function _later0(Function callback) { |
| } |
| // TODO(sigmund): expose this functionality |
|
Emily Fortuna
2012/04/20 20:06:19
Comment obsolete now?
Siggi Cherem (dart-lang)
2012/04/21 00:03:43
Done.
|
| -/** Like [_later0] but expecting a callback with 1 argument. */ |
| -Function _later1(Function callback) { |
| +/** Like [later0] but expecting a callback with 1 argument. */ |
| +Function later1(Function callback) { |
|
Emily Fortuna
2012/04/20 20:06:19
I'm not thrilled with the names of these functions
Siggi Cherem (dart-lang)
2012/04/21 00:03:43
I'm not thrilled either. There is a way to elimina
|
| Expect.isTrue(_currentTest < _tests.length); |
| var testCase = _tests[_currentTest]; |
| testCase.callbacks++; |
| @@ -222,8 +223,8 @@ Function _later1(Function callback) { |
| } |
| // TODO(sigmund): expose this functionality |
| -/** Like [_later0] but expecting a callback with 2 arguments. */ |
| -Function _later2(Function callback) { |
| +/** Like [later0] but expecting a callback with 2 arguments. */ |
| +Function later2(Function callback) { |
| Expect.isTrue(_currentTest < _tests.length); |
| var testCase = _tests[_currentTest]; |
| testCase.callbacks++; |
| @@ -237,7 +238,7 @@ Function _later2(Function callback) { |
| * body of the function passed to this will inherit this group's description. |
| */ |
| void group(String description, void body()) { |
| - _ensureInitialized(); |
| + ensureInitialized(); |
| // Concatenate the new group. |
| final oldGroup = _currentGroup; |
| @@ -275,6 +276,7 @@ void callbackDone() { |
| } |
| } |
| +/** Menchanism to notify that an error was caught outside of this library. */ |
|
Bob Nystrom
2012/04/20 22:31:36
Should this even be public?
Siggi Cherem (dart-lang)
2012/04/21 00:03:43
Yes - we need it to be public so that unittest can
Bob Nystrom
2012/04/23 17:34:07
In that case, can we rename it something a little
|
| void notifyError(String msg, String trace) { |
| if (_currentTest < _tests.length) { |
| final testCase = _tests[_currentTest]; |
| @@ -284,6 +286,8 @@ void notifyError(String msg, String trace) { |
| _currentTest++; |
| _testRunner(); |
| } |
| + } else { |
| + _uncaughtErrorMessage = "$msg: $trace"; |
| } |
| } |
| @@ -380,7 +384,8 @@ _completeTests() { |
| } |
| } |
| - _config.onDone(testsPassed_, testsFailed_, testsErrors_, _tests); |
| + _config.onDone(testsPassed_, testsFailed_, testsErrors_, _tests, |
| + _uncaughtErrorMessage); |
| } |
| String _fullSpec(String spec) { |
| @@ -391,7 +396,7 @@ String _fullSpec(String spec) { |
| /** |
| * Lazily initializes the test library if not already initialized. |
| */ |
| -_ensureInitialized() { |
| +ensureInitialized() { |
| if (_state != _UNINITIALIZED) return; |
| _tests = <TestCase>[]; |