OLD | NEW |
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 library future_test; | 5 library future_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:isolate'; | 8 import 'dart:isolate'; |
9 | 9 |
10 testImmediate() { | 10 testImmediate() { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 var port = new ReceivePort(); | 94 var port = new ReceivePort(); |
95 future | 95 future |
96 .then((v) { throw "Value not expected"; }) | 96 .then((v) { throw "Value not expected"; }) |
97 .catchError((e) { | 97 .catchError((e) { |
98 Expect.equals(e.error, ex); | 98 Expect.equals(e.error, ex); |
99 port.close(); | 99 port.close(); |
100 }, test: (e) => e == ex); | 100 }, test: (e) => e == ex); |
101 completer.completeError(ex); | 101 completer.completeError(ex); |
102 } | 102 } |
103 | 103 |
104 testExceptionNoSuccessListeners() { | |
105 final completer = new Completer<int>(); | |
106 final future = completer.future; | |
107 final ex = new Exception(); | |
108 completer.completeException(ex); // future.then is not called, so no exception | |
109 } | |
110 | |
111 testExceptionHandler() { | 104 testExceptionHandler() { |
112 final completer = new Completer<int>(); | 105 final completer = new Completer<int>(); |
113 final future = completer.future; | 106 final future = completer.future; |
114 final ex = new Exception(); | 107 final ex = new Exception(); |
115 | 108 |
116 var ex2; | 109 var ex2; |
117 var done = future.catchError((e) { ex2 = e.error; }); | 110 var done = future.catchError((e) { ex2 = e.error; }); |
118 completer.completeError(ex); | 111 completer.completeError(ex); |
119 | 112 |
120 var port = new ReceivePort(); | 113 var port = new ReceivePort(); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 testFutureAsStreamCompleteImmediate(); | 361 testFutureAsStreamCompleteImmediate(); |
369 testFutureAsStreamCompleteErrorAfter(); | 362 testFutureAsStreamCompleteErrorAfter(); |
370 testFutureAsStreamWrapper(); | 363 testFutureAsStreamWrapper(); |
371 | 364 |
372 testFutureWhenCompleteValue(); | 365 testFutureWhenCompleteValue(); |
373 testFutureWhenCompleteError(); | 366 testFutureWhenCompleteError(); |
374 testFutureWhenCompleteValueNewError(); | 367 testFutureWhenCompleteValueNewError(); |
375 testFutureWhenCompleteErrorNewError(); | 368 testFutureWhenCompleteErrorNewError(); |
376 } | 369 } |
377 | 370 |
OLD | NEW |