From: Alan T. DeKok Date: Tue, 23 Aug 2022 13:25:58 +0000 (-0400) Subject: we now support native expressions in conditions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6000b936be7f67c35578da62841a3dceee9accbb;p=thirdparty%2Ffreeradius-server.git we now support native expressions in conditions --- diff --git a/src/tests/keywords/expr b/src/tests/keywords/expr index 4eaea70b094..1f2c02fa594 100644 --- a/src/tests/keywords/expr +++ b/src/tests/keywords/expr @@ -8,6 +8,9 @@ if ("%{expr: 1 + 2 + 3 + 4}" != 10) { test_fail } +if (1 + 2 + 3 + 4 != 10) { + test_fail +} # # Precedence @@ -15,6 +18,9 @@ if ("%{expr: 1 + 2 + 3 + 4}" != 10) { if ("%{expr: 1 + 2 * 3 + 4}" != 11) { test_fail } +if (1 + 2 * 3 + 4 != 11) { + test_fail +} # # attribute references @@ -27,39 +33,66 @@ if ("%{expr: 1 + 2 * 3 + 4}" != 11) { if ("%{expr: 1 + 2 * &Tmp-Integer-1 + 4}" != 11) { test_fail } +if (1 + 2 * &Tmp-Integer-1 + 4 != 11) { + test_fail +} if ("%{expr: 1 + 2 * (&Tmp-Integer-1 + 4)}" != 15) { test_fail } +if (1 + 2 * (&Tmp-Integer-1 + 4) != 15) { + test_fail +} if ("%{expr: 1 + 2 * (&Tmp-Integer-1 + &Tmp-Integer-2)}" != 15) { test_fail } +if (1 + 2 * (&Tmp-Integer-1 + &Tmp-Integer-2) != 15) { + test_fail +} if ("%{expr: 1 & ~1}" != 0) { test_fail } +if ((1 & ~1) != 0) { # needs an extra () to resolve ambiguities and warnings + test_fail +} if ("%{expr: 1 & ~2}" != 1) { test_fail } +if ((1 & ~2) != 1) { # needs an extra () to resolve ambiguities and warnings + test_fail +} if ("%{expr: -1 * 2}" != -2) { test_fail } +if (-1 * 2 != -2) { + test_fail +} if ("%{expr: 2 - -1}" != 3) { test_fail } +if (2 - -1 != 3) { + test_fail +} if ("%{expr: 1 << 2 | 1}" != 5) { test_fail } +if (((1 << 2) | 1) != 5) { # needs extra () to resolve precedence + test_fail +} if ("%{expr: &Tmp-Date-0}" <= 0) { test_fail } +if (&Tmp-Date-0 <= 0) { + test_fail +} # # Unary negation @@ -67,9 +100,15 @@ if ("%{expr: &Tmp-Date-0}" <= 0) { if ("%{expr: 6 + -(1 + 3)}" != 2) { test_fail } +if (6 + -(1 + 3) != 2) { + test_fail +} if ("%{expr: 6 * -&Tmp-Integer-2}" != -24) { test_fail } +if (6 * -&Tmp-Integer-2 != -24) { + test_fail +} success diff --git a/src/tests/keywords/load-balance b/src/tests/keywords/load-balance index 17f1b7c1323..9f5e5e36c1a 100644 --- a/src/tests/keywords/load-balance +++ b/src/tests/keywords/load-balance @@ -90,7 +90,7 @@ if ((&Tmp-Integer-0 == 0) || (&Tmp-Integer-1 == 0)) { test_fail } -if (%{expr:%{Tmp-Integer-0} + %{Tmp-Integer-1}} != 50) { +if (&Tmp-Integer-0 + &Tmp-Integer-1 != 50) { test_fail }