Raise if Abs
function got a boolean
Reviewers: florijan, mislav.bradac Reviewed By: mislav.bradac Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D289
This commit is contained in:
parent
231b84e834
commit
dbe5ffc4ea
@ -15,8 +15,6 @@ TypedValue Abs(const std::vector<TypedValue> &args) {
|
||||
switch (args[0].type()) {
|
||||
case TypedValue::Type::Null:
|
||||
return TypedValue::Null;
|
||||
case TypedValue::Type::Bool:
|
||||
return args[0].Value<bool>();
|
||||
case TypedValue::Type::Int:
|
||||
return static_cast<int64_t>(
|
||||
std::abs(static_cast<long long>(args[0].Value<int64_t>())));
|
||||
|
@ -246,7 +246,7 @@ TEST(ExpressionEvaluator, IsNullOperator) {
|
||||
ASSERT_EQ(eval.eval.PopBack().Value<bool>(), true);
|
||||
}
|
||||
|
||||
TEST(ExpressionEvaluator, Function) {
|
||||
TEST(ExpressionEvaluator, AbsFunction) {
|
||||
AstTreeStorage storage;
|
||||
NoContextExpressionEvaluator eval;
|
||||
{
|
||||
@ -271,8 +271,7 @@ TEST(ExpressionEvaluator, Function) {
|
||||
{
|
||||
std::vector<Expression *> arguments = {storage.Create<Literal>(true)};
|
||||
auto *op = storage.Create<Function>(NameToFunction("ABS"), arguments);
|
||||
op->Accept(eval.eval);
|
||||
ASSERT_EQ(eval.eval.PopBack().Value<bool>(), true);
|
||||
ASSERT_THROW(op->Accept(eval.eval), QueryRuntimeException);
|
||||
}
|
||||
{
|
||||
std::vector<Expression *> arguments = {
|
||||
|
Loading…
Reference in New Issue
Block a user