MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestMathRuntimeErrors

Function TestMathRuntimeErrors

ext/math_test.go:302–516  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

300}
301
302func TestMathRuntimeErrors(t *testing.T) {
303 mathTests := []struct {
304 expr string
305 err string
306 in any
307 }{
308 // Tests for math.least
309 {
310 expr: "math.least(a, b)",
311 err: "no such overload: math.@min",
312 in: map[string]any{
313 "a": []int{},
314 "b": 1,
315 },
316 },
317 {
318 expr: "math.least(b, a)",
319 err: "no such overload: math.@min",
320 in: map[string]any{
321 "a": []int{},
322 "b": 1,
323 },
324 },
325 {
326 expr: "math.least(a)",
327 err: "math.@min(list) argument must not be empty",
328 in: map[string]any{
329 "a": []int{},
330 },
331 },
332 {
333 expr: "math.least(a)",
334 err: "no such overload: math.@min",
335 in: map[string]any{
336 "a": []any{"hello"},
337 },
338 },
339 {
340 expr: "math.least(a)",
341 err: "no such overload: math.@min",
342 in: map[string]any{
343 "a": []any{[]int{}, []int{}},
344 },
345 },
346 {
347 expr: "math.least(a)",
348 err: "no such overload: math.@min",
349 in: map[string]any{
350 "a": []any{1, true, 2},
351 },
352 },
353 {
354 expr: "math.least(dyn('string'))",
355 err: "no such overload: math.@min",
356 },
357
358 // Tests for math.greatest
359 {

Callers

nothing calls this directly

Calls 9

VariableFunction · 0.92
NoVarsFunction · 0.92
testMathEnvFunction · 0.85
ErrMethod · 0.80
ProgramMethod · 0.80
CompileMethod · 0.65
EvalMethod · 0.65
ContainsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected