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

Function TestMacroSubset

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

Source from the content-addressed store, hash-verified

910}
911
912func TestMacroSubset(t *testing.T) {
913 // Only enable the 'has' macro rather than all parser macros.
914 env := testEnv(t,
915 ClearMacros(), Macros(HasMacro),
916 Variable("name", MapType(StringType, StringType)),
917 )
918 out, err := interpret(t, env, `has(name.first)`,
919 map[string]any{
920 "name": map[string]string{
921 "first": "Jim",
922 },
923 })
924 if err != nil {
925 t.Fatal(err)
926 }
927 if out != types.True {
928 t.Errorf("got %v, wanted true", out)
929 }
930 out, err = interpret(t, env, `[1, 2].all(i, i > 0)`, NoVars())
931 if err == nil {
932 t.Errorf("got %v, wanted err", out)
933 }
934}
935
936func TestCustomMacro(t *testing.T) {
937 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