]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
we now support native expressions in conditions
authorAlan T. DeKok <aland@freeradius.org>
Tue, 23 Aug 2022 13:25:58 +0000 (09:25 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 23 Aug 2022 15:11:57 +0000 (11:11 -0400)
src/tests/keywords/expr
src/tests/keywords/load-balance

index 4eaea70b094459fadfd4f093db4c810573c7417b..1f2c02fa5949ac2a6706ba9657c9d4e1f1e755cd 100644 (file)
@@ -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
index 17f1b7c132303740d94a25b3e32da09709e041d3..9f5e5e36c1a1e89ca3f50561b1f7d00a02d9bda6 100644 (file)
@@ -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
 }