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

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

Issue 10546131: Update Future tests to match new "stackTrace" property. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 future.handleException((e) { ex2 = e; return false; }); 301 future.handleException((e) { ex2 = e; return false; });
302 Expect.throws(() { future.then((e) { }); }); 302 Expect.throws(() { future.then((e) { }); });
303 Expect.equals(ex, ex2); 303 Expect.equals(ex, ex2);
304 } 304 }
305 305
306 // Tests for accessing the exception call stack. 306 // Tests for accessing the exception call stack.
307 307
308 testCallStackThrowsIfNotComplete() { 308 testCallStackThrowsIfNotComplete() {
309 var exception; 309 var exception;
310 try { 310 try {
311 new Completer().future.callStack; 311 new Completer().future.stackTrace;
312 } catch (var ex) { 312 } catch (var ex) {
313 exception = ex; 313 exception = ex;
314 } 314 }
315 315
316 Expect.isTrue(exception is FutureNotCompleteException); 316 Expect.isTrue(exception is FutureNotCompleteException);
317 } 317 }
318 318
319 testCallStackIsNullIfCompletedSuccessfully() { 319 testCallStackIsNullIfCompletedSuccessfully() {
320 Expect.isNull(new Future.immediate('blah').callStack); 320 Expect.isNull(new Future.immediate('blah').stackTrace);
321 } 321 }
322 322
323 testCallStackReturnsCallstackPassedToCompleteException() { 323 testCallStackReturnsCallstackPassedToCompleteException() {
324 final completer = new Completer(); 324 final completer = new Completer();
325 final future = completer.future; 325 final future = completer.future;
326 326
327 final callstack = 'fake call stack'; 327 final stackTrace = 'fake stack trace';
328 completer.completeException(new Exception(), callstack); 328 completer.completeException(new Exception(), stackTrace);
329 Expect.equals(callstack, future.callStack); 329 Expect.equals(stackTrace, future.stackTrace);
330 } 330 }
331 331
332 testCallStackIsCapturedIfTransformCallbackThrows() { 332 testCallStackIsCapturedIfTransformCallbackThrows() {
333 final completer = new Completer(); 333 final completer = new Completer();
334 final transformed = completer.future.transform((_) { 334 final transformed = completer.future.transform((_) {
335 throw 'whoops!'; 335 throw 'whoops!';
336 }); 336 });
337 337
338 final callstack = 'fake call stack'; 338 final stackTrace = 'fake stack trace';
339 completer.complete('blah'); 339 completer.complete('blah');
340 Expect.isNotNull(transformed.callStack); 340 Expect.isNotNull(transformed.stackTrace);
341 } 341 }
342 342
343 testCallStackIsCapturedIfChainCallbackThrows() { 343 testCallStackIsCapturedIfChainCallbackThrows() {
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 callstack = 'fake call stack'; 349 final stackTrace = 'fake stack trace';
350 completer.complete('blah'); 350 completer.complete('blah');
351 Expect.isNotNull(chained.callStack); 351 Expect.isNotNull(chained.stackTrace);
352 } 352 }
353 353
354 // Tests for mixed usage of [onComplete], [then], and [handleException] 354 // Tests for mixed usage of [onComplete], [then], and [handleException]
355 355
356 testCompleteWithCompletionAndSuccessHandlers() { 356 testCompleteWithCompletionAndSuccessHandlers() {
357 final completer = new Completer<int>(); 357 final completer = new Completer<int>();
358 final future = completer.future; 358 final future = completer.future;
359 359
360 var valueFromSuccessHandler; 360 var valueFromSuccessHandler;
361 var valueFromCompletionHandler; 361 var valueFromCompletionHandler;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 testExceptionWithCompletionAndSuccessHandlers(); 527 testExceptionWithCompletionAndSuccessHandlers();
528 testExceptionWithCompletionAndSuccessAndExceptionHandlers(); 528 testExceptionWithCompletionAndSuccessAndExceptionHandlers();
529 testTransformSuccess(); 529 testTransformSuccess();
530 testTransformFutureFails(); 530 testTransformFutureFails();
531 testTransformTransformerFails(); 531 testTransformTransformerFails();
532 testChainSuccess(); 532 testChainSuccess();
533 testChainFirstFutureFails(); 533 testChainFirstFutureFails();
534 testChainTransformerFails(); 534 testChainTransformerFails();
535 testChainSecondFutureFails(); 535 testChainSecondFutureFails();
536 } 536 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698