11const makeTest = require ( './make' )
22const repeats = 200
33
4- makeTest ( 'test ended iterator' , function ( db , t , done ) {
5- // First test normal and proper usage: calling it.end() before db.close()
4+ makeTest ( 'test legacy ended iterator' , function ( db , t , done ) {
5+ // First test the old proper usage: calling it.end() before db.close().
66 var it = db . iterator ( { keyAsBuffer : false , valueAsBuffer : false } )
77
88 it . next ( function ( err , key , value ) {
@@ -17,7 +17,7 @@ makeTest('test ended iterator', function (db, t, done) {
1717} )
1818
1919makeTest ( 'test likely-ended iterator' , function ( db , t , done ) {
20- // Test improper usage: not calling it.end() before db.close(). Cleanup of the
20+ // Test simpler usage: not calling it.end() before db.close(). Cleanup of the
2121 // database will crash Node if not handled properly.
2222 var it = db . iterator ( { keyAsBuffer : false , valueAsBuffer : false } )
2323
@@ -49,7 +49,7 @@ makeTest('test non-ended iterator', function (db, t, done) {
4949
5050makeTest ( 'test multiple likely-ended iterators' , function ( db , t , done ) {
5151 // Same as the test above but repeated and with an extra iterator that is not
52- // nexting, which means its EndWorker will be executed almost immediately .
52+ // nexting, which follows a different (faster) code path .
5353 for ( let i = 0 ; i < repeats ; i ++ ) {
5454 db . iterator ( )
5555 db . iterator ( ) . next ( function ( ) { } )
@@ -70,7 +70,7 @@ makeTest('test multiple non-ended iterators', function (db, t, done) {
7070
7171global . gc && makeTest ( 'test multiple non-ended iterators with forced gc' , function ( db , t , done ) {
7272 // Same as the test above but with forced GC, to test that the lifespan of an
73- // iterator is tied to *both* its JS object and whether the iterator was ended .
73+ // iterator is tied to *both* its JS object and whether it's busy (nexting) .
7474 for ( let i = 0 ; i < repeats ; i ++ ) {
7575 db . iterator ( { highWaterMark : 0 } )
7676 db . iterator ( { highWaterMark : 0 } ) . next ( function ( ) { } )
@@ -83,6 +83,7 @@ global.gc && makeTest('test multiple non-ended iterators with forced gc', functi
8383} )
8484
8585global . gc && makeTest ( 'test multiple iterators with forced gc in next()' , function ( db , t , done ) {
86+ // Simulate GC in between NextWorker::DoComplete() and ::DoFinally().
8687 for ( let i = 0 ; i < 10 ; i ++ ) {
8788 db . iterator ( { highWaterMark : 0 } ) . next ( function ( ) {
8889 global . gc ( )
@@ -92,8 +93,8 @@ global.gc && makeTest('test multiple iterators with forced gc in next()', functi
9293 setImmediate ( done )
9394} )
9495
95- makeTest ( 'test ending iterators' , function ( db , t , done ) {
96- // At least one end() should be in progress when we try to close the db .
96+ makeTest ( 'test legacy ended iterators' , function ( db , t , done ) {
97+ // This test doesn't have added value anymore .
9798 var it1 = db . iterator ( ) . next ( function ( ) {
9899 it1 . end ( function ( ) { } )
99100 } )
0 commit comments