diff options
| author | Anton Korshunov <anton.korshunov@mongodb.com> | 2019-12-10 11:53:27 +0000 |
|---|---|---|
| committer | evergreen <evergreen@mongodb.com> | 2019-12-10 11:53:27 +0000 |
| commit | d1450aa60419dd7c3fda9d96bad2d27c70067311 (patch) | |
| tree | 50284ffec7cd159486439d9604aac38d113aa39f /jstests | |
| parent | 998d3bacac8a853cd85871eb9995634d9a89507f (diff) | |
| download | mongo-d1450aa60419dd7c3fda9d96bad2d27c70067311.tar.gz | |
SERVER-43764 Add more testing for special values in DoubleDoubleSummation
(cherry picked from commit abe90fb2090ead3fdbf9f62d5db50c88eb31d527)
Diffstat (limited to 'jstests')
| -rw-r--r-- | jstests/aggregation/bugs/server42756.js | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/jstests/aggregation/bugs/server42756.js b/jstests/aggregation/bugs/server42756.js index a270dfcda02..8219ac1ff75 100644 --- a/jstests/aggregation/bugs/server42756.js +++ b/jstests/aggregation/bugs/server42756.js @@ -10,39 +10,37 @@ assert.commandWorked(coll.insert({inf: Infinity, nan: NaN})); - (function testCommutativityWithConstArguments() { - specials.forEach((special) => { - numbers.forEach((num) => { - const expected = [ - {a: (num instanceof NumberDecimal ? NumberDecimal(special.val) : special.val)} - ]; - assert.eq( - expected, - coll.aggregate([{$project: {a: {"$multiply": [special.val, num]}, _id: 0}}]) - .toArray()); - assert.eq( - expected, - coll.aggregate([{$project: {a: {"$multiply": [num, special.val]}, _id: 0}}]) - .toArray()); + ["$multiply", "$add", "$sum"].forEach((op) => { + (function testCommutativityWithConstArguments() { + specials.forEach((special) => { + numbers.forEach((num) => { + const expected = [{ + a: (num instanceof NumberDecimal ? NumberDecimal(special.val) : special.val) + }]; + assert.eq(expected, + coll.aggregate([{$project: {a: {[op]: [special.val, num]}, _id: 0}}]) + .toArray()); + assert.eq(expected, + coll.aggregate([{$project: {a: {[op]: [num, special.val]}, _id: 0}}]) + .toArray()); + }); }); - }); - })(); + })(); - (function testCommutativityWithNonConstArgument() { - specials.forEach((special) => { - numbers.forEach((num) => { - const expected = [ - {a: (num instanceof NumberDecimal ? NumberDecimal(special.val) : special.val)} - ]; - assert.eq( - expected, - coll.aggregate([{$project: {a: {"$multiply": [special.path, num]}, _id: 0}}]) - .toArray()); - assert.eq( - expected, - coll.aggregate([{$project: {a: {"$multiply": [num, special.path]}, _id: 0}}]) - .toArray()); + (function testCommutativityWithNonConstArgument() { + specials.forEach((special) => { + numbers.forEach((num) => { + const expected = [{ + a: (num instanceof NumberDecimal ? NumberDecimal(special.val) : special.val) + }]; + assert.eq(expected, + coll.aggregate([{$project: {a: {[op]: [special.path, num]}, _id: 0}}]) + .toArray()); + assert.eq(expected, + coll.aggregate([{$project: {a: {[op]: [num, special.path]}, _id: 0}}]) + .toArray()); + }); }); - }); - })(); + })(); + }); })(); |
