MCPcopy
hub / github.com/expr-lang/expr / TestConstExpr_error_panic

Function TestConstExpr_error_panic

expr_test.go:1662–1674  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1660}
1661
1662func TestConstExpr_error_panic(t *testing.T) {
1663 env := map[string]any{
1664 "divide": func(a, b int) int { return a / b },
1665 }
1666
1667 _, err := expr.Compile(
1668 `1 + divide(1, 0)`,
1669 expr.Env(env),
1670 expr.ConstExpr("divide"),
1671 )
1672 require.Error(t, err)
1673 require.Equal(t, "compile error: integer divide by zero (1:5)\n | 1 + divide(1, 0)\n | ....^", err.Error())
1674}
1675
1676type divideError struct{ Message string }
1677

Callers

nothing calls this directly

Calls 6

CompileFunction · 0.92
EnvStruct · 0.92
ConstExprFunction · 0.92
ErrorFunction · 0.92
EqualFunction · 0.92
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…