switch (op) {
case OP_NOT:
- ret = 5;
- break;
- case OP_MULT:
- case OP_AND:
- ret = 4;
+ ret = 6;
break;
case OP_PLUS:
- case OP_OR:
- ret = 3;
+ ret = 5;
break;
case OP_GE:
case OP_GT:
case OP_LE:
case OP_LT:
+ ret = 4;
+ break;
+ case OP_MULT:
+ case OP_AND:
+ ret = 3;
+ break;
+ case OP_OR:
ret = 2;
break;
case OP_OBRACE:
len = strlen (line);
}
+ memset (&elt, 0, sizeof (elt));
num_re = rspamd_regexp_cache_create (NULL, "/^\\d+(\\s+|[)]|$)/", NULL, NULL);
p = line;
test("Expression process function", function()
local function process_func(token, input)
- print(token)
+ --print(token)
local t = input[token]
if t then return 1 end
{'A & (!B | C)', 1},
{'A + B + C + D + E + F >= 2', 1},
{'((A + B + C + D) > 1) & F', 0},
+ {'(A + B + C + D) > 1 && F || E', 1},
+ {'(A + B + C + D) > 100 && F || !E', 0},
{'!!C', 1},
}
for _,c in ipairs(cases) do
{parse_func, process_func}, pool)
assert_not_nil(expr, "Cannot parse " .. c[1])
+ --print(expr)
res = expr:process(atoms)
assert_equal(res, c[2], string.format("Processed expr '%s' returned '%d', expected: '%d'",
expr:to_string(), res, c[2]))