@@ -51,44 +51,50 @@ const iterableFactories = [
51
51
52
52
[ 'a sync iterable of values' , ( ) => {
53
53
const chunks = [ 'a' , 'b' ] ;
54
- const it = {
54
+ const iterator = {
55
55
next ( ) {
56
56
return {
57
57
done : chunks . length === 0 ,
58
58
value : chunks . shift ( )
59
59
} ;
60
- } ,
61
- [ Symbol . iterator ] : ( ) => it
60
+ }
61
+ } ;
62
+ const iterable = {
63
+ [ Symbol . iterator ] : ( ) => iterator
62
64
} ;
63
- return it ;
65
+ return iterable ;
64
66
} ] ,
65
67
66
68
[ 'a sync iterable of promises' , ( ) => {
67
69
const chunks = [ 'a' , 'b' ] ;
68
- const it = {
70
+ const iterator = {
69
71
next ( ) {
70
72
return chunks . length === 0 ? { done : true } : {
71
73
done : false ,
72
74
value : Promise . resolve ( chunks . shift ( ) )
73
75
} ;
74
- } ,
75
- [ Symbol . iterator ] : ( ) => it
76
+ }
77
+ } ;
78
+ const iterable = {
79
+ [ Symbol . iterator ] : ( ) => iterator
76
80
} ;
77
- return it ;
81
+ return iterable ;
78
82
} ] ,
79
83
80
84
[ 'an async iterable' , ( ) => {
81
85
const chunks = [ 'a' , 'b' ] ;
82
- const it = {
86
+ const asyncIterator = {
83
87
next ( ) {
84
88
return Promise . resolve ( {
85
89
done : chunks . length === 0 ,
86
90
value : chunks . shift ( )
87
91
} )
88
- } ,
89
- [ Symbol . asyncIterator ] : ( ) => it
92
+ }
93
+ } ;
94
+ const asyncIterable = {
95
+ [ Symbol . asyncIterator ] : ( ) => asyncIterator
90
96
} ;
91
- return it ;
97
+ return asyncIterable ;
92
98
} ] ,
93
99
94
100
[ 'a ReadableStream' , ( ) => {
@@ -186,6 +192,18 @@ test(t => {
186
192
assert_throws_exactly ( theError , ( ) => ReadableStream . from ( iterable ) , 'from() should re-throw the error' ) ;
187
193
} , `ReadableStream.from ignores @@iterator if @@asyncIterator exists` ) ;
188
194
195
+ test ( ( ) => {
196
+ const theError = new Error ( 'a unique string' ) ;
197
+ const iterable = {
198
+ [ Symbol . asyncIterator ] : null ,
199
+ [ Symbol . iterator ] ( ) {
200
+ throw theError
201
+ }
202
+ } ;
203
+
204
+ assert_throws_exactly ( theError , ( ) => ReadableStream . from ( iterable ) , 'from() should re-throw the error' ) ;
205
+ } , `ReadableStream.from ignores a null @@asyncIterator` ) ;
206
+
189
207
promise_test ( async ( ) => {
190
208
191
209
const iterable = {
0 commit comments