Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add some more tests for $in and $all working together. QA-46 & SERVER…

…-2165.
  • Loading branch information...
commit 75eb7ca39ab4d5180078402bb3c4ed948705c83f 1 parent 3fc16f4
Spencer T Brody stbrody authored
Showing with 21 additions and 11 deletions.
  1. +21 −11 jstests/indexl.js
32 jstests/indexl.js
View
@@ -1,17 +1,27 @@
// Check nonoverlapping $in/$all with multikeys SERVER-2165
t = db.jstests_indexl;
-t.drop();
-t.save( {a:[1,2]} );
-assert.eq( 1, t.count( {a:{$all:[1],$in:[2]}} ) );
-assert.eq( 1, t.count( {a:{$all:[2],$in:[1]}} ) );
-assert.eq( 1, t.count( {a:{$in:[2],$all:[1]}} ) );
-assert.eq( 1, t.count( {a:{$in:[1],$all:[2]}} ) );
+function test(t) {
+ t.save( {a:[1,2]} );
+ assert.eq( 1, t.count( {a:{$all:[1],$in:[2]}} ) );
+ assert.eq( 1, t.count( {a:{$all:[2],$in:[1]}} ) );
+ assert.eq( 1, t.count( {a:{$in:[2],$all:[1]}} ) );
+ assert.eq( 1, t.count( {a:{$in:[1],$all:[2]}} ) );
+ assert.eq( 1, t.count( {a:{$all:[1],$in:[2]}} ) );
+ t.save({a:[3,4]})
+ t.save({a:[2,3]})
+ t.save({a:[1,2,3,4]})
+ assert.eq( 2, t.count( {a:{$in:[2],$all:[1]}} ) );
+ assert.eq( 1, t.count( {a:{$in:[3],$all:[1,2]}} ) );
+ assert.eq( 1, t.count( {a:{$in:[1],$all:[3]}} ) );
+ assert.eq( 2, t.count( {a:{$in:[2,3],$all:[1]}} ) );
+ assert.eq( 1, t.count( {a:{$in:[4],$all:[2,3]}} ) );
+ assert.eq( 3, t.count( {a:{$in:[1,3],$all:[2]}} ) );
+}
+t.drop();
+test(t);
+t.drop();
t.ensureIndex( {a:1} );
-assert.eq( 1, t.count( {a:{$all:[1],$in:[2]}} ) );
-assert.eq( 1, t.count( {a:{$all:[2],$in:[1]}} ) );
-assert.eq( 1, t.count( {a:{$in:[2],$all:[1]}} ) );
-assert.eq( 1, t.count( {a:{$in:[1],$all:[2]}} ) );
-assert.eq( 1, t.count( {a:{$all:[1],$in:[2]}} ) );
+test(t);
Please sign in to comment.
Something went wrong with that request. Please try again.