OLD | NEW |
1 dart_library.library('language/async_star_test_03_multi', null, /* Imports */[ | 1 dart_library.library('language/async_star_test_03_multi', null, /* Imports */[ |
2 'dart_sdk', | 2 'dart_sdk', |
3 'unittest' | 3 'unittest' |
4 ], function load__async_star_test_03_multi(exports, dart_sdk, unittest) { | 4 ], function load__async_star_test_03_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_03_multi = Object.create(null); | 15 const async_star_test_03_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_03_multi.main = function() { | 67 async_star_test_03_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_03_multi.expectList(f(), core.List.generate(10, a
sync_star_test_03_multi.id)); | 133 return async_star_test_03_multi.expectList(f(), core.List.generate(10, a
sync_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 145 return async_star_test_03_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_03_multi.expectList(f(), core.List.generate(10, a
sync_star_test_03_multi.id)); | 157 return async_star_test_03_multi.expectList(f(), core.List.generate(10, a
sync_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([1, 2,
3])); | 167 return async_star_test_03_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_03_multi.expectList(f(3), JSArrayOfint().of([3, 2
, 1, 0, 1, 2, 3])); | 182 return async_star_test_03_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_03_multi.getErrors), 'single'), 'then', dart.fn(v => { | 192 return f(42).transform(dart.dynamic)(async_star_test_03_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_03_multi.N
otAStream()), 'transform', async_star_test_03_multi.getErrors), 'single'), 'then
', dart.fn(v => { | 204 return f(new async_star_test_03_multi.NotAStream()).transform(dart.dynam
ic)(async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([0])); | 218 return async_star_test_03_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_03_multi.expectList(f(true), JSArrayOf
int().of([0])), 'whenComplete', dart.fn(() => { | 233 return dart.dsend(async_star_test_03_multi.expectList(f(true), JSArrayOf
int().of([0])), 'whenComplete', dart.fn(() => { |
204 async_star_test_03_multi.expectList(f(false), JSArrayOfint().of([1])); | 234 async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 251 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([0])); | 263 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 275 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 287 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 305 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 318 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 331 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([0, 2]
)); | 350 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([1, 2]
)); | 369 return async_star_test_03_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_03_multi.expectList(f(), []); | 380 return async_star_test_03_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_03_multi.expectList(f(), []); | 395 return async_star_test_03_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_03_multi.expectList(f(), []); | 408 return async_star_test_03_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_03_multi.expectList(f(), []); | 421 return async_star_test_03_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_03_multi.expectList(f(), []); | 434 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 447 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 458 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 472 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 483 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 494 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 505 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 516 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 527 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 538 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 549 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 559 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([42]))
; | 570 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([0, 1,
2])); | 656 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint().of([0, 1,
2, 3, 4, 5])); | 670 return async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint(
).of([0, 1, 2])), 'whenComplete', dart.fn(() => { | 687 return dart.dsend(async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint(
).of([0, 1, 2])), 'whenComplete', dart.fn(() => { | 709 return dart.dsend(async_star_test_03_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_03_multi.expectList(f(), JSArrayOfint(
).of([0, 1, 2])), 'whenComplete', dart.fn(() => { | 730 return dart.dsend(async_star_test_03_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_03_multi.expectList(dart.dsend(f(), 'take', 3), J
SArrayOfint().of([0, 1, 2])); | 748 return async_star_test_03_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_03_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_03_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_03_m
ulti.expectList(f(), JSArrayOfint().of([1, 2, 3])), VoidTodynamic())); | 820 unittest$.test("- all, sanity check", dart.fn(() => async_star_test_03_m
ulti.expectList(f(), JSArrayOfint().of([1, 2, 3])), VoidTodynamic())); |
791 unittest$.test("after end", dart.fn(() => async_star_test_03_multi.expec
tList(dart.dsend(f(), 'take', 4), JSArrayOfint().of([1, 2, 3])), VoidTodynamic()
)); | 821 unittest$.test("after end", dart.fn(() => async_star_test_03_multi.expec
tList(f().take(4), JSArrayOfint().of([1, 2, 3])), VoidTodynamic())); |
792 unittest$.test("at end", dart.fn(() => async_star_test_03_multi.expectLi
st(dart.dsend(f(), 'take', 3), JSArrayOfint().of([1, 2, 3])), VoidTodynamic())); | 822 unittest$.test("at end", dart.fn(() => async_star_test_03_multi.expectLi
st(f().take(3), JSArrayOfint().of([1, 2, 3])), VoidTodynamic())); |
793 unittest$.test("before end", dart.fn(() => async_star_test_03_multi.expe
ctList(dart.dsend(f(), 'take', 2), JSArrayOfint().of([1, 2])), VoidTodynamic()))
; | 823 unittest$.test("before end", dart.fn(() => async_star_test_03_multi.expe
ctList(f().take(2), JSArrayOfint().of([1, 2])), VoidTodynamic())); |
794 unittest$.test("early", dart.fn(() => async_star_test_03_multi.expectLis
t(dart.dsend(f(), 'take', 1), JSArrayOfint().of([1])), VoidTodynamic())); | 824 unittest$.test("early", dart.fn(() => async_star_test_03_multi.expectLis
t(f().take(1), JSArrayOfint().of([1])), VoidTodynamic())); |
795 unittest$.test("at start", dart.fn(() => async_star_test_03_multi.expect
List(dart.dsend(f(), 'take', 0), []), VoidTodynamic())); | 825 unittest$.test("at start", dart.fn(() => async_star_test_03_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_03_multi.MS['*'](300), dart.fn(() =>
{ | 878 async.Timer.new(async_star_test_03_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_03_mul
ti.MS['*'](300))); | 913 dart.dsend(sub, 'pause', async.Future.delayed(async_star_test_03_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 }, VoidTovoid())); | 925 }, VoidTovoid())); |
896 unittest$.group("await for", dart.fn(() => { | 926 unittest$.group("await for", dart.fn(() => { |
897 function mkStream(n) { | 927 function mkStream(n) { |
898 return dart.asyncStar(function*(stream, n) { | 928 return dart.asyncStar(function*(stream, n) { |
899 for (let i = 0; i < dart.notNull(n); i++) { | 929 for (let i = 0; i < dart.notNull(n); i++) { |
900 if (stream.add(i)) return; | 930 if (stream.add(i)) return; |
901 yield; | 931 yield; |
902 } | 932 } |
903 }, dart.dynamic, n); | 933 }, core.int, n); |
904 } | 934 } |
905 dart.fn(mkStream, intTodynamic()); | 935 dart.fn(mkStream, intToStreamOfint()); |
906 unittest$.test("simple stream", dart.fn(() => { | 936 unittest$.test("simple stream", dart.fn(() => { |
907 function f(s) { | 937 function f(s) { |
908 return dart.async(function*(s) { | 938 return dart.async(function*(s) { |
909 let r = 0; | 939 let r = 0; |
910 let it = async.StreamIterator.new(async.Stream._check(s)); | 940 let it = async.StreamIterator.new(async.Stream._check(s)); |
911 try { | 941 try { |
912 while (yield it.moveNext()) { | 942 while (yield it.moveNext()) { |
913 let v = it.current; | 943 let v = it.current; |
914 r = dart.notNull(r) + dart.notNull(core.int._check(v)); | 944 r = dart.notNull(r) + dart.notNull(core.int._check(v)); |
915 } | 945 } |
916 } finally { | 946 } finally { |
917 yield it.cancel(); | 947 yield it.cancel(); |
918 } | 948 } |
919 return r; | 949 return r; |
920 }, dart.dynamic, s); | 950 }, core.int, s); |
921 } | 951 } |
922 dart.fn(f, dynamicTodynamic()); | 952 dart.fn(f, dynamicToFutureOfint()); |
923 return dart.dsend(f(mkStream(5)), 'then', dart.fn(v => { | 953 return f(mkStream(5)).then(dart.dynamic)(dart.fn(v => { |
924 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10))
; | 954 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10))
; |
925 }, dynamicTodynamic())); | 955 }, intTodynamic())); |
926 }, VoidTodynamic())); | 956 }, VoidToFuture())); |
927 unittest$.test("simple stream, await", dart.fn(() => { | 957 unittest$.test("simple stream, await", dart.fn(() => { |
928 function f(s) { | 958 function f(s) { |
929 return dart.async(function*(s) { | 959 return dart.async(function*(s) { |
930 let r = 0; | 960 let r = 0; |
931 let it = async.StreamIterator.new(async.Stream._check(s)); | 961 let it = async.StreamIterator.new(async.Stream._check(s)); |
932 try { | 962 try { |
933 while (yield it.moveNext()) { | 963 while (yield it.moveNext()) { |
934 let v = it.current; | 964 let v = it.current; |
935 r = dart.notNull(r) + dart.notNull(core.int._check(yield async.F
uture.microtask(dart.fn(() => v, VoidTodynamic())))); | 965 r = dart.notNull(r) + dart.notNull(core.int._check(yield async.F
uture.microtask(dart.fn(() => v, VoidTodynamic())))); |
936 } | 966 } |
937 } finally { | 967 } finally { |
938 yield it.cancel(); | 968 yield it.cancel(); |
939 } | 969 } |
940 return r; | 970 return r; |
941 }, dart.dynamic, s); | 971 }, core.int, s); |
942 } | 972 } |
943 dart.fn(f, dynamicTodynamic()); | 973 dart.fn(f, dynamicToFutureOfint()); |
944 return dart.dsend(f(mkStream(5)), 'then', dart.fn(v => { | 974 return f(mkStream(5)).then(dart.dynamic)(dart.fn(v => { |
945 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10))
; | 975 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10))
; |
946 }, dynamicTodynamic())); | 976 }, intTodynamic())); |
947 }, VoidTodynamic())); | 977 }, VoidToFuture())); |
948 unittest$.test("simple stream - take", dart.fn(() => { | 978 unittest$.test("simple stream - take", dart.fn(() => { |
949 function f(s) { | 979 function f(s) { |
950 return dart.async(function*(s) { | 980 return dart.async(function*(s) { |
951 let r = 0; | 981 let r = 0; |
952 let it = async.StreamIterator.new(async.Stream._check(dart.dsend(s,
'take', 5))); | 982 let it = async.StreamIterator.new(async.Stream._check(dart.dsend(s,
'take', 5))); |
953 try { | 983 try { |
954 while (yield it.moveNext()) { | 984 while (yield it.moveNext()) { |
955 let v = it.current; | 985 let v = it.current; |
956 r = dart.notNull(r) + dart.notNull(core.int._check(v)); | 986 r = dart.notNull(r) + dart.notNull(core.int._check(v)); |
957 } | 987 } |
958 } finally { | 988 } finally { |
959 yield it.cancel(); | 989 yield it.cancel(); |
960 } | 990 } |
961 return r; | 991 return r; |
962 }, dart.dynamic, s); | 992 }, core.int, s); |
963 } | 993 } |
964 dart.fn(f, dynamicTodynamic()); | 994 dart.fn(f, dynamicToFutureOfint()); |
965 return dart.dsend(f(mkStream(10)), 'then', dart.fn(v => { | 995 return f(mkStream(10)).then(dart.dynamic)(dart.fn(v => { |
966 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10))
; | 996 src__matcher__expect.expect(v, src__matcher__core_matchers.equals(10))
; |
967 }, dynamicTodynamic())); | 997 }, intTodynamic())); |
968 }, VoidTodynamic())); | 998 }, VoidToFuture())); |
969 unittest$.test("simple stream reyield", dart.fn(() => { | 999 unittest$.test("simple stream reyield", dart.fn(() => { |
970 function f(s) { | 1000 function f(s) { |
971 return dart.asyncStar(function*(stream, s) { | 1001 return dart.asyncStar(function*(stream, s) { |
972 let r = 0; | 1002 let r = 0; |
973 let it = async.StreamIterator.new(async.Stream._check(s)); | 1003 let it = async.StreamIterator.new(async.Stream._check(s)); |
974 try { | 1004 try { |
975 while (yield it.moveNext()) { | 1005 while (yield it.moveNext()) { |
976 let v = it.current; | 1006 let v = it.current; |
977 if (stream.add((r = dart.notNull(r) + dart.notNull(core.int._che
ck(v))))) return; | 1007 if (stream.add((r = dart.notNull(r) + dart.notNull(core.int._che
ck(v))))) return; |
978 yield; | 1008 yield; |
979 } | 1009 } |
980 } finally { | 1010 } finally { |
981 yield it.cancel(); | 1011 yield it.cancel(); |
982 } | 1012 } |
983 }, dart.dynamic, s); | 1013 }, core.num, s); |
984 } | 1014 } |
985 dart.fn(f, dynamicTodynamic()); | 1015 dart.fn(f, dynamicToStreamOfnum()); |
986 return async_star_test_03_multi.expectList(f(mkStream(5)), JSArrayOfint(
).of([0, 1, 3, 6, 10])); | 1016 return async_star_test_03_multi.expectList(f(mkStream(5)), JSArrayOfint(
).of([0, 1, 3, 6, 10])); |
987 }, VoidTodynamic())); | 1017 }, VoidTodynamic())); |
988 unittest$.test("simple stream, await, reyield", dart.fn(() => { | 1018 unittest$.test("simple stream, await, reyield", dart.fn(() => { |
989 function f(s) { | 1019 function f(s) { |
990 return dart.asyncStar(function*(stream, s) { | 1020 return dart.asyncStar(function*(stream, s) { |
991 let r = 0; | 1021 let r = 0; |
992 let it = async.StreamIterator.new(async.Stream._check(s)); | 1022 let it = async.StreamIterator.new(async.Stream._check(s)); |
993 try { | 1023 try { |
994 while (yield it.moveNext()) { | 1024 while (yield it.moveNext()) { |
995 let v = it.current; | 1025 let v = it.current; |
996 if (stream.add((r = dart.notNull(r) + dart.notNull(core.int._che
ck(yield async.Future.microtask(dart.fn(() => v, VoidTodynamic()))))))) return; | 1026 if (stream.add((r = dart.notNull(r) + dart.notNull(core.int._che
ck(yield async.Future.microtask(dart.fn(() => v, VoidTodynamic()))))))) return; |
997 yield; | 1027 yield; |
998 } | 1028 } |
999 } finally { | 1029 } finally { |
1000 yield it.cancel(); | 1030 yield it.cancel(); |
1001 } | 1031 } |
1002 }, dart.dynamic, s); | 1032 }, core.num, s); |
1003 } | 1033 } |
1004 dart.fn(f, dynamicTodynamic()); | 1034 dart.fn(f, dynamicToStreamOfnum()); |
1005 return async_star_test_03_multi.expectList(f(mkStream(5)), JSArrayOfint(
).of([0, 1, 3, 6, 10])); | 1035 return async_star_test_03_multi.expectList(f(mkStream(5)), JSArrayOfint(
).of([0, 1, 3, 6, 10])); |
1006 }, VoidTodynamic())); | 1036 }, VoidTodynamic())); |
1007 unittest$.test("nested", dart.fn(() => { | 1037 unittest$.test("nested", dart.fn(() => { |
1008 function f() { | 1038 function f() { |
1009 return dart.async(function*() { | 1039 return dart.async(function*() { |
1010 let r = 0; | 1040 let r = 0; |
1011 let it = async.StreamIterator.new(async.Stream._check(mkStream(5))); | 1041 let it = async.StreamIterator.new(mkStream(5)); |
1012 try { | 1042 try { |
1013 while (yield it.moveNext()) { | 1043 while (yield it.moveNext()) { |
1014 let i = it.current; | 1044 let i = it.current; |
1015 let it$ = async.StreamIterator.new(async.Stream._check(mkStream(
3))); | 1045 let it$ = async.StreamIterator.new(mkStream(3)); |
1016 try { | 1046 try { |
1017 while (yield it$.moveNext()) { | 1047 while (yield it$.moveNext()) { |
1018 let j = it$.current; | 1048 let j = it$.current; |
1019 r = dart.notNull(r) + dart.notNull(core.int._check(dart.dsen
d(i, '*', j))); | 1049 r = r + dart.notNull(i) * dart.notNull(j); |
1020 } | 1050 } |
1021 } finally { | 1051 } finally { |
1022 yield it$.cancel(); | 1052 yield it$.cancel(); |
1023 } | 1053 } |
1024 } | 1054 } |
1025 } finally { | 1055 } finally { |
1026 yield it.cancel(); | 1056 yield it.cancel(); |
1027 } | 1057 } |
1028 return r; | 1058 return r; |
1029 }, dart.dynamic); | 1059 }, core.int); |
1030 } | 1060 } |
1031 dart.fn(f, VoidTodynamic()); | 1061 dart.fn(f, VoidToFutureOfint()); |
1032 return dart.dsend(f(), 'then', dart.fn(v => { | 1062 return f().then(dart.dynamic)(dart.fn(v => { |
1033 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); | 1063 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); |
1034 }, dynamicTodynamic())); | 1064 }, intTodynamic())); |
1035 }, VoidTodynamic())); | 1065 }, VoidToFuture())); |
1036 unittest$.test("nested, await", dart.fn(() => { | 1066 unittest$.test("nested, await", dart.fn(() => { |
1037 function f() { | 1067 function f() { |
1038 return dart.async(function*() { | 1068 return dart.async(function*() { |
1039 let r = 0; | 1069 let r = 0; |
1040 let it = async.StreamIterator.new(async.Stream._check(mkStream(5))); | 1070 let it = async.StreamIterator.new(mkStream(5)); |
1041 try { | 1071 try { |
1042 while (yield it.moveNext()) { | 1072 while (yield it.moveNext()) { |
1043 let i = it.current; | 1073 let i = it.current; |
1044 let it$ = async.StreamIterator.new(async.Stream._check(mkStream(
3))); | 1074 let it$ = async.StreamIterator.new(mkStream(3)); |
1045 try { | 1075 try { |
1046 while (yield it$.moveNext()) { | 1076 while (yield it$.moveNext()) { |
1047 let j = it$.current; | 1077 let j = it$.current; |
1048 r = dart.notNull(r) + dart.notNull(core.int._check(yield asy
nc.Future.microtask(dart.fn(() => dart.dsend(i, '*', j), VoidTodynamic())))); | 1078 r = dart.notNull(r) + dart.notNull(core.int._check(yield asy
nc.Future.microtask(dart.fn(() => dart.notNull(i) * dart.notNull(j), VoidToint()
)))); |
1049 } | 1079 } |
1050 } finally { | 1080 } finally { |
1051 yield it$.cancel(); | 1081 yield it$.cancel(); |
1052 } | 1082 } |
1053 } | 1083 } |
1054 } finally { | 1084 } finally { |
1055 yield it.cancel(); | 1085 yield it.cancel(); |
1056 } | 1086 } |
1057 return r; | 1087 return r; |
1058 }, dart.dynamic); | 1088 }, core.int); |
1059 } | 1089 } |
1060 dart.fn(f, VoidTodynamic()); | 1090 dart.fn(f, VoidToFutureOfint()); |
1061 return dart.dsend(f(), 'then', dart.fn(v => { | 1091 return f().then(dart.dynamic)(dart.fn(v => { |
1062 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); | 1092 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); |
1063 }, dynamicTodynamic())); | 1093 }, intTodynamic())); |
1064 }, VoidTodynamic())); | 1094 }, VoidToFuture())); |
1065 unittest$.test("nested, await * 2", dart.fn(() => { | 1095 unittest$.test("nested, await * 2", dart.fn(() => { |
1066 function f() { | 1096 function f() { |
1067 return dart.async(function*() { | 1097 return dart.async(function*() { |
1068 let r = 0; | 1098 let r = 0; |
1069 let it = async.StreamIterator.new(async.Stream._check(mkStream(5))); | 1099 let it = async.StreamIterator.new(mkStream(5)); |
1070 try { | 1100 try { |
1071 while (yield it.moveNext()) { | 1101 while (yield it.moveNext()) { |
1072 let i = it.current; | 1102 let i = it.current; |
1073 let ai = (yield async.Future.microtask(dart.fn(() => i, VoidTody
namic()))); | 1103 let ai = (yield async.Future.microtask(dart.fn(() => i, VoidToin
t()))); |
1074 let it$ = async.StreamIterator.new(async.Stream._check(mkStream(
3))); | 1104 let it$ = async.StreamIterator.new(mkStream(3)); |
1075 try { | 1105 try { |
1076 while (yield it$.moveNext()) { | 1106 while (yield it$.moveNext()) { |
1077 let j = it$.current; | 1107 let j = it$.current; |
1078 r = dart.notNull(r) + dart.notNull(core.int._check(yield asy
nc.Future.microtask(dart.fn(() => dart.dsend(ai, '*', j), VoidTodynamic())))); | 1108 r = dart.notNull(r) + dart.notNull(core.int._check(yield asy
nc.Future.microtask(dart.fn(() => dart.dsend(ai, '*', j), VoidTodynamic())))); |
1079 } | 1109 } |
1080 } finally { | 1110 } finally { |
1081 yield it$.cancel(); | 1111 yield it$.cancel(); |
1082 } | 1112 } |
1083 } | 1113 } |
1084 } finally { | 1114 } finally { |
1085 yield it.cancel(); | 1115 yield it.cancel(); |
1086 } | 1116 } |
1087 return r; | 1117 return r; |
1088 }, dart.dynamic); | 1118 }, core.int); |
1089 } | 1119 } |
1090 dart.fn(f, VoidTodynamic()); | 1120 dart.fn(f, VoidToFutureOfint()); |
1091 return dart.dsend(f(), 'then', dart.fn(v => { | 1121 return f().then(dart.dynamic)(dart.fn(v => { |
1092 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); | 1122 src__matcher__expect.expect(v, src__matcher__core_matchers.equals((1 +
2 + 3 + 4) * (1 + 2))); |
1093 }, dynamicTodynamic())); | 1123 }, intTodynamic())); |
1094 }, VoidTodynamic())); | 1124 }, VoidToFuture())); |
1095 }, VoidTovoid())); | 1125 }, VoidTovoid())); |
1096 }; | 1126 }; |
1097 dart.fn(async_star_test_03_multi.main, VoidTodynamic()); | 1127 dart.fn(async_star_test_03_multi.main, VoidTodynamic()); |
1098 async_star_test_03_multi.id = function(x) { | 1128 async_star_test_03_multi.id = function(x) { |
1099 try { | 1129 try { |
1100 if (x != null) dart.throw(x); | 1130 if (x != null) dart.throw(x); |
1101 } catch (e) { | 1131 } catch (e) { |
1102 return e; | 1132 return e; |
1103 } | 1133 } |
1104 | 1134 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 }; | 1186 }; |
1157 dart.setSignature(async_star_test_03_multi.Sync, { | 1187 dart.setSignature(async_star_test_03_multi.Sync, { |
1158 methods: () => ({ | 1188 methods: () => ({ |
1159 wait: dart.definiteFunctionType(async.Future, [], [dart.dynamic]), | 1189 wait: dart.definiteFunctionType(async.Future, [], [dart.dynamic]), |
1160 release: dart.definiteFunctionType(dart.void, [], [dart.dynamic]) | 1190 release: dart.definiteFunctionType(dart.void, [], [dart.dynamic]) |
1161 }) | 1191 }) |
1162 }); | 1192 }); |
1163 // Exports: | 1193 // Exports: |
1164 exports.async_star_test_03_multi = async_star_test_03_multi; | 1194 exports.async_star_test_03_multi = async_star_test_03_multi; |
1165 }); | 1195 }); |
OLD | NEW |