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

Unified Diff: lib/unittest/unittest.dart

Issue 10766005: Allow asynchronous tests to explicitly register exceptions along with stack traces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/unittest/unittest.dart
diff --git a/lib/unittest/unittest.dart b/lib/unittest/unittest.dart
index 58a2898854a5aff1295eef47632805893e3769ea..7d9b68b994f1722d2d99dfab4042645a679d183f 100644
--- a/lib/unittest/unittest.dart
+++ b/lib/unittest/unittest.dart
@@ -669,13 +669,25 @@ _runTests() {
guardAsync(tryBody, [finallyBody]) {
try {
return tryBody();
- } catch (ExpectException e, var trace) {
+ } catch (var e, var trace) {
+ registerException(e, trace);
+ } finally {
+ _state = _READY;
+ if (finallyBody != null) finallyBody();
+ }
+}
+
+/**
+ * Registers that an exception was caught for the current test.
+ */
+registerException(e, [trace]) {
+ if (e is ExpectException) {
Expect.isTrue(_currentTest < _tests.length);
if (_state != _UNCAUGHT_ERROR) {
_tests[_currentTest].fail(e.message,
trace == null ? '' : trace.toString());
}
- } catch (var e, var trace) {
+ } else {
if (_state == _RUNNING_TEST) {
// If a random exception is thrown from within a test, we consider that
// a test failure too. A test case implicitly has an expectation that it
@@ -686,9 +698,6 @@ guardAsync(tryBody, [finallyBody]) {
_tests[_currentTest].error('Caught $e',
trace == null ? '' : trace.toString());
}
- } finally {
- _state = _READY;
- if (finallyBody != null) finallyBody();
}
}
« no previous file with comments | « no previous file | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698