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

Function TestMacroSubset

cel/cel_test.go:807–829  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

805}
806
807func TestMacroSubset(t *testing.T) {
808 // Only enable the 'has' macro rather than all parser macros.
809 env := testEnv(t,
810 ClearMacros(), Macros(HasMacro),
811 Variable("name", MapType(StringType, StringType)),
812 )
813 out, err := interpret(t, env, `has(name.first)`,
814 map[string]any{
815 "name": map[string]string{
816 "first": "Jim",
817 },
818 })
819 if err != nil {
820 t.Fatal(err)
821 }
822 if out != types.True {
823 t.Errorf("got %v, wanted true", out)
824 }
825 out, err = interpret(t, env, `[1, 2].all(i, i > 0)`, NoVars())
826 if err == nil {
827 t.Errorf("got %v, wanted err", out)
828 }
829}
830
831func TestCustomMacro(t *testing.T) {
832 joinMacro := NewReceiverMacro("join", 1,

Callers

nothing calls this directly

Calls 6

ClearMacrosFunction · 0.85
interpretFunction · 0.85
NoVarsFunction · 0.85
testEnvFunction · 0.70
MacrosFunction · 0.70
VariableFunction · 0.70

Tested by

no test coverage detected