summaryrefslogtreecommitdiff
path: root/jstests/eval9.js
blob: 9c6642901e45c2f3afcc05366caeef47fa3b9cfc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

a = [ 1 , "asd" , null , [ 2 , 3 ] , new Date() , { x : 1 } ]

for ( var i=0; i<a.length; i++ ){
    var ret = db.eval( "function( a , i ){ return a[i]; }" , a , i );
    assert.eq( typeof( a[i] ) , typeof( ret ) , "type test" );
    assert.eq( a[i] , ret , "val test: " + typeof( a[i] ) );
}

db.eval9.drop();
db.eval9.save( { a : 17 } );

assert.eq( 1 , db.eval( "return db.eval9.find().toArray()" ).length , "A" );
assert.eq( 17 , db.eval( "return db.eval9.find().toArray()" )[0].a , "B" );

// just to make sure these things don't crash (but may throw an exception)
try {
    db.eval( "return db.eval9.find()" );
    db.eval( "return db.eval9" );
    db.eval( "return db" );
    db.eval( "return print" );
} catch (ex) { }