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

Function TestDelError

repl/evaluator_test.go:156–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

154}
155
156func TestDelError(t *testing.T) {
157 eval, err := NewEvaluator()
158 if err != nil {
159 t.Fatalf("NewEvaluator() failed with: %v", err)
160 }
161
162 eval.AddLetVar("z", "41", nil)
163 eval.AddLetVar("y", "z + 1", nil)
164
165 err = eval.DelLetVar("z")
166 if err == nil {
167 t.Errorf("eval.DelLetVar('z') got %v, wanted error", err)
168 }
169
170 val, _, err := eval.Evaluate("y")
171 if err != nil {
172 t.Errorf("eval.Evaluate('y') failed %v, wanted non-error", err)
173 } else if val.Value().(int64) != 42 {
174 t.Errorf("eval.Evaluate('y') got %v, wanted 42", val.Value())
175 }
176
177}
178
179func TestAddLetFn(t *testing.T) {
180 eval, err := NewEvaluator()

Callers

nothing calls this directly

Calls 5

AddLetVarMethod · 0.95
DelLetVarMethod · 0.95
EvaluateMethod · 0.95
NewEvaluatorFunction · 0.85
ValueMethod · 0.65

Tested by

no test coverage detected