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

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

Issue 2774783002: Re-land "Format all multitests" (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « tests/language/sync_generator3_test.dart ('k') | tests/language/syntax_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 Iterable<int> foo1() sync* { 7 Iterable<int> foo1() sync* {
8 yield 1; 8 yield 1;
9 } 9 }
10 10
11 Iterable<int> foo2(p) sync* { 11 Iterable<int> foo2(p) sync* {
12 bool t = false; 12 bool t = false;
13 yield null; 13 yield null;
14 while (true) { 14 while (true) {
15 a: for (int i = 0; i < p; i++) { 15 a:
16 for (int i = 0; i < p; i++) {
16 if (!t) { 17 if (!t) {
17 for (int j = 0; j < 3; j++) { 18 for (int j = 0; j < 3; j++) {
18 yield -1; 19 yield -1;
19 t = true; 20 t = true;
20 break a; 21 break a;
21 } 22 }
22 } 23 }
23 yield i; 24 yield i;
24 } 25 }
25 } 26 }
26 } 27 }
27 28
28 // p is copied to all Iterators from the Iterable returned by foo3. 29 // p is copied to all Iterators from the Iterable returned by foo3.
29 // Also each iterator will have its own i. 30 // Also each iterator will have its own i.
30 Iterable<int> foo3(int p) sync* { 31 Iterable<int> foo3(int p) sync* {
31 int i = 0; 32 int i = 0;
32 i++; 33 i++;
33 p++; 34 p++;
34 yield p + i; 35 yield p + i;
35 } 36 }
36 37
37 main() { 38 main() {
38 Expect.listEquals([1], foo1().toList()); 39 Expect.listEquals([1], foo1().toList());
39 Expect.listEquals([null, -1, 0, 1, 2, 3, 0, 1, 2, 3], 40 Expect.listEquals(
40 foo2(4).take(10).toList()); 41 [null, -1, 0, 1, 2, 3, 0, 1, 2, 3], foo2(4).take(10).toList());
41 Iterable t = foo3(0); 42 Iterable t = foo3(0);
42 Iterator it1 = t.iterator; 43 Iterator it1 = t.iterator;
43 Iterator it2 = t.iterator; //# copyParameters: ok 44 Iterator it2 = t.iterator; //# copyParameters: ok
44 it1.moveNext(); 45 it1.moveNext();
45 it2.moveNext(); //# copyParameters: continued 46 it2.moveNext(); //# copyParameters: continued
46 Expect.equals(2, it1.current); 47 Expect.equals(2, it1.current);
47 // TODO(sigurdm): Check up on the spec here. 48 // TODO(sigurdm): Check up on the spec here.
48 Expect.equals(2, it2.current); // //# copyParameters: continued 49 Expect.equals(2, it2.current); // //# copyParameters: continued
49 Expect.isFalse(it1.moveNext()); 50 Expect.isFalse(it1.moveNext());
50 // Test that two `moveNext()` calls are fine. 51 // Test that two `moveNext()` calls are fine.
51 Expect.isFalse(it1.moveNext()); 52 Expect.isFalse(it1.moveNext());
52 Expect.isFalse(it2.moveNext()); //# copyParameters: continued 53 Expect.isFalse(it2.moveNext()); //# copyParameters: continued
53 Expect.isFalse(it2.moveNext()); //# copyParameters: continued 54 Expect.isFalse(it2.moveNext()); //# copyParameters: continued
54 } 55 }
OLDNEW
« no previous file with comments | « tests/language/sync_generator3_test.dart ('k') | tests/language/syntax_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698