OLD | NEW |
| (Empty) |
1 dart_library.library('syncstar_yield_test', null, /* Imports */[ | |
2 "dart_runtime/dart", | |
3 'dart/core', | |
4 'expect' | |
5 ], /* Lazy imports */[ | |
6 ], function(exports, dart, core, expect) { | |
7 'use strict'; | |
8 let dartx = dart.dartx; | |
9 function* foo1() { | |
10 yield 1; | |
11 } | |
12 dart.fn(foo1, core.Iterable$(core.int), []); | |
13 function* foo2(p) { | |
14 let t = false; | |
15 yield null; | |
16 while (true) { | |
17 a: | |
18 for (let i = 0; dart.notNull(i) < dart.notNull(dart.as(p, core.num)); i
= dart.notNull(i) + 1) { | |
19 if (!dart.notNull(t)) { | |
20 for (let j = 0; dart.notNull(j) < 3; j = dart.notNull(j) + 1) { | |
21 yield -1; | |
22 t = true; | |
23 break a; | |
24 } | |
25 } | |
26 yield i; | |
27 } | |
28 } | |
29 } | |
30 dart.fn(foo2, core.Iterable$(core.int), [dart.dynamic]); | |
31 function* foo3(p) { | |
32 let i = 0; | |
33 i = dart.notNull(i) + 1; | |
34 p = dart.notNull(p) + 1; | |
35 yield dart.notNull(p) + dart.notNull(i); | |
36 } | |
37 dart.fn(foo3, core.Iterable$(core.int), [core.int]); | |
38 function main() { | |
39 expect.Expect.listEquals([1], foo1()[dartx.toList]()); | |
40 expect.Expect.listEquals([null, -1, 0, 1, 2, 3, 0, 1, 2, 3], foo2(4)[dartx.t
ake](10)[dartx.toList]()); | |
41 let t = foo3(0); | |
42 let it1 = t[dartx.iterator]; | |
43 let it2 = t[dartx.iterator]; | |
44 it1.moveNext(); | |
45 it2.moveNext(); | |
46 expect.Expect.equals(2, it1.current); | |
47 expect.Expect.equals(2, it2.current); | |
48 expect.Expect.isFalse(it1.moveNext()); | |
49 expect.Expect.isFalse(it1.moveNext()); | |
50 expect.Expect.isFalse(it2.moveNext()); | |
51 expect.Expect.isFalse(it2.moveNext()); | |
52 } | |
53 dart.fn(main); | |
54 // Exports: | |
55 exports.foo1 = foo1; | |
56 exports.foo2 = foo2; | |
57 exports.foo3 = foo3; | |
58 exports.main = main; | |
59 }); | |
OLD | NEW |