diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-31 12:17:32 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-03-31 12:17:32 +0100 |
commit | 69afd99f549e49252c36f6d3d08d992b1a8a8e56 (patch) | |
tree | d2d6783d4d3ca70fcc0389123082bf6901e6aad2 /test/lua/unit/expressions.lua | |
parent | 40237abf07581cf725a8f3713e67598351214bc1 (diff) | |
download | rspamd-69afd99f549e49252c36f6d3d08d992b1a8a8e56.tar.gz rspamd-69afd99f549e49252c36f6d3d08d992b1a8a8e56.zip |
[Tests] Add more tests for expressions
Diffstat (limited to 'test/lua/unit/expressions.lua')
-rw-r--r-- | test/lua/unit/expressions.lua | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/test/lua/unit/expressions.lua b/test/lua/unit/expressions.lua index c0677f435..f2c4014b5 100644 --- a/test/lua/unit/expressions.lua +++ b/test/lua/unit/expressions.lua @@ -25,23 +25,24 @@ context("Rspamd expressions", function() local pool = rspamd_mempool.create() local cases = { - {'A & B | !C', 'C ! A B & |'}, - {'A & (B | !C)', 'A B C ! | &'}, + {'A & B | !C', '(C) ! (A) (B) & |'}, + {'A & (B | !C)', '(A) (B) (C) ! | &'}, {'A & B &', nil}, -- Unbalanced braces {'(((A))', nil}, -- Balanced braces - {'(((A)))', 'A'}, + {'(((A)))', '(A)'}, -- Plus and comparision operators - {'A + B + C + D > 2', '2 A B C D +(4) >'}, + {'A + B + C + D > 2', '2 (A) (B) (C) (D) +(4) >'}, -- Plus and logic operators - {'((A + B + C + D) > 2) & D', 'D 2 A B C D +(4) > &'}, + {'((A + B + C + D) > 2) & D', '(D) 2 (A) (B) (C) (D) +(4) > &'}, -- Associativity - {'A | B | C & D & E', 'A B C D E &(3) |(3)'}, + {'A | B | C & D & E', '(A) (B) (C) (D) (E) &(3) |(3)'}, -- More associativity - {'1 | 0 & 0 | 0', '1 0 0 & 0 |(3)'}, + {'1 | 0 & 0 | 0', '(1) (0) (0) (0) & |(3)'}, + {'(A) & (B) & ((C) | (D) | (E) | (F))', '(A) (B) (C) (D) (E) (F) |(4) &(3)' }, -- Extra space - {'A & B | ! C', 'C ! A B & |'}, + {'A & B | ! C', '(C) ! (A) (B) & |'}, } for _,c in ipairs(cases) do local expr,err = rspamd_expression.create(c[1], @@ -76,6 +77,11 @@ context("Rspamd expressions", function() D = false, E = true, F = false, + G = false, + H = false, + I = false, + J = false, + K = false, } local cases = { {'A & B | !C', 0}, @@ -87,6 +93,7 @@ context("Rspamd expressions", function() {'F && ((A + B + C + D) > 1)', 0}, {'(E) && ((B + B + B + B) >= 1)', 0}, {'!!C', 1}, + {'(B) & (D) & ((G) | (H) | (I) | (A))', 0} } for _,c in ipairs(cases) do local expr,err = rspamd_expression.create(c[1], |