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

Function TestContextEvalAllowsPartialUnknown

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

Source from the content-addressed store, hash-verified

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