diff options
author | James Wahlin <james.wahlin@mongodb.com> | 2019-10-02 13:21:46 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-02 13:21:46 +0000 |
commit | 3af1b9921b1fd802bfbb84681da445207b5f8f37 (patch) | |
tree | 44feefe4781ee6ae81c0184c910039c872843964 /src/mongo/db/pipeline/expression_javascript_test.cpp | |
parent | db4a142a48ccf757e8eeb89485bec28957c3d789 (diff) | |
download | mongo-3af1b9921b1fd802bfbb84681da445207b5f8f37.tar.gz |
Revert "SERVER-43138 Remove restriction on number of arguments to $_internalJs"
This reverts commit dfb22aca7b1e62693fd5272d37239a40000c3d0e.
Diffstat (limited to 'src/mongo/db/pipeline/expression_javascript_test.cpp')
-rw-r--r-- | src/mongo/db/pipeline/expression_javascript_test.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/mongo/db/pipeline/expression_javascript_test.cpp b/src/mongo/db/pipeline/expression_javascript_test.cpp index 96ff7295ddc..8060a2b66d5 100644 --- a/src/mongo/db/pipeline/expression_javascript_test.cpp +++ b/src/mongo/db/pipeline/expression_javascript_test.cpp @@ -90,21 +90,22 @@ TEST_F(MapReduceFixture, ExpressionInternalJsProducesExpectedResult) { Value result = expr->evaluate(Document{BSON("a" << 2)}, getVariables()); ASSERT_VALUE_EQ(result, Value(6)); +} - bsonExpr = +TEST_F(MapReduceFixture, ExpressionInternalJsFailsWithIncorrectNumberOfArguments) { + auto bsonExpr = BSON("expr" << BSON("eval" << "function(first, second, third) {return first + second + third;};" << "args" << BSON_ARRAY(1 << 2 << 4))); - expr = ExpressionInternalJs::parse(getExpCtx(), bsonExpr.firstElement(), getVPS()); - result = expr->evaluate(Document{BSONObj{}}, getVariables()); - ASSERT_VALUE_EQ(result, Value(7)); + auto expr = ExpressionInternalJs::parse(getExpCtx(), bsonExpr.firstElement(), getVPS()); + + ASSERT_THROWS_CODE(expr->evaluate({}, getVariables()), AssertionException, 31267); bsonExpr = BSON("expr" << BSON("eval" << "function(first) {return first;};" << "args" << BSON_ARRAY(1))); expr = ExpressionInternalJs::parse(getExpCtx(), bsonExpr.firstElement(), getVPS()); - result = expr->evaluate(Document{BSONObj{}}, getVariables()); - ASSERT_VALUE_EQ(result, Value(1)); + ASSERT_THROWS_CODE(expr->evaluate({}, getVariables()), AssertionException, 31267); } TEST_F(MapReduceFixture, ExpressionInternalJsFailsIfArgsDoesNotEvaluateToArray) { |