summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/expression_compare_test.cpp
diff options
context:
space:
mode:
authorJacob Evans <jacob.evans@10gen.com>2020-05-12 15:55:02 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-05-16 01:30:05 +0000
commita7f769dd597e33e988832c43c99912c1d3139c9b (patch)
tree9366f0dfc75db2c9c92e2b101de17542ae573e89 /src/mongo/db/pipeline/expression_compare_test.cpp
parent6b38c78843e7eb58dc344d88903727762d7d486d (diff)
downloadmongo-a7f769dd597e33e988832c43c99912c1d3139c9b.tar.gz
SERVER-47713 Change Expression code to remove intrusive ExpressionContext
Diffstat (limited to 'src/mongo/db/pipeline/expression_compare_test.cpp')
-rw-r--r--src/mongo/db/pipeline/expression_compare_test.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/mongo/db/pipeline/expression_compare_test.cpp b/src/mongo/db/pipeline/expression_compare_test.cpp
index 8ed9b2aa3d8..11836d77267 100644
--- a/src/mongo/db/pipeline/expression_compare_test.cpp
+++ b/src/mongo/db/pipeline/expression_compare_test.cpp
@@ -91,9 +91,9 @@ public:
void run() {
BSONObj specObject = BSON("" << spec());
BSONElement specElement = specObject.firstElement();
- intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
- VariablesParseState vps = expCtx->variablesParseState;
- intrusive_ptr<Expression> expression = Expression::parseOperand(expCtx, specElement, vps);
+ auto expCtx = ExpressionContextForTest{};
+ VariablesParseState vps = expCtx.variablesParseState;
+ intrusive_ptr<Expression> expression = Expression::parseOperand(&expCtx, specElement, vps);
intrusive_ptr<Expression> optimized = expression->optimize();
ASSERT_BSONOBJ_EQ(constify(expectedOptimized()), expressionToBson(optimized));
}
@@ -122,16 +122,16 @@ public:
OptimizeBase::run();
BSONObj specObject = BSON("" << spec());
BSONElement specElement = specObject.firstElement();
- intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
- VariablesParseState vps = expCtx->variablesParseState;
- intrusive_ptr<Expression> expression = Expression::parseOperand(expCtx, specElement, vps);
+ auto expCtx = ExpressionContextForTest{};
+ VariablesParseState vps = expCtx.variablesParseState;
+ intrusive_ptr<Expression> expression = Expression::parseOperand(&expCtx, specElement, vps);
// Check expression spec round trip.
ASSERT_BSONOBJ_EQ(constify(spec()), expressionToBson(expression));
// Check evaluation result.
- ASSERT_BSONOBJ_EQ(expectedResult(), toBson(expression->evaluate({}, &expCtx->variables)));
+ ASSERT_BSONOBJ_EQ(expectedResult(), toBson(expression->evaluate({}, &expCtx.variables)));
// Check that the result is the same after optimizing.
intrusive_ptr<Expression> optimized = expression->optimize();
- ASSERT_BSONOBJ_EQ(expectedResult(), toBson(optimized->evaluate({}, &expCtx->variables)));
+ ASSERT_BSONOBJ_EQ(expectedResult(), toBson(optimized->evaluate({}, &expCtx.variables)));
}
protected:
@@ -160,11 +160,11 @@ class ParseError {
public:
virtual ~ParseError() {}
void run() {
- intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
+ auto expCtx = ExpressionContextForTest{};
BSONObj specObject = BSON("" << spec());
BSONElement specElement = specObject.firstElement();
- VariablesParseState vps = expCtx->variablesParseState;
- ASSERT_THROWS(Expression::parseOperand(expCtx, specElement, vps), AssertionException);
+ VariablesParseState vps = expCtx.variablesParseState;
+ ASSERT_THROWS(Expression::parseOperand(&expCtx, specElement, vps), AssertionException);
}
protected:
@@ -365,10 +365,10 @@ public:
void run() {
BSONObj specObject = BSON("" << BSON("$ne" << BSON_ARRAY("a" << 1)));
BSONElement specElement = specObject.firstElement();
- intrusive_ptr<ExpressionContextForTest> expCtx(new ExpressionContextForTest());
- VariablesParseState vps = expCtx->variablesParseState;
- intrusive_ptr<Expression> expression = Expression::parseOperand(expCtx, specElement, vps);
- ASSERT_VALUE_EQ(expression->evaluate({}, &expCtx->variables), Value(true));
+ auto expCtx = ExpressionContextForTest{};
+ VariablesParseState vps = expCtx.variablesParseState;
+ intrusive_ptr<Expression> expression = Expression::parseOperand(&expCtx, specElement, vps);
+ ASSERT_VALUE_EQ(expression->evaluate({}, &expCtx.variables), Value(true));
}
};