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

Function TestMathRuntimeErrors

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

Source from the content-addressed store, hash-verified

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

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