diff options
Diffstat (limited to 'jstests/core/eval3.js')
-rw-r--r-- | jstests/core/eval3.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/jstests/core/eval3.js b/jstests/core/eval3.js new file mode 100644 index 00000000000..404d4d863b7 --- /dev/null +++ b/jstests/core/eval3.js @@ -0,0 +1,21 @@ + +t = db.eval3; +t.drop(); + +t.save( { _id : 1 , name : "eliot" } ); +assert.eq( 1 , t.count() , "A" ); + +function z( a , b ){ + db.eval3.save( { _id : a , name : b } ); + return b; +} + +z( 2 , "sara" ); +assert.eq( 2 , t.count() , "B" ); + +assert.eq( "eliot,sara" , t.find().toArray().map( function(z){ return z.name; } ).sort().toString() ); + +assert.eq( "joe" , db.eval( z , 3 , "joe" ) , "C" ); +assert.eq( 3 , t.count() , "D" ); + +assert.eq( "eliot,joe,sara" , t.find().toArray().map( function(z){ return z.name; } ).sort().toString() ); |