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

Function TestMemberCall

common/ast/expr_test.go:137–163  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

135}
136
137func TestMemberCall(t *testing.T) {
138 fac := ast.NewExprFactory()
139 expr := fac.NewMemberCall(1, "size", fac.NewLiteral(2, types.String("hello")))
140 if expr.Kind() != ast.CallKind {
141 t.Fatalf("NewCall() produced non-call expression: %v", expr.Kind())
142 }
143 call := expr.AsCall()
144 if call.FunctionName() != "size" {
145 t.Errorf("Function() got %s, wanted 'size''", call.FunctionName())
146 }
147 if len(call.Args()) != 0 {
148 t.Errorf("Args() got %v, wanted zero", call.Args())
149 }
150 if !call.IsMemberFunction() {
151 t.Error("IsMemberFunction() got false, wanted true")
152 }
153 if call.Target().ID() != 2 {
154 t.Errorf("Target() got %d, wanted 2", call.Target().ID())
155 }
156 expr.RenumberIDs(testIDGen(100))
157 if expr.ID() != 101 {
158 t.Errorf("expr.ID() got %d, wanted 101 after RenumberIDs", expr.ID())
159 }
160 if expr.AsCall().Target().ID() != 102 {
161 t.Errorf("Target().ID() got %d, wanted 102 after RenumberIDs", expr.AsCall().Target().ID())
162 }
163}
164
165func TestCallNil(t *testing.T) {
166 expr := nilTestExpr(t)

Callers

nothing calls this directly

Calls 14

NewMemberCallMethod · 0.95
NewLiteralMethod · 0.95
NewExprFactoryFunction · 0.92
StringTypeAlias · 0.92
testIDGenFunction · 0.85
KindMethod · 0.65
AsCallMethod · 0.65
FunctionNameMethod · 0.65
ArgsMethod · 0.65
IsMemberFunctionMethod · 0.65
IDMethod · 0.65
TargetMethod · 0.65

Tested by

no test coverage detected