Permalink
Browse files

more tests passing, _id in front

  • Loading branch information...
1 parent 2ada81b commit 3247006c76379d26f490727fbea723a3583ba039 @erh erh committed May 14, 2009
Showing with 23 additions and 16 deletions.
  1. +10 −10 jstests/count.js
  2. +5 −5 jstests/objid1.js
  3. +1 −1 jstests/objid3.js
  4. +7 −0 scripting/engine_spidermonkey.cpp
View
20 jstests/count.js
@@ -3,21 +3,21 @@ t = db.jstests_count;
t.drop();
t.save( { i: 1 } );
t.save( { i: 2 } );
-assert.eq( 1, t.find( { i: 1 } ).count() );
-assert.eq( 1, t.count( { i: 1 } ) );
-assert.eq( 2, t.find().count() );
-assert.eq( 2, t.find( undefined ).count() );
-assert.eq( 2, t.find( null ).count() );
-assert.eq( 2, t.count() );
+assert.eq( 1, t.find( { i: 1 } ).count(), "A" );
+assert.eq( 1, t.count( { i: 1 } ) , "B" );
+assert.eq( 2, t.find().count() , "C" );
+assert.eq( 2, t.find( undefined ).count() , "D" );
+assert.eq( 2, t.find( null ).count() , "E" );
+assert.eq( 2, t.count() , "F" );
t.drop();
t.save( {a:true,b:false} );
t.ensureIndex( {b:1,a:1} );
-assert.eq( 1, t.find( {a:true,b:false} ).count() );
-assert.eq( 1, t.find( {b:false,a:true} ).count() );
+assert.eq( 1, t.find( {a:true,b:false} ).count() , "G" );
+assert.eq( 1, t.find( {b:false,a:true} ).count() , "H" );
t.drop();
t.save( {a:true,b:false} );
t.ensureIndex( {b:1,a:1,c:1} );
-assert.eq( 1, t.find( {a:true,b:false} ).count() );
-assert.eq( 1, t.find( {b:false,a:true} ).count() );
+assert.eq( 1, t.find( {a:true,b:false} ).count() , "I" );
+assert.eq( 1, t.find( {b:false,a:true} ).count() , "J" );
View
10 jstests/objid1.js
@@ -2,12 +2,12 @@ t = db.objid1;
t.drop();
b = new ObjectId();
-assert( b.str , "objid1 test1" );
+assert( b.str , "A" );
-a = ObjectId( b.str );
-assert.eq( a.str , b.str );
+a = new ObjectId( b.str );
+assert.eq( a.str , b.str , "B" );
t.save( { a : a } )
-assert( t.findOne().a.isObjectId );
-assert.eq( a.str , t.findOne().a.str );
+assert( t.findOne().a.isObjectId , "C" );
+assert.eq( a.str , t.findOne().a.str , "D" );
View
2 jstests/objid3.js
@@ -3,7 +3,7 @@ t.drop();
t.save( { a : "bob" , _id : 517 } );
for ( var k in t.findOne() ){
- assert.eq( k , "_id" );
+ assert.eq( k , "_id" , "keys out of order" );
break;
}
View
7 scripting/engine_spidermonkey.cpp
@@ -109,6 +109,11 @@ namespace mongo {
BSONObjBuilder b;
+ jsval theid = getProperty( o , "_id" );
+ if ( ! JSVAL_IS_VOID( theid ) ){
+ append( b , "_id" , theid );
+ }
+
JSIdArray * properties = JS_Enumerate( _context , o );
assert( properties );
@@ -117,6 +122,8 @@ namespace mongo {
jsval nameval;
assert( JS_IdToValue( _context ,id , &nameval ) );
string name = toString( nameval );
+ if ( name == "_id" )
+ continue;
append( b , name , getProperty( o , name.c_str() ) );
}

0 comments on commit 3247006

Please sign in to comment.