diff options
author | Antonin Kral <a.kral@bobek.cz> | 2010-01-31 08:32:52 +0100 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2010-01-31 08:32:52 +0100 |
commit | 4eefaf421bfeddf040d96a3dafb12e09673423d7 (patch) | |
tree | cb2e5ccc7f98158894f977ff131949da36673591 /jstests/jni4.js | |
download | mongodb-4eefaf421bfeddf040d96a3dafb12e09673423d7.tar.gz |
Imported Upstream version 1.3.1
Diffstat (limited to 'jstests/jni4.js')
-rw-r--r-- | jstests/jni4.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/jstests/jni4.js b/jstests/jni4.js new file mode 100644 index 0000000..b9f429e --- /dev/null +++ b/jstests/jni4.js @@ -0,0 +1,49 @@ +t = db.jni4; +t.drop(); + +real = { a : 1 , + b : "abc" , + c : /abc/i , + d : new Date(111911100111) , + e : null , + f : true + }; + +t.save( real ); + +assert.eq( "/abc/i" , real.c.toString() , "regex 1" ); + +var cursor = t.find( { $where : + function(){ + fullObject; + assert.eq( 7 , Object.keySet( obj ).length , "A" ) + assert.eq( 1 , obj.a , "B" ); + assert.eq( "abc" , obj.b , "C" ); + assert.eq( "/abc/i" , obj.c.toString() , "D" ); + assert.eq( 111911100111 , obj.d.getTime() , "E" ); + assert( obj.f , "F" ); + assert( ! obj.e , "G" ); + + return true; + } + } ); +assert.eq( 1 , cursor.toArray().length ); +assert.eq( "abc" , cursor[0].b ); + +// --- + +t.drop(); +t.save( { a : 2 , b : { c : 7 , d : "d is good" } } ); +var cursor = t.find( { $where : + function(){ + fullObject; + assert.eq( 3 , Object.keySet( obj ).length ) + assert.eq( 2 , obj.a ); + assert.eq( 7 , obj.b.c ); + assert.eq( "d is good" , obj.b.d ); + return true; + } + } ); +assert.eq( 1 , cursor.toArray().length ); + +assert(t.validate().valid); |