@@ -31,6 +31,30 @@ async function testFromAsyncGenerator() {
3131 assert . deepStrictEqual ( batches [ 1 ] [ 0 ] , new Uint8Array ( [ 30 , 40 ] ) ) ;
3232}
3333
34+ async function testFromBoundsNestedAsyncIterable ( ) {
35+ let nestedClosed = false ;
36+ async function * nested ( ) {
37+ try {
38+ let value = 0 ;
39+ while ( true ) yield new Uint8Array ( [ value ++ ] ) ;
40+ } finally {
41+ nestedClosed = true ;
42+ }
43+ }
44+
45+ async function * source ( ) {
46+ yield nested ( ) ;
47+ }
48+
49+ const iterator = from ( source ( ) ) [ Symbol . asyncIterator ] ( ) ;
50+ const first = await iterator . next ( ) ;
51+ assert . strictEqual ( first . done , false ) ;
52+ assert . strictEqual ( first . value . length , 128 ) ;
53+
54+ await iterator . return ( ) ;
55+ assert . strictEqual ( nestedClosed , true ) ;
56+ }
57+
3458async function testFromSyncIterableAsAsync ( ) {
3559 // Sync iterable passed to from() should work
3660 function * gen ( ) {
@@ -274,6 +298,7 @@ function testFromUndefinedThrows() {
274298Promise . all ( [
275299 testFromString ( ) ,
276300 testFromAsyncGenerator ( ) ,
301+ testFromBoundsNestedAsyncIterable ( ) ,
277302 testFromSyncIterableAsAsync ( ) ,
278303 testFromSyncIterableAwaitsPromiseValues ( ) ,
279304 testFromSyncIterableRejectsNestedAsyncIterable ( ) ,
0 commit comments