DEATH_TEST_REGEX_F(DocumentSourceMatchTest,
                   ShouldFailToDescendExpressionOnPathThatContainsElemMatchWithObject,
                   R"#(Invariant failure.*node->matchType\(\))#") {
    const auto expCtx = getExpCtx();
    const auto matchSpec = BSON("a" << BSON("$elemMatch" << BSON("a.b" << 1)));
    const auto matchExpression =
        unittest::assertGet(MatchExpressionParser::parse(matchSpec, expCtx));
    BSONObjBuilder out;
    matchExpression->serialize(&out);
    DocumentSourceMatch::descendMatchOnPath(matchExpression.get(), "a", expCtx);
}
DEATH_TEST_REGEX_F(DocumentSourceMatchTest,
                   ShouldFailToDescendExpressionOnPathThatContainsElemMatchWithObject,
                   R"#(Invariant failure.*node->matchType\(\))#") {
    const auto expCtx = getExpCtx();
    const auto matchSpec = BSON("a" << BSON("$elemMatch" << BSON("a.b" << 1)));
    const auto matchExpression =
        unittest::assertGet(MatchExpressionParser::parse(matchSpec, expCtx));
    BSONObjBuilder out;
    matchExpression->serialize(&out);
    DocumentSourceMatch::descendMatchOnPath(matchExpression.get(), "a", expCtx);
}