diff options
author | Aaron <aaron@10gen.com> | 2011-06-15 17:32:00 -0700 |
---|---|---|
committer | Aaron <aaron@10gen.com> | 2011-06-15 21:03:06 -0700 |
commit | 666397744ecbcfd1237ffe1dd454e1502ab3f60b (patch) | |
tree | 71a118c84b88b62bf31c44c295aaa3bd5def025a /jstests/orj.js | |
parent | 6646b9024f755ea666b5e9a5660e6c55d3705a3a (diff) | |
download | mongo-666397744ecbcfd1237ffe1dd454e1502ab3f60b.tar.gz |
SERVER-3192 a few more test cases
Diffstat (limited to 'jstests/orj.js')
-rw-r--r-- | jstests/orj.js | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/jstests/orj.js b/jstests/orj.js index 92c53997a4d..fa234f36cb5 100644 --- a/jstests/orj.js +++ b/jstests/orj.js @@ -3,6 +3,8 @@ t = db.jstests_orj; t.drop(); +t.save( {a:1,b:2} ); + function check() { assert.throws( function() { t.find( { x:0,$or:"a" } ).toArray(); } ); @@ -21,8 +23,6 @@ assert.throws( function() { t.find( { x:0,$nor:[{$nor:"a"}] } ).toArray(); } ); assert.throws( function() { t.find( { x:0,$nor:[{$nor:[]}] } ).toArray(); } ); assert.throws( function() { t.find( { x:0,$nor:[{$nor:[ "a" ]}] } ).toArray(); } ); -t.remove(); -t.save( {a:1,b:2} ); assert.eq( 1, t.find( {a:1,b:2} ).itcount() ); assert.eq( 1, t.find( {a:1,$or:[{b:2}]} ).itcount() ); @@ -75,3 +75,47 @@ t.dropIndexes(); t.ensureIndex( {a:1,b:1} ); check(); t.dropIndexes(); + +t.ensureIndex( {a:1} ); +t.ensureIndex( {b:1} ); +t.ensureIndex( {a:1,b:1} ); +check(); + +function checkHinted( hint ) { + assert.eq( 1, t.find( {a:1,b:2} ).hint( hint ).itcount() ); + + assert.eq( 1, t.find( {a:1,$or:[{b:2}]} ).hint( hint ).itcount() ); + assert.eq( 0, t.find( {a:1,$or:[{b:3}]} ).hint( hint ).itcount() ); + + assert.eq( 1, t.find( {a:1,$or:[{$or:[{b:2}]}]} ).hint( hint ).itcount() ); + assert.eq( 1, t.find( {a:1,$or:[{$or:[{b:2}]}]} ).hint( hint ).itcount() ); + assert.eq( 0, t.find( {a:1,$or:[{$or:[{b:3}]}]} ).hint( hint ).itcount() ); + + assert.eq( 1, t.find( {$or:[{$or:[{a:2},{b:2}]}]} ).hint( hint ).itcount() ); + assert.eq( 1, t.find( {$or:[{a:2},{$or:[{b:2}]}]} ).hint( hint ).itcount() ); + assert.eq( 1, t.find( {$or:[{a:1},{$or:[{b:3}]}]} ).hint( hint ).itcount() ); + + assert.eq( 1, t.find( {$or:[{$or:[{a:1},{a:2}]},{$or:[{b:3},{b:4}]}]} ).hint( hint ).itcount() ); + assert.eq( 1, t.find( {$or:[{$or:[{a:0},{a:2}]},{$or:[{b:2},{b:4}]}]} ).hint( hint ).itcount() ); + assert.eq( 0, t.find( {$or:[{$or:[{a:0},{a:2}]},{$or:[{b:3},{b:4}]}]} ).hint( hint ).itcount() ); + + assert.eq( 1, t.find( {a:1,$and:[{$or:[{$or:[{b:2}]}]}]} ).hint( hint ).itcount() ); + assert.eq( 0, t.find( {a:1,$and:[{$or:[{$or:[{b:3}]}]}]} ).hint( hint ).itcount() ); + + assert.eq( 1, t.find( {$and:[{$or:[{a:1},{a:2}]},{$or:[{b:1},{b:2}]}]} ).hint( hint ).itcount() ); + assert.eq( 0, t.find( {$and:[{$or:[{a:3},{a:2}]},{$or:[{b:1},{b:2}]}]} ).hint( hint ).itcount() ); + assert.eq( 0, t.find( {$and:[{$or:[{a:1},{a:2}]},{$or:[{b:3},{b:1}]}]} ).hint( hint ).itcount() ); + + assert.eq( 0, t.find( {$and:[{$nor:[{a:1},{a:2}]},{$nor:[{b:1},{b:2}]}]} ).hint( hint ).itcount() ); + assert.eq( 0, t.find( {$and:[{$nor:[{a:3},{a:2}]},{$nor:[{b:1},{b:2}]}]} ).hint( hint ).itcount() ); + assert.eq( 1, t.find( {$and:[{$nor:[{a:3},{a:2}]},{$nor:[{b:3},{b:1}]}]} ).hint( hint ).itcount() ); + + assert.eq( 1, t.find( {$and:[{$or:[{a:1},{a:2}]},{$nor:[{b:1},{b:3}]}]} ).hint( hint ).itcount() ); + assert.eq( 0, t.find( {$and:[{$or:[{a:3},{a:2}]},{$nor:[{b:1},{b:3}]}]} ).hint( hint ).itcount() ); + assert.eq( 0, t.find( {$and:[{$or:[{a:1},{a:2}]},{$nor:[{b:1},{b:2}]}]} ).hint( hint ).itcount() ); +} + +checkHinted( {$natural:1} ); +checkHinted( {a:1} ); +checkHinted( {b:1} ); +checkHinted( {a:1,b:1} );
\ No newline at end of file |