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

Function TestCostModelValidation

cel/cel_test.go:5778–5788  ·  view source on GitHub ↗

TestCostModelValidation covers rejection of a model whose projection has no runtime counterpart. Environment construction is the last point at which such a model can be reported.

(t *testing.T)

Source from the content-addressed store, hash-verified

5776// TestCostModelValidation covers rejection of a model whose projection has no runtime counterpart.
5777// Environment construction is the last point at which such a model can be reported.
5778func TestCostModelValidation(t *testing.T) {
5779 _, err := NewEnv(CostModel(
5780 cost.Overload(overloads.InList, cost.EvalCost(cost.ElemOf(cost.Const(3)))),
5781 ))
5782 if err == nil {
5783 t.Fatal("NewEnv() succeeded, wanted the unanswerable projection reported")
5784 }
5785 if !strings.Contains(err.Error(), "ElemOf is not defined over Const") {
5786 t.Errorf("NewEnv() errored: %v, wanted the unanswerable projection reported", err)
5787 }
5788}
5789
5790// TestCostModelValueProjections charges an element projection through a real evaluation. The two
5791// lists have the same length and the same number of literals, so every other term in the total is

Callers

nothing calls this directly

Calls 8

OverloadFunction · 0.92
EvalCostFunction · 0.92
ElemOfFunction · 0.92
ConstFunction · 0.92
CostModelFunction · 0.85
NewEnvFunction · 0.70
ContainsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected