summaryrefslogtreecommitdiff
path: root/jstests/core/and.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/core/and.js')
-rw-r--r--jstests/core/and.js31
1 files changed, 10 insertions, 21 deletions
diff --git a/jstests/core/and.js b/jstests/core/and.js
index 4d8c2cd7d49..f05c289966f 100644
--- a/jstests/core/and.js
+++ b/jstests/core/and.js
@@ -13,7 +13,7 @@ function check() {
assert.throws( function() { t.find( {$and:[]} ).toArray() } );
// $and elements must be objects
assert.throws( function() { t.find( {$and:[4]} ).toArray() } );
-
+
// Check equality matching
assert.eq( 1, t.count( {$and:[{a:1}]} ) );
assert.eq( 1, t.count( {$and:[{a:1},{a:2}]} ) );
@@ -21,13 +21,13 @@ function check() {
assert.eq( 0, t.count( {$and:[{a:1},{a:2},{a:3}]} ) );
assert.eq( 1, t.count( {$and:[{a:'foo'}]} ) );
assert.eq( 0, t.count( {$and:[{a:'foo'},{a:'g'}]} ) );
-
+
// Check $and with other fields
assert.eq( 1, t.count( {a:2,$and:[{a:1}]} ) );
assert.eq( 0, t.count( {a:0,$and:[{a:1}]} ) );
assert.eq( 0, t.count( {a:2,$and:[{a:0}]} ) );
assert.eq( 1, t.count( {a:1,$and:[{a:1}]} ) );
-
+
// Check recursive $and
assert.eq( 1, t.count( {a:2,$and:[{$and:[{a:1}]}]} ) );
assert.eq( 0, t.count( {a:0,$and:[{$and:[{a:1}]}]} ) );
@@ -38,10 +38,10 @@ function check() {
assert.eq( 0, t.count( {$and:[{a:0},{$and:[{a:1}]}]} ) );
assert.eq( 0, t.count( {$and:[{a:2},{$and:[{a:0}]}]} ) );
assert.eq( 1, t.count( {$and:[{a:1},{$and:[{a:1}]}]} ) );
-
+
// Some of these cases were more important with an alternative $and syntax
// that was rejected, but they're still valid checks.
-
+
// Check simple regex
assert.eq( 1, t.count( {$and:[{a:/foo/}]} ) );
// Check multiple regexes
@@ -51,17 +51,15 @@ function check() {
// Check regex flags
assert.eq( 0, t.count( {$and:[{a:/^F/},{a:'foo'}]} ) );
assert.eq( 1, t.count( {$and:[{a:/^F/i},{a:'foo'}]} ) );
-
-
-
+
// Check operator
assert.eq( 1, t.count( {$and:[{a:{$gt:0}}]} ) );
-
+
// Check where
assert.eq( 1, t.count( {a:'foo',$where:'this.a=="foo"'} ) );
assert.eq( 1, t.count( {$and:[{a:'foo'}],$where:'this.a=="foo"'} ) );
assert.eq( 1, t.count( {$and:[{a:'foo'}],$where:'this.a=="foo"'} ) );
-
+
// Nested where ok
assert.eq( 1, t.count({$and:[{$where:'this.a=="foo"'}]}) );
assert.eq( 1, t.count({$and:[{a:'foo'},{$where:'this.a=="foo"'}]}) );
@@ -71,15 +69,6 @@ function check() {
check();
t.ensureIndex( {a:1} );
check();
-var e = t.find( {$and:[{a:1}]} ).explain();
-assert.eq( 'BtreeCursor a_1', e.cursor );
-assert.eq( [[1,1]], e.indexBounds.a );
-
-function checkBounds( query ) {
- var e = t.find( query ).explain(true);
- printjson(e);
- assert.eq( 1, e.n );
-}
-checkBounds( {a:1,$and:[{a:2}]} );
-checkBounds( {$and:[{a:1},{a:2}]} );
+assert.eq( 1, t.find({a:1,$and:[{a:2}]}).itcount() );
+assert.eq( 1, t.find({$and:[{a:1},{a:2}]}).itcount() );