@@ -3017,6 +3017,53 @@ exports['Should correctly apply map to forEach'] = {
3017
3017
3018
3018
var collection = db . collection ( 'map_forEach' ) ;
3019
3019
3020
+ // insert all docs
3021
+ collection . insert ( docs , configuration . writeConcernMax ( ) , function ( err , result ) {
3022
+ test . equal ( null , err ) ;
3023
+ var total = 0 ;
3024
+
3025
+ // Create a cursor for the content
3026
+ var cursor = collection . find ( { } )
3027
+ . map ( function ( x ) { return { a :2 } ; } )
3028
+ . map ( function ( x ) { return { a : x . a * x . a } ; } )
3029
+ . batchSize ( 5 )
3030
+ . limit ( 10 ) ;
3031
+ cursor . forEach ( function ( doc ) {
3032
+ test . equal ( 4 , doc . a ) ;
3033
+ } , function ( err , doc ) {
3034
+ test . equal ( null , err ) ;
3035
+ db . close ( ) ;
3036
+ test . done ( ) ;
3037
+ } ) ;
3038
+ } )
3039
+ } ) ;
3040
+ }
3041
+ }
3042
+
3043
+ /**
3044
+ * @ignore
3045
+ * @api private
3046
+ */
3047
+ exports [ 'Should correctly apply multiple uses of map and apply forEach' ] = {
3048
+ // Add a tag that our runner can trigger on
3049
+ // in this case we are setting that node needs to be higher than 0.10.X to run
3050
+ metadata : { requires : { topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
3051
+
3052
+ // The actual test we wish to run
3053
+ test : function ( configuration , test ) {
3054
+ var docs = [ ] ;
3055
+
3056
+ for ( var i = 0 ; i < 1000 ; i ++ ) {
3057
+ var d = new Date ( ) . getTime ( ) + i * 1000 ;
3058
+ docs [ i ] = { 'a' :i , createdAt :new Date ( d ) } ;
3059
+ }
3060
+
3061
+ var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 } ) ;
3062
+ db . open ( function ( err , db ) {
3063
+ test . equal ( null , err ) ;
3064
+
3065
+ var collection = db . collection ( 'map_mapmapforEach' ) ;
3066
+
3020
3067
// insert all docs
3021
3068
collection . insert ( docs , configuration . writeConcernMax ( ) , function ( err , result ) {
3022
3069
test . equal ( null , err ) ;
0 commit comments