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

Function TestMacroSubset

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

Source from the content-addressed store, hash-verified

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