diff options
Diffstat (limited to 'jstests/core/capped6.js')
-rw-r--r-- | jstests/core/capped6.js | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/jstests/core/capped6.js b/jstests/core/capped6.js index e643c77760d..d7b8a60985a 100644 --- a/jstests/core/capped6.js +++ b/jstests/core/capped6.js @@ -12,19 +12,19 @@ * check is performed in both forward and reverse directions. */ function checkOrder(i, valueArray) { - res = coll.find().sort( { $natural: -1 } ); - assert( res.hasNext(), "A" ); + res = coll.find().sort({$natural: -1}); + assert(res.hasNext(), "A"); var j = i; - while(res.hasNext()) { - assert.eq( valueArray[j--].a, res.next().a, "B" ); + while (res.hasNext()) { + assert.eq(valueArray[j--].a, res.next().a, "B"); } - res = coll.find().sort( { $natural: 1 } ); - assert( res.hasNext(), "C" ); - while( res.hasNext() ) { - assert.eq( valueArray[++j].a, res.next().a, "D" ); + res = coll.find().sort({$natural: 1}); + assert(res.hasNext(), "C"); + while (res.hasNext()) { + assert.eq(valueArray[++j].a, res.next().a, "D"); } - assert.eq( j, i, "E" ); + assert.eq(j, i, "E"); } /* @@ -32,13 +32,15 @@ */ function prepareCollection(shouldReverse) { coll.drop(); - db._dbCommand({create: "capped6", capped: true, size: 1000, $nExtents: 11, - autoIndexId: false}); + db._dbCommand( + {create: "capped6", capped: true, size: 1000, $nExtents: 11, autoIndexId: false}); var valueArray = new Array(maxDocuments); var c = ""; - for( i = 0; i < maxDocuments; ++i, c += "-" ) { + for (i = 0; i < maxDocuments; ++i, c += "-") { // The a values are strings of increasing length. - valueArray[i] = {a: c}; + valueArray[i] = { + a: c + }; } if (shouldReverse) { valueArray.reverse(); @@ -52,11 +54,10 @@ * 'maxDocuments' number of documents since it is a capped collection. * 2. Remove all but one documents via one or more "captrunc" requests. * 3. For each subsequent call to this function, keep track of the removed documents using - * 'valueArrayIndexes' and re-insert the removed documents each time this function is + * 'valueArrayIndexes' and re-insert the removed documents each time this function is * called. */ function runCapTrunc(valueArray, valueArrayCurIndex, n, inc) { - // If n <= 0, no documents are removed by captrunc. assert.gt(n, 0); assert.gte(valueArray.length, maxDocuments); @@ -73,7 +74,7 @@ var iterations = Math.floor((count - 1) / (n + inc)); for (i = 0; i < iterations; ++i) { - assert.commandWorked(db.runCommand({captrunc:"capped6", n:n, inc:inc})); + assert.commandWorked(db.runCommand({captrunc: "capped6", n: n, inc: inc})); count -= (n + inc); valueArrayCurIndex -= (n + inc); checkOrder(valueArrayCurIndex, valueArray); |