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

Function TestCall

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

Source from the content-addressed store, hash-verified

107}
108
109func TestCall(t *testing.T) {
110 fac := ast.NewExprFactory()
111 expr := fac.NewCall(1, "size", fac.NewLiteral(2, types.String("hello")))
112 if expr.Kind() != ast.CallKind {
113 t.Fatalf("NewCall() produced non-call expression: %v", expr.Kind())
114 }
115 call := expr.AsCall()
116 if call.FunctionName() != "size" {
117 t.Errorf("Function() got %s, wanted 'size''", call.FunctionName())
118 }
119 if len(call.Args()) != 1 {
120 t.Errorf("Args() got %v, wanted one", call.Args())
121 }
122 if call.IsMemberFunction() {
123 t.Error("IsMemberFunction() got true, wanted false")
124 }
125 if call.Target().ID() != 0 {
126 t.Errorf("empty Target() got %d, wanted 0", call.Target().ID())
127 }
128 expr.RenumberIDs(testIDGen(100))
129 if expr.ID() != 101 {
130 t.Errorf("expr.ID() got %d, wanted 101 after RenumberIDs", expr.ID())
131 }
132 if expr.AsCall().Args()[0].ID() != 102 {
133 t.Errorf("Args()[0].ID() got %d, wanted 102 after RenumberIDs", expr.AsCall().Args()[0].ID())
134 }
135}
136
137func TestMemberCall(t *testing.T) {
138 fac := ast.NewExprFactory()

Callers

nothing calls this directly

Calls 14

NewCallMethod · 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