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

Function assertFuncEquals

common/env/env_test.go:1493–1531  ·  view source on GitHub ↗
(t *testing.T, got, want *decls.FunctionDecl)

Source from the content-addressed store, hash-verified

1491}
1492
1493func assertFuncEquals(t *testing.T, got, want *decls.FunctionDecl) {
1494 t.Helper()
1495 if got.Name() != want.Name() {
1496 t.Fatalf("got function name %s, wanted %s", got.Name(), want.Name())
1497 }
1498 if len(got.OverloadDecls()) != len(want.OverloadDecls()) {
1499 t.Fatalf("got overload count %d, wanted %d", len(got.OverloadDecls()), len(want.OverloadDecls()))
1500 }
1501 for i, gotOverload := range got.OverloadDecls() {
1502 wantOverload := want.OverloadDecls()[i]
1503 if gotOverload.ID() != wantOverload.ID() {
1504 t.Errorf("got overload id: %s, wanted: %s", gotOverload.ID(), wantOverload.ID())
1505 }
1506 if gotOverload.IsMemberFunction() != wantOverload.IsMemberFunction() {
1507 t.Errorf("got is member function %t, wanted %t", gotOverload.IsMemberFunction(), wantOverload.IsMemberFunction())
1508 }
1509 if len(gotOverload.ArgTypes()) != len(wantOverload.ArgTypes()) {
1510 t.Fatalf("got arg count %d, wanted %d", len(gotOverload.ArgTypes()), len(wantOverload.ArgTypes()))
1511 }
1512 for i, p := range gotOverload.ArgTypes() {
1513 wp := wantOverload.ArgTypes()[i]
1514 if !p.IsExactType(wp) {
1515 t.Errorf("got arg[%d] type %v, wanted %v", i, p, wp)
1516 }
1517 }
1518 if len(gotOverload.TypeParams()) != len(wantOverload.TypeParams()) {
1519 t.Fatalf("got type param count %d, wanted %d", len(gotOverload.TypeParams()), len(wantOverload.TypeParams()))
1520 }
1521 for i, p := range gotOverload.TypeParams() {
1522 wp := wantOverload.TypeParams()[i]
1523 if p != wp {
1524 t.Errorf("got type param[%d] %s, wanted %s", i, p, wp)
1525 }
1526 }
1527 if !gotOverload.ResultType().IsExactType(wantOverload.ResultType()) {
1528 t.Errorf("got result type %v, wanted %v", gotOverload.ResultType(), wantOverload.ResultType())
1529 }
1530 }
1531}
1532
1533func unmarshalYAML(t *testing.T, data []byte) *Config {
1534 t.Helper()

Callers 2

TestSubsetFunctionFunction · 0.85

Calls 8

OverloadDeclsMethod · 0.80
ArgTypesMethod · 0.80
IsExactTypeMethod · 0.80
TypeParamsMethod · 0.80
NameMethod · 0.65
IDMethod · 0.65
IsMemberFunctionMethod · 0.65
ResultTypeMethod · 0.45

Tested by

no test coverage detected