Skip to content

Commit

Permalink
easier to debug tests
Browse files Browse the repository at this point in the history
  • Loading branch information
erh committed Jan 24, 2012
1 parent 4a39fd4 commit 65749eb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions jstests/exists6.js
Expand Up @@ -10,9 +10,13 @@ t.save( {b:null} );

checkExists = function( query ) {
// Index range constraint on 'b' is universal, so a BasicCursor is the default cursor type.
assert.eq( 'BasicCursor', t.find( query ).explain().cursor );
var x = t.find( query ).explain()
assert.eq( 'BasicCursor', x.cursor , tojson(x) );
// Index bounds include all elements.
assert.eq( [ [ { $minElement:1 }, { $maxElement:1 } ] ], t.find( query ).hint( {b:1} ).explain().indexBounds.b );

var x = t.find( query ).hint( {b:1} ).explain()
if ( ! x.indexBounds ) x.indexBounds = {}
assert.eq( [ [ { $minElement:1 }, { $maxElement:1 } ] ], x.indexBounds.b , tojson(x) );
// All keys must be scanned.
assert.eq( 3, t.find( query ).hint( {b:1} ).explain().nscanned );
// 2 docs will match.
Expand Down
1 change: 1 addition & 0 deletions jstests/or5.js
Expand Up @@ -6,6 +6,7 @@ t.ensureIndex( {b:1} );

assert.eq.automsg( "'BasicCursor'", "t.find( {$or:[{a:2},{b:3},{}]} ).explain().cursor" );
assert.eq.automsg( "'BasicCursor'", "t.find( {$or:[{a:2},{b:3},{c:4}]} ).explain().cursor" );
printjson( t.find( {$or:[{a:2},{b:3}]} ).sort( {c:1} ).explain() );
assert.eq.automsg( "'BasicCursor'", "t.find( {$or:[{a:2},{b:3}]} ).sort( {c:1} ).explain().cursor" );
e = t.find( {$or:[{a:2},{b:3}]} ).sort( {a:1} ).explain();
assert.eq.automsg( "'BtreeCursor a_1'", "e.cursor" );
Expand Down
3 changes: 2 additions & 1 deletion jstests/queryoptimizer4.js
Expand Up @@ -24,7 +24,8 @@ function reset( matches, filler ) {
function checkCursor( query, cursor ) {
t.find(query).itcount();
// Check that index on 'cursor' was chosen in the above query.
assert.eq( 'BtreeCursor ' + cursor, t.find(query).explain(true).oldPlan.cursor );
var x = t.find(query).explain(true);
assert.eq( 'BtreeCursor ' + cursor, x.oldPlan.cursor , tojson(x) );
}

// Check {b:1} takes over when {a:1} is much worse for query {a:100,b:100}.
Expand Down
3 changes: 2 additions & 1 deletion jstests/queryoptimizer7.js
Expand Up @@ -3,7 +3,8 @@
t = db.jstests_queryoptimizer7;

function assertPlanWasRecorded( query ) {
assert.eq( 'BtreeCursor a_1', t.find( query ).explain( true ).oldPlan.cursor );
var x = t.find( query ).explain( true );
assert.eq( 'BtreeCursor a_1', x.oldPlan.cursor , tojson(x) );
}

function assertNoPlanWasRecorded( query ) {
Expand Down

0 comments on commit 65749eb

Please sign in to comment.