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

Function TestContextEvalAllowsPartialUnknown

cel/program_async_test.go:531–548  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

529}
530
531func TestContextEvalAllowsPartialUnknown(t *testing.T) {
532 // A variable unknown from partial evaluation must NOT be mistaken for an async call.
533 prg := mustProgram(t, `x + 1`,
534 cel.Variable("x", cel.IntType),
535 cel.EvalOptions(cel.OptPartialEval),
536 )
537 pvars, err := cel.PartialVars(map[string]any{}, cel.AttributePattern("x"))
538 if err != nil {
539 t.Fatalf("PartialVars() failed: %v", err)
540 }
541 out, _, err := prg.ContextEval(context.Background(), pvars)
542 if err != nil {
543 t.Fatalf("ContextEval() with partial unknown returned error: %v", err)
544 }
545 if !types.IsUnknown(out) {
546 t.Errorf("ContextEval() = %v, want Unknown", out)
547 }
548}
549
550func TestConcurrentEvalAllowsPartialUnknown(t *testing.T) {
551 prg := mustProgram(t, `async_func(42) + x`,

Callers

nothing calls this directly

Calls 7

VariableFunction · 0.92
EvalOptionsFunction · 0.92
PartialVarsFunction · 0.92
AttributePatternFunction · 0.92
IsUnknownFunction · 0.92
mustProgramFunction · 0.85
ContextEvalMethod · 0.65

Tested by

no test coverage detected