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

Function assertFuncEquals

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

Source from the content-addressed store, hash-verified

1598}
1599
1600func assertFuncEquals(t *testing.T, got, want *decls.FunctionDecl) {
1601 t.Helper()
1602 if got.Name() != want.Name() {
1603 t.Fatalf("got function name %s, wanted %s", got.Name(), want.Name())
1604 }
1605 if len(got.OverloadDecls()) != len(want.OverloadDecls()) {
1606 t.Fatalf("got overload count %d, wanted %d", len(got.OverloadDecls()), len(want.OverloadDecls()))
1607 }
1608 for i, gotOverload := range got.OverloadDecls() {
1609 wantOverload := want.OverloadDecls()[i]
1610 if gotOverload.ID() != wantOverload.ID() {
1611 t.Errorf("got overload id: %s, wanted: %s", gotOverload.ID(), wantOverload.ID())
1612 }
1613 if gotOverload.IsMemberFunction() != wantOverload.IsMemberFunction() {
1614 t.Errorf("got is member function %t, wanted %t", gotOverload.IsMemberFunction(), wantOverload.IsMemberFunction())
1615 }
1616 if len(gotOverload.ArgTypes()) != len(wantOverload.ArgTypes()) {
1617 t.Fatalf("got arg count %d, wanted %d", len(gotOverload.ArgTypes()), len(wantOverload.ArgTypes()))
1618 }
1619 for i, p := range gotOverload.ArgTypes() {
1620 wp := wantOverload.ArgTypes()[i]
1621 if !p.IsExactType(wp) {
1622 t.Errorf("got arg[%d] type %v, wanted %v", i, p, wp)
1623 }
1624 }
1625 if len(gotOverload.TypeParams()) != len(wantOverload.TypeParams()) {
1626 t.Fatalf("got type param count %d, wanted %d", len(gotOverload.TypeParams()), len(wantOverload.TypeParams()))
1627 }
1628 for i, p := range gotOverload.TypeParams() {
1629 wp := wantOverload.TypeParams()[i]
1630 if p != wp {
1631 t.Errorf("got type param[%d] %s, wanted %s", i, p, wp)
1632 }
1633 }
1634 if !gotOverload.ResultType().IsExactType(wantOverload.ResultType()) {
1635 t.Errorf("got result type %v, wanted %v", gotOverload.ResultType(), wantOverload.ResultType())
1636 }
1637 if !reflect.DeepEqual(gotOverload.Examples(), wantOverload.Examples()) {
1638 t.Errorf("got examples %v, wanted %v", gotOverload.Examples(), wantOverload.Examples())
1639 }
1640 }
1641}
1642
1643func unmarshalYAML(t *testing.T, data []byte) *Config {
1644 t.Helper()

Callers 2

TestSubsetFunctionFunction · 0.85

Calls 9

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

Tested by

no test coverage detected