summaryrefslogtreecommitdiff
path: root/jstests/core/min_max_key.js
diff options
context:
space:
mode:
authorclang-format-7.0.1 <adam.martin@10gen.com>2019-07-26 18:20:35 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2019-07-27 11:02:23 -0400
commit134a4083953270e8a11430395357fb70a29047ad (patch)
treedd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/core/min_max_key.js
parent1e46b5049003f427047e723ea5fab15b5a9253ca (diff)
downloadmongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/core/min_max_key.js')
-rw-r--r--jstests/core/min_max_key.js166
1 files changed, 83 insertions, 83 deletions
diff --git a/jstests/core/min_max_key.js b/jstests/core/min_max_key.js
index d65d68292fa..e14a7ba4fda 100644
--- a/jstests/core/min_max_key.js
+++ b/jstests/core/min_max_key.js
@@ -1,98 +1,98 @@
// Tests the behavior of queries using MinKey and MaxKey
(function() {
- "use strict";
+"use strict";
- load("jstests/aggregation/extras/utils.js"); // For 'resultsEq'.
+load("jstests/aggregation/extras/utils.js"); // For 'resultsEq'.
- const coll = db.test_min_max;
- coll.drop();
+const coll = db.test_min_max;
+coll.drop();
- const allElements = [
+const allElements = [
+ {_id: "a_max_key", a: MaxKey},
+ {_id: "a_min_key", a: MinKey},
+ {_id: "a_null", a: null},
+ {_id: "a_number", a: 4},
+ {_id: "a_subobject", a: {b: "hi"}},
+ {_id: "a_undefined", a: undefined},
+ {_id: "a_string", a: "hello"}
+];
+
+assert.writeOK(coll.insert(allElements));
+
+function testQueriesWithMinOrMaxKey() {
+ const eqMinRes = coll.find({a: {$eq: MinKey}}).toArray();
+ const expectedEqMin = [{_id: "a_min_key", a: MinKey}];
+ assert(resultsEq(expectedEqMin, eqMinRes), tojson(eqMinRes));
+
+ const gtMinRes = coll.find({a: {$gt: MinKey}}).toArray();
+ const expectedGtMin = [
{_id: "a_max_key", a: MaxKey},
- {_id: "a_min_key", a: MinKey},
{_id: "a_null", a: null},
{_id: "a_number", a: 4},
{_id: "a_subobject", a: {b: "hi"}},
{_id: "a_undefined", a: undefined},
{_id: "a_string", a: "hello"}
];
+ assert(resultsEq(expectedGtMin, gtMinRes), tojson(gtMinRes));
+
+ const gteMinRes = coll.find({a: {$gte: MinKey}}).toArray();
+ assert(resultsEq(allElements, gteMinRes), tojson(gteMinRes));
+
+ const ltMinRes = coll.find({a: {$lt: MinKey}}).toArray();
+ assert(resultsEq([], ltMinRes), tojson(ltMinRes));
+
+ const lteMinRes = coll.find({a: {$lte: MinKey}}).toArray();
+ assert(resultsEq(expectedEqMin, lteMinRes), tojson(lteMinRes));
+
+ const eqMaxRes = coll.find({a: {$eq: MaxKey}}).toArray();
+ const expectedEqMax = [{_id: "a_max_key", a: MaxKey}];
+ assert(resultsEq(expectedEqMax, eqMaxRes), tojson(eqMaxRes));
+
+ const gtMaxRes = coll.find({a: {$gt: MaxKey}}).toArray();
+ assert(resultsEq([], gtMaxRes), tojson(gtMaxRes));
- assert.writeOK(coll.insert(allElements));
-
- function testQueriesWithMinOrMaxKey() {
- const eqMinRes = coll.find({a: {$eq: MinKey}}).toArray();
- const expectedEqMin = [{_id: "a_min_key", a: MinKey}];
- assert(resultsEq(expectedEqMin, eqMinRes), tojson(eqMinRes));
-
- const gtMinRes = coll.find({a: {$gt: MinKey}}).toArray();
- const expectedGtMin = [
- {_id: "a_max_key", a: MaxKey},
- {_id: "a_null", a: null},
- {_id: "a_number", a: 4},
- {_id: "a_subobject", a: {b: "hi"}},
- {_id: "a_undefined", a: undefined},
- {_id: "a_string", a: "hello"}
- ];
- assert(resultsEq(expectedGtMin, gtMinRes), tojson(gtMinRes));
-
- const gteMinRes = coll.find({a: {$gte: MinKey}}).toArray();
- assert(resultsEq(allElements, gteMinRes), tojson(gteMinRes));
-
- const ltMinRes = coll.find({a: {$lt: MinKey}}).toArray();
- assert(resultsEq([], ltMinRes), tojson(ltMinRes));
-
- const lteMinRes = coll.find({a: {$lte: MinKey}}).toArray();
- assert(resultsEq(expectedEqMin, lteMinRes), tojson(lteMinRes));
-
- const eqMaxRes = coll.find({a: {$eq: MaxKey}}).toArray();
- const expectedEqMax = [{_id: "a_max_key", a: MaxKey}];
- assert(resultsEq(expectedEqMax, eqMaxRes), tojson(eqMaxRes));
-
- const gtMaxRes = coll.find({a: {$gt: MaxKey}}).toArray();
- assert(resultsEq([], gtMaxRes), tojson(gtMaxRes));
-
- const gteMaxRes = coll.find({a: {$gte: MaxKey}}).toArray();
- assert(resultsEq(expectedEqMax, gteMaxRes), tojson(gteMaxRes));
-
- const ltMaxRes = coll.find({a: {$lt: MaxKey}}).toArray();
- const expectedLtMax = [
- {_id: "a_min_key", a: MinKey},
- {_id: "a_null", a: null},
- {_id: "a_number", a: 4},
- {_id: "a_subobject", a: {b: "hi"}},
- {_id: "a_undefined", a: undefined},
- {_id: "a_string", a: "hello"}
- ];
- assert(resultsEq(expectedLtMax, ltMaxRes), tojson(ltMaxRes));
-
- const lteMaxRes = coll.find({a: {$lte: MaxKey}}).toArray();
- assert(resultsEq(allElements, lteMaxRes), tojson(lteMaxRes));
- }
-
- function testTypeBracketedQueries() {
- // Queries that do not involve MinKey or MaxKey follow type bracketing and thus do not
- // return MinKey or MaxKey as results. These queries are being run to test this
- // functionality.
- const numRes = coll.find({a: {$gt: 3}}).toArray();
- const expectedNum = [{_id: "a_number", a: 4}];
- assert(resultsEq(expectedNum, numRes), tojson(numRes));
- const noNum = coll.find({a: {$lt: 3}}).toArray();
- assert(resultsEq([], noNum), tojson(noNum));
-
- const stringRes = coll.find({a: {$gt: "best"}}).toArray();
- const expectedString = [{_id: "a_string", a: "hello"}];
- assert(resultsEq(expectedString, stringRes), tojson(stringRes));
- }
-
- testQueriesWithMinOrMaxKey();
- testTypeBracketedQueries();
-
- assert.commandWorked(coll.createIndex({a: 1}));
- // TODO: SERVER-35921 The results of the queries above should not change based on the
- // presence of an index
- assert.commandWorked(coll.dropIndexes());
-
- testQueriesWithMinOrMaxKey();
- testTypeBracketedQueries();
+ const gteMaxRes = coll.find({a: {$gte: MaxKey}}).toArray();
+ assert(resultsEq(expectedEqMax, gteMaxRes), tojson(gteMaxRes));
+
+ const ltMaxRes = coll.find({a: {$lt: MaxKey}}).toArray();
+ const expectedLtMax = [
+ {_id: "a_min_key", a: MinKey},
+ {_id: "a_null", a: null},
+ {_id: "a_number", a: 4},
+ {_id: "a_subobject", a: {b: "hi"}},
+ {_id: "a_undefined", a: undefined},
+ {_id: "a_string", a: "hello"}
+ ];
+ assert(resultsEq(expectedLtMax, ltMaxRes), tojson(ltMaxRes));
+
+ const lteMaxRes = coll.find({a: {$lte: MaxKey}}).toArray();
+ assert(resultsEq(allElements, lteMaxRes), tojson(lteMaxRes));
+}
+
+function testTypeBracketedQueries() {
+ // Queries that do not involve MinKey or MaxKey follow type bracketing and thus do not
+ // return MinKey or MaxKey as results. These queries are being run to test this
+ // functionality.
+ const numRes = coll.find({a: {$gt: 3}}).toArray();
+ const expectedNum = [{_id: "a_number", a: 4}];
+ assert(resultsEq(expectedNum, numRes), tojson(numRes));
+ const noNum = coll.find({a: {$lt: 3}}).toArray();
+ assert(resultsEq([], noNum), tojson(noNum));
+
+ const stringRes = coll.find({a: {$gt: "best"}}).toArray();
+ const expectedString = [{_id: "a_string", a: "hello"}];
+ assert(resultsEq(expectedString, stringRes), tojson(stringRes));
+}
+
+testQueriesWithMinOrMaxKey();
+testTypeBracketedQueries();
+
+assert.commandWorked(coll.createIndex({a: 1}));
+// TODO: SERVER-35921 The results of the queries above should not change based on the
+// presence of an index
+assert.commandWorked(coll.dropIndexes());
+
+testQueriesWithMinOrMaxKey();
+testTypeBracketedQueries();
}());