OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 async_start_test; | 5 library async_start_test; |
6 | 6 |
7 import "package:unittest/unittest.dart"; | 7 import "package:unittest/unittest.dart"; |
8 import "dart:async"; | 8 import "dart:async"; |
9 | 9 |
10 main() { | 10 main() { |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 sub.pause(); /// 02: contin
ued | 731 sub.pause(); /// 02: contin
ued |
732 return sync.wait(); /// 02: contin
ued | 732 return sync.wait(); /// 02: contin
ued |
733 }).whenComplete(() { /// 02: contin
ued | 733 }).whenComplete(() { /// 02: contin
ued |
734 expect(list, equals(["*1", 1, "*2"])); /// 02: contin
ued | 734 expect(list, equals(["*1", 1, "*2"])); /// 02: contin
ued |
735 sub.cancel(); /// 02: contin
ued | 735 sub.cancel(); /// 02: contin
ued |
736 return new Future.delayed(MS * 200, () { /// 02: contin
ued | 736 return new Future.delayed(MS * 200, () { /// 02: contin
ued |
737 // Should not have yielded 2 or added *3 while paused. /// 02: contin
ued | 737 // Should not have yielded 2 or added *3 while paused. /// 02: contin
ued |
738 expect(list, equals(["*1", 1, "*2"])); /// 02: contin
ued | 738 expect(list, equals(["*1", 1, "*2"])); /// 02: contin
ued |
739 }); /// 02: contin
ued | 739 }); /// 02: contin
ued |
740 }); /// 02: contin
ued | 740 }); /// 02: contin
ued |
741 }, skip: "other impls aren't passing this test, see " | 741 }); /// 02: contin
ued |
742 "https://github.com/dart-lang/sdk/issues/22853");
/// 02: continued | |
743 }); | 742 }); |
744 | 743 |
745 group("await for", () { | 744 group("await for", () { |
746 mkStream(int n) async* { | 745 mkStream(int n) async* { |
747 for (int i = 0; i < n; i++) yield i; | 746 for (int i = 0; i < n; i++) yield i; |
748 } | 747 } |
749 | 748 |
750 test("simple stream", () { | 749 test("simple stream", () { |
751 f(s) async { | 750 f(s) async { |
752 var r = 0; | 751 var r = 0; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 f(s) async { /// 05: con
tinued | 863 f(s) async { /// 05: con
tinued |
865 var r = 0; /// 05: con
tinued | 864 var r = 0; /// 05: con
tinued |
866 await for (var i in s) { /// 05: con
tinued | 865 await for (var i in s) { /// 05: con
tinued |
867 r += await new Future.delayed(MS * 10, () => i); /// 05: con
tinued | 866 r += await new Future.delayed(MS * 10, () => i); /// 05: con
tinued |
868 } /// 05: con
tinued | 867 } /// 05: con
tinued |
869 return r; /// 05: con
tinued | 868 return r; /// 05: con
tinued |
870 } /// 05: con
tinued | 869 } /// 05: con
tinued |
871 return f(sc.stream).then((v) { /// 05: con
tinued | 870 return f(sc.stream).then((v) { /// 05: con
tinued |
872 expect(v, equals(10)); /// 05: con
tinued | 871 expect(v, equals(10)); /// 05: con
tinued |
873 }); /// 05: con
tinued | 872 }); /// 05: con
tinued |
874 }, skip: "other impls aren't passing this test, see " | 873 }); /// 05: con
tinued |
875 "https://github.com/dart-lang/sdk/issues/22853");
/// 05: continued | |
876 }); | 874 }); |
877 } | 875 } |
878 | 876 |
879 // Obscuring identity function. | 877 // Obscuring identity function. |
880 id(x) { | 878 id(x) { |
881 try { | 879 try { |
882 if (x != null) throw x; | 880 if (x != null) throw x; |
883 } catch (e) { | 881 } catch (e) { |
884 return e; | 882 return e; |
885 } | 883 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 } | 921 } |
924 | 922 |
925 // Release whoever is currently waiting. | 923 // Release whoever is currently waiting. |
926 void release([v]) { | 924 void release([v]) { |
927 if (_completer != null) { | 925 if (_completer != null) { |
928 _completer.complete(v); | 926 _completer.complete(v); |
929 _completer = null; | 927 _completer = null; |
930 } | 928 } |
931 } | 929 } |
932 } | 930 } |
OLD | NEW |