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

Function newStandardInterpreter

interpreter/interpreter_test.go:2664–2684  ·  view source on GitHub ↗

newStandardInterpreter builds a Dispatcher and TypeProvider with support for all of the CEL builtins defined in the language definition.

(t *testing.T,
	container *containers.Container,
	provider types.Provider,
	adapter types.Adapter,
	resolver AttributeFactory,
	optFuncs ...*decls.FunctionDecl)

Source from the content-addressed store, hash-verified

2662// newStandardInterpreter builds a Dispatcher and TypeProvider with support for all of the CEL
2663// builtins defined in the language definition.
2664func newStandardInterpreter(t *testing.T,
2665 container *containers.Container,
2666 provider types.Provider,
2667 adapter types.Adapter,
2668 resolver AttributeFactory,
2669 optFuncs ...*decls.FunctionDecl) Interpreter {
2670 t.Helper()
2671 disp := NewDispatcher()
2672 addFunctionBindings(t, disp)
2673 for _, fn := range optFuncs {
2674 bindings, err := fn.Bindings()
2675 if err != nil {
2676 t.Fatalf("fn.Bindings() failed for function %v. error: %v", fn.Name(), err)
2677 }
2678 err = disp.Add(bindings...)
2679 if err != nil {
2680 t.Fatalf("dispatcher.Add() failed: %v", err)
2681 }
2682 }
2683 return NewInterpreter(disp, container, provider, adapter, resolver)
2684}
2685
2686func addFunctionBindings(t testing.TB, dispatcher Dispatcher) {
2687 funcs := stdlib.Functions()

Calls 6

AddMethod · 0.95
NewDispatcherFunction · 0.85
addFunctionBindingsFunction · 0.85
NewInterpreterFunction · 0.85
BindingsMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected