Permalink
Browse files

SERVER-446 js implementation of keySet()

  • Loading branch information...
1 parent 83d4e4f commit 81b7e051b2c42e47566b9005e3db13e6a59ea68b @astaple astaple committed Dec 21, 2009
View
@@ -5,5 +5,5 @@ t.drop();
t.insert( { "one" : { "two" : {"three":"four"} } } );
x = t.find({},{"one.two":1})[0]
-assert.eq( 1 , x.one.keySet().length , "ks l 1" );
+assert.eq( 1 , Object.keySet( x.one ).length , "ks l 1" );
View
@@ -16,7 +16,7 @@ assert.eq( "/abc/i" , real.c.toString() , "regex 1" );
var cursor = t.find( { $where :
function(){
fullObject;
- assert.eq( 7 , obj.keySet().length , "A" )
+ 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" );
@@ -37,7 +37,7 @@ t.save( { a : 2 , b : { c : 7 , d : "d is good" } } );
var cursor = t.find( { $where :
function(){
fullObject;
- assert.eq( 3 , obj.keySet().length )
+ 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 );
View
@@ -60,7 +60,7 @@ x.find().forEach( d );
z = {};
x.find().forEach( function(a){ z[a[ks]] = a.value.count; } );
d( z );
-assert.eq( 3 , z.keySet().length , "C" );
+assert.eq( 3 , Object.keySet( z ).length , "C" );
assert.eq( 2 , z.a , "D" );
assert.eq( 3 , z.b , "E" );
assert.eq( 3 , z.c , "F" );
View
@@ -28,7 +28,7 @@ r = function( key , values ){
res = t.mapReduce( m , r );
z = res.convertToSingleObject()
-assert.eq( 3 , z.keySet().length , "A1" );
+assert.eq( 3 , Object.keySet( z ).length , "A1" );
assert.eq( 2 , z.a.count , "A2" );
assert.eq( 3 , z.b.count , "A3" );
assert.eq( 3 , z.c.count , "A4" );
@@ -38,7 +38,7 @@ res.drop();
res = t.mapReduce( m , r , { mapparams : [ 2 , 2 ] } );
z = res.convertToSingleObject()
-assert.eq( 3 , z.keySet().length , "B1" );
+assert.eq( 3 , Object.keySet( z ).length , "B1" );
assert.eq( 8 , z.a.count , "B2" );
assert.eq( 12 , z.b.count , "B3" );
assert.eq( 12 , z.c.count , "B4" );
View
@@ -26,7 +26,7 @@ r = function( key , values ){
res = t.mapReduce( m , r , { scope : { xx : 1 } } );
z = res.convertToSingleObject()
-assert.eq( 3 , z.keySet().length , "A1" );
+assert.eq( 3 , Object.keySet( z ).length , "A1" );
assert.eq( 2 , z.a.count , "A2" );
assert.eq( 3 , z.b.count , "A3" );
assert.eq( 3 , z.c.count , "A4" );
@@ -37,7 +37,7 @@ res.drop();
res = t.mapReduce( m , r , { scope : { xx : 2 } } );
z = res.convertToSingleObject()
-assert.eq( 3 , z.keySet().length , "A1" );
+assert.eq( 3 , Object.keySet( z ).length , "A1" );
assert.eq( 4 , z.a.count , "A2" );
assert.eq( 6 , z.b.count , "A3" );
assert.eq( 6 , z.c.count , "A4" );
View
@@ -29,7 +29,7 @@ res = t.mapReduce( m , r , { scope : { xx : 1 } } );
res.find().forEach( printjson )
z = res.convertToSingleObject()
-assert.eq( 2 , z.keySet().length , "A" )
+assert.eq( 2 , Object.keySet( z ).length , "A" )
assert.eq( [ 9 , 11 , 30 ] , z["1"].stats , "B" )
assert.eq( [ 9 , 41 , 41 ] , z["2"].stats , "B" )
View
@@ -5,12 +5,12 @@ t.drop();
t.insert( { _id : 1, emb : {} });
t.update( { _id : 1 }, { $set : { emb : { 'a.dot' : 'data'} }});
-assert.eq( 1 , t.findOne().emb.keySet().length , "A" );
-assert.eq( "a.dot" , t.findOne().emb.keySet()[0] , "B" );
+assert.eq( 1 , Object.keySet( t.findOne().emb ).length , "A" );
+assert.eq( "a.dot" , Object.keySet( t.findOne().emb )[0] , "B" );
t.update( { _id : 1 }, { $set : { 'emb.b' : { dot : 'data'} }});
-assert.eq( 2 , t.findOne().emb.keySet().length , "C" );
-//assert.eq( "a.dot" , t.findOne().emb.keySet()[0] , "D" );
-//assert.eq( "b" , t.findOne().emb.keySet()[0] , "E" );
+assert.eq( 2 , Object.keySet( t.findOne().emb ).length , "C" );
+//assert.eq( "a.dot" , Object.keySet( t.findOne().emb )[0] , "D" );
+//assert.eq( "b" , Obkect.keySet( t.findOne().emb )[0] , "E" );
@@ -95,7 +95,7 @@ doMR = function( n ){
var z = {};
x.find().forEach( function(a){ z[a._id] = a.value.count; } );
- assert.eq( 3 , z.keySet().length , "MR T2 " + n );
+ assert.eq( 3 , Object.keySet( z ).length , "MR T2 " + n );
assert.eq( 2 , z.a , "MR T2 " + n );
assert.eq( 3 , z.b , "MR T2 " + n );
assert.eq( 3 , z.c , "MR T2 " + n );
View
@@ -6,11 +6,11 @@ t.save( { a : 1 , b : { c : 1 , d : 1 } } );
t.update( { a : 1 } , { $inc : { "b.c" : 1 } } );
assert.eq( 2 , t.findOne().b.c , "A" );
-assert.eq( "c,d" , t.findOne().b.keySet().toString() , "B" );
+assert.eq( "c,d" , Object.keySet( t.findOne().b ).toString() , "B" );
t.update( { a : 1 } , { $inc : { "b.0e" : 1 } } );
assert.eq( 1 , t.findOne().b["0e"] , "C" );
-assert.eq( "0e,c,d" , t.findOne().b.keySet().toString() , "D" );
+assert.eq( "0e,c,d" , Object.keySet( t.findOne().b ).toString() , "D" );
// -----
@@ -23,9 +23,9 @@ t.save( {"_id" : 2 ,
);
-assert.eq( 4 , t.find({_id:2},{b3:1})[0].b3.keySet().length , "test 1 : ks before" );
+assert.eq( 4 , Object.keySet( t.find({_id:2},{b3:1})[0].b3 ).length , "test 1 : ks before" );
t.update({_id:2},{$inc: { 'b3.0719' : 1}},true)
-assert.eq( 5 , t.find({_id:2},{b3:1})[0].b3.keySet().length , "test 1 : ks after" );
+assert.eq( 5 , Object.keySet( t.find({_id:2},{b3:1})[0].b3 ).length , "test 1 : ks after" );
// -----
@@ -39,8 +39,8 @@ t.save( {"_id" : 2 ,
);
-assert.eq( 4 , t.find({_id:2},{b3:1})[0].b3.keySet().length , "test 2 : ks before" );
+assert.eq( 4 , Object.keySet( t.find({_id:2},{b3:1})[0].b3 ).length , "test 2 : ks before" );
printjson( t.find({_id:2},{b3:1})[0].b3 )
t.update({_id:2},{$inc: { 'b3.0719' : 1}} )
printjson( t.find({_id:2},{b3:1})[0].b3 )
-assert.eq( 5 , t.find({_id:2},{b3:1})[0].b3.keySet().length , "test 2 : ks after" );
+assert.eq( 5 , Object.keySet( t.find({_id:2},{b3:1})[0].b3 ).length , "test 2 : ks after" );
Oops, something went wrong.

0 comments on commit 81b7e05

Please sign in to comment.