update expr to 1.17.2 (#3519)

* update expr to 1.17.2

* add if test

---------

Co-authored-by: Sebastien Blot <sebastien@crowdsec.net>
This commit is contained in:
mmetc 2025-05-09 12:55:01 +02:00 committed by GitHub
parent ce6018fbbf
commit 9510146780
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 3 deletions

View file

@ -1,4 +1,5 @@
//go:build expr_debug
package exprhelpers
import (
@ -273,6 +274,20 @@ func TestBaseDbg(t *testing.T) {
{Code: "and", CodeDepth: 0, JumpIf: true, IfFalse: true, StrConditionResult: "false", ConditionResult: boolPtr(false), Finalized: true},
},
},
{
Name: "if",
Expr: `if base_int != 42 {
true
} else {
false
}`,
Env: defaultEnv,
ExpectedOutputs: []OpOutput{
{Code: "!= 42 {", CodeDepth: 0, Negated: true, Comparison: true, Left: "42", Right: "42", StrConditionResult: "[true]", ConditionResult: boolPtr(true), Finalized: true},
{Code: "if base_int != 42 {", CodeDepth: 0, ConditionResult: boolPtr(false), Finalized: false, IfFalse: true, JumpIf: true, StrConditionResult: "false"},
{Code: "false }", CodeDepth: 0, StrConditionResult: "false", Condition: true, ConditionResult: boolPtr(false), Finalized: true},
},
},
}
logger := log.WithField("test", "exprhelpers")