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

Side by Side Diff: tests/corelib/future_test.dart

Issue 11308281: Preserve the stack trace for rethrown exceptions in Future.transformException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « sdk/lib/core/future_impl.dart ('k') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Tests for Future.immediate 5 // Tests for Future.immediate
6 6
7 testImmediate() { 7 testImmediate() {
8 final future = new Future<String>.immediate("42"); 8 final future = new Future<String>.immediate("42");
9 Expect.isTrue(future.isComplete); 9 Expect.isTrue(future.isComplete);
10 Expect.isTrue(future.hasValue); 10 Expect.isTrue(future.hasValue);
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 final completer = new Completer(); 344 final completer = new Completer();
345 final chained = completer.future.chain((_) { 345 final chained = completer.future.chain((_) {
346 throw 'whoops!'; 346 throw 'whoops!';
347 }); 347 });
348 348
349 final stackTrace = 'fake stack trace'; 349 final stackTrace = 'fake stack trace';
350 completer.complete('blah'); 350 completer.complete('blah');
351 Expect.isNotNull(chained.stackTrace); 351 Expect.isNotNull(chained.stackTrace);
352 } 352 }
353 353
354 testCallStackIsPreservedIfExceptionIsRethrownInTransformException() {
355 final completer = new Completer();
356 var chained = completer.future.chain((_) {
357 throw 'whoops!';
358 });
359 var transformed = chained.transformException((e) {
360 throw e;
361 });
362
363 completer.complete('blah');
364 Expect.equals(transformed.stackTrace, chained.stackTrace);
365 }
366
354 // Tests for mixed usage of [onComplete], [then], and [handleException] 367 // Tests for mixed usage of [onComplete], [then], and [handleException]
355 368
356 testCompleteWithCompletionAndSuccessHandlers() { 369 testCompleteWithCompletionAndSuccessHandlers() {
357 final completer = new Completer<int>(); 370 final completer = new Completer<int>();
358 final future = completer.future; 371 final future = completer.future;
359 372
360 var valueFromSuccessHandler; 373 var valueFromSuccessHandler;
361 var valueFromCompletionHandler; 374 var valueFromCompletionHandler;
362 future.onComplete((f) { 375 future.onComplete((f) {
363 Expect.isNotNull(valueFromSuccessHandler); 376 Expect.isNotNull(valueFromSuccessHandler);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 testExceptionHandlerReturnsTrue2(); 683 testExceptionHandlerReturnsTrue2();
671 testExceptionHandlerReturnsFalse(); 684 testExceptionHandlerReturnsFalse();
672 testExceptionHandlerReturnsFalse2(); 685 testExceptionHandlerReturnsFalse2();
673 testExceptionHandlerAfterCompleteThenNotCalled(); 686 testExceptionHandlerAfterCompleteThenNotCalled();
674 testExceptionHandlerAfterCompleteReturnsFalseThenThrows(); 687 testExceptionHandlerAfterCompleteReturnsFalseThenThrows();
675 testCallStackThrowsIfNotComplete(); 688 testCallStackThrowsIfNotComplete();
676 testCallStackIsNullIfCompletedSuccessfully(); 689 testCallStackIsNullIfCompletedSuccessfully();
677 testCallStackReturnsCallstackPassedToCompleteException(); 690 testCallStackReturnsCallstackPassedToCompleteException();
678 testCallStackIsCapturedIfTransformCallbackThrows(); 691 testCallStackIsCapturedIfTransformCallbackThrows();
679 testCallStackIsCapturedIfChainCallbackThrows(); 692 testCallStackIsCapturedIfChainCallbackThrows();
693 testCallStackIsPreservedIfExceptionIsRethrownInTransformException();
680 testCompleteWithCompletionAndSuccessHandlers(); 694 testCompleteWithCompletionAndSuccessHandlers();
681 testExceptionWithCompletionAndSuccessHandlers(); 695 testExceptionWithCompletionAndSuccessHandlers();
682 testExceptionWithCompletionAndSuccessAndExceptionHandlers(); 696 testExceptionWithCompletionAndSuccessAndExceptionHandlers();
683 testTransformSuccess(); 697 testTransformSuccess();
684 testTransformFutureFails(); 698 testTransformFutureFails();
685 testTransformTransformerFails(); 699 testTransformTransformerFails();
686 testChainSuccess(); 700 testChainSuccess();
687 testChainFirstFutureFails(); 701 testChainFirstFutureFails();
688 testChainTransformerFails(); 702 testChainTransformerFails();
689 testChainSecondFutureFails(); 703 testChainSecondFutureFails();
690 testTransformExceptionCompletesNormally(); 704 testTransformExceptionCompletesNormally();
691 testTransformExceptionThrows(); 705 testTransformExceptionThrows();
692 testTransformExceptionReturns(); 706 testTransformExceptionReturns();
693 testTransformExceptionReturnsAFuture(); 707 testTransformExceptionReturnsAFuture();
694 testExceptionTravelsAlongBothBranches(); 708 testExceptionTravelsAlongBothBranches();
695 testExceptionTravelsAlongBothBranchesAfterComplete(); 709 testExceptionTravelsAlongBothBranchesAfterComplete();
696 testExceptionIsHandledInBaseAndBranch(); 710 testExceptionIsHandledInBaseAndBranch();
697 testExceptionIsHandledInBaseAndBranchAfterComplete(); 711 testExceptionIsHandledInBaseAndBranchAfterComplete();
698 } 712 }
OLDNEW
« no previous file with comments | « sdk/lib/core/future_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698