OLD | NEW |
1 dart_library.library('language/async_star_test_02_multi', null, /* Imports */[ | 1 dart_library.library('language/async_star_test_02_multi', null, /* Imports */[ |
2 'dart_sdk', | 2 'dart_sdk', |
3 'unittest' | 3 'unittest' |
4 ], function load__async_star_test_02_multi(exports, dart_sdk, unittest) { | 4 ], function load__async_star_test_02_multi(exports, dart_sdk, unittest) { |
5 'use strict'; | 5 'use strict'; |
6 const core = dart_sdk.core; | 6 const core = dart_sdk.core; |
| 7 const async = dart_sdk.async; |
7 const _interceptors = dart_sdk._interceptors; | 8 const _interceptors = dart_sdk._interceptors; |
8 const async = dart_sdk.async; | |
9 const dart = dart_sdk.dart; | 9 const dart = dart_sdk.dart; |
10 const dartx = dart_sdk.dartx; | 10 const dartx = dart_sdk.dartx; |
11 const unittest$ = unittest.unittest; | 11 const unittest$ = unittest.unittest; |
12 const src__matcher__expect = unittest.src__matcher__expect; | 12 const src__matcher__expect = unittest.src__matcher__expect; |
13 const src__matcher__core_matchers = unittest.src__matcher__core_matchers; | 13 const src__matcher__core_matchers = unittest.src__matcher__core_matchers; |
14 const src__matcher__numeric_matchers = unittest.src__matcher__numeric_matchers
; | 14 const src__matcher__numeric_matchers = unittest.src__matcher__numeric_matchers
; |
15 const async_star_test_02_multi = Object.create(null); | 15 const async_star_test_02_multi = Object.create(null); |
| 16 let StreamOfint = () => (StreamOfint = dart.constFn(async.Stream$(core.int)))(
); |
16 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c
ore.int)))(); | 17 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c
ore.int)))(); |
| 18 let ListOfint = () => (ListOfint = dart.constFn(core.List$(core.int)))(); |
17 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr
ray$(core.Object)))(); | 19 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr
ray$(core.Object)))(); |
18 let StreamOfint = () => (StreamOfint = dart.constFn(async.Stream$(core.int)))(
); | 20 let VoidToObject = () => (VoidToObject = dart.constFn(dart.functionType(core.O
bject, [])))(); |
| 21 let StreamOfVoidToObject = () => (StreamOfVoidToObject = dart.constFn(async.St
ream$(VoidToObject())))(); |
19 let FutureOfObject = () => (FutureOfObject = dart.constFn(async.Future$(core.O
bject)))(); | 22 let FutureOfObject = () => (FutureOfObject = dart.constFn(async.Future$(core.O
bject)))(); |
| 23 let VoidToFutureOfObject = () => (VoidToFutureOfObject = dart.constFn(dart.fun
ctionType(FutureOfObject(), [])))(); |
| 24 let StreamOfVoidToFutureOfObject = () => (StreamOfVoidToFutureOfObject = dart.
constFn(async.Stream$(VoidToFutureOfObject())))(); |
20 let StreamOfObject = () => (StreamOfObject = dart.constFn(async.Stream$(core.O
bject)))(); | 25 let StreamOfObject = () => (StreamOfObject = dart.constFn(async.Stream$(core.O
bject)))(); |
| 26 let VoidToStreamOfObject = () => (VoidToStreamOfObject = dart.constFn(dart.fun
ctionType(StreamOfObject(), [])))(); |
| 27 let StreamOfVoidToStreamOfObject = () => (StreamOfVoidToStreamOfObject = dart.
constFn(async.Stream$(VoidToStreamOfObject())))(); |
21 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr
ray$(core.String)))(); | 28 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr
ray$(core.String)))(); |
| 29 let StreamOfvoid = () => (StreamOfvoid = dart.constFn(async.Stream$(dart.void)
))(); |
| 30 let FutureOfint = () => (FutureOfint = dart.constFn(async.Future$(core.int)))(
); |
| 31 let StreamOfnum = () => (StreamOfnum = dart.constFn(async.Stream$(core.num)))(
); |
| 32 let VoidToStream = () => (VoidToStream = dart.constFn(dart.definiteFunctionTyp
e(async.Stream, [])))(); |
| 33 let ListTodynamic = () => (ListTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [core.List])))(); |
| 34 let VoidToFuture = () => (VoidToFuture = dart.constFn(dart.definiteFunctionTyp
e(async.Future, [])))(); |
| 35 let VoidToStreamOfint = () => (VoidToStreamOfint = dart.constFn(dart.definiteF
unctionType(StreamOfint(), [])))(); |
| 36 let ListOfintTodynamic = () => (ListOfintTodynamic = dart.constFn(dart.definit
eFunctionType(dart.dynamic, [ListOfint()])))(); |
| 37 let intTovoid = () => (intTovoid = dart.constFn(dart.definiteFunctionType(dart
.void, [core.int])))(); |
22 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); | 38 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 39 let dynamicTovoid = () => (dynamicTovoid = dart.constFn(dart.definiteFunctionT
ype(dart.void, [dart.dynamic])))(); |
| 40 let dynamicToStream = () => (dynamicToStream = dart.constFn(dart.definiteFunct
ionType(async.Stream, [dart.dynamic])))(); |
23 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); | 41 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); |
24 let dynamicTovoid = () => (dynamicTovoid = dart.constFn(dart.definiteFunctionT
ype(dart.void, [dart.dynamic])))(); | |
25 let VoidToFuture = () => (VoidToFuture = dart.constFn(dart.definiteFunctionTyp
e(async.Future, [])))(); | |
26 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); | 42 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); |
27 let VoidToObject = () => (VoidToObject = dart.constFn(dart.definiteFunctionTyp
e(core.Object, [])))(); | 43 let dynamicToStreamOfint = () => (dynamicToStreamOfint = dart.constFn(dart.def
initeFunctionType(StreamOfint(), [dart.dynamic])))(); |
28 let VoidToFutureOfObject = () => (VoidToFutureOfObject = dart.constFn(dart.def
initeFunctionType(FutureOfObject(), [])))(); | 44 let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core
.int, [])))(); |
29 let VoidToStreamOfObject = () => (VoidToStreamOfObject = dart.constFn(dart.def
initeFunctionType(StreamOfObject(), [])))(); | 45 let VoidToObject$ = () => (VoidToObject$ = dart.constFn(dart.definiteFunctionT
ype(core.Object, [])))(); |
| 46 let VoidToStreamOfVoidToObject = () => (VoidToStreamOfVoidToObject = dart.cons
tFn(dart.definiteFunctionType(StreamOfVoidToObject(), [])))(); |
| 47 let FnTodynamic = () => (FnTodynamic = dart.constFn(dart.definiteFunctionType(
dart.dynamic, [VoidToObject()])))(); |
| 48 let VoidToFutureOfObject$ = () => (VoidToFutureOfObject$ = dart.constFn(dart.d
efiniteFunctionType(FutureOfObject(), [])))(); |
| 49 let VoidToStreamOfVoidToFutureOfObject = () => (VoidToStreamOfVoidToFutureOfOb
ject = dart.constFn(dart.definiteFunctionType(StreamOfVoidToFutureOfObject(), []
)))(); |
| 50 let ObjectTodynamic = () => (ObjectTodynamic = dart.constFn(dart.definiteFunct
ionType(dart.dynamic, [core.Object])))(); |
| 51 let FnToFutureOfObject = () => (FnToFutureOfObject = dart.constFn(dart.definit
eFunctionType(FutureOfObject(), [VoidToFutureOfObject()])))(); |
| 52 let VoidToStreamOfObject$ = () => (VoidToStreamOfObject$ = dart.constFn(dart.d
efiniteFunctionType(StreamOfObject(), [])))(); |
| 53 let VoidToStreamOfVoidToStreamOfObject = () => (VoidToStreamOfVoidToStreamOfOb
ject = dart.constFn(dart.definiteFunctionType(StreamOfVoidToStreamOfObject(), []
)))(); |
| 54 let FnToFutureOfObject$ = () => (FnToFutureOfObject$ = dart.constFn(dart.defin
iteFunctionType(FutureOfObject(), [VoidToStreamOfObject()])))(); |
| 55 let VoidToStreamOfvoid = () => (VoidToStreamOfvoid = dart.constFn(dart.definit
eFunctionType(StreamOfvoid(), [])))(); |
| 56 let voidTovoid = () => (voidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [dart.void])))(); |
30 let dynamicToFuture = () => (dynamicToFuture = dart.constFn(dart.definiteFunct
ionType(async.Future, [dart.dynamic])))(); | 57 let dynamicToFuture = () => (dynamicToFuture = dart.constFn(dart.definiteFunct
ionType(async.Future, [dart.dynamic])))(); |
31 let VoidToint = () => (VoidToint = dart.constFn(dart.definiteFunctionType(core
.int, [])))(); | 58 let intToStreamOfint = () => (intToStreamOfint = dart.constFn(dart.definiteFun
ctionType(StreamOfint(), [core.int])))(); |
| 59 let dynamicToFutureOfint = () => (dynamicToFutureOfint = dart.constFn(dart.def
initeFunctionType(FutureOfint(), [dart.dynamic])))(); |
32 let intTodynamic = () => (intTodynamic = dart.constFn(dart.definiteFunctionTyp
e(dart.dynamic, [core.int])))(); | 60 let intTodynamic = () => (intTodynamic = dart.constFn(dart.definiteFunctionTyp
e(dart.dynamic, [core.int])))(); |
| 61 let dynamicToStreamOfnum = () => (dynamicToStreamOfnum = dart.constFn(dart.def
initeFunctionType(StreamOfnum(), [dart.dynamic])))(); |
| 62 let VoidToFutureOfint = () => (VoidToFutureOfint = dart.constFn(dart.definiteF
unctionType(FutureOfint(), [])))(); |
33 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons
tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))(); | 63 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons
tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))(); |
34 let dynamicAndEventSinkTovoid = () => (dynamicAndEventSinkTovoid = dart.constF
n(dart.definiteFunctionType(dart.void, [dart.dynamic, async.EventSink])))(); | 64 let dynamicAndEventSinkTovoid = () => (dynamicAndEventSinkTovoid = dart.constF
n(dart.definiteFunctionType(dart.void, [dart.dynamic, async.EventSink])))(); |
35 let ObjectAndStackTraceAndEventSinkTovoid = () => (ObjectAndStackTraceAndEvent
SinkTovoid = dart.constFn(dart.definiteFunctionType(dart.void, [core.Object, cor
e.StackTrace, async.EventSink])))(); | 65 let ObjectAndStackTraceAndEventSinkTovoid = () => (ObjectAndStackTraceAndEvent
SinkTovoid = dart.constFn(dart.definiteFunctionType(dart.void, [core.Object, cor
e.StackTrace, async.EventSink])))(); |
36 let EventSinkTovoid = () => (EventSinkTovoid = dart.constFn(dart.definiteFunct
ionType(dart.void, [async.EventSink])))(); | 66 let EventSinkTovoid = () => (EventSinkTovoid = dart.constFn(dart.definiteFunct
ionType(dart.void, [async.EventSink])))(); |
37 async_star_test_02_multi.main = function() { | 67 async_star_test_02_multi.main = function() { |
38 unittest$.group("basic", dart.fn(() => { | 68 unittest$.group("basic", dart.fn(() => { |
39 unittest$.test("empty", dart.fn(() => { | 69 unittest$.test("empty", dart.fn(() => { |
40 function f() { | 70 function f() { |
41 return dart.asyncStar(function*(stream) { | 71 return dart.asyncStar(function*(stream) { |
42 }, dart.dynamic); | 72 }, dart.dynamic); |
43 } | 73 } |
44 dart.fn(f, VoidTodynamic()); | 74 dart.fn(f, VoidToStream()); |
45 return dart.dsend(dart.dsend(f(), 'toList'), 'then', dart.fn(v => { | 75 return f().toList().then(dart.dynamic)(dart.fn(v => { |
46 src__matcher__expect.expect(v, src__matcher__core_matchers.equals([]))
; | 76 src__matcher__expect.expect(v, src__matcher__core_matchers.equals([]))
; |
47 }, dynamicTodynamic())); | 77 }, ListTodynamic())); |
48 }, VoidTodynamic())); | 78 }, VoidToFuture())); |
49 unittest$.test("single", dart.fn(() => { | 79 unittest$.test("single", dart.fn(() => { |
50 function f() { | 80 function f() { |
51 return dart.asyncStar(function*(stream) { | 81 return dart.asyncStar(function*(stream) { |
52 if (stream.add(42)) return; | 82 if (stream.add(42)) return; |
53 yield; | 83 yield; |
54 }, dart.dynamic); | 84 }, core.int); |
55 } | 85 } |
56 dart.fn(f, VoidTodynamic()); | 86 dart.fn(f, VoidToStreamOfint()); |
57 return dart.dsend(dart.dsend(f(), 'toList'), 'then', dart.fn(v => { | 87 return f().toList().then(dart.dynamic)(dart.fn(v => { |
58 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(JSAr
rayOfint().of([42]))); | 88 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(JSAr
rayOfint().of([42]))); |
59 }, dynamicTodynamic())); | 89 }, ListOfintTodynamic())); |
60 }, VoidTodynamic())); | 90 }, VoidToFuture())); |
61 unittest$.test("call delays", dart.fn(() => { | 91 unittest$.test("call delays", dart.fn(() => { |
62 let list = []; | 92 let list = []; |
63 function f() { | 93 function f() { |
64 return dart.asyncStar(function*(stream) { | 94 return dart.asyncStar(function*(stream) { |
65 list[dartx.add](1); | 95 list[dartx.add](1); |
66 if (stream.add(2)) return; | 96 if (stream.add(2)) return; |
67 yield; | 97 yield; |
68 }, dart.dynamic); | 98 }, core.int); |
69 } | 99 } |
70 dart.fn(f, VoidTodynamic()); | 100 dart.fn(f, VoidToStreamOfint()); |
71 let res = dart.dsend(f(), 'forEach', dart.fn(x => list[dartx.add](x), dy
namicTovoid())); | 101 let res = f().forEach(dart.fn(x => list[dartx.add](x), intTovoid())); |
72 list[dartx.add](0); | 102 list[dartx.add](0); |
73 return dart.dsend(res, 'whenComplete', dart.fn(() => { | 103 return res.whenComplete(dart.fn(() => { |
74 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfint().of([0, 1, 2]))); | 104 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfint().of([0, 1, 2]))); |
75 }, VoidTodynamic())); | 105 }, VoidTodynamic())); |
76 }, VoidTodynamic())); | 106 }, VoidToFuture())); |
77 unittest$.test("throws", dart.fn(() => { | 107 unittest$.test("throws", dart.fn(() => { |
78 function f() { | 108 function f() { |
79 return dart.asyncStar(function*(stream) { | 109 return dart.asyncStar(function*(stream) { |
80 if (stream.add(1)) return; | 110 if (stream.add(1)) return; |
81 yield; | 111 yield; |
82 dart.throw(2); | 112 dart.throw(2); |
83 }, dart.dynamic); | 113 }, core.int); |
84 } | 114 } |
85 dart.fn(f, VoidTodynamic()); | 115 dart.fn(f, VoidToStreamOfint()); |
86 let completer = async.Completer.new(); | 116 let completer = async.Completer.new(); |
87 let list = []; | 117 let list = []; |
88 dart.dsend(f(), 'listen', dart.fn(x => list[dartx.add](x), dynamicTovoid
()), {onError: dart.fn(v => list[dartx.add](dart.str`${v}`), dynamicTovoid()), o
nDone: dart.bind(completer, 'complete')}); | 118 f().listen(dart.fn(x => list[dartx.add](x), intTovoid()), {onError: dart
.fn(v => list[dartx.add](dart.str`${v}`), dynamicTovoid()), onDone: dart.bind(co
mpleter, 'complete')}); |
89 return completer.future.whenComplete(dart.fn(() => { | 119 return completer.future.whenComplete(dart.fn(() => { |
90 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfObject().of([1, "2"]))); | 120 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfObject().of([1, "2"]))); |
91 }, VoidTodynamic())); | 121 }, VoidTodynamic())); |
92 }, VoidToFuture())); | 122 }, VoidToFuture())); |
93 unittest$.test("multiple", dart.fn(() => { | 123 unittest$.test("multiple", dart.fn(() => { |
94 function f() { | 124 function f() { |
95 return dart.asyncStar(function*(stream) { | 125 return dart.asyncStar(function*(stream) { |
96 for (let i = 0; i < 10; i++) { | 126 for (let i = 0; i < 10; i++) { |
97 if (stream.add(i)) return; | 127 if (stream.add(i)) return; |
98 yield; | 128 yield; |
99 } | 129 } |
100 }, dart.dynamic); | 130 }, core.int); |
101 } | 131 } |
102 dart.fn(f, VoidTodynamic()); | 132 dart.fn(f, VoidToStreamOfint()); |
103 return async_star_test_02_multi.expectList(f(), core.List.generate(10, a
sync_star_test_02_multi.id)); | 133 return async_star_test_02_multi.expectList(f(), core.List.generate(10, a
sync_star_test_02_multi.id)); |
104 }, VoidTodynamic())); | 134 }, VoidTodynamic())); |
105 unittest$.test("allows await", dart.fn(() => { | 135 unittest$.test("allows await", dart.fn(() => { |
106 function f() { | 136 function f() { |
107 return dart.asyncStar(function*(stream) { | 137 return dart.asyncStar(function*(stream) { |
108 let x = (yield async.Future.value(42)); | 138 let x = (yield async.Future.value(42)); |
109 if (stream.add(x)) return; | 139 if (stream.add(x)) return; |
110 yield; | 140 yield; |
111 x = (yield async.Future.value(42)); | 141 x = (yield async.Future.value(42)); |
112 }, dart.dynamic); | 142 }, dart.dynamic); |
113 } | 143 } |
114 dart.fn(f, VoidTodynamic()); | 144 dart.fn(f, VoidToStream()); |
115 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 145 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
116 }, VoidTodynamic())); | 146 }, VoidTodynamic())); |
117 unittest$.test("allows await in loop", dart.fn(() => { | 147 unittest$.test("allows await in loop", dart.fn(() => { |
118 function f() { | 148 function f() { |
119 return dart.asyncStar(function*(stream) { | 149 return dart.asyncStar(function*(stream) { |
120 for (let i = 0; i < 10; i++) { | 150 for (let i = 0; i < 10; i++) { |
121 if (stream.add(yield i)) return; | 151 if (stream.add(yield i)) return; |
122 yield; | 152 yield; |
123 } | 153 } |
124 }, dart.dynamic); | 154 }, core.int); |
125 } | 155 } |
126 dart.fn(f, VoidTodynamic()); | 156 dart.fn(f, VoidToStreamOfint()); |
127 return async_star_test_02_multi.expectList(f(), core.List.generate(10, a
sync_star_test_02_multi.id)); | 157 return async_star_test_02_multi.expectList(f(), core.List.generate(10, a
sync_star_test_02_multi.id)); |
128 }, VoidTodynamic())); | 158 }, VoidTodynamic())); |
129 unittest$.test("allows yield*", dart.fn(() => { | 159 unittest$.test("allows yield*", dart.fn(() => { |
130 function f() { | 160 function f() { |
131 return dart.asyncStar(function*(stream) { | 161 return dart.asyncStar(function*(stream) { |
132 if (stream.addStream(StreamOfint().fromIterable(JSArrayOfint().of([1
, 2, 3])))) return; | 162 if (stream.addStream(StreamOfint().fromIterable(JSArrayOfint().of([1
, 2, 3])))) return; |
133 yield; | 163 yield; |
134 }, dart.dynamic); | 164 }, core.int); |
135 } | 165 } |
136 dart.fn(f, VoidTodynamic()); | 166 dart.fn(f, VoidToStreamOfint()); |
137 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([1, 2,
3])); | 167 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([1, 2,
3])); |
138 }, VoidTodynamic())); | 168 }, VoidTodynamic())); |
139 unittest$.test("allows yield* of async*", dart.fn(() => { | 169 unittest$.test("allows yield* of async*", dart.fn(() => { |
140 function f(n) { | 170 function f(n) { |
141 return dart.asyncStar(function*(stream, n) { | 171 return dart.asyncStar(function*(stream, n) { |
142 if (stream.add(n)) return; | 172 if (stream.add(n)) return; |
143 yield; | 173 yield; |
144 if (dart.equals(n, 0)) return; | 174 if (dart.equals(n, 0)) return; |
145 if (stream.addStream(async.Stream._check(f(dart.dsend(n, '-', 1)))))
return; | 175 if (stream.addStream(async.Stream._check(f(dart.dsend(n, '-', 1)))))
return; |
146 yield; | 176 yield; |
147 if (stream.add(n)) return; | 177 if (stream.add(n)) return; |
148 yield; | 178 yield; |
149 }, dart.dynamic, n); | 179 }, dart.dynamic, n); |
150 } | 180 } |
151 dart.fn(f, dynamicTodynamic()); | 181 dart.fn(f, dynamicToStream()); |
152 return async_star_test_02_multi.expectList(f(3), JSArrayOfint().of([3, 2
, 1, 0, 1, 2, 3])); | 182 return async_star_test_02_multi.expectList(f(3), JSArrayOfint().of([3, 2
, 1, 0, 1, 2, 3])); |
153 }, VoidTodynamic())); | 183 }, VoidTodynamic())); |
154 unittest$.test("Cannot yield* non-stream", dart.fn(() => { | 184 unittest$.test("Cannot yield* non-stream", dart.fn(() => { |
155 function f(s) { | 185 function f(s) { |
156 return dart.asyncStar(function*(stream, s) { | 186 return dart.asyncStar(function*(stream, s) { |
157 if (stream.addStream(async.Stream._check(s))) return; | 187 if (stream.addStream(async.Stream._check(s))) return; |
158 yield; | 188 yield; |
159 }, dart.dynamic, s); | 189 }, dart.dynamic, s); |
160 } | 190 } |
161 dart.fn(f, dynamicTodynamic()); | 191 dart.fn(f, dynamicToStream()); |
162 return dart.dsend(dart.dload(dart.dsend(f(42), 'transform', async_star_t
est_02_multi.getErrors), 'single'), 'then', dart.fn(v => { | 192 return f(42).transform(dart.dynamic)(async_star_test_02_multi.getErrors)
.single.then(dart.dynamic)(dart.fn(v => { |
163 src__matcher__expect.expect(core.Error.is(v), src__matcher__core_match
ers.isTrue); | 193 src__matcher__expect.expect(core.Error.is(v), src__matcher__core_match
ers.isTrue); |
164 }, dynamicTodynamic())); | 194 }, dynamicTodynamic())); |
165 }, VoidTodynamic())); | 195 }, VoidToFuture())); |
166 unittest$.test("Cannot yield* non-stream", dart.fn(() => { | 196 unittest$.test("Cannot yield* non-stream", dart.fn(() => { |
167 function f(s) { | 197 function f(s) { |
168 return dart.asyncStar(function*(stream, s) { | 198 return dart.asyncStar(function*(stream, s) { |
169 if (stream.addStream(async.Stream._check(s))) return; | 199 if (stream.addStream(async.Stream._check(s))) return; |
170 yield; | 200 yield; |
171 }, dart.dynamic, s); | 201 }, dart.dynamic, s); |
172 } | 202 } |
173 dart.fn(f, dynamicTodynamic()); | 203 dart.fn(f, dynamicToStream()); |
174 return dart.dsend(dart.dload(dart.dsend(f(new async_star_test_02_multi.N
otAStream()), 'transform', async_star_test_02_multi.getErrors), 'single'), 'then
', dart.fn(v => { | 204 return f(new async_star_test_02_multi.NotAStream()).transform(dart.dynam
ic)(async_star_test_02_multi.getErrors).single.then(dart.dynamic)(dart.fn(v => { |
175 src__matcher__expect.expect(core.Error.is(v), src__matcher__core_match
ers.isTrue); | 205 src__matcher__expect.expect(core.Error.is(v), src__matcher__core_match
ers.isTrue); |
176 }, dynamicTodynamic())); | 206 }, dynamicTodynamic())); |
177 }, VoidTodynamic())); | 207 }, VoidToFuture())); |
178 }, VoidTovoid())); | 208 }, VoidTovoid())); |
179 unittest$.group("yield statement context", dart.fn(() => { | 209 unittest$.group("yield statement context", dart.fn(() => { |
180 unittest$.test("plain", dart.fn(() => { | 210 unittest$.test("plain", dart.fn(() => { |
181 function f() { | 211 function f() { |
182 return dart.asyncStar(function*(stream) { | 212 return dart.asyncStar(function*(stream) { |
183 if (stream.add(0)) return; | 213 if (stream.add(0)) return; |
184 yield; | 214 yield; |
185 }, dart.dynamic); | 215 }, core.int); |
186 } | 216 } |
187 dart.fn(f, VoidTodynamic()); | 217 dart.fn(f, VoidToStreamOfint()); |
188 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0])); | 218 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0])); |
189 }, VoidTodynamic())); | 219 }, VoidTodynamic())); |
190 unittest$.test("if-then-else", dart.fn(() => { | 220 unittest$.test("if-then-else", dart.fn(() => { |
191 function f(b) { | 221 function f(b) { |
192 return dart.asyncStar(function*(stream, b) { | 222 return dart.asyncStar(function*(stream, b) { |
193 if (dart.test(b)) { | 223 if (dart.test(b)) { |
194 if (stream.add(0)) return; | 224 if (stream.add(0)) return; |
195 yield; | 225 yield; |
196 } else { | 226 } else { |
197 if (stream.add(1)) return; | 227 if (stream.add(1)) return; |
198 yield; | 228 yield; |
199 } | 229 } |
200 }, dart.dynamic, b); | 230 }, core.int, b); |
201 } | 231 } |
202 dart.fn(f, dynamicTodynamic()); | 232 dart.fn(f, dynamicToStreamOfint()); |
203 return dart.dsend(async_star_test_02_multi.expectList(f(true), JSArrayOf
int().of([0])), 'whenComplete', dart.fn(() => { | 233 return dart.dsend(async_star_test_02_multi.expectList(f(true), JSArrayOf
int().of([0])), 'whenComplete', dart.fn(() => { |
204 async_star_test_02_multi.expectList(f(false), JSArrayOfint().of([1])); | 234 async_star_test_02_multi.expectList(f(false), JSArrayOfint().of([1])); |
205 }, VoidTodynamic())); | 235 }, VoidTodynamic())); |
206 }, VoidTodynamic())); | 236 }, VoidTodynamic())); |
207 unittest$.test("block", dart.fn(() => { | 237 unittest$.test("block", dart.fn(() => { |
208 function f() { | 238 function f() { |
209 return dart.asyncStar(function*(stream) { | 239 return dart.asyncStar(function*(stream) { |
210 if (stream.add(0)) return; | 240 if (stream.add(0)) return; |
211 yield; | 241 yield; |
212 { | 242 { |
213 if (stream.add(1)) return; | 243 if (stream.add(1)) return; |
214 yield; | 244 yield; |
215 } | 245 } |
216 if (stream.add(2)) return; | 246 if (stream.add(2)) return; |
217 yield; | 247 yield; |
218 }, dart.dynamic); | 248 }, core.int); |
219 } | 249 } |
220 dart.fn(f, VoidTodynamic()); | 250 dart.fn(f, VoidToStreamOfint()); |
221 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 251 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); |
222 }, VoidTodynamic())); | 252 }, VoidTodynamic())); |
223 unittest$.test("labeled", dart.fn(() => { | 253 unittest$.test("labeled", dart.fn(() => { |
224 function f() { | 254 function f() { |
225 return dart.asyncStar(function*(stream) { | 255 return dart.asyncStar(function*(stream) { |
226 label1: { | 256 label1: { |
227 if (stream.add(0)) return; | 257 if (stream.add(0)) return; |
228 yield; | 258 yield; |
229 } | 259 } |
230 }, dart.dynamic); | 260 }, core.int); |
231 } | 261 } |
232 dart.fn(f, VoidTodynamic()); | 262 dart.fn(f, VoidToStreamOfint()); |
233 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0])); | 263 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0])); |
234 }, VoidTodynamic())); | 264 }, VoidTodynamic())); |
235 unittest$.test("for-loop", dart.fn(() => { | 265 unittest$.test("for-loop", dart.fn(() => { |
236 function f() { | 266 function f() { |
237 return dart.asyncStar(function*(stream) { | 267 return dart.asyncStar(function*(stream) { |
238 for (let i = 0; i < 3; i++) { | 268 for (let i = 0; i < 3; i++) { |
239 if (stream.add(i)) return; | 269 if (stream.add(i)) return; |
240 yield; | 270 yield; |
241 } | 271 } |
242 }, dart.dynamic); | 272 }, core.int); |
243 } | 273 } |
244 dart.fn(f, VoidTodynamic()); | 274 dart.fn(f, VoidToStreamOfint()); |
245 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 275 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); |
246 }, VoidTodynamic())); | 276 }, VoidTodynamic())); |
247 unittest$.test("for-in-loop", dart.fn(() => { | 277 unittest$.test("for-in-loop", dart.fn(() => { |
248 function f() { | 278 function f() { |
249 return dart.asyncStar(function*(stream) { | 279 return dart.asyncStar(function*(stream) { |
250 for (let i of JSArrayOfint().of([0, 1, 2])) { | 280 for (let i of JSArrayOfint().of([0, 1, 2])) { |
251 if (stream.add(i)) return; | 281 if (stream.add(i)) return; |
252 yield; | 282 yield; |
253 } | 283 } |
254 }, dart.dynamic); | 284 }, core.int); |
255 } | 285 } |
256 dart.fn(f, VoidTodynamic()); | 286 dart.fn(f, VoidToStreamOfint()); |
257 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 287 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); |
258 }, VoidTodynamic())); | 288 }, VoidTodynamic())); |
259 unittest$.test("await for-in-loop", dart.fn(() => { | 289 unittest$.test("await for-in-loop", dart.fn(() => { |
260 function f() { | 290 function f() { |
261 return dart.asyncStar(function*(stream) { | 291 return dart.asyncStar(function*(stream) { |
262 let it = async.StreamIterator.new(StreamOfint().fromIterable(JSArray
Ofint().of([0, 1, 2]))); | 292 let it = async.StreamIterator.new(StreamOfint().fromIterable(JSArray
Ofint().of([0, 1, 2]))); |
263 try { | 293 try { |
264 while (yield it.moveNext()) { | 294 while (yield it.moveNext()) { |
265 let i = it.current; | 295 let i = it.current; |
266 if (stream.add(i)) return; | 296 if (stream.add(i)) return; |
267 yield; | 297 yield; |
268 } | 298 } |
269 } finally { | 299 } finally { |
270 yield it.cancel(); | 300 yield it.cancel(); |
271 } | 301 } |
272 }, dart.dynamic); | 302 }, core.int); |
273 } | 303 } |
274 dart.fn(f, VoidTodynamic()); | 304 dart.fn(f, VoidToStreamOfint()); |
275 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 305 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); |
276 }, VoidTodynamic())); | 306 }, VoidTodynamic())); |
277 unittest$.test("while-loop", dart.fn(() => { | 307 unittest$.test("while-loop", dart.fn(() => { |
278 function f() { | 308 function f() { |
279 return dart.asyncStar(function*(stream) { | 309 return dart.asyncStar(function*(stream) { |
280 let i = 0; | 310 let i = 0; |
281 while (i < 3) { | 311 while (i < 3) { |
282 if (stream.add(i++)) return; | 312 if (stream.add(i++)) return; |
283 yield; | 313 yield; |
284 } | 314 } |
285 }, dart.dynamic); | 315 }, core.int); |
286 } | 316 } |
287 dart.fn(f, VoidTodynamic()); | 317 dart.fn(f, VoidToStreamOfint()); |
288 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 318 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); |
289 }, VoidTodynamic())); | 319 }, VoidTodynamic())); |
290 unittest$.test("do-while-loop", dart.fn(() => { | 320 unittest$.test("do-while-loop", dart.fn(() => { |
291 function f() { | 321 function f() { |
292 return dart.asyncStar(function*(stream) { | 322 return dart.asyncStar(function*(stream) { |
293 let i = 0; | 323 let i = 0; |
294 do { | 324 do { |
295 if (stream.add(i++)) return; | 325 if (stream.add(i++)) return; |
296 yield; | 326 yield; |
297 } while (i < 3); | 327 } while (i < 3); |
298 }, dart.dynamic); | 328 }, core.int); |
299 } | 329 } |
300 dart.fn(f, VoidTodynamic()); | 330 dart.fn(f, VoidToStreamOfint()); |
301 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 331 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); |
302 }, VoidTodynamic())); | 332 }, VoidTodynamic())); |
303 unittest$.test("try-catch-finally", dart.fn(() => { | 333 unittest$.test("try-catch-finally", dart.fn(() => { |
304 function f() { | 334 function f() { |
305 return dart.asyncStar(function*(stream) { | 335 return dart.asyncStar(function*(stream) { |
306 try { | 336 try { |
307 if (stream.add(0)) return; | 337 if (stream.add(0)) return; |
308 yield; | 338 yield; |
309 } catch (e) { | 339 } catch (e) { |
310 if (stream.add(1)) return; | 340 if (stream.add(1)) return; |
311 yield; | 341 yield; |
312 } | 342 } |
313 finally { | 343 finally { |
314 if (stream.add(2)) return; | 344 if (stream.add(2)) return; |
315 yield; | 345 yield; |
316 } | 346 } |
317 }, dart.dynamic); | 347 }, core.int); |
318 } | 348 } |
319 dart.fn(f, VoidTodynamic()); | 349 dart.fn(f, VoidToStreamOfint()); |
320 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 2]
)); | 350 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 2]
)); |
321 }, VoidTodynamic())); | 351 }, VoidTodynamic())); |
322 unittest$.test("try-catch-finally 2", dart.fn(() => { | 352 unittest$.test("try-catch-finally 2", dart.fn(() => { |
323 function f() { | 353 function f() { |
324 return dart.asyncStar(function*(stream) { | 354 return dart.asyncStar(function*(stream) { |
325 try { | 355 try { |
326 if (stream.add(dart.throw(0))) return; | 356 if (stream.add(dart.throw(0))) return; |
327 yield; | 357 yield; |
328 } catch (e) { | 358 } catch (e) { |
329 if (stream.add(1)) return; | 359 if (stream.add(1)) return; |
330 yield; | 360 yield; |
331 } | 361 } |
332 finally { | 362 finally { |
333 if (stream.add(2)) return; | 363 if (stream.add(2)) return; |
334 yield; | 364 yield; |
335 } | 365 } |
336 }, dart.dynamic); | 366 }, core.int); |
337 } | 367 } |
338 dart.fn(f, VoidTodynamic()); | 368 dart.fn(f, VoidToStreamOfint()); |
339 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([1, 2]
)); | 369 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([1, 2]
)); |
340 }, VoidTodynamic())); | 370 }, VoidTodynamic())); |
341 unittest$.test("dead-code return", dart.fn(() => { | 371 unittest$.test("dead-code return", dart.fn(() => { |
342 function f() { | 372 function f() { |
343 return dart.asyncStar(function*(stream) { | 373 return dart.asyncStar(function*(stream) { |
344 return; | 374 return; |
345 if (stream.add(1)) return; | 375 if (stream.add(1)) return; |
346 yield; | 376 yield; |
347 }, dart.dynamic); | 377 }, core.int); |
348 } | 378 } |
349 dart.fn(f, VoidTodynamic()); | 379 dart.fn(f, VoidToStreamOfint()); |
350 return async_star_test_02_multi.expectList(f(), []); | 380 return async_star_test_02_multi.expectList(f(), []); |
351 }, VoidTodynamic())); | 381 }, VoidTodynamic())); |
352 unittest$.test("dead-code throw", dart.fn(() => { | 382 unittest$.test("dead-code throw", dart.fn(() => { |
353 function f() { | 383 function f() { |
354 return dart.asyncStar(function*(stream) { | 384 return dart.asyncStar(function*(stream) { |
355 try { | 385 try { |
356 dart.throw(0); | 386 dart.throw(0); |
357 if (stream.add(1)) return; | 387 if (stream.add(1)) return; |
358 yield; | 388 yield; |
359 } catch (_) { | 389 } catch (_) { |
360 } | 390 } |
361 | 391 |
362 }, dart.dynamic); | 392 }, core.int); |
363 } | 393 } |
364 dart.fn(f, VoidTodynamic()); | 394 dart.fn(f, VoidToStreamOfint()); |
365 return async_star_test_02_multi.expectList(f(), []); | 395 return async_star_test_02_multi.expectList(f(), []); |
366 }, VoidTodynamic())); | 396 }, VoidTodynamic())); |
367 unittest$.test("dead-code break", dart.fn(() => { | 397 unittest$.test("dead-code break", dart.fn(() => { |
368 function f() { | 398 function f() { |
369 return dart.asyncStar(function*(stream) { | 399 return dart.asyncStar(function*(stream) { |
370 while (true) { | 400 while (true) { |
371 break; | 401 break; |
372 if (stream.add(1)) return; | 402 if (stream.add(1)) return; |
373 yield; | 403 yield; |
374 } | 404 } |
375 }, dart.dynamic); | 405 }, core.int); |
376 } | 406 } |
377 dart.fn(f, VoidTodynamic()); | 407 dart.fn(f, VoidToStreamOfint()); |
378 return async_star_test_02_multi.expectList(f(), []); | 408 return async_star_test_02_multi.expectList(f(), []); |
379 }, VoidTodynamic())); | 409 }, VoidTodynamic())); |
380 unittest$.test("dead-code break 2", dart.fn(() => { | 410 unittest$.test("dead-code break 2", dart.fn(() => { |
381 function f() { | 411 function f() { |
382 return dart.asyncStar(function*(stream) { | 412 return dart.asyncStar(function*(stream) { |
383 label: { | 413 label: { |
384 break label; | 414 break label; |
385 if (stream.add(1)) return; | 415 if (stream.add(1)) return; |
386 yield; | 416 yield; |
387 } | 417 } |
388 }, dart.dynamic); | 418 }, core.int); |
389 } | 419 } |
390 dart.fn(f, VoidTodynamic()); | 420 dart.fn(f, VoidToStreamOfint()); |
391 return async_star_test_02_multi.expectList(f(), []); | 421 return async_star_test_02_multi.expectList(f(), []); |
392 }, VoidTodynamic())); | 422 }, VoidTodynamic())); |
393 unittest$.test("dead-code continue", dart.fn(() => { | 423 unittest$.test("dead-code continue", dart.fn(() => { |
394 function f() { | 424 function f() { |
395 return dart.asyncStar(function*(stream) { | 425 return dart.asyncStar(function*(stream) { |
396 do { | 426 do { |
397 continue; | 427 continue; |
398 if (stream.add(1)) return; | 428 if (stream.add(1)) return; |
399 yield; | 429 yield; |
400 } while (false); | 430 } while (false); |
401 }, dart.dynamic); | 431 }, core.int); |
402 } | 432 } |
403 dart.fn(f, VoidTodynamic()); | 433 dart.fn(f, VoidToStreamOfint()); |
404 return async_star_test_02_multi.expectList(f(), []); | 434 return async_star_test_02_multi.expectList(f(), []); |
405 }, VoidTodynamic())); | 435 }, VoidTodynamic())); |
406 }, VoidTovoid())); | 436 }, VoidTovoid())); |
407 unittest$.group("yield expressions", dart.fn(() => { | 437 unittest$.group("yield expressions", dart.fn(() => { |
408 unittest$.test("local variable", dart.fn(() => { | 438 unittest$.test("local variable", dart.fn(() => { |
409 function f() { | 439 function f() { |
410 return dart.asyncStar(function*(stream) { | 440 return dart.asyncStar(function*(stream) { |
411 let x = 42; | 441 let x = 42; |
412 if (stream.add(x)) return; | 442 if (stream.add(x)) return; |
413 yield; | 443 yield; |
414 }, dart.dynamic); | 444 }, core.int); |
415 } | 445 } |
416 dart.fn(f, VoidTodynamic()); | 446 dart.fn(f, VoidToStreamOfint()); |
417 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 447 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
418 }, VoidTodynamic())); | 448 }, VoidTodynamic())); |
419 unittest$.test("constant variable", dart.fn(() => { | 449 unittest$.test("constant variable", dart.fn(() => { |
420 function f() { | 450 function f() { |
421 return dart.asyncStar(function*(stream) { | 451 return dart.asyncStar(function*(stream) { |
422 let x = 42; | 452 let x = 42; |
423 if (stream.add(x)) return; | 453 if (stream.add(x)) return; |
424 yield; | 454 yield; |
425 }, dart.dynamic); | 455 }, core.int); |
426 } | 456 } |
427 dart.fn(f, VoidTodynamic()); | 457 dart.fn(f, VoidToStreamOfint()); |
428 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 458 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
429 }, VoidTodynamic())); | 459 }, VoidTodynamic())); |
430 unittest$.test("function call", dart.fn(() => { | 460 unittest$.test("function call", dart.fn(() => { |
431 function g() { | 461 function g() { |
432 return 42; | 462 return 42; |
433 } | 463 } |
434 dart.fn(g, VoidTodynamic()); | 464 dart.fn(g, VoidToint()); |
435 function f() { | 465 function f() { |
436 return dart.asyncStar(function*(stream) { | 466 return dart.asyncStar(function*(stream) { |
437 if (stream.add(g())) return; | 467 if (stream.add(g())) return; |
438 yield; | 468 yield; |
439 }, dart.dynamic); | 469 }, core.int); |
440 } | 470 } |
441 dart.fn(f, VoidTodynamic()); | 471 dart.fn(f, VoidToStreamOfint()); |
442 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 472 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
443 }, VoidTodynamic())); | 473 }, VoidTodynamic())); |
444 unittest$.test("unary operator", dart.fn(() => { | 474 unittest$.test("unary operator", dart.fn(() => { |
445 function f() { | 475 function f() { |
446 return dart.asyncStar(function*(stream) { | 476 return dart.asyncStar(function*(stream) { |
447 let x = -42; | 477 let x = -42; |
448 if (stream.add(-x)) return; | 478 if (stream.add(-x)) return; |
449 yield; | 479 yield; |
450 }, dart.dynamic); | 480 }, core.int); |
451 } | 481 } |
452 dart.fn(f, VoidTodynamic()); | 482 dart.fn(f, VoidToStreamOfint()); |
453 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 483 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
454 }, VoidTodynamic())); | 484 }, VoidTodynamic())); |
455 unittest$.test("binary operator", dart.fn(() => { | 485 unittest$.test("binary operator", dart.fn(() => { |
456 function f() { | 486 function f() { |
457 return dart.asyncStar(function*(stream) { | 487 return dart.asyncStar(function*(stream) { |
458 let x = 21; | 488 let x = 21; |
459 if (stream.add(x + x)) return; | 489 if (stream.add(x + x)) return; |
460 yield; | 490 yield; |
461 }, dart.dynamic); | 491 }, core.int); |
462 } | 492 } |
463 dart.fn(f, VoidTodynamic()); | 493 dart.fn(f, VoidToStreamOfint()); |
464 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 494 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
465 }, VoidTodynamic())); | 495 }, VoidTodynamic())); |
466 unittest$.test("ternary operator", dart.fn(() => { | 496 unittest$.test("ternary operator", dart.fn(() => { |
467 function f() { | 497 function f() { |
468 return dart.asyncStar(function*(stream) { | 498 return dart.asyncStar(function*(stream) { |
469 let x = 21; | 499 let x = 21; |
470 if (stream.add(x == 21 ? x + x : x)) return; | 500 if (stream.add(x == 21 ? x + x : x)) return; |
471 yield; | 501 yield; |
472 }, dart.dynamic); | 502 }, core.int); |
473 } | 503 } |
474 dart.fn(f, VoidTodynamic()); | 504 dart.fn(f, VoidToStreamOfint()); |
475 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 505 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
476 }, VoidTodynamic())); | 506 }, VoidTodynamic())); |
477 unittest$.test("suffix post-increment", dart.fn(() => { | 507 unittest$.test("suffix post-increment", dart.fn(() => { |
478 function f() { | 508 function f() { |
479 return dart.asyncStar(function*(stream) { | 509 return dart.asyncStar(function*(stream) { |
480 let x = 42; | 510 let x = 42; |
481 if (stream.add(x++)) return; | 511 if (stream.add(x++)) return; |
482 yield; | 512 yield; |
483 }, dart.dynamic); | 513 }, core.int); |
484 } | 514 } |
485 dart.fn(f, VoidTodynamic()); | 515 dart.fn(f, VoidToStreamOfint()); |
486 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 516 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
487 }, VoidTodynamic())); | 517 }, VoidTodynamic())); |
488 unittest$.test("suffix pre-increment", dart.fn(() => { | 518 unittest$.test("suffix pre-increment", dart.fn(() => { |
489 function f() { | 519 function f() { |
490 return dart.asyncStar(function*(stream) { | 520 return dart.asyncStar(function*(stream) { |
491 let x = 41; | 521 let x = 41; |
492 if (stream.add(++x)) return; | 522 if (stream.add(++x)) return; |
493 yield; | 523 yield; |
494 }, dart.dynamic); | 524 }, core.int); |
495 } | 525 } |
496 dart.fn(f, VoidTodynamic()); | 526 dart.fn(f, VoidToStreamOfint()); |
497 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 527 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
498 }, VoidTodynamic())); | 528 }, VoidTodynamic())); |
499 unittest$.test("assignment", dart.fn(() => { | 529 unittest$.test("assignment", dart.fn(() => { |
500 function f() { | 530 function f() { |
501 return dart.asyncStar(function*(stream) { | 531 return dart.asyncStar(function*(stream) { |
502 let x = 37; | 532 let x = 37; |
503 if (stream.add(x = 42)) return; | 533 if (stream.add(x = 42)) return; |
504 yield; | 534 yield; |
505 }, dart.dynamic); | 535 }, core.int); |
506 } | 536 } |
507 dart.fn(f, VoidTodynamic()); | 537 dart.fn(f, VoidToStreamOfint()); |
508 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 538 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
509 }, VoidTodynamic())); | 539 }, VoidTodynamic())); |
510 unittest$.test("assignment op", dart.fn(() => { | 540 unittest$.test("assignment op", dart.fn(() => { |
511 function f() { | 541 function f() { |
512 return dart.asyncStar(function*(stream) { | 542 return dart.asyncStar(function*(stream) { |
513 let x = 41; | 543 let x = 41; |
514 if (stream.add((x = x + 1))) return; | 544 if (stream.add((x = x + 1))) return; |
515 yield; | 545 yield; |
516 }, dart.dynamic); | 546 }, core.int); |
517 } | 547 } |
518 dart.fn(f, VoidTodynamic()); | 548 dart.fn(f, VoidToStreamOfint()); |
519 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 549 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
520 }, VoidTodynamic())); | 550 }, VoidTodynamic())); |
521 unittest$.test("await", dart.fn(() => { | 551 unittest$.test("await", dart.fn(() => { |
522 function f() { | 552 function f() { |
523 return dart.asyncStar(function*(stream) { | 553 return dart.asyncStar(function*(stream) { |
524 if (stream.add(yield async.Future.value(42))) return; | 554 if (stream.add(yield async.Future.value(42))) return; |
525 yield; | 555 yield; |
526 }, dart.dynamic); | 556 }, dart.dynamic); |
527 } | 557 } |
528 dart.fn(f, VoidTodynamic()); | 558 dart.fn(f, VoidToStream()); |
529 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 559 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
530 }, VoidTodynamic())); | 560 }, VoidTodynamic())); |
531 unittest$.test("index operator", dart.fn(() => { | 561 unittest$.test("index operator", dart.fn(() => { |
532 function f() { | 562 function f() { |
533 return dart.asyncStar(function*(stream) { | 563 return dart.asyncStar(function*(stream) { |
534 let x = JSArrayOfint().of([42]); | 564 let x = JSArrayOfint().of([42]); |
535 if (stream.add(x[dartx.get](0))) return; | 565 if (stream.add(x[dartx.get](0))) return; |
536 yield; | 566 yield; |
537 }, dart.dynamic); | 567 }, core.int); |
538 } | 568 } |
539 dart.fn(f, VoidTodynamic()); | 569 dart.fn(f, VoidToStreamOfint()); |
540 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; | 570 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([42]))
; |
541 }, VoidTodynamic())); | 571 }, VoidTodynamic())); |
542 unittest$.test("function expression block", dart.fn(() => { | 572 unittest$.test("function expression block", dart.fn(() => { |
543 let o = new core.Object(); | 573 let o = new core.Object(); |
544 function f() { | 574 function f() { |
545 return dart.asyncStar(function*(stream) { | 575 return dart.asyncStar(function*(stream) { |
546 if (stream.add(dart.fn(() => o, VoidToObject()))) return; | 576 if (stream.add(dart.fn(() => o, VoidToObject$()))) return; |
547 yield; | 577 yield; |
548 }, dart.dynamic); | 578 }, VoidToObject()); |
549 } | 579 } |
550 dart.fn(f, VoidTodynamic()); | 580 dart.fn(f, VoidToStreamOfVoidToObject()); |
551 return dart.dsend(dart.dload(f(), 'first'), 'then', dart.fn(v => { | 581 return f().first.then(dart.dynamic)(dart.fn(v => { |
552 src__matcher__expect.expect(dart.dcall(v), src__matcher__core_matchers
.same(o)); | 582 src__matcher__expect.expect(v(), src__matcher__core_matchers.same(o)); |
553 }, dynamicTodynamic())); | 583 }, FnTodynamic())); |
554 }, VoidTodynamic())); | 584 }, VoidToFuture())); |
555 unittest$.test("function expression arrow", dart.fn(() => { | 585 unittest$.test("function expression arrow", dart.fn(() => { |
556 let o = new core.Object(); | 586 let o = new core.Object(); |
557 function f() { | 587 function f() { |
558 return dart.asyncStar(function*(stream) { | 588 return dart.asyncStar(function*(stream) { |
559 if (stream.add(dart.fn(() => o, VoidToObject()))) return; | 589 if (stream.add(dart.fn(() => o, VoidToObject$()))) return; |
560 yield; | 590 yield; |
561 }, dart.dynamic); | 591 }, VoidToObject()); |
562 } | 592 } |
563 dart.fn(f, VoidTodynamic()); | 593 dart.fn(f, VoidToStreamOfVoidToObject()); |
564 return dart.dsend(dart.dload(f(), 'first'), 'then', dart.fn(v => { | 594 return f().first.then(dart.dynamic)(dart.fn(v => { |
565 src__matcher__expect.expect(dart.dcall(v), src__matcher__core_matchers
.same(o)); | 595 src__matcher__expect.expect(v(), src__matcher__core_matchers.same(o)); |
566 }, dynamicTodynamic())); | 596 }, FnTodynamic())); |
567 }, VoidTodynamic())); | 597 }, VoidToFuture())); |
568 unittest$.test("function expression block async", dart.fn(() => { | 598 unittest$.test("function expression block async", dart.fn(() => { |
569 let o = new core.Object(); | 599 let o = new core.Object(); |
570 function f() { | 600 function f() { |
571 return dart.asyncStar(function*(stream) { | 601 return dart.asyncStar(function*(stream) { |
572 if (stream.add(dart.fn(() => dart.async(function*() { | 602 if (stream.add(dart.fn(() => dart.async(function*() { |
573 return o; | 603 return o; |
574 }, core.Object), VoidToFutureOfObject()))) return; | 604 }, core.Object), VoidToFutureOfObject$()))) return; |
575 yield; | 605 yield; |
576 }, dart.dynamic); | 606 }, VoidToFutureOfObject()); |
577 } | 607 } |
578 dart.fn(f, VoidTodynamic()); | 608 dart.fn(f, VoidToStreamOfVoidToFutureOfObject()); |
579 return dart.dsend(dart.dsend(dart.dload(f(), 'first'), 'then', dart.fn(v
=> dart.dcall(v), dynamicTodynamic())), 'then', dart.fn(v => { | 609 return f().first.then(FutureOfObject())(dart.fn(v => v(), FnToFutureOfOb
ject())).then(dart.dynamic)(dart.fn(v => { |
580 src__matcher__expect.expect(v, src__matcher__core_matchers.same(o)); | 610 src__matcher__expect.expect(v, src__matcher__core_matchers.same(o)); |
581 }, dynamicTodynamic())); | 611 }, ObjectTodynamic())); |
582 }, VoidTodynamic())); | 612 }, VoidToFuture())); |
583 unittest$.test("function expression arrow async", dart.fn(() => { | 613 unittest$.test("function expression arrow async", dart.fn(() => { |
584 let o = new core.Object(); | 614 let o = new core.Object(); |
585 function f() { | 615 function f() { |
586 return dart.asyncStar(function*(stream) { | 616 return dart.asyncStar(function*(stream) { |
587 if (stream.add(dart.fn(() => dart.async(function*() { | 617 if (stream.add(dart.fn(() => dart.async(function*() { |
588 return o; | 618 return o; |
589 }, core.Object), VoidToFutureOfObject()))) return; | 619 }, core.Object), VoidToFutureOfObject$()))) return; |
590 yield; | 620 yield; |
591 }, dart.dynamic); | 621 }, VoidToFutureOfObject()); |
592 } | 622 } |
593 dart.fn(f, VoidTodynamic()); | 623 dart.fn(f, VoidToStreamOfVoidToFutureOfObject()); |
594 return dart.dsend(dart.dsend(dart.dload(f(), 'first'), 'then', dart.fn(v
=> dart.dcall(v), dynamicTodynamic())), 'then', dart.fn(v => { | 624 return f().first.then(FutureOfObject())(dart.fn(v => v(), FnToFutureOfOb
ject())).then(dart.dynamic)(dart.fn(v => { |
595 src__matcher__expect.expect(v, src__matcher__core_matchers.same(o)); | 625 src__matcher__expect.expect(v, src__matcher__core_matchers.same(o)); |
596 }, dynamicTodynamic())); | 626 }, ObjectTodynamic())); |
597 }, VoidTodynamic())); | 627 }, VoidToFuture())); |
598 unittest$.test("function expression block async*", dart.fn(() => { | 628 unittest$.test("function expression block async*", dart.fn(() => { |
599 let o = new core.Object(); | 629 let o = new core.Object(); |
600 function f() { | 630 function f() { |
601 return dart.asyncStar(function*(stream) { | 631 return dart.asyncStar(function*(stream) { |
602 if (stream.add(dart.fn(() => dart.asyncStar(function*(stream) { | 632 if (stream.add(dart.fn(() => dart.asyncStar(function*(stream) { |
603 if (stream.add(o)) return; | 633 if (stream.add(o)) return; |
604 yield; | 634 yield; |
605 }, core.Object), VoidToStreamOfObject()))) return; | 635 }, core.Object), VoidToStreamOfObject$()))) return; |
606 yield; | 636 yield; |
607 }, dart.dynamic); | 637 }, VoidToStreamOfObject()); |
608 } | 638 } |
609 dart.fn(f, VoidTodynamic()); | 639 dart.fn(f, VoidToStreamOfVoidToStreamOfObject()); |
610 return dart.dsend(dart.dsend(dart.dload(f(), 'first'), 'then', dart.fn(v
=> dart.dload(dart.dcall(v), 'first'), dynamicTodynamic())), 'then', dart.fn(v
=> { | 640 return f().first.then(FutureOfObject())(dart.fn(v => v().first, FnToFutu
reOfObject$())).then(dart.dynamic)(dart.fn(v => { |
611 src__matcher__expect.expect(v, src__matcher__core_matchers.same(o)); | 641 src__matcher__expect.expect(v, src__matcher__core_matchers.same(o)); |
612 }, dynamicTodynamic())); | 642 }, ObjectTodynamic())); |
613 }, VoidTodynamic())); | 643 }, VoidToFuture())); |
614 }, VoidTovoid())); | 644 }, VoidTovoid())); |
615 unittest$.group("loops", dart.fn(() => { | 645 unittest$.group("loops", dart.fn(() => { |
616 unittest$.test("simple yield", dart.fn(() => { | 646 unittest$.test("simple yield", dart.fn(() => { |
617 function f() { | 647 function f() { |
618 return dart.asyncStar(function*(stream) { | 648 return dart.asyncStar(function*(stream) { |
619 for (let i = 0; i < 3; i++) { | 649 for (let i = 0; i < 3; i++) { |
620 if (stream.add(i)) return; | 650 if (stream.add(i)) return; |
621 yield; | 651 yield; |
622 } | 652 } |
623 }, dart.dynamic); | 653 }, core.int); |
624 } | 654 } |
625 dart.fn(f, VoidTodynamic()); | 655 dart.fn(f, VoidToStreamOfint()); |
626 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 656 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); |
627 }, VoidTodynamic())); | 657 }, VoidTodynamic())); |
628 unittest$.test("yield in double loop", dart.fn(() => { | 658 unittest$.test("yield in double loop", dart.fn(() => { |
629 function f() { | 659 function f() { |
630 return dart.asyncStar(function*(stream) { | 660 return dart.asyncStar(function*(stream) { |
631 for (let i = 0; i < 3; i++) { | 661 for (let i = 0; i < 3; i++) { |
632 for (let j = 0; j < 2; j++) { | 662 for (let j = 0; j < 2; j++) { |
633 if (stream.add(i * 2 + j)) return; | 663 if (stream.add(i * 2 + j)) return; |
634 yield; | 664 yield; |
635 } | 665 } |
636 } | 666 } |
637 }, dart.dynamic); | 667 }, core.int); |
638 } | 668 } |
639 dart.fn(f, VoidTodynamic()); | 669 dart.fn(f, VoidToStreamOfint()); |
640 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2, 3, 4, 5])); | 670 return async_star_test_02_multi.expectList(f(), JSArrayOfint().of([0, 1,
2, 3, 4, 5])); |
641 }, VoidTodynamic())); | 671 }, VoidTodynamic())); |
642 unittest$.test("yield in try body", dart.fn(() => { | 672 unittest$.test("yield in try body", dart.fn(() => { |
643 let list = []; | 673 let list = []; |
644 function f() { | 674 function f() { |
645 return dart.asyncStar(function*(stream) { | 675 return dart.asyncStar(function*(stream) { |
646 for (let i = 0; i < 3; i++) { | 676 for (let i = 0; i < 3; i++) { |
647 try { | 677 try { |
648 if (stream.add(i)) return; | 678 if (stream.add(i)) return; |
649 yield; | 679 yield; |
650 } finally { | 680 } finally { |
651 list[dartx.add](dart.str`${i}`); | 681 list[dartx.add](dart.str`${i}`); |
652 } | 682 } |
653 } | 683 } |
654 }, dart.dynamic); | 684 }, core.int); |
655 } | 685 } |
656 dart.fn(f, VoidTodynamic()); | 686 dart.fn(f, VoidToStreamOfint()); |
657 return dart.dsend(async_star_test_02_multi.expectList(f(), JSArrayOfint(
).of([0, 1, 2])), 'whenComplete', dart.fn(() => { | 687 return dart.dsend(async_star_test_02_multi.expectList(f(), JSArrayOfint(
).of([0, 1, 2])), 'whenComplete', dart.fn(() => { |
658 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfString().of(["0", "1", "2"]))); | 688 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfString().of(["0", "1", "2"]))); |
659 }, VoidTodynamic())); | 689 }, VoidTodynamic())); |
660 }, VoidTodynamic())); | 690 }, VoidTodynamic())); |
661 unittest$.test("yield in catch", dart.fn(() => { | 691 unittest$.test("yield in catch", dart.fn(() => { |
662 let list = []; | 692 let list = []; |
663 function f() { | 693 function f() { |
664 return dart.asyncStar(function*(stream) { | 694 return dart.asyncStar(function*(stream) { |
665 for (let i = 0; i < 3; i++) { | 695 for (let i = 0; i < 3; i++) { |
666 try { | 696 try { |
667 dart.throw(i); | 697 dart.throw(i); |
668 } catch (e) { | 698 } catch (e) { |
669 if (stream.add(e)) return; | 699 if (stream.add(e)) return; |
670 yield; | 700 yield; |
671 } | 701 } |
672 finally { | 702 finally { |
673 list[dartx.add](dart.str`${i}`); | 703 list[dartx.add](dart.str`${i}`); |
674 } | 704 } |
675 } | 705 } |
676 }, dart.dynamic); | 706 }, dart.dynamic); |
677 } | 707 } |
678 dart.fn(f, VoidTodynamic()); | 708 dart.fn(f, VoidToStream()); |
679 return dart.dsend(async_star_test_02_multi.expectList(f(), JSArrayOfint(
).of([0, 1, 2])), 'whenComplete', dart.fn(() => { | 709 return dart.dsend(async_star_test_02_multi.expectList(f(), JSArrayOfint(
).of([0, 1, 2])), 'whenComplete', dart.fn(() => { |
680 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfString().of(["0", "1", "2"]))); | 710 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfString().of(["0", "1", "2"]))); |
681 }, VoidTodynamic())); | 711 }, VoidTodynamic())); |
682 }, VoidTodynamic())); | 712 }, VoidTodynamic())); |
683 unittest$.test("yield in finally", dart.fn(() => { | 713 unittest$.test("yield in finally", dart.fn(() => { |
684 let list = []; | 714 let list = []; |
685 function f() { | 715 function f() { |
686 return dart.asyncStar(function*(stream) { | 716 return dart.asyncStar(function*(stream) { |
687 for (let i = 0; i < 3; i++) { | 717 for (let i = 0; i < 3; i++) { |
688 try { | 718 try { |
689 dart.throw(i); | 719 dart.throw(i); |
690 } finally { | 720 } finally { |
691 if (stream.add(i)) return; | 721 if (stream.add(i)) return; |
692 yield; | 722 yield; |
693 list[dartx.add](dart.str`${i}`); | 723 list[dartx.add](dart.str`${i}`); |
694 continue; | 724 continue; |
695 } | 725 } |
696 } | 726 } |
697 }, dart.dynamic); | 727 }, core.int); |
698 } | 728 } |
699 dart.fn(f, VoidTodynamic()); | 729 dart.fn(f, VoidToStreamOfint()); |
700 return dart.dsend(async_star_test_02_multi.expectList(f(), JSArrayOfint(
).of([0, 1, 2])), 'whenComplete', dart.fn(() => { | 730 return dart.dsend(async_star_test_02_multi.expectList(f(), JSArrayOfint(
).of([0, 1, 2])), 'whenComplete', dart.fn(() => { |
701 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfString().of(["0", "1", "2"]))); | 731 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfString().of(["0", "1", "2"]))); |
702 }, VoidTodynamic())); | 732 }, VoidTodynamic())); |
703 }, VoidTodynamic())); | 733 }, VoidTodynamic())); |
704 unittest$.test("keep yielding after cancel", dart.fn(() => { | 734 unittest$.test("keep yielding after cancel", dart.fn(() => { |
705 function f() { | 735 function f() { |
706 return dart.asyncStar(function*(stream) { | 736 return dart.asyncStar(function*(stream) { |
707 for (let i = 0; i < 10; i++) { | 737 for (let i = 0; i < 10; i++) { |
708 try { | 738 try { |
709 if (stream.add(i)) return; | 739 if (stream.add(i)) return; |
710 yield; | 740 yield; |
711 } finally { | 741 } finally { |
712 continue; | 742 continue; |
713 } | 743 } |
714 } | 744 } |
715 }, dart.dynamic); | 745 }, core.int); |
716 } | 746 } |
717 dart.fn(f, VoidTodynamic()); | 747 dart.fn(f, VoidToStreamOfint()); |
718 return async_star_test_02_multi.expectList(dart.dsend(f(), 'take', 3), J
SArrayOfint().of([0, 1, 2])); | 748 return async_star_test_02_multi.expectList(f().take(3), JSArrayOfint().o
f([0, 1, 2])); |
719 }, VoidTodynamic())); | 749 }, VoidTodynamic())); |
720 }, VoidTovoid())); | 750 }, VoidTovoid())); |
721 unittest$.group("canceling", dart.fn(() => { | 751 unittest$.group("canceling", dart.fn(() => { |
722 unittest$.test("cancels at yield", dart.fn(() => { | 752 unittest$.test("cancels at yield", dart.fn(() => { |
723 let exits = async.Completer.new(); | 753 let exits = async.Completer.new(); |
724 let list = []; | 754 let list = []; |
725 function f() { | 755 function f() { |
726 return dart.asyncStar(function*(stream) { | 756 return dart.asyncStar(function*(stream) { |
727 try { | 757 try { |
728 list[dartx.add](0); | 758 list[dartx.add](0); |
729 if (stream.add(list[dartx.add](1))) return; | 759 if (stream.add(list[dartx.add](1))) return; |
730 yield; | 760 yield; |
731 list[dartx.add](2); | 761 list[dartx.add](2); |
732 } finally { | 762 } finally { |
733 exits.complete(3); | 763 exits.complete(3); |
734 } | 764 } |
735 }, dart.dynamic); | 765 }, dart.void); |
736 } | 766 } |
737 dart.fn(f, VoidTodynamic()); | 767 dart.fn(f, VoidToStreamOfvoid()); |
738 let subscription = dart.dsend(f(), 'listen', dart.fn(v => { | 768 let subscription = f().listen(dart.fn(v => { |
739 src__matcher__expect.fail(dart.str`Received event ${v}`); | 769 src__matcher__expect.fail(dart.str`Received event ${v}`); |
740 }, dynamicTodynamic()), {onDone: dart.fn(() => { | 770 }, voidTovoid()), {onDone: dart.fn(() => { |
741 src__matcher__expect.fail("Received done"); | 771 src__matcher__expect.fail("Received done"); |
742 }, VoidTodynamic())}); | 772 }, VoidTovoid())}); |
743 dart.dsend(subscription, 'cancel'); | 773 subscription.cancel(); |
744 return exits.future.then(dart.dynamic)(dart.fn(v => { | 774 return exits.future.then(dart.dynamic)(dart.fn(v => { |
745 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(3)); | 775 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(3)); |
746 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfint().of([0, 1]))); | 776 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfint().of([0, 1]))); |
747 }, dynamicTodynamic())); | 777 }, dynamicTodynamic())); |
748 }, VoidToFuture())); | 778 }, VoidToFuture())); |
749 unittest$.test("does cancel eventually", dart.fn(() => { | 779 unittest$.test("does cancel eventually", dart.fn(() => { |
750 let exits = async.Completer.new(); | 780 let exits = async.Completer.new(); |
751 let list = []; | 781 let list = []; |
752 function f() { | 782 function f() { |
753 return dart.asyncStar(function*(stream) { | 783 return dart.asyncStar(function*(stream) { |
754 let i = 0; | 784 let i = 0; |
755 try { | 785 try { |
756 while (true) { | 786 while (true) { |
757 if (stream.add(i++)) return; | 787 if (stream.add(i++)) return; |
758 yield; | 788 yield; |
759 } | 789 } |
760 } finally { | 790 } finally { |
761 list[dartx.add]("a"); | 791 list[dartx.add]("a"); |
762 exits.complete(i); | 792 exits.complete(i); |
763 } | 793 } |
764 }, dart.dynamic); | 794 }, core.int); |
765 } | 795 } |
766 dart.fn(f, VoidTodynamic()); | 796 dart.fn(f, VoidToStreamOfint()); |
767 return dart.dsend(dart.dsend(async_star_test_02_multi.expectList(dart.ds
end(f(), 'take', 5), JSArrayOfint().of([0, 1, 2, 3, 4])), 'then', dart.fn(_ => e
xits.future, dynamicToFuture())), 'then', dart.fn(v => { | 797 return dart.dsend(dart.dsend(async_star_test_02_multi.expectList(f().tak
e(5), JSArrayOfint().of([0, 1, 2, 3, 4])), 'then', dart.fn(_ => exits.future, dy
namicToFuture())), 'then', dart.fn(v => { |
768 src__matcher__expect.expect(v, src__matcher__numeric_matchers.greaterT
han(4)); | 798 src__matcher__expect.expect(v, src__matcher__numeric_matchers.greaterT
han(4)); |
769 src__matcher__expect.expect(list, JSArrayOfString().of(["a"])); | 799 src__matcher__expect.expect(list, JSArrayOfString().of(["a"])); |
770 }, dynamicTodynamic())); | 800 }, dynamicTodynamic())); |
771 }, VoidTodynamic())); | 801 }, VoidTodynamic())); |
772 unittest$.group("at index", dart.fn(() => { | 802 unittest$.group("at index", dart.fn(() => { |
773 function f() { | 803 function f() { |
774 return dart.asyncStar(function*(stream) { | 804 return dart.asyncStar(function*(stream) { |
775 try { | 805 try { |
776 if (stream.add(yield async.Future.microtask(dart.fn(() => 1, VoidT
oint())))) return; | 806 if (stream.add(yield async.Future.microtask(dart.fn(() => 1, VoidT
oint())))) return; |
777 yield; | 807 yield; |
778 } finally { | 808 } finally { |
779 try { | 809 try { |
780 if (stream.add(yield async.Future.microtask(dart.fn(() => 2, Voi
dToint())))) return; | 810 if (stream.add(yield async.Future.microtask(dart.fn(() => 2, Voi
dToint())))) return; |
781 yield; | 811 yield; |
782 } finally { | 812 } finally { |
783 if (stream.add(yield async.Future.microtask(dart.fn(() => 3, Voi
dToint())))) return; | 813 if (stream.add(yield async.Future.microtask(dart.fn(() => 3, Voi
dToint())))) return; |
784 yield; | 814 yield; |
785 } | 815 } |
786 } | 816 } |
787 }, dart.dynamic); | 817 }, dart.dynamic); |
788 } | 818 } |
789 dart.fn(f, VoidTodynamic()); | 819 dart.fn(f, VoidToStream()); |
790 unittest$.test("- all, sanity check", dart.fn(() => async_star_test_02_m
ulti.expectList(f(), JSArrayOfint().of([1, 2, 3])), VoidTodynamic())); | 820 unittest$.test("- all, sanity check", dart.fn(() => async_star_test_02_m
ulti.expectList(f(), JSArrayOfint().of([1, 2, 3])), VoidTodynamic())); |
791 unittest$.test("after end", dart.fn(() => async_star_test_02_multi.expec
tList(dart.dsend(f(), 'take', 4), JSArrayOfint().of([1, 2, 3])), VoidTodynamic()
)); | 821 unittest$.test("after end", dart.fn(() => async_star_test_02_multi.expec
tList(f().take(4), JSArrayOfint().of([1, 2, 3])), VoidTodynamic())); |
792 unittest$.test("at end", dart.fn(() => async_star_test_02_multi.expectLi
st(dart.dsend(f(), 'take', 3), JSArrayOfint().of([1, 2, 3])), VoidTodynamic())); | 822 unittest$.test("at end", dart.fn(() => async_star_test_02_multi.expectLi
st(f().take(3), JSArrayOfint().of([1, 2, 3])), VoidTodynamic())); |
793 unittest$.test("before end", dart.fn(() => async_star_test_02_multi.expe
ctList(dart.dsend(f(), 'take', 2), JSArrayOfint().of([1, 2])), VoidTodynamic()))
; | 823 unittest$.test("before end", dart.fn(() => async_star_test_02_multi.expe
ctList(f().take(2), JSArrayOfint().of([1, 2])), VoidTodynamic())); |
794 unittest$.test("early", dart.fn(() => async_star_test_02_multi.expectLis
t(dart.dsend(f(), 'take', 1), JSArrayOfint().of([1])), VoidTodynamic())); | 824 unittest$.test("early", dart.fn(() => async_star_test_02_multi.expectLis
t(f().take(1), JSArrayOfint().of([1])), VoidTodynamic())); |
795 unittest$.test("at start", dart.fn(() => async_star_test_02_multi.expect
List(dart.dsend(f(), 'take', 0), []), VoidTodynamic())); | 825 unittest$.test("at start", dart.fn(() => async_star_test_02_multi.expect
List(f().take(0), []), VoidTodynamic())); |
796 }, VoidTovoid())); | 826 }, VoidTovoid())); |
797 }, VoidTovoid())); | 827 }, VoidTovoid())); |
798 unittest$.group("pausing", dart.fn(() => { | 828 unittest$.group("pausing", dart.fn(() => { |
799 unittest$.test("pauses execution at yield for at least a microtask", dart.
fn(() => { | 829 unittest$.test("pauses execution at yield for at least a microtask", dart.
fn(() => { |
800 let list = []; | 830 let list = []; |
801 function f() { | 831 function f() { |
802 return dart.asyncStar(function*(stream) { | 832 return dart.asyncStar(function*(stream) { |
803 list[dartx.add](1); | 833 list[dartx.add](1); |
804 if (stream.add(2)) return; | 834 if (stream.add(2)) return; |
805 yield; | 835 yield; |
806 list[dartx.add](3); | 836 list[dartx.add](3); |
807 if (stream.add(4)) return; | 837 if (stream.add(4)) return; |
808 yield; | 838 yield; |
809 list[dartx.add](5); | 839 list[dartx.add](5); |
810 }, dart.dynamic); | 840 }, core.int); |
811 } | 841 } |
812 dart.fn(f, VoidTodynamic()); | 842 dart.fn(f, VoidToStreamOfint()); |
813 let done = async.Completer.new(); | 843 let done = async.Completer.new(); |
814 let sub = dart.dsend(f(), 'listen', dart.fn(v => { | 844 let sub = f().listen(dart.fn(v => { |
815 if (dart.equals(v, 2)) { | 845 if (v == 2) { |
816 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1]))); | 846 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1]))); |
817 } else if (dart.equals(v, 4)) { | 847 } else if (v == 4) { |
818 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1, 3]))); | 848 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1, 3]))); |
819 } else { | 849 } else { |
820 src__matcher__expect.fail(dart.str`Unexpected value ${v}`); | 850 src__matcher__expect.fail(dart.str`Unexpected value ${v}`); |
821 } | 851 } |
822 }, dynamicTodynamic()), {onDone: dart.fn(() => { | 852 }, intTovoid()), {onDone: dart.fn(() => { |
823 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1, 3, 5]))); | 853 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1, 3, 5]))); |
824 done.complete(); | 854 done.complete(); |
825 }, VoidTodynamic())}); | 855 }, VoidTovoid())}); |
826 return done.future; | 856 return done.future; |
827 }, VoidToFuture())); | 857 }, VoidToFuture())); |
828 unittest$.test("pause stops execution at yield", dart.fn(() => { | 858 unittest$.test("pause stops execution at yield", dart.fn(() => { |
829 let list = []; | 859 let list = []; |
830 function f() { | 860 function f() { |
831 return dart.asyncStar(function*(stream) { | 861 return dart.asyncStar(function*(stream) { |
832 list[dartx.add](1); | 862 list[dartx.add](1); |
833 if (stream.add(2)) return; | 863 if (stream.add(2)) return; |
834 yield; | 864 yield; |
835 list[dartx.add](3); | 865 list[dartx.add](3); |
836 if (stream.add(4)) return; | 866 if (stream.add(4)) return; |
837 yield; | 867 yield; |
838 list[dartx.add](5); | 868 list[dartx.add](5); |
839 }, dart.dynamic); | 869 }, core.int); |
840 } | 870 } |
841 dart.fn(f, VoidTodynamic()); | 871 dart.fn(f, VoidToStreamOfint()); |
842 let done = async.Completer.new(); | 872 let done = async.Completer.new(); |
843 let sub = null; | 873 let sub = null; |
844 sub = dart.dsend(f(), 'listen', dart.fn(v => { | 874 sub = f().listen(dart.fn(v => { |
845 if (dart.equals(v, 2)) { | 875 if (v == 2) { |
846 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1]))); | 876 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1]))); |
847 dart.dsend(sub, 'pause'); | 877 dart.dsend(sub, 'pause'); |
848 async.Timer.new(async_star_test_02_multi.MS['*'](300), dart.fn(() =>
{ | 878 async.Timer.new(async_star_test_02_multi.MS['*'](300), dart.fn(() =>
{ |
849 src__matcher__expect.expect(list[dartx.length], src__matcher__nume
ric_matchers.lessThan(3)); | 879 src__matcher__expect.expect(list[dartx.length], src__matcher__nume
ric_matchers.lessThan(3)); |
850 dart.dsend(sub, 'resume'); | 880 dart.dsend(sub, 'resume'); |
851 }, VoidTovoid())); | 881 }, VoidTovoid())); |
852 } else if (dart.equals(v, 4)) { | 882 } else if (v == 4) { |
853 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1, 3]))); | 883 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1, 3]))); |
854 } else { | 884 } else { |
855 src__matcher__expect.fail(dart.str`Unexpected value ${v}`); | 885 src__matcher__expect.fail(dart.str`Unexpected value ${v}`); |
856 } | 886 } |
857 }, dynamicTodynamic()), {onDone: dart.fn(() => { | 887 }, intTovoid()), {onDone: dart.fn(() => { |
858 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1, 3, 5]))); | 888 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfint().of([1, 3, 5]))); |
859 done.complete(); | 889 done.complete(); |
860 }, VoidTodynamic())}); | 890 }, VoidTovoid())}); |
861 return done.future; | 891 return done.future; |
862 }, VoidToFuture())); | 892 }, VoidToFuture())); |
863 unittest$.test("pause stops execution at yield 2", dart.fn(() => { | 893 unittest$.test("pause stops execution at yield 2", dart.fn(() => { |
864 let list = []; | 894 let list = []; |
865 function f() { | 895 function f() { |
866 return dart.asyncStar(function*(stream) { | 896 return dart.asyncStar(function*(stream) { |
867 let i = 0; | 897 let i = 0; |
868 while (true) { | 898 while (true) { |
869 if (stream.add(i)) return; | 899 if (stream.add(i)) return; |
870 yield; | 900 yield; |
871 list[dartx.add](i); | 901 list[dartx.add](i); |
872 i++; | 902 i++; |
873 } | 903 } |
874 }, dart.dynamic); | 904 }, core.int); |
875 } | 905 } |
876 dart.fn(f, VoidTodynamic()); | 906 dart.fn(f, VoidToStreamOfint()); |
877 let expected = 0; | 907 let expected = 0; |
878 let done = async.Completer.new(); | 908 let done = async.Completer.new(); |
879 let sub = null; | 909 let sub = null; |
880 sub = dart.dsend(f(), 'listen', dart.fn(v => { | 910 sub = f().listen(dart.fn(v => { |
881 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(expe
cted++)); | 911 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(expe
cted++)); |
882 if (dart.equals(dart.dsend(v, '%', 5), 0)) { | 912 if (v[dartx['%']](5) == 0) { |
883 dart.dsend(sub, 'pause', async.Future.delayed(async_star_test_02_mul
ti.MS['*'](300))); | 913 dart.dsend(sub, 'pause', async.Future.delayed(async_star_test_02_mul
ti.MS['*'](300))); |
884 } else if (dart.equals(v, 17)) { | 914 } else if (v == 17) { |
885 dart.dsend(sub, 'cancel'); | 915 dart.dsend(sub, 'cancel'); |
886 done.complete(); | 916 done.complete(); |
887 } | 917 } |
888 }, dynamicTodynamic()), {onDone: dart.fn(() => { | 918 }, intTovoid()), {onDone: dart.fn(() => { |
889 src__matcher__expect.fail("Unexpected done!"); | 919 src__matcher__expect.fail("Unexpected done!"); |
890 }, VoidTodynamic())}); | 920 }, VoidTovoid())}); |
891 return done.future.whenComplete(dart.fn(() => { | 921 return done.future.whenComplete(dart.fn(() => { |
892 src__matcher__expect.expect(list[dartx.length] == 18 || list[dartx.len
gth] == 19, src__matcher__core_matchers.isTrue); | 922 src__matcher__expect.expect(list[dartx.length] == 18 || list[dartx.len
gth] == 19, src__matcher__core_matchers.isTrue); |
893 }, VoidTodynamic())); | 923 }, VoidTodynamic())); |
894 }, VoidToFuture())); | 924 }, VoidToFuture())); |
895 unittest$.test("canceling while paused at yield", dart.fn(() => { | 925 unittest$.test("canceling while paused at yield", dart.fn(() => { |
896 let list = []; | 926 let list = []; |
897 let sync = new async_star_test_02_multi.Sync(); | 927 let sync = new async_star_test_02_multi.Sync(); |
898 function f() { | 928 function f() { |
899 return dart.asyncStar(function*(stream) { | 929 return dart.asyncStar(function*(stream) { |
900 list[dartx.add]("*1"); | 930 list[dartx.add]("*1"); |
901 if (stream.add(1)) return; | 931 if (stream.add(1)) return; |
902 yield; | 932 yield; |
903 yield sync.wait(); | 933 yield sync.wait(); |
904 sync.release(); | 934 sync.release(); |
905 list[dartx.add]("*2"); | 935 list[dartx.add]("*2"); |
906 if (stream.add(2)) return; | 936 if (stream.add(2)) return; |
907 yield; | 937 yield; |
908 list[dartx.add]("*3"); | 938 list[dartx.add]("*3"); |
909 }, dart.dynamic); | 939 }, core.int); |
910 } | 940 } |
911 dart.fn(f, VoidTodynamic()); | 941 dart.fn(f, VoidToStreamOfint()); |
912 ; | 942 ; |
913 let stream = f(); | 943 let stream = f(); |
914 let sub = dart.dsend(stream, 'listen', dart.fn(x => list[dartx.add](x),
dynamicTovoid())); | 944 let sub = stream.listen(dart.fn(x => list[dartx.add](x), intTovoid())); |
915 return sync.wait().whenComplete(dart.fn(() => { | 945 return sync.wait().whenComplete(dart.fn(() => { |
916 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfObject().of(["*1", 1]))); | 946 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfObject().of(["*1", 1]))); |
917 dart.dsend(sub, 'pause'); | 947 sub.pause(); |
918 return sync.wait(); | 948 return sync.wait(); |
919 }, VoidToFuture())).whenComplete(dart.fn(() => { | 949 }, VoidToFuture())).whenComplete(dart.fn(() => { |
920 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfObject().of(["*1", 1, "*2"]))); | 950 src__matcher__expect.expect(list, src__matcher__core_matchers.equals(J
SArrayOfObject().of(["*1", 1, "*2"]))); |
921 dart.dsend(sub, 'cancel'); | 951 sub.cancel(); |
922 return async.Future.delayed(async_star_test_02_multi.MS['*'](200), dar
t.fn(() => { | 952 return async.Future.delayed(async_star_test_02_multi.MS['*'](200), dar
t.fn(() => { |
923 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfObject().of(["*1", 1, "*2"]))); | 953 src__matcher__expect.expect(list, src__matcher__core_matchers.equals
(JSArrayOfObject().of(["*1", 1, "*2"]))); |
924 }, VoidTodynamic())); | 954 }, VoidTodynamic())); |
925 }, VoidToFuture())); | 955 }, VoidToFuture())); |
926 }, VoidToFuture())); | 956 }, VoidToFuture())); |
927 }, VoidTovoid())); | 957 }, VoidTovoid())); |
928 unittest$.group("await for", dart.fn(() => { | 958 unittest$.group("await for", dart.fn(() => { |
929 function mkStream(n) { | 959 function mkStream(n) { |
930 return dart.asyncStar(function*(stream, n) { | 960 return dart.asyncStar(function*(stream, n) { |
931 for (let i = 0; i < dart.notNull(n); i++) { | 961 for (let i = 0; i < dart.notNull(n); i++) { |
932 if (stream.add(i)) return; | 962 if (stream.add(i)) return; |
933 yield; | 963 yield; |
934 } | 964 } |
935 }, dart.dynamic, n); | 965 }, core.int, n); |
936 } | 966 } |
937 dart.fn(mkStream, intTodynamic()); | 967 dart.fn(mkStream, intToStreamOfint()); |
938 unittest$.test("simple stream", dart.fn(() => { | 968 unittest$.test("simple stream", dart.fn(() => { |
939 function f(s) { | 969 function f(s) { |
940 return dart.async(function*(s) { | 970 return dart.async(function*(s) { |
941 let r = 0; | 971 let r = 0; |
942 let it = async.StreamIterator.new(async.Stream._check(s)); | 972 let it = async.StreamIterator.new(async.Stream._check(s)); |
943 try { | 973 try { |
944 while (yield it.moveNext()) { | 974 while (yield it.moveNext()) { |
945 let v = it.current; | 975 let v = it.current; |
946 r = dart.notNull(r) + dart.notNull(core.int._check(v)); | 976 r = dart.notNull(r) + dart.notNull(core.int._check(v)); |
947 } | 977 } |
948 } finally { | 978 } finally { |
949 yield it.cancel(); | 979 yield it.cancel(); |
950 } | 980 } |
951 return r; | 981 return r; |
952 }, dart.dynamic, s); | 982 }, core.int, s); |
953 } | 983 } |
954 dart.fn(f, dynamicTodynamic()); | 984 dart.fn(f, dynamicToFutureOfint()); |
955 return dart.dsend(f(mkStream(5)), 'then', dart.fn(v => { | 985 return f(mkStream(5)).then(dart.dynamic)(dart.fn(v => { |
956 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10))
; | 986 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10))
; |
957 }, dynamicTodynamic())); | 987 }, intTodynamic())); |
958 }, VoidTodynamic())); | 988 }, VoidToFuture())); |
959 unittest$.test("simple stream, await", dart.fn(() => { | 989 unittest$.test("simple stream, await", dart.fn(() => { |
960 function f(s) { | 990 function f(s) { |
961 return dart.async(function*(s) { | 991 return dart.async(function*(s) { |
962 let r = 0; | 992 let r = 0; |
963 let it = async.StreamIterator.new(async.Stream._check(s)); | 993 let it = async.StreamIterator.new(async.Stream._check(s)); |
964 try { | 994 try { |
965 while (yield it.moveNext()) { | 995 while (yield it.moveNext()) { |
966 let v = it.current; | 996 let v = it.current; |
967 r = dart.notNull(r) + dart.notNull(core.int._check(yield async.F
uture.microtask(dart.fn(() => v, VoidTodynamic())))); | 997 r = dart.notNull(r) + dart.notNull(core.int._check(yield async.F
uture.microtask(dart.fn(() => v, VoidTodynamic())))); |
968 } | 998 } |
969 } finally { | 999 } finally { |
970 yield it.cancel(); | 1000 yield it.cancel(); |
971 } | 1001 } |
972 return r; | 1002 return r; |
973 }, dart.dynamic, s); | 1003 }, core.int, s); |
974 } | 1004 } |
975 dart.fn(f, dynamicTodynamic()); | 1005 dart.fn(f, dynamicToFutureOfint()); |
976 return dart.dsend(f(mkStream(5)), 'then', dart.fn(v => { | 1006 return f(mkStream(5)).then(dart.dynamic)(dart.fn(v => { |
977 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10))
; | 1007 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10))
; |
978 }, dynamicTodynamic())); | 1008 }, intTodynamic())); |
979 }, VoidTodynamic())); | 1009 }, VoidToFuture())); |
980 unittest$.test("simple stream reyield", dart.fn(() => { | 1010 unittest$.test("simple stream reyield", dart.fn(() => { |
981 function f(s) { | 1011 function f(s) { |
982 return dart.asyncStar(function*(stream, s) { | 1012 return dart.asyncStar(function*(stream, s) { |
983 let r = 0; | 1013 let r = 0; |
984 let it = async.StreamIterator.new(async.Stream._check(s)); | 1014 let it = async.StreamIterator.new(async.Stream._check(s)); |
985 try { | 1015 try { |
986 while (yield it.moveNext()) { | 1016 while (yield it.moveNext()) { |
987 let v = it.current; | 1017 let v = it.current; |
988 if (stream.add((r = dart.notNull(r) + dart.notNull(core.int._che
ck(v))))) return; | 1018 if (stream.add((r = dart.notNull(r) + dart.notNull(core.int._che
ck(v))))) return; |
989 yield; | 1019 yield; |
990 } | 1020 } |
991 } finally { | 1021 } finally { |
992 yield it.cancel(); | 1022 yield it.cancel(); |
993 } | 1023 } |
994 }, dart.dynamic, s); | 1024 }, core.num, s); |
995 } | 1025 } |
996 dart.fn(f, dynamicTodynamic()); | 1026 dart.fn(f, dynamicToStreamOfnum()); |
997 return async_star_test_02_multi.expectList(f(mkStream(5)), JSArrayOfint(
).of([0, 1, 3, 6, 10])); | 1027 return async_star_test_02_multi.expectList(f(mkStream(5)), JSArrayOfint(
).of([0, 1, 3, 6, 10])); |
998 }, VoidTodynamic())); | 1028 }, VoidTodynamic())); |
999 unittest$.test("simple stream, await, reyield", dart.fn(() => { | 1029 unittest$.test("simple stream, await, reyield", dart.fn(() => { |
1000 function f(s) { | 1030 function f(s) { |
1001 return dart.asyncStar(function*(stream, s) { | 1031 return dart.asyncStar(function*(stream, s) { |
1002 let r = 0; | 1032 let r = 0; |
1003 let it = async.StreamIterator.new(async.Stream._check(s)); | 1033 let it = async.StreamIterator.new(async.Stream._check(s)); |
1004 try { | 1034 try { |
1005 while (yield it.moveNext()) { | 1035 while (yield it.moveNext()) { |
1006 let v = it.current; | 1036 let v = it.current; |
1007 if (stream.add((r = dart.notNull(r) + dart.notNull(core.int._che
ck(yield async.Future.microtask(dart.fn(() => v, VoidTodynamic()))))))) return; | 1037 if (stream.add((r = dart.notNull(r) + dart.notNull(core.int._che
ck(yield async.Future.microtask(dart.fn(() => v, VoidTodynamic()))))))) return; |
1008 yield; | 1038 yield; |
1009 } | 1039 } |
1010 } finally { | 1040 } finally { |
1011 yield it.cancel(); | 1041 yield it.cancel(); |
1012 } | 1042 } |
1013 }, dart.dynamic, s); | 1043 }, core.num, s); |
1014 } | 1044 } |
1015 dart.fn(f, dynamicTodynamic()); | 1045 dart.fn(f, dynamicToStreamOfnum()); |
1016 return async_star_test_02_multi.expectList(f(mkStream(5)), JSArrayOfint(
).of([0, 1, 3, 6, 10])); | 1046 return async_star_test_02_multi.expectList(f(mkStream(5)), JSArrayOfint(
).of([0, 1, 3, 6, 10])); |
1017 }, VoidTodynamic())); | 1047 }, VoidTodynamic())); |
1018 unittest$.test("nested", dart.fn(() => { | 1048 unittest$.test("nested", dart.fn(() => { |
1019 function f() { | 1049 function f() { |
1020 return dart.async(function*() { | 1050 return dart.async(function*() { |
1021 let r = 0; | 1051 let r = 0; |
1022 let it = async.StreamIterator.new(async.Stream._check(mkStream(5))); | 1052 let it = async.StreamIterator.new(mkStream(5)); |
1023 try { | 1053 try { |
1024 while (yield it.moveNext()) { | 1054 while (yield it.moveNext()) { |
1025 let i = it.current; | 1055 let i = it.current; |
1026 let it$ = async.StreamIterator.new(async.Stream._check(mkStream(
3))); | 1056 let it$ = async.StreamIterator.new(mkStream(3)); |
1027 try { | 1057 try { |
1028 while (yield it$.moveNext()) { | 1058 while (yield it$.moveNext()) { |
1029 let j = it$.current; | 1059 let j = it$.current; |
1030 r = dart.notNull(r) + dart.notNull(core.int._check(dart.dsen
d(i, '*', j))); | 1060 r = r + dart.notNull(i) * dart.notNull(j); |
1031 } | 1061 } |
1032 } finally { | 1062 } finally { |
1033 yield it$.cancel(); | 1063 yield it$.cancel(); |
1034 } | 1064 } |
1035 } | 1065 } |
1036 } finally { | 1066 } finally { |
1037 yield it.cancel(); | 1067 yield it.cancel(); |
1038 } | 1068 } |
1039 return r; | 1069 return r; |
1040 }, dart.dynamic); | 1070 }, core.int); |
1041 } | 1071 } |
1042 dart.fn(f, VoidTodynamic()); | 1072 dart.fn(f, VoidToFutureOfint()); |
1043 return dart.dsend(f(), 'then', dart.fn(v => { | 1073 return f().then(dart.dynamic)(dart.fn(v => { |
1044 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); | 1074 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); |
1045 }, dynamicTodynamic())); | 1075 }, intTodynamic())); |
1046 }, VoidTodynamic())); | 1076 }, VoidToFuture())); |
1047 unittest$.test("nested, await", dart.fn(() => { | 1077 unittest$.test("nested, await", dart.fn(() => { |
1048 function f() { | 1078 function f() { |
1049 return dart.async(function*() { | 1079 return dart.async(function*() { |
1050 let r = 0; | 1080 let r = 0; |
1051 let it = async.StreamIterator.new(async.Stream._check(mkStream(5))); | 1081 let it = async.StreamIterator.new(mkStream(5)); |
1052 try { | 1082 try { |
1053 while (yield it.moveNext()) { | 1083 while (yield it.moveNext()) { |
1054 let i = it.current; | 1084 let i = it.current; |
1055 let it$ = async.StreamIterator.new(async.Stream._check(mkStream(
3))); | 1085 let it$ = async.StreamIterator.new(mkStream(3)); |
1056 try { | 1086 try { |
1057 while (yield it$.moveNext()) { | 1087 while (yield it$.moveNext()) { |
1058 let j = it$.current; | 1088 let j = it$.current; |
1059 r = dart.notNull(r) + dart.notNull(core.int._check(yield asy
nc.Future.microtask(dart.fn(() => dart.dsend(i, '*', j), VoidTodynamic())))); | 1089 r = dart.notNull(r) + dart.notNull(core.int._check(yield asy
nc.Future.microtask(dart.fn(() => dart.notNull(i) * dart.notNull(j), VoidToint()
)))); |
1060 } | 1090 } |
1061 } finally { | 1091 } finally { |
1062 yield it$.cancel(); | 1092 yield it$.cancel(); |
1063 } | 1093 } |
1064 } | 1094 } |
1065 } finally { | 1095 } finally { |
1066 yield it.cancel(); | 1096 yield it.cancel(); |
1067 } | 1097 } |
1068 return r; | 1098 return r; |
1069 }, dart.dynamic); | 1099 }, core.int); |
1070 } | 1100 } |
1071 dart.fn(f, VoidTodynamic()); | 1101 dart.fn(f, VoidToFutureOfint()); |
1072 return dart.dsend(f(), 'then', dart.fn(v => { | 1102 return f().then(dart.dynamic)(dart.fn(v => { |
1073 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); | 1103 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); |
1074 }, dynamicTodynamic())); | 1104 }, intTodynamic())); |
1075 }, VoidTodynamic())); | 1105 }, VoidToFuture())); |
1076 unittest$.test("nested, await * 2", dart.fn(() => { | 1106 unittest$.test("nested, await * 2", dart.fn(() => { |
1077 function f() { | 1107 function f() { |
1078 return dart.async(function*() { | 1108 return dart.async(function*() { |
1079 let r = 0; | 1109 let r = 0; |
1080 let it = async.StreamIterator.new(async.Stream._check(mkStream(5))); | 1110 let it = async.StreamIterator.new(mkStream(5)); |
1081 try { | 1111 try { |
1082 while (yield it.moveNext()) { | 1112 while (yield it.moveNext()) { |
1083 let i = it.current; | 1113 let i = it.current; |
1084 let ai = (yield async.Future.microtask(dart.fn(() => i, VoidTody
namic()))); | 1114 let ai = (yield async.Future.microtask(dart.fn(() => i, VoidToin
t()))); |
1085 let it$ = async.StreamIterator.new(async.Stream._check(mkStream(
3))); | 1115 let it$ = async.StreamIterator.new(mkStream(3)); |
1086 try { | 1116 try { |
1087 while (yield it$.moveNext()) { | 1117 while (yield it$.moveNext()) { |
1088 let j = it$.current; | 1118 let j = it$.current; |
1089 r = dart.notNull(r) + dart.notNull(core.int._check(yield asy
nc.Future.microtask(dart.fn(() => dart.dsend(ai, '*', j), VoidTodynamic())))); | 1119 r = dart.notNull(r) + dart.notNull(core.int._check(yield asy
nc.Future.microtask(dart.fn(() => dart.dsend(ai, '*', j), VoidTodynamic())))); |
1090 } | 1120 } |
1091 } finally { | 1121 } finally { |
1092 yield it$.cancel(); | 1122 yield it$.cancel(); |
1093 } | 1123 } |
1094 } | 1124 } |
1095 } finally { | 1125 } finally { |
1096 yield it.cancel(); | 1126 yield it.cancel(); |
1097 } | 1127 } |
1098 return r; | 1128 return r; |
1099 }, dart.dynamic); | 1129 }, core.int); |
1100 } | 1130 } |
1101 dart.fn(f, VoidTodynamic()); | 1131 dart.fn(f, VoidToFutureOfint()); |
1102 return dart.dsend(f(), 'then', dart.fn(v => { | 1132 return f().then(dart.dynamic)(dart.fn(v => { |
1103 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); | 1133 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); |
1104 }, dynamicTodynamic())); | 1134 }, intTodynamic())); |
1105 }, VoidTodynamic())); | 1135 }, VoidToFuture())); |
1106 }, VoidTovoid())); | 1136 }, VoidTovoid())); |
1107 }; | 1137 }; |
1108 dart.fn(async_star_test_02_multi.main, VoidTodynamic()); | 1138 dart.fn(async_star_test_02_multi.main, VoidTodynamic()); |
1109 async_star_test_02_multi.id = function(x) { | 1139 async_star_test_02_multi.id = function(x) { |
1110 try { | 1140 try { |
1111 if (x != null) dart.throw(x); | 1141 if (x != null) dart.throw(x); |
1112 } catch (e) { | 1142 } catch (e) { |
1113 return e; | 1143 return e; |
1114 } | 1144 } |
1115 | 1145 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 }; | 1197 }; |
1168 dart.setSignature(async_star_test_02_multi.Sync, { | 1198 dart.setSignature(async_star_test_02_multi.Sync, { |
1169 methods: () => ({ | 1199 methods: () => ({ |
1170 wait: dart.definiteFunctionType(async.Future, [], [dart.dynamic]), | 1200 wait: dart.definiteFunctionType(async.Future, [], [dart.dynamic]), |
1171 release: dart.definiteFunctionType(dart.void, [], [dart.dynamic]) | 1201 release: dart.definiteFunctionType(dart.void, [], [dart.dynamic]) |
1172 }) | 1202 }) |
1173 }); | 1203 }); |
1174 // Exports: | 1204 // Exports: |
1175 exports.async_star_test_02_multi = async_star_test_02_multi; | 1205 exports.async_star_test_02_multi = async_star_test_02_multi; |
1176 }); | 1206 }); |
OLD | NEW |