| 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 'package:async_helper/async_helper.dart'; | 7 import 'package:async_helper/async_helper.dart'; |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 | 10 |
| (...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 testType(name, future.whenComplete(() {}), depth - 1); | 987 testType(name, future.whenComplete(() {}), depth - 1); |
| 988 } | 988 } |
| 989 } | 989 } |
| 990 | 990 |
| 991 for (var value in [42, null]) { | 991 for (var value in [42, null]) { |
| 992 testType("Future($value)", new Future<int>(() => value)); | 992 testType("Future($value)", new Future<int>(() => value)); |
| 993 testType("Future.delayed($value)", | 993 testType("Future.delayed($value)", |
| 994 new Future<int>.delayed(Duration.ZERO, () => value)); | 994 new Future<int>.delayed(Duration.ZERO, () => value)); |
| 995 testType( | 995 testType( |
| 996 "Future.microtask($value)", new Future<int>.microtask(() => value)); | 996 "Future.microtask($value)", new Future<int>.microtask(() => value)); |
| 997 testType("Future.sync($value)", new Future<int>.sync(() => value)); // //
# 01: ok | 997 testType("Future.sync($value)", new Future<int>.sync(() => value)); //# 01:
ok |
| 998 testType("Future.sync(future($value))", // //
# 01: continued | 998 testType("Future.sync(future($value))", // //# 01:
continued |
| 999 new Future<int>.sync(() async => new Future<int>.value(value))); //
# 01: continued | 999 new Future<int>.sync(() => new Future<int>.value(value))); //# 01:
continued |
| 1000 testType("Future.value($value)", new Future<int>.value(value)); | 1000 testType("Future.value($value)", new Future<int>.value(value)); |
| 1001 } | 1001 } |
| 1002 testType("Completer.future", new Completer<int>().future); | 1002 testType("Completer.future", new Completer<int>().future); |
| 1003 testType("Future.error", new Future<int>.error("ERR")..catchError((_) {})); | 1003 testType("Future.error", new Future<int>.error("ERR")..catchError((_) {})); |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 void testAnyValue() { | 1006 void testAnyValue() { |
| 1007 asyncStart(); | 1007 asyncStart(); |
| 1008 var cs = new List.generate(3, (_) => new Completer()); | 1008 var cs = new List.generate(3, (_) => new Completer()); |
| 1009 var result = Future.any(cs.map((x) => x.future)); | 1009 var result = Future.any(cs.map((x) => x.future)); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 return (new StreamController() | 1231 return (new StreamController() |
| 1232 ..add(_result) | 1232 ..add(_result) |
| 1233 ..close()) | 1233 ..close()) |
| 1234 .stream; | 1234 .stream; |
| 1235 } | 1235 } |
| 1236 | 1236 |
| 1237 Future timeout(Duration duration, {onTimeout()}) { | 1237 Future timeout(Duration duration, {onTimeout()}) { |
| 1238 return this; | 1238 return this; |
| 1239 } | 1239 } |
| 1240 } | 1240 } |
| OLD | NEW |