Chromium Code Reviews| 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 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 }); | 869 }); |
| 870 | 870 |
| 871 }, onError: (int index, s) { | 871 }, onError: (int index, s) { |
| 872 Expect.isTrue(index == 0 || index == 2, "$index"); | 872 Expect.isTrue(index == 0 || index == 2, "$index"); |
| 873 Expect.isFalse(uncaughts[index]); | 873 Expect.isFalse(uncaughts[index]); |
| 874 uncaughts[index] = true; | 874 uncaughts[index] = true; |
| 875 asyncEnd(); | 875 asyncEnd(); |
| 876 }); | 876 }); |
| 877 } | 877 } |
| 878 | 878 |
| 879 void testWaitSyncError() { | |
| 880 var cms = const Duration(milliseconds: 100); | |
| 881 var cleanups = new List.filled(3, false); | |
| 882 var uncaughts = new List.filled(3, false); | |
| 883 asyncStart(); | |
| 884 asyncStart(); | |
| 885 runZoned(() { | |
| 886 Future.wait(new Iterable.generate(4, (i) { | |
|
Lasse Reichstein Nielsen
2016/08/18 11:15:08
change to 5, so there is a potential element after
floitsch
2016/08/18 11:42:55
Done.
| |
| 887 if (i != 3) return new Future.delayed(cms * (i + 1), () => i); | |
| 888 throw "throwing synchronously in iterable"; | |
| 889 }), cleanUp: (index) { | |
| 890 Expect.isTrue(0 <= index && index < 4); | |
|
Lasse Reichstein Nielsen
2016/08/18 11:15:08
< 3
Likely not necessary since you use `index` as
floitsch
2016/08/18 11:42:55
Removed the check.
| |
| 891 Expect.isFalse(cleanups[index]); | |
| 892 cleanups[index] = true; | |
| 893 if (cleanups.every((x) => x)) asyncEnd(); | |
| 894 }); | |
| 895 }, onError: (e, s) { | |
| 896 asyncEnd(); | |
| 897 }); | |
| 898 } | |
| 899 | |
| 879 void testBadFuture() { | 900 void testBadFuture() { |
| 880 var bad = new BadFuture(); | 901 var bad = new BadFuture(); |
| 881 // Completing with bad future (then call throws) puts error in result. | 902 // Completing with bad future (then call throws) puts error in result. |
| 882 asyncStart(); | 903 asyncStart(); |
| 883 Completer completer = new Completer(); | 904 Completer completer = new Completer(); |
| 884 completer.complete(bad); | 905 completer.complete(bad); |
| 885 completer.future.then((_) { Expect.fail("unreachable"); }, | 906 completer.future.then((_) { Expect.fail("unreachable"); }, |
| 886 onError: (e, s) { | 907 onError: (e, s) { |
| 887 Expect.isTrue(completer.isCompleted); | 908 Expect.isTrue(completer.isCompleted); |
| 888 asyncEnd(); | 909 asyncEnd(); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1068 testFutureCatchRethrowsAsync(); | 1089 testFutureCatchRethrowsAsync(); |
| 1069 | 1090 |
| 1070 testChainedFutureValue(); | 1091 testChainedFutureValue(); |
| 1071 testChainedFutureValueDelay(); | 1092 testChainedFutureValueDelay(); |
| 1072 testChainedFutureError(); | 1093 testChainedFutureError(); |
| 1073 | 1094 |
| 1074 testSyncFuture_i13368(); | 1095 testSyncFuture_i13368(); |
| 1075 | 1096 |
| 1076 testWaitCleanUp(); | 1097 testWaitCleanUp(); |
| 1077 testWaitCleanUpError(); | 1098 testWaitCleanUpError(); |
| 1099 testWaitSyncError(); | |
| 1078 | 1100 |
| 1079 testBadFuture(); | 1101 testBadFuture(); |
| 1080 | 1102 |
| 1081 testTypes(); | 1103 testTypes(); |
| 1082 | 1104 |
| 1083 testAnyValue(); | 1105 testAnyValue(); |
| 1084 testAnyError(); | 1106 testAnyError(); |
| 1085 testAnyIgnoreIncomplete(); | 1107 testAnyIgnoreIncomplete(); |
| 1086 testAnyIgnoreError(); | 1108 testAnyIgnoreError(); |
| 1087 | 1109 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1139 Future whenComplete(action()) { | 1161 Future whenComplete(action()) { |
| 1140 return new Future.microtask(action).then((_) => this); | 1162 return new Future.microtask(action).then((_) => this); |
| 1141 } | 1163 } |
| 1142 Stream asStream() { | 1164 Stream asStream() { |
| 1143 return (new StreamController()..add(_result)..close()).stream; | 1165 return (new StreamController()..add(_result)..close()).stream; |
| 1144 } | 1166 } |
| 1145 Future timeout(Duration duration, {onTimeout()}) { | 1167 Future timeout(Duration duration, {onTimeout()}) { |
| 1146 return this; | 1168 return this; |
| 1147 } | 1169 } |
| 1148 } | 1170 } |
| OLD | NEW |