@@ -341,6 +341,7 @@ suite('DatabaseSync.prototype.close()', () => {
341341
342342 const select = db . prepare ( 'SELECT * FROM data' ) ;
343343 const insert = db . prepare ( 'INSERT INTO data (key, val) VALUES (?, ?)' ) ;
344+ const iterator = select . iterate ( ) ;
344345
345346 t . assert . strictEqual ( db . close ( ) , undefined ) ;
346347 t . assert . strictEqual ( db . isOpen , false ) ;
@@ -366,12 +367,24 @@ suite('DatabaseSync.prototype.close()', () => {
366367 code : 'ERR_INVALID_STATE' ,
367368 message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
368369 } ) ;
370+ t . assert . throws ( ( ) => {
371+ select . iterate ( ) ;
372+ } , {
373+ code : 'ERR_INVALID_STATE' ,
374+ message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
375+ } ) ;
369376 t . assert . throws ( ( ) => {
370377 insert . run ( 2 , 4 ) ;
371378 } , {
372379 code : 'ERR_INVALID_STATE' ,
373380 message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
374381 } ) ;
382+ t . assert . throws ( ( ) => {
383+ iterator . next ( ) ;
384+ } , {
385+ code : 'ERR_INVALID_STATE' ,
386+ message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
387+ } ) ;
375388 } ) ;
376389
377390 test ( 'keeps prepared statements invalid after reopening' , ( t ) => {
@@ -387,6 +400,7 @@ suite('DatabaseSync.prototype.close()', () => {
387400
388401 const select = db . prepare ( 'SELECT * FROM data' ) ;
389402 const insert = db . prepare ( 'INSERT INTO data (key, val) VALUES (?, ?)' ) ;
403+ const iterator = select . iterate ( ) ;
390404
391405 db . close ( ) ;
392406 db . open ( ) ;
@@ -403,12 +417,24 @@ suite('DatabaseSync.prototype.close()', () => {
403417 code : 'ERR_INVALID_STATE' ,
404418 message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
405419 } ) ;
420+ t . assert . throws ( ( ) => {
421+ select . iterate ( ) ;
422+ } , {
423+ code : 'ERR_INVALID_STATE' ,
424+ message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
425+ } ) ;
406426 t . assert . throws ( ( ) => {
407427 insert . run ( 2 , 4 ) ;
408428 } , {
409429 code : 'ERR_INVALID_STATE' ,
410430 message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
411431 } ) ;
432+ t . assert . throws ( ( ) => {
433+ iterator . next ( ) ;
434+ } , {
435+ code : 'ERR_INVALID_STATE' ,
436+ message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
437+ } ) ;
412438
413439 t . assert . deepStrictEqual (
414440 db . prepare ( 'SELECT * FROM data' ) . all ( ) ,
@@ -620,6 +646,7 @@ suite('DatabaseSync.prototype[Symbol.dispose]', () => {
620646
621647 const select = db . prepare ( 'SELECT * FROM data' ) ;
622648 const insert = db . prepare ( 'INSERT INTO data (key, val) VALUES (?, ?)' ) ;
649+ const iterator = select . iterate ( ) ;
623650
624651 db [ Symbol . dispose ] ( ) ;
625652 t . assert . strictEqual ( db . isOpen , false ) ;
@@ -645,11 +672,23 @@ suite('DatabaseSync.prototype[Symbol.dispose]', () => {
645672 code : 'ERR_INVALID_STATE' ,
646673 message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
647674 } ) ;
675+ t . assert . throws ( ( ) => {
676+ select . iterate ( ) ;
677+ } , {
678+ code : 'ERR_INVALID_STATE' ,
679+ message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
680+ } ) ;
648681 t . assert . throws ( ( ) => {
649682 insert . run ( 2 , 4 ) ;
650683 } , {
651684 code : 'ERR_INVALID_STATE' ,
652685 message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
653686 } ) ;
687+ t . assert . throws ( ( ) => {
688+ iterator . next ( ) ;
689+ } , {
690+ code : 'ERR_INVALID_STATE' ,
691+ message : / s t a t e m e n t h a s b e e n f i n a l i z e d / ,
692+ } ) ;
654693 } ) ;
655694} ) ;
0 commit comments