1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
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
assert( db.eval( "return db.eval9.find()" ) );
assert( db.eval( "return db.eval9" ) );
assert( db.eval( "return db" ) );
|