@@ -11,17 +11,6 @@ const {
11
11
const assert = require ( 'assert' ) ;
12
12
13
13
async function tests ( ) {
14
- {
15
- const AsyncIteratorPrototype = Object . getPrototypeOf (
16
- Object . getPrototypeOf ( async function * ( ) { } ) . prototype ) ;
17
- const rs = new Readable ( {
18
- read ( ) { }
19
- } ) ;
20
- assert . strictEqual (
21
- Object . getPrototypeOf ( Object . getPrototypeOf ( rs [ Symbol . asyncIterator ] ( ) ) ) ,
22
- AsyncIteratorPrototype ) ;
23
- }
24
-
25
14
{
26
15
// v1 stream
27
16
@@ -53,7 +42,9 @@ async function tests() {
53
42
} ) ;
54
43
55
44
const iter = Readable . prototype [ Symbol . asyncIterator ] . call ( stream ) ;
56
- iter . next ( ) . catch ( common . mustCall ( ( err ) => {
45
+ await iter . next ( ) ;
46
+ await iter . next ( ) ;
47
+ await iter . next ( ) . catch ( common . mustCall ( ( err ) => {
57
48
assert . strictEqual ( err . message , 'asd' ) ;
58
49
} ) ) ;
59
50
}
@@ -189,12 +180,19 @@ async function tests() {
189
180
resolved . forEach ( common . mustCall (
190
181
( item , i ) => assert . strictEqual ( item . value , 'hello-' + i ) , max ) ) ;
191
182
192
- errors . forEach ( ( promise ) => {
183
+ errors . slice ( 0 , 1 ) . forEach ( ( promise ) => {
193
184
promise . catch ( common . mustCall ( ( err ) => {
194
185
assert . strictEqual ( err . message , 'kaboom' ) ;
195
186
} ) ) ;
196
187
} ) ;
197
188
189
+ errors . slice ( 1 ) . forEach ( ( promise ) => {
190
+ promise . then ( common . mustCall ( ( { done, value } ) => {
191
+ assert . strictEqual ( done , true ) ;
192
+ assert . strictEqual ( value , undefined ) ;
193
+ } ) ) ;
194
+ } ) ;
195
+
198
196
readable . destroy ( new Error ( 'kaboom' ) ) ;
199
197
}
200
198
@@ -284,28 +282,6 @@ async function tests() {
284
282
assert . strictEqual ( received , 1 ) ;
285
283
}
286
284
287
- {
288
- // Iterator throw.
289
-
290
- const readable = new Readable ( {
291
- objectMode : true ,
292
- read ( ) {
293
- this . push ( 'hello' ) ;
294
- }
295
- } ) ;
296
-
297
- readable . on ( 'error' , common . mustCall ( ( err ) => {
298
- assert . strictEqual ( err . message , 'kaboom' ) ;
299
- } ) ) ;
300
-
301
- const it = readable [ Symbol . asyncIterator ] ( ) ;
302
- it . throw ( new Error ( 'kaboom' ) ) . catch ( common . mustCall ( ( err ) => {
303
- assert . strictEqual ( err . message , 'kaboom' ) ;
304
- } ) ) ;
305
-
306
- assert . strictEqual ( readable . destroyed , true ) ;
307
- }
308
-
309
285
{
310
286
console . log ( 'destroyed by throw' ) ;
311
287
const readable = new Readable ( {
@@ -577,12 +553,15 @@ async function tests() {
577
553
assert . strictEqual ( e , err ) ;
578
554
} ) ( ) , ( async ( ) => {
579
555
let e ;
556
+ let x ;
580
557
try {
581
- await d ;
558
+ x = await d ;
582
559
} catch ( _e ) {
583
560
e = _e ;
584
561
}
585
- assert . strictEqual ( e , err ) ;
562
+ assert . strictEqual ( e , undefined ) ;
563
+ assert . strictEqual ( x . done , true ) ;
564
+ assert . strictEqual ( x . value , undefined ) ;
586
565
} ) ( ) ] ) ;
587
566
}
588
567
0 commit comments