Files
mongo/jstests/core/server9547.js
Siyuan Zhou 3660343e0b SERVER-12127 migrate js tests to jscore suite when not related to writes
Migrate js tests starting from j-z.
Include SERVER-12920 Update use_power_of_2.js

Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
2014-03-03 22:54:10 -05:00

22 lines
591 B
JavaScript

// SERVER-9547
// Test that sorting with .max() and .min() doesn't crash.
var t = db.server9547;
t.drop();
for (var i=0; i<10; i++) {
t.save({a: i});
}
t.ensureIndex({a: 1});
// note: max() value is exclusive upper bound
assert.eq(4, t.find({}).max({a: 4}).toArray().length, "no order");
// Ascending order is fine.
assert.eq(4, t.find({}).max({a: 4}).sort({a: 1}).toArray().length, "ascending");
// Descending order is still broken.
// This should really return the same # of results but doesn't.
assert.eq(5, t.find({}).max({a: 4}).sort({a: -1}).toArray().length, "descending");