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)
| 2662 | // newStandardInterpreter builds a Dispatcher and TypeProvider with support for all of the CEL |
| 2663 | // builtins defined in the language definition. |
| 2664 | func 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 | |
| 2686 | func addFunctionBindings(t testing.TB, dispatcher Dispatcher) { |
| 2687 | funcs := stdlib.Functions() |
no test coverage detected