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

Side by Side Diff: tests/language/async_star_stream_take_test.dart

Issue 1270413002: Factor failing tests out of language/async_star_test.dart (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments. Created 5 years, 4 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
OLDNEW
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 import "dart:async";
5 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
6 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
7 8
8 range(start, end) async* { 9 Stream makeStream(int n) async* {
9 for (int i = start; i < end; i++) { 10 for (int i = 0; i < n; i++) yield i;
10 yield i;
11 }
12 }
13
14 concat(a, b) async* {
15 yield* a;
16 yield* b;
17 }
18
19 test() async {
20 Expect.listEquals([1, 2, 3, 11, 12, 13],
21 await concat(range(1, 4), range(11, 14)).toList());
22 } 11 }
23 12
24 main() { 13 main() {
14 f(Stream s) async {
15 var r = 0;
16 await for(var v in s.take(5)) r += v;
17 return r;
18 }
19
25 asyncStart(); 20 asyncStart();
26 test().then((_) { 21 f(makeStream(10)).then((v) {
22 Expect.equals(10, v);
27 asyncEnd(); 23 asyncEnd();
28 }); 24 });
29 } 25 }
26
OLDNEW
« no previous file with comments | « tests/language/async_star_regression_fisk_test.dart ('k') | tests/language/async_star_take_reyield_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698