From 4197c9d99e0158f969d192ee714adb8b48cd7465 Mon Sep 17 00:00:00 2001 From: dr-dimitru Date: Wed, 21 Dec 2016 03:20:17 +0300 Subject: [PATCH] Add missing semicolons, fix variables scope - Lines 481 - 498: `val` and `x` is defined twice (hoisting) - Lines 973 - 975 and 980 - 982: `expectedRemoves` and `expectedAdds` is defined on lines 952 and 955 --- packages/mongo/mongo_livedata_tests.js | 64 +++++++++++++------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/mongo/mongo_livedata_tests.js b/packages/mongo/mongo_livedata_tests.js index cf06c5033d..1aaa5c71f7 100644 --- a/packages/mongo/mongo_livedata_tests.js +++ b/packages/mongo/mongo_livedata_tests.js @@ -478,22 +478,24 @@ Tinytest.addAsync("mongo-livedata - fuzz test, " + idGeneration, function(test, var batch_count = rnd(10) + 1; for (var i = 0; i < batch_count; i++) { // 25% add, 25% remove, 25% change in place, 25% change and move + var x; var op = rnd(4); var which = rnd(correct.length); if (op === 0 || step < 2 || !correct.length) { // Add - var x = rnd(1000000); + x = rnd(1000000); coll.insert({run: run, x: x}); correct.push(x); max_counters.add++; } else if (op === 1 || op === 2) { - var x = correct[which]; + var val; + x = correct[which]; if (op === 1) // Small change, not likely to cause a move - var val = x + (rnd(2) ? -1 : 1); + val = x + (rnd(2) ? -1 : 1); else // Large change, likely to cause a move - var val = rnd(1000000); + val = rnd(1000000); coll.update({run: run, x: x}, {$set: {x: val}}); correct[which] = val; max_counters.change++; @@ -968,16 +970,16 @@ if (Meteor.isServer) { // another. Poll-n-diff code, on the other side, analyzes the batch action // of multiple remove. Because of that difference, expected outputs differ. if (usesOplog) { - var expectedRemoves = [{removed: docId3}, {removed: docId1}, + expectedRemoves = [{removed: docId3}, {removed: docId1}, {removed: docId2}, {removed: docId4}]; - var expectedAdds = [{added: docId4}, {added: docId8}, + expectedAdds = [{added: docId4}, {added: docId8}, {added: docId7}, {added: docId6}]; test.length(o.output, 8); } else { - var expectedRemoves = [{removed: docId3}, {removed: docId1}, + expectedRemoves = [{removed: docId3}, {removed: docId1}, {removed: docId2}]; - var expectedAdds = [{added: docId8}, {added: docId7}, {added: docId6}]; + expectedAdds = [{added: docId8}, {added: docId7}, {added: docId6}]; test.length(o.output, 6); } @@ -2229,7 +2231,7 @@ function collectionInsert (test, expect, coll, index) { test.isTrue(_.isObject(o)); test.equal(o.name, 'foo'); })); -}; +} function collectionUpsert (test, expect, coll, index) { var upsertId = '123456' + index; @@ -2242,7 +2244,7 @@ function collectionUpsert (test, expect, coll, index) { test.isTrue(_.isObject(o)); test.equal(o.name, 'foo'); })); -}; +} function collectionUpsertExisting (test, expect, coll, index) { var clientSideId = coll.insert({name: "foo"}, expect(function (err1, id) { @@ -2262,7 +2264,7 @@ function collectionUpsertExisting (test, expect, coll, index) { test.isTrue(_.isObject(o)); test.equal(o.name, 'bar'); })); -}; +} function functionCallsInsert (test, expect, coll, index) { Meteor.call("insertObjects", coll._name, {name: "foo"}, 1, expect(function (err1, ids) { @@ -2276,7 +2278,7 @@ function functionCallsInsert (test, expect, coll, index) { test.isTrue(_.isObject(o)); test.equal(o.name, 'foo'); })); -}; +} function functionCallsUpsert (test, expect, coll, index) { var upsertId = '123456' + index; @@ -2288,7 +2290,7 @@ function functionCallsUpsert (test, expect, coll, index) { test.isTrue(_.isObject(o)); test.equal(o.name, 'foo'); })); -}; +} function functionCallsUpsertExisting (test, expect, coll, index) { var id = coll.insert({name: "foo"}); @@ -2305,7 +2307,7 @@ function functionCallsUpsertExisting (test, expect, coll, index) { test.isTrue(_.isObject(o)); test.equal(o.name, 'bar'); })); -}; +} function functionCalls3Inserts (test, expect, coll, index) { Meteor.call("insertObjects", coll._name, {name: "foo"}, 3, expect(function (err1, ids) { @@ -2321,7 +2323,7 @@ function functionCalls3Inserts (test, expect, coll, index) { test.equal(o.name, 'foo'); } })); -}; +} function functionChainInsert (test, expect, coll, index) { Meteor.call("doMeteorCall", "insertObjects", coll._name, {name: "foo"}, 1, expect(function (err1, ids) { @@ -2335,7 +2337,7 @@ function functionChainInsert (test, expect, coll, index) { test.isTrue(_.isObject(o)); test.equal(o.name, 'foo'); })); -}; +} function functionChain2Insert (test, expect, coll, index) { Meteor.call("doMeteorCall", "doMeteorCall", "insertObjects", coll._name, {name: "foo"}, 1, expect(function (err1, ids) { @@ -2349,7 +2351,7 @@ function functionChain2Insert (test, expect, coll, index) { test.isTrue(_.isObject(o)); test.equal(o.name, 'foo'); })); -}; +} function functionChain2Upsert (test, expect, coll, index) { var upsertId = '123456' + index; @@ -2361,7 +2363,7 @@ function functionChain2Upsert (test, expect, coll, index) { test.isTrue(_.isObject(o)); test.equal(o.name, 'foo'); })); -}; +} _.each( {collectionInsert: collectionInsert, collectionUpsert: collectionUpsert, @@ -2999,9 +3001,7 @@ _.extend(TestCustomType.prototype, { return new TestCustomType(this.myHead, this.myTail); }, equals: function (other) { - return other instanceof TestCustomType - && EJSON.equals(this.myHead, other.myHead) - && EJSON.equals(this.myTail, other.myTail); + return other instanceof TestCustomType && EJSON.equals(this.myHead, other.myHead) && EJSON.equals(this.myTail, other.myTail); }, typeName: function () { return 'someCustomType'; @@ -3367,23 +3367,23 @@ if (Meteor.isServer) { coll.insert({animal: 'platypus', legs: 4}); coll.insert({animal: 'starfish', legs: 5}); - var affected = coll.update({legs: 4}, {$set: {category: 'quadruped'}}) + var affected = coll.update({legs: 4}, {$set: {category: 'quadruped'}}); test.equal(affected, 1); //Changes only 3 but matched 4 documents - var affected = coll.update({legs: 4}, {$set: {category: 'quadruped'}}, {multi: true}) + affected = coll.update({legs: 4}, {$set: {category: 'quadruped'}}, {multi: true}); test.equal(affected, 4); //Again, changes nothing but returns nModified - var affected = coll.update({legs: 4}, {$set: {category: 'quadruped'}}, {multi: true}) + affected = coll.update({legs: 4}, {$set: {category: 'quadruped'}}, {multi: true}); test.equal(affected, 4); //upsert:true changes nothing, 4 modified - var affected = coll.update({legs: 4}, {$set: {category: 'quadruped'}}, {multi: true, upsert:true}) + affected = coll.update({legs: 4}, {$set: {category: 'quadruped'}}, {multi: true, upsert:true}); test.equal(affected, 4); //upsert method works as upsert:true - var result = coll.upsert({legs: 4}, {$set: {category: 'quadruped'}}, {multi: true}) + var result = coll.upsert({legs: 4}, {$set: {category: 'quadruped'}}, {multi: true}); test.equal(result.numberAffected, 4); }); @@ -3401,8 +3401,8 @@ if (Meteor.isServer) { coll.update({legs: 4}, {$set: {category: 'quadruped'}}, function (err, result) { test.equal(result, 1); test2(); - }) - } + }); + }; var test2 = function () { //Changes only 3 but matched 4 documents @@ -3410,7 +3410,7 @@ if (Meteor.isServer) { test.equal(result, 4); test3(); }); - } + }; var test3 = function () { //Again, changes nothing but returns nModified @@ -3418,7 +3418,7 @@ if (Meteor.isServer) { test.equal(result, 4); test4(); }); - } + }; var test4 = function () { //upsert:true changes nothing, 4 modified @@ -3426,7 +3426,7 @@ if (Meteor.isServer) { test.equal(result, 4); test5(); }); - } + }; var test5 = function () { //upsert method works as upsert:true @@ -3434,7 +3434,7 @@ if (Meteor.isServer) { test.equal(result.numberAffected, 4); onComplete(); }); - } + }; test1(); });