diff options
Diffstat (limited to 'src/tests/keywords/expr')
-rw-r--r-- | src/tests/keywords/expr | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/src/tests/keywords/expr b/src/tests/keywords/expr new file mode 100644 index 0000000..7645931 --- /dev/null +++ b/src/tests/keywords/expr @@ -0,0 +1,108 @@ +# +# PRE: update if +# +update control { + Cleartext-Password := 'hello' +} + +update reply { + Filter-Id := "filter" +} + +# +# Simple +# +if ("%{expr: 1 + 2 + 3 + 4}" != 10) { + update reply { + Filter-Id := "fail-1" + } +} + +# +# Precedence +# +if ("%{expr: 1 + 2 * 3 + 4}" != 11) { + update reply { + Filter-Id := "fail-2" + } +} + +# +# attribute references +# +update request { + Tmp-Integer-0 = 1 + Tmp-Integer-1 = 3 + Tmp-Integer-2 = 4 + Tmp-Date-0 = "%l" +} + +if ("%{expr: 1 + 2 * &Tmp-Integer-1 + 4}" != 11) { + update reply { + Filter-Id := "fail-3" + } +} + +if ("%{expr: 1 + 2 * (&Tmp-Integer-1 + 4)}" != 15) { + update reply { + Filter-Id := "fail-4" + } +} + +if ("%{expr: 1 + 2 * (&Tmp-Integer-1 + &Tmp-Integer-2)}" != 15) { + update reply { + Filter-Id := "fail-5" + } +} + +if ("%{expr: 1 & ~1}" != 0) { + update reply { + Filter-Id := "fail-6" + } +} + +if ("%{expr: 1 & ~2}" != 1) { + update reply { + Filter-Id := "fail-7" + } +} + +if ("%{expr: -1 * 2}" != -2) { + update reply { + Filter-Id := "fail-8" + } +} + +if ("%{expr: 2 - -1}" != 3) { + update reply { + Filter-Id := "fail-9" + } +} + +if ("%{expr: 1 << 2 | 1}" != 5) { + update reply { + Filter-Id := "fail-10" + } +} + +if ("%{expr: &Tmp-Date-0}" <= 0) { + update reply { + Filter-Id := "fail-11" + } +} + +# +# Unary negation +# +if ("%{expr: 6 + -(1 + 3)}" != 2) { + update reply { + Filter-Id := "fail-12" + } +} + +if ("%{expr: 6 * -&Tmp-Integer-2}" != -24) { + update reply { + Filter-Id := "fail-13" + } +} + |