Skip to content

Commit

Permalink
JS tests for SERVER-5127
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Briskin committed Jul 12, 2012
1 parent 64b4f8d commit d8a7ced
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
27 changes: 27 additions & 0 deletions jstests/nestedarr1.js
@@ -0,0 +1,27 @@
//SERVER-5127, SERVER-5036

function makeNestArr(depth){
if(depth == 1){
return {a : [depth]};
}
else{
return {a : [makeNestArr(depth - 1)] };
}
}

t = db.arrNestTest;
t.drop();
t.ensureIndex({a:1});

nestedArr = makeNestArr(300);
print(nestedArr);

t.save( { tst : "test1", a : nestedArr } );
t.save( { tst : "test2", a : nestedArr } );
t.save( { tst : "test3", a : nestedArr } );

assert.eq(3, t.count(), "records in collection");
assert.eq(1, t.find({tst : "test2"}).count(), "find test");

//make sure index insertion failed (nesting must be large enough)
assert.eq(0, t.find().hint({a:1}).explain().n, "index not empty");
29 changes: 29 additions & 0 deletions jstests/nestedobj1.js
@@ -0,0 +1,29 @@
//SERVER-5127, SERVER-5036


function makeNestObj(depth){
toret = { a : 1};

for(i = 1; i < depth; i++){
toret = {a : toret};
}

return toret;
}

t = db.objNestTest;
t.drop();
t.ensureIndex({a:1});

nestedObj = makeNestObj(1500);
print(nestedObj);

t.insert( { tst : "test1", a : nestedObj }, true );
t.insert( { tst : "test2", a : nestedObj }, true );
t.insert( { tst : "test3", a : nestedObj }, true );

assert.eq(3, t.count(), "records in collection");
assert.eq(1, t.find({tst : "test2"}).count(), "find test");

//make sure index insertion failed (nesting must be large enough)
assert.eq(0, t.find().hint({a:1}).explain().n, "index not empty");

0 comments on commit d8a7ced

Please sign in to comment.