diff options
author | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2014-03-03 17:15:39 -0500 |
---|---|---|
committer | Matt Kangas <matt.kangas@mongodb.com> | 2014-03-03 22:54:14 -0500 |
commit | 93d8befdbac74fb965faa4d3a8ae3e60d5a7a5b9 (patch) | |
tree | b1be042b0d074266fb417177b33aa0f266a3f38b /jstests/sortc.js | |
parent | 3660343e0b4627d2fee4afb89b74d32644d16d18 (diff) | |
download | mongo-93d8befdbac74fb965faa4d3a8ae3e60d5a7a5b9.tar.gz |
SERVER-12127 Temporarily put back jstest in order not to lose test coverage.
Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
Diffstat (limited to 'jstests/sortc.js')
-rw-r--r-- | jstests/sortc.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/jstests/sortc.js b/jstests/sortc.js new file mode 100644 index 00000000000..f9aa202508b --- /dev/null +++ b/jstests/sortc.js @@ -0,0 +1,37 @@ +// Test sorting with skipping and multiple candidate query plans. + +t = db.jstests_sortc; +t.drop(); + +t.save( {a:1} ); +t.save( {a:2} ); + +function checkA( a, sort, skip, query ) { + query = query || {}; + assert.eq( a, t.find( query ).sort( sort ).skip( skip )[ 0 ].a ); +} + +function checkSortAndSkip() { + checkA( 1, {a:1}, 0 ); + checkA( 2, {a:1}, 1 ); + + checkA( 1, {a:1}, 0, {a:{$gt:0},b:null} ); + checkA( 2, {a:1}, 1, {a:{$gt:0},b:null} ); + + checkA( 2, {a:-1}, 0 ); + checkA( 1, {a:-1}, 1 ); + + checkA( 2, {a:-1}, 0, {a:{$gt:0},b:null} ); + checkA( 1, {a:-1}, 1, {a:{$gt:0},b:null} ); + + checkA( 1, {$natural:1}, 0 ); + checkA( 2, {$natural:1}, 1 ); + + checkA( 2, {$natural:-1}, 0 ); + checkA( 1, {$natural:-1}, 1 ); +} + +checkSortAndSkip(); + +t.ensureIndex( {a:1} ); +checkSortAndSkip(); |