summaryrefslogtreecommitdiff
path: root/jstests/sortc.js
diff options
context:
space:
mode:
authorSiyuan Zhou <siyuan.zhou@mongodb.com>2014-03-03 17:15:39 -0500
committerMatt Kangas <matt.kangas@mongodb.com>2014-03-03 22:54:14 -0500
commit93d8befdbac74fb965faa4d3a8ae3e60d5a7a5b9 (patch)
treeb1be042b0d074266fb417177b33aa0f266a3f38b /jstests/sortc.js
parent3660343e0b4627d2fee4afb89b74d32644d16d18 (diff)
downloadmongo-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.js37
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();