| Index: tests/corelib/future_test.dart
|
| diff --git a/tests/corelib/future_test.dart b/tests/corelib/future_test.dart
|
| index c96b2c60538bde9cdf273faef5e21dc7a45c546d..96f5aa66cf58b9246d665a588be7bd8ea6e7aee1 100644
|
| --- a/tests/corelib/future_test.dart
|
| +++ b/tests/corelib/future_test.dart
|
| @@ -206,7 +206,7 @@ testException() {
|
| final ex = new Exception();
|
| future.then((_) {}); // exception is thrown if we plan to use the value
|
| Expect.throws(
|
| - () { completer.completeException(ex); },
|
| + () { completer.completeException(ex); },
|
| check: (e) => e == ex);
|
| }
|
|
|
| @@ -262,7 +262,7 @@ testExceptionHandlerReturnsFalse() {
|
| future.handleException((e) { return false; });
|
| future.handleException((e) { reached = true; return false; }); // overshadowed
|
| Expect.throws(
|
| - () { completer.completeException(ex); },
|
| + () { completer.completeException(ex); },
|
| check: (e) => e == ex);
|
| Expect.isTrue(reached);
|
| }
|
| @@ -303,6 +303,54 @@ testExceptionHandlerAfterCompleteReturnsFalseThenThrows() {
|
| Expect.equals(ex, ex2);
|
| }
|
|
|
| +// Tests for accessing the exception call stack.
|
| +
|
| +testCallStackThrowsIfNotComplete() {
|
| + var exception;
|
| + try {
|
| + new Completer().future.callStack;
|
| + } catch (var ex) {
|
| + exception = ex;
|
| + }
|
| +
|
| + Expect.isTrue(exception is FutureNotCompleteException);
|
| +}
|
| +
|
| +testCallStackIsNullIfCompletedSuccessfully() {
|
| + Expect.isNull(new Future.immediate('blah').callStack);
|
| +}
|
| +
|
| +testCallStackReturnsCallstackPassedToCompleteException() {
|
| + final completer = new Completer();
|
| + final future = completer.future;
|
| +
|
| + final callstack = 'fake call stack';
|
| + completer.completeException(new Exception(), callstack);
|
| + Expect.equals(callstack, future.callStack);
|
| +}
|
| +
|
| +testCallStackIsCapturedIfTransformCallbackThrows() {
|
| + final completer = new Completer();
|
| + final transformed = completer.future.transform((_) {
|
| + throw 'whoops!';
|
| + });
|
| +
|
| + final callstack = 'fake call stack';
|
| + completer.complete('blah');
|
| + Expect.isNotNull(transformed.callStack);
|
| +}
|
| +
|
| +testCallStackIsCapturedIfChainCallbackThrows() {
|
| + final completer = new Completer();
|
| + final chained = completer.future.chain((_) {
|
| + throw 'whoops!';
|
| + });
|
| +
|
| + final callstack = 'fake call stack';
|
| + completer.complete('blah');
|
| + Expect.isNotNull(chained.callStack);
|
| +}
|
| +
|
| // Tests for mixed usage of [onComplete], [then], and [handleException]
|
|
|
| testCompleteWithCompletionAndSuccessHandlers() {
|
| @@ -470,6 +518,11 @@ main() {
|
| testExceptionHandlerReturnsFalse2();
|
| testExceptionHandlerAfterCompleteThenNotCalled();
|
| testExceptionHandlerAfterCompleteReturnsFalseThenThrows();
|
| + testCallStackThrowsIfNotComplete();
|
| + testCallStackIsNullIfCompletedSuccessfully();
|
| + testCallStackReturnsCallstackPassedToCompleteException();
|
| + testCallStackIsCapturedIfTransformCallbackThrows();
|
| + testCallStackIsCapturedIfChainCallbackThrows();
|
| testCompleteWithCompletionAndSuccessHandlers();
|
| testExceptionWithCompletionAndSuccessHandlers();
|
| testExceptionWithCompletionAndSuccessAndExceptionHandlers();
|
|
|