jstests/core/arrayfind8.js
/**
 * Check matching for different query types.
 * @param bothMatch - document matched by both standardQuery and elemMatchQuery
 * @param elemMatch - document matched by elemMatchQuery but not standardQuery
 * @param notElemMatch - document matched by standardQuery but not elemMatchQuery
 */
Check matching for different query types.
@param bothMatch - document matched by both standardQuery and elemMatchQuery
@param elemMatch - document matched by elemMatchQuery but not standardQuery
@param notElemMatch - document matched by standardQuery but not elemMatchQuery
Check matching for different query types . @param bothMatch - document matched by both standardQuery and elemMatchQuery @param elemMatch - document matched by elemMatchQuery but not standardQuery @param notElemMatch - document matched by standardQuery but not elemMatchQuery
function checkMatch(bothMatch, elemMatch, nonElemMatch, standardQuery, elemMatchQuery, context) {
    function mayPush(arr, elt) {
        if (elt) {
            arr.push(elt);
        }
    }
    let expectedStandardQueryResults = [];
    mayPush(expectedStandardQueryResults, bothMatch);
    mayPush(expectedStandardQueryResults, nonElemMatch);
    assertResults(expectedStandardQueryResults, standardQuery, context + ' standard query');
    let expectedElemMatchQueryResults = [];
    mayPush(expectedElemMatchQueryResults, bothMatch);
    mayPush(expectedElemMatchQueryResults, elemMatch);
    assertResults(expectedElemMatchQueryResults, elemMatchQuery, context + ' elemMatch query');
}
function checkMatch ( bothMatch , elemMatch , nonElemMatch , standardQuery , elemMatchQuery , context ) { function mayPush ( arr , elt ) { if ( elt ) { arr . push ( elt ) ; } } let expectedStandardQueryResults = [ ] ; mayPush ( expectedStandardQueryResults , bothMatch ) ; mayPush ( expectedStandardQueryResults , nonElemMatch ) ; assertResults ( expectedStandardQueryResults , standardQuery , context + ' standard query' ) ; let expectedElemMatchQueryResults = [ ] ; mayPush ( expectedElemMatchQueryResults , bothMatch ) ; mayPush ( expectedElemMatchQueryResults , elemMatch ) ; assertResults ( expectedElemMatchQueryResults , elemMatchQuery , context + ' elemMatch query' ) ; }
Check matching for different query types.
Check matching for different query types .