diff options
Diffstat (limited to 'jstests/core/sort10.js')
-rw-r--r-- | jstests/core/sort10.js | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/jstests/core/sort10.js b/jstests/core/sort10.js index 657da665499..207be0226fa 100644 --- a/jstests/core/sort10.js +++ b/jstests/core/sort10.js @@ -3,23 +3,21 @@ t = db.sort10; function checkSorting1(opts) { t.drop(); - t.insert({ x: new Date(50000) }); - t.insert({ x: new Date(-50) }); + t.insert({x: new Date(50000)}); + t.insert({x: new Date(-50)}); var d = new Date(-50); for (var pass = 0; pass < 2; pass++) { - assert(t.find().sort({x:1})[0].x.valueOf() == d.valueOf()); - t.ensureIndex({ x: 1 }, opts); - t.insert({ x: new Date() }); + assert(t.find().sort({x: 1})[0].x.valueOf() == d.valueOf()); + t.ensureIndex({x: 1}, opts); + t.insert({x: new Date()}); } } checkSorting1({}); -checkSorting1({"background":true}); - - +checkSorting1({"background": true}); function checkSorting2(dates, sortOrder) { - cur = t.find().sort({x:sortOrder}); + cur = t.find().sort({x: sortOrder}); assert.eq(dates.length, cur.count(), "Incorrect number of results returned"); index = 0; while (cur.hasNext()) { @@ -32,17 +30,19 @@ function checkSorting2(dates, sortOrder) { t.drop(); dates = [new Date(-5000000000000), new Date(5000000000000), new Date(0), new Date(5), new Date(-5)]; for (var i = 0; i < dates.length; i++) { - t.insert({x:dates[i]}); + t.insert({x: dates[i]}); } -dates.sort(function(a,b){return a - b;}); +dates.sort(function(a, b) { + return a - b; +}); reverseDates = dates.slice(0).reverse(); checkSorting2(dates, 1); checkSorting2(reverseDates, -1); -t.ensureIndex({x:1}); +t.ensureIndex({x: 1}); checkSorting2(dates, 1); checkSorting2(reverseDates, -1); t.dropIndexes(); -t.ensureIndex({x:-1}); +t.ensureIndex({x: -1}); checkSorting2(dates, 1); checkSorting2(reverseDates, -1); |