From: Alan T. DeKok Date: Tue, 4 Jul 2023 20:46:39 +0000 (-0400) Subject: tests and cleanups for logical and X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a4bafaa94012616d661b706df1ce3fdc690128d;p=thirdparty%2Ffreeradius-server.git tests and cleanups for logical and --- diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 054fb92fe6a..4371d9b32b4 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -1219,14 +1219,11 @@ static xlat_action_t xlat_logical_resume(TALLOC_CTX *ctx, fr_dcursor_t *out, rctx->box->vb_bool = false; /* - * Try for another match, if possible. + * we didn't match, (&&), so we're done. */ - if (inst->stop_on_match) goto next; - - goto done; + if (!inst->stop_on_match) goto done; } -next: fr_value_box_list_talloc_free(&rctx->list); rctx->current++; diff --git a/src/tests/keywords/logical-and b/src/tests/keywords/logical-and new file mode 100644 index 00000000000..fd67fe654ae --- /dev/null +++ b/src/tests/keywords/logical-and @@ -0,0 +1,30 @@ +# +# PRE: edit +# +&request += { + &Tmp-Integer-0 = 0 + &Tmp-Integer-1 = 1 +} + +# +# ! (true && true) --> false +# +if !((&Tmp-Integer-0 == 0) && (&Tmp-Integer-1 == 1)) { + test_fail +} + +# +# false && true --> false +# +if ((&Tmp-Integer-0 == 1) && (&Tmp-Integer-1 == 1)) { + test_fail +} + +# +# true && false -> false +# +if ((&Tmp-Integer-0 == 0) && (&Tmp-Integer-1 == 0)) { + test_fail +} + +success