diff options
Diffstat (limited to 'jstests/aggregation')
22 files changed, 51 insertions, 51 deletions
diff --git a/jstests/aggregation/bugs/firstlast.js b/jstests/aggregation/bugs/firstlast.js index b57c488e76b..5b3a92be2b4 100644 --- a/jstests/aggregation/bugs/firstlast.js +++ b/jstests/aggregation/bugs/firstlast.js @@ -7,7 +7,7 @@ t.drop(); /** Check expected $first and $last result values. */ function assertFirstLast( expectedFirst, expectedLast, pipeline, expression ) { pipeline = pipeline || []; - expression = expression || '$b' + expression = expression || '$b'; pipeline.push( { $group:{ _id:'$a', first:{ $first:expression }, last:{ $last:expression } } } ); diff --git a/jstests/aggregation/bugs/ifnull.js b/jstests/aggregation/bugs/ifnull.js index 2bc98f8393b..a8f0ccf4c66 100644 --- a/jstests/aggregation/bugs/ifnull.js +++ b/jstests/aggregation/bugs/ifnull.js @@ -8,7 +8,7 @@ t.drop(); t.save( {} ); function assertError( expectedErrorCode, ifNullSpec ) { - assertErrorCode(t, {$project: {a: {$ifNull: ifNullSpec}}}, expectedErrorCode) + assertErrorCode(t, {$project: {a: {$ifNull: ifNullSpec}}}, expectedErrorCode); } function assertResult( expectedResult, arg0, arg1 ) { diff --git a/jstests/aggregation/bugs/match.js b/jstests/aggregation/bugs/match.js index 74b36bd7014..f3f8452f059 100644 --- a/jstests/aggregation/bugs/match.js +++ b/jstests/aggregation/bugs/match.js @@ -12,9 +12,9 @@ identityProjection = { _id:'$_id', a:'$a' }; function assertError( expectedCode, matchSpec ) { matchStage = { $match:matchSpec }; // Check where matching is folded in to DocumentSourceCursor. - assertErrorCode(t, [matchStage], expectedCode) + assertErrorCode(t, [matchStage], expectedCode); // Check where matching is not folded in to DocumentSourceCursor. - assertErrorCode(t, [{$project: identityProjection}, matchStage], expectedCode) + assertErrorCode(t, [{$project: identityProjection}, matchStage], expectedCode); } /** Assert that the contents of two arrays are equal, ignoring element ordering. */ diff --git a/jstests/aggregation/bugs/server11675.js b/jstests/aggregation/bugs/server11675.js index e59eea12d26..513714f98d7 100644 --- a/jstests/aggregation/bugs/server11675.js +++ b/jstests/aggregation/bugs/server11675.js @@ -44,7 +44,7 @@ var server11675 = function() { var findRes = cursor.toArray(); var aggRes = t.aggregate(pipeline).toArray(); assert.docEq(aggRes, findRes); - } + }; assertSameAsFind({query: {}}); // sanity check assertSameAsFind({query: {$text:{$search:"apple"}}}); @@ -158,5 +158,5 @@ var server11675 = function() { // wrong $stage, but correct position assertErrorCode(t, [{$project: {searchValue: {$text: {$search: 'apple banana'}}}}], 15999); assertErrorCode(t, [{$sort: {$text: {$search: 'apple banana'}}}], 17312); -} +}; server11675(); diff --git a/jstests/aggregation/bugs/server4638.js b/jstests/aggregation/bugs/server4638.js index a6689e8ca5b..7d0f4b67e34 100644 --- a/jstests/aggregation/bugs/server4638.js +++ b/jstests/aggregation/bugs/server4638.js @@ -1,7 +1,7 @@ // SERVER-4638 - this tests explicit undefined values // This case is marked as a dup of SERVER-4674 -t = db.server4638 +t = db.server4638; t.drop(); t.insert( { _id : 0 , x : 0 , undef: undefined } ); diff --git a/jstests/aggregation/bugs/server4656.js b/jstests/aggregation/bugs/server4656.js index e66f1939f3b..cbb07f81ea5 100644 --- a/jstests/aggregation/bugs/server4656.js +++ b/jstests/aggregation/bugs/server4656.js @@ -5,12 +5,12 @@ c.drop(); NUM_OBJS = 100; -var randoms = {} +var randoms = {}; function generateRandom() { // we want unique randoms since $sort isn't guaranteed stable var random; do { - random = Math.round(Math.random() * 1000 * NUM_OBJS) + random = Math.round(Math.random() * 1000 * NUM_OBJS); } while (randoms[random]); randoms[random] = true; return random; diff --git a/jstests/aggregation/bugs/server5973.js b/jstests/aggregation/bugs/server5973.js index 2d174f9cef5..9ad4549ef80 100644 --- a/jstests/aggregation/bugs/server5973.js +++ b/jstests/aggregation/bugs/server5973.js @@ -5,9 +5,9 @@ db = db.getSiblingDB('aggdb'); db.test.drop(); -db.test.insert({d:ISODate('1950-01-01')}) -db.test.insert({d:ISODate('1980-01-01')}) +db.test.insert({d:ISODate('1950-01-01')}); +db.test.insert({d:ISODate('1980-01-01')}); var out = db.test.aggregate({$sort:{d:1}}).toArray(); -assert.lt(out[0].d, out[1].d) +assert.lt(out[0].d, out[1].d); diff --git a/jstests/aggregation/bugs/server6118.js b/jstests/aggregation/bugs/server6118.js index 83a56c4ec23..561d9d900ea 100644 --- a/jstests/aggregation/bugs/server6118.js +++ b/jstests/aggregation/bugs/server6118.js @@ -36,6 +36,6 @@ for(var i = 0; i < N; ++i) { assert.eq(i, result[i]._id); } -s.stop() +s.stop(); })(); diff --git a/jstests/aggregation/bugs/server6125.js b/jstests/aggregation/bugs/server6125.js index 3bb76235fad..fcf6984e6ed 100644 --- a/jstests/aggregation/bugs/server6125.js +++ b/jstests/aggregation/bugs/server6125.js @@ -68,7 +68,7 @@ function setupArray(){ { _id : 16, a : function(){}, ty : "Code" }, //Code with Scope not implemented in JS { _id : 17, a : MaxKey, ty : "MaxKey"} - ] + ]; } //*** @@ -78,7 +78,7 @@ function setupArray(){ runSort( { a : 1 }, false, "p1" ); //problem 2, does aggregate $sort work with all types nested -runSort( { "a" : 1 }, true, "p2a" ) +runSort( { "a" : 1 }, true, "p2a" ); runSort( { "a.b" : 1 }, true, "p2b" ); //problem 3, check reverse order sort diff --git a/jstests/aggregation/bugs/server6181.js b/jstests/aggregation/bugs/server6181.js index 053aa8b237d..68fc7998435 100644 --- a/jstests/aggregation/bugs/server6181.js +++ b/jstests/aggregation/bugs/server6181.js @@ -5,8 +5,8 @@ c.drop(); c.save( { a:2 } ); -res = c.aggregate( { $project:{ _id:'$a' } } ) -assert.eq(res.toArray(), [{_id:2}]) +res = c.aggregate( { $project:{ _id:'$a' } } ); +assert.eq(res.toArray(), [{_id:2}]); -res = c.aggregate( { $project:{ _id:{$add: [1, '$a']} } } ) -assert.eq(res.toArray(), [{_id:3}]) +res = c.aggregate( { $project:{ _id:{$add: [1, '$a']} } } ); +assert.eq(res.toArray(), [{_id:3}]); diff --git a/jstests/aggregation/bugs/server6184.js b/jstests/aggregation/bugs/server6184.js index 9ecc4691f17..fd2e1b397aa 100644 --- a/jstests/aggregation/bugs/server6184.js +++ b/jstests/aggregation/bugs/server6184.js @@ -6,15 +6,15 @@ c.drop(); c.save( { a:'missing', b:{ c:'bar', a: 'baz', z:'not there' } } ); function test(projection) { - res = c.aggregate({$project: projection}) + res = c.aggregate({$project: projection}); assert.eq(res.toArray()[0], {b: {c: 'bar', a: 'baz'}}); } -test({_id:0, b: {a:1}, 'b.c': 1}) -test({_id:0, 'b.c': 1, b: {a:1}}) +test({_id:0, b: {a:1}, 'b.c': 1}); +test({_id:0, 'b.c': 1, b: {a:1}}); // Synthetic fields should be in the order they appear in the $project -one = {$add:[1]} -res = c.aggregate({$project: {_id:0, 'A.Z':one, A:{Y:one, A:one}, 'A.B': one}}) +one = {$add:[1]}; +res = c.aggregate({$project: {_id:0, 'A.Z':one, A:{Y:one, A:one}, 'A.B': one}}); assert.eq(res.toArray()[0], {A: {Z:1, Y:1, A:1, B:1}}); diff --git a/jstests/aggregation/bugs/server6195.js b/jstests/aggregation/bugs/server6195.js index b24235d1404..72e0054b4fb 100644 --- a/jstests/aggregation/bugs/server6195.js +++ b/jstests/aggregation/bugs/server6195.js @@ -1,6 +1,6 @@ // ensure $concat asserts on string -load('jstests/aggregation/extras/utils.js') +load('jstests/aggregation/extras/utils.js'); c = db.s6570; c.drop(); diff --git a/jstests/aggregation/bugs/server6361.js b/jstests/aggregation/bugs/server6361.js index a25454a6dda..86eddd2b4e8 100644 --- a/jstests/aggregation/bugs/server6361.js +++ b/jstests/aggregation/bugs/server6361.js @@ -17,7 +17,7 @@ assert.eq(res.toArray()[0], {a:2}); assertErrorCode(c, {$project: {'nested._id':0}}, 16406); // nested _id is not automatically included -res = c.aggregate({$project: {_id:0, 'nested.other':1}}) +res = c.aggregate({$project: {_id:0, 'nested.other':1}}); assert.eq(res.toArray()[0], {nested: {other:2}}); // not including anything is an error diff --git a/jstests/aggregation/bugs/server6468.js b/jstests/aggregation/bugs/server6468.js index e12ecf1f25c..aea9586973b 100644 --- a/jstests/aggregation/bugs/server6468.js +++ b/jstests/aggregation/bugs/server6468.js @@ -5,12 +5,12 @@ c.drop(); c.save( { a:'foo', b:{ c:'bar', z:'not there' } } ); function test(projection) { - res = c.aggregate({$project: projection}) + res = c.aggregate({$project: projection}); assert.eq(res.toArray()[0], {b: {c: 'bar'}}); } // These should all mean the same thing -test({_id:0, 'b.c':1}) -test({_id:0, 'b.c':'$b.c'}) -test({_id:0, b: {c:1}}) -test({_id:0, b: {c:'$b.c'}}) +test({_id:0, 'b.c':1}); +test({_id:0, 'b.c':'$b.c'}); +test({_id:0, b: {c:1}}); +test({_id:0, b: {c:'$b.c'}}); diff --git a/jstests/aggregation/bugs/server6556.js b/jstests/aggregation/bugs/server6556.js index cdc743c3184..65a78e714b9 100644 --- a/jstests/aggregation/bugs/server6556.js +++ b/jstests/aggregation/bugs/server6556.js @@ -15,5 +15,5 @@ assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq:["as", "$foo"]}}}).toArr assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq:["as\0de", "$foo"]}}}).toArray(), [{matches:false}]); // should assert on fieldpaths with a null assert.throws( function() { - c.aggregate({$project: {_id: 0, matches: {$eq:["as\0df", "$f\0oo"]}}}) + c.aggregate({$project: {_id: 0, matches: {$eq:["as\0df", "$f\0oo"]}}}); }); diff --git a/jstests/aggregation/bugs/server7768.js b/jstests/aggregation/bugs/server7768.js index 2e1c91e05a1..a6c96d8f912 100644 --- a/jstests/aggregation/bugs/server7768.js +++ b/jstests/aggregation/bugs/server7768.js @@ -9,4 +9,4 @@ res = db.runCommand({ 'aggregate': collection }); assert.commandWorked(res); -assert.eq(res.result, [{foo:1}]) +assert.eq(res.result, [{foo:1}]); diff --git a/jstests/aggregation/bugs/server7781.js b/jstests/aggregation/bugs/server7781.js index 96d8ed01634..4d2c3c1a3fa 100644 --- a/jstests/aggregation/bugs/server7781.js +++ b/jstests/aggregation/bugs/server7781.js @@ -28,7 +28,7 @@ function checkOutput(cmdOut, aggOut, expectedNum) { var massaged; // massage geoNear command output to match output from agg pipeline for (var i=0; i < cmdOut.length; i++) { massaged = {}; - Object.extend(massaged, cmdOut[i].obj, /*deep=*/true) + Object.extend(massaged, cmdOut[i].obj, /*deep=*/true); massaged.stats = {'dis': cmdOut[i].dis, 'loc': cmdOut[i].loc}; diff --git a/jstests/aggregation/bugs/server9840.js b/jstests/aggregation/bugs/server9840.js index cf4330d04cb..61c95ab9cd0 100644 --- a/jstests/aggregation/bugs/server9840.js +++ b/jstests/aggregation/bugs/server9840.js @@ -59,7 +59,7 @@ test({$let: {vars: {x: 6, y: 10}, // unicode is allowed -test({$let: {vars: {'日本語': 10}, in: '$$日本語'}}, 10) // Japanese for "Japanese language" +test({$let: {vars: {'日本語': 10}, in: '$$日本語'}}, 10); // Japanese for "Japanese language" // Can use ROOT and CURRENT directly with no subfield (SERVER-5916) t.drop(); diff --git a/jstests/aggregation/disabled/server5369.js b/jstests/aggregation/disabled/server5369.js index f886f9371c8..754917ff8b4 100644 --- a/jstests/aggregation/disabled/server5369.js +++ b/jstests/aggregation/disabled/server5369.js @@ -6,7 +6,7 @@ db = db.getSiblingDB('aggdb'); // empty and populate db.test.drop(); -db.test.save({a:1,b:2}) +db.test.save({a:1,b:2}); // agg with exclusion than ensure fields are only the two we expect var f = db.test.aggregate({$project:{a:0}}); diff --git a/jstests/aggregation/extras/mrabench.js b/jstests/aggregation/extras/mrabench.js index c43265c184c..ca0a6ade0fe 100644 --- a/jstests/aggregation/extras/mrabench.js +++ b/jstests/aggregation/extras/mrabench.js @@ -4,10 +4,10 @@ One way to do this is to dump and restore it using mongodump and mongorestore */ -db = db.getSiblingDB( "mongousage" ) +db = db.getSiblingDB( "mongousage" ); function rollupMap() { - emit( this._id.t , { total : this.value , unique : 1 } ) + emit( this._id.t , { total : this.value , unique : 1 } ); } function rollupReduce(key, values) { @@ -22,22 +22,22 @@ function rollupReduce(key, values) { function mrrollups() { res = db.gen.monthly.ip.mapReduce( rollupMap , rollupReduce , - { out : "gen.monthly" } ) - res.find().sort( { _id : -1 } ).forEach( printjsononeline ) + { out : "gen.monthly" } ); + res.find().sort( { _id : -1 } ).forEach( printjsononeline ); res = db.gen.weekly.ip.mapReduce( rollupMap , rollupReduce , - { out : "gen.weekly" } ) - res.find().sort( { _id : -1 } ).forEach( printjsononeline ) + { out : "gen.weekly" } ); + res.find().sort( { _id : -1 } ).forEach( printjsononeline ); } function rollupMonthlyMR() { resMonthlyMR = db.gen.monthly.ip.mapReduce( rollupMap , rollupReduce , - { out: { inline : 1 }} ) + { out: { inline : 1 }} ); } function rollupWeeklyMR() { resWeeklyMR = db.gen.weekly.ip.mapReduce( rollupMap , rollupReduce , - { out : {inline : 1 }} ) + { out : {inline : 1 }} ); } function rollupMonthlyA() { diff --git a/jstests/aggregation/extras/utils.js b/jstests/aggregation/extras/utils.js index d0a13f820cb..60081dd56b9 100644 --- a/jstests/aggregation/extras/utils.js +++ b/jstests/aggregation/extras/utils.js @@ -260,7 +260,7 @@ function assertErrorCode(coll, pipe, code, errmsg) { var followupBatchSize = 0; // default var cursor = new DBCommandCursor(coll.getMongo(), cursorRes, followupBatchSize); - var error = assert.throws(function(){cursor.itcount()}, [], "expected error: " + code); + var error = assert.throws(function(){cursor.itcount();}, [], "expected error: " + code); if (!error.message.search(code)) { assert(false, "expected error: " + code + " got: " + error); } diff --git a/jstests/aggregation/testshard1.js b/jstests/aggregation/testshard1.js index 2e4eeb94d5b..64cc46ffaa6 100644 --- a/jstests/aggregation/testshard1.js +++ b/jstests/aggregation/testshard1.js @@ -3,8 +3,8 @@ load('jstests/aggregation/extras/utils.js'); // Use this for aggregations that only have arrays or results of specified order. // It will check that cursors return the same results as non-cursors. function aggregateOrdered(coll, pipeline) { - var cursor = coll.aggregate(pipeline).toArray() - var noCursor = coll.runCommand('aggregate', {pipeline:pipeline}).result + var cursor = coll.aggregate(pipeline).toArray(); + var noCursor = coll.runCommand('aggregate', {pipeline:pipeline}).result; assert.eq(cursor, noCursor); return cursor; } @@ -156,7 +156,7 @@ var a4 = aggregateNoOrder(db.ts1, [ assert.eq(a4.length, 6, tojson(a4)); for(i = 0; i < 6; ++i) { c = a4[i].counter; - printjson({c:c}) + printjson({c:c}); assert((c == 55) || (c == 1111) || (c == 2222) || (c == 33333) || (c == 99999) || (c == 55555), 'agg sharded test simple match failed'); @@ -166,7 +166,7 @@ function testSkipLimit(ops, expectedCount) { jsTestLog('testSkipLimit(' + tojson(ops) + ', ' + expectedCount + ')'); if (expectedCount > 10) { // make shard -> mongos intermediate results less than 16MB - ops.unshift({$project: {_id:1}}) + ops.unshift({$project: {_id:1}}); } ops.push({$group: {_id:1, count: {$sum: 1}}}); @@ -213,9 +213,9 @@ function testAvgStdDev() { var res = db.ts1.aggregate([{$group: {_id: null, avg: {$avg: '$counter'}, stdDevPop: {$stdDevPop: '$counter'}, - }}]).toArray() + }}]).toArray(); // http://en.wikipedia.org/wiki/Arithmetic_progression#Sum - var avg = (1 + nItems) / 2 + var avg = (1 + nItems) / 2; assert.close(res[0].avg, avg, '', 10 /*decimal places*/); // http://en.wikipedia.org/wiki/Arithmetic_progression#Standard_deviation |