jstests/core/hashed_partial_and_sparse_index.js
/**
 * Runs find command with the 'filter' and validates that the output returned matches
 * 'expectedOutput'. Also runs explain() command on the same find command and validates that all
 * the 'expectedStages' are present in the plan returned.
 */
Runs find command with the 'filter' and validates that the output returned matches
'expectedOutput'. Also runs explain() command on the same find command and validates that all
the 'expectedStages' are present in the plan returned.
Runs find command with the ' filter ' and validates that the output returned matches ' expectedOutput ' . Also runs explain () command on the same find command and validates that all the ' expectedStages ' are present in the plan returned .
function validateFindCmdOutputAndPlan({filter, expectedStages, expectedOutput}) {
    const cmdObj = {find: coll.getName(), filter: filter, projection: {_id: 0}};
    if (expectedOutput) {
        const res = assert.commandWorked(coll.runCommand(cmdObj));
        const ouputArray = new DBCommandCursor(coll.getDB(), res).toArray();
        assert(arrayEq(expectedOutput, ouputArray), ouputArray);
    }
    assertStagesForExplainOfCommand({coll: coll, cmdObj: cmdObj, expectedStages: expectedStages});
}
function validateFindCmdOutputAndPlan ( { filter , expectedStages , expectedOutput } ) { const cmdObj = { find : coll . getName ( ) , filter : filter , projection : { _id : 0 } } ; if ( expectedOutput ) { const res = assert . commandWorked ( coll . runCommand ( cmdObj ) ) ; const ouputArray = new DBCommandCursor ( coll . getDB ( ) , res ) . toArray ( ) ; assert ( arrayEq ( expectedOutput , ouputArray ) , ouputArray ) ; } assertStagesForExplainOfCommand ( { coll : coll , cmdObj : cmdObj , expectedStages : expectedStages } ) ; }
Runs find command with the 'filter' and validates that the output returned matches
 'expectedOutput'.
Runs find command with the ' filter ' and validates that the output returned matches ' expectedOutput ' .
// We ignore the order since hashed index order is not predictable.