diff --git a/.golangci.yaml b/.golangci.yaml index cc341ef..b466884 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -2,7 +2,7 @@ linters: enable-all: true disable: - cyclop - - gocognit + - depguard - dogsled - errorlint - exhaustivestruct @@ -13,6 +13,7 @@ linters: - ireturn - gochecknoglobals - gochecknoinits + - gocognit - godot - maintidx - maligned @@ -70,6 +71,12 @@ issues: - revive - stylecheck - unused + - linters: + - unused + path: generator/testmoqs/fnadaptors_test.go + - linters: + - unused + path: generator/testmoqs/usualadaptors_test.go include: # disable excluding of issues about comments from golint. - EXC0002 diff --git a/ast/cache.go b/ast/cache.go index 4b57062..b887db5 100644 --- a/ast/cache.go +++ b/ast/cache.go @@ -4,6 +4,7 @@ package ast import ( "errors" "fmt" + "go/token" "io/fs" "os" "path/filepath" @@ -23,9 +24,11 @@ import ( const ( builtinPkg = "builtin" - genTypeSuffix = "_genType" - starGenTypeSuffix = "_starGenType" - testPkgSuffix = "_test" + genTypeSuffix = "_genType" + starGenTypeSuffix = "_starGenType" + indexGenTypeSuffix = "_indexGenType" + indexListGenTypeSuffix = "_indexListGenType" + testPkgSuffix = "_test" ) //go:generate moqueries LoadFn @@ -194,9 +197,10 @@ func (c *Cache) Type(id dst.Ident, contextPkg string, testImport bool) (TypeInfo }, nil } -// IsComparable determines if an expression is comparable -func (c *Cache) IsComparable(expr dst.Expr) (bool, error) { - return c.isDefaultComparable(expr, true) +// IsComparable determines if an expression is comparable. The optional +// parentType can be used to supply type parameters. +func (c *Cache) IsComparable(expr dst.Expr, parentType TypeInfo) (bool, error) { + return c.isDefaultComparable(expr, &parentType, true, false) } // IsDefaultComparable determines if an expression is comparable. Returns the @@ -204,8 +208,8 @@ func (c *Cache) IsComparable(expr dst.Expr) (bool, error) { // by default (interface implementations that are not comparable and put into a // map key will panic at runtime and by default pointers use a deep hash to be // comparable). -func (c *Cache) IsDefaultComparable(expr dst.Expr) (bool, error) { - return c.isDefaultComparable(expr, false) +func (c *Cache) IsDefaultComparable(expr dst.Expr, parentType TypeInfo) (bool, error) { + return c.isDefaultComparable(expr, &parentType, false, false) } // FindPackage finds the package for a given directory @@ -363,43 +367,113 @@ func isExported(name, pkgPath string) bool { return false } -func (c *Cache) isDefaultComparable(expr dst.Expr, interfacePointerDefault bool) (bool, error) { +func (c *Cache) isDefaultComparable( + expr dst.Expr, + parentType *TypeInfo, + interfacePointerDefault bool, + genericType bool, +) (bool, error) { + subInterfaceDefault := interfacePointerDefault + if genericType { + subInterfaceDefault = false + } switch e := expr.(type) { case *dst.ArrayType: if e.Len == nil { return false, nil } - return c.isDefaultComparable(e.Elt, interfacePointerDefault) - case *dst.MapType, *dst.Ellipsis, *dst.FuncType: + + return c.isDefaultComparable(e.Elt, parentType, interfacePointerDefault, genericType) + case *dst.BinaryExpr: + comp, err := c.isDefaultComparable(e.X, parentType, interfacePointerDefault, genericType) + if err != nil || !comp { + return comp, err + } + + return c.isDefaultComparable(e.Y, parentType, interfacePointerDefault, genericType) + case *dst.Ellipsis: + return false, nil + case *dst.FuncType: return false, nil - case *dst.StarExpr: - return interfacePointerDefault, nil case *dst.InterfaceType: - return interfacePointerDefault, nil - case *dst.Ident: - if e.Obj != nil { - typ, ok := e.Obj.Decl.(*dst.TypeSpec) - if !ok { - return false, fmt.Errorf("%q: %w", e.String(), ErrInvalidType) + if e.Methods == nil || len(e.Methods.List) == 0 { + // Basically an "any" interface + return subInterfaceDefault, nil + } + hasTypeConstraints := false + for _, m := range e.Methods.List { + if _, ok := m.Type.(*dst.FuncType); ok { + // Skip methods as the don't change whether something is + // comparable + continue } - if typ.Name.Name == "string" && typ.Name.Path == "" { - return true, nil + hasTypeConstraints = true + + comp, err := c.isDefaultComparable(m.Type, parentType, subInterfaceDefault, genericType) + if err != nil || !comp { + return comp, err } + } - return c.isDefaultComparable(typ.Type, interfacePointerDefault) + if hasTypeConstraints { + // If an interface has type constraints and none of them were not + // comparable (none were because we would have returned early + // above), then it is always comparable + return true, nil } + + return subInterfaceDefault, nil + case *dst.Ident: + // if e.Obj != nil { + // var tExpr dst.Expr + // switch typ := e.Obj.Decl.(type) { + // case *dst.TypeSpec: + // tExpr = typ.Type + // case *dst.Field: + // tExpr = typ.Type + // default: + // return false, fmt.Errorf("identity expression %q: %w", e.String(), ErrInvalidType) + // } + // + // return c.isDefaultComparable(tExpr, parentType, "", interfacePointerDefault, false) + // } + // TODO: Generic type parameters should trump types in the cache (call + // findGenericType first) + pkgPath := e.Path typ, ok := c.typesByIdent[e.String()] + if !ok && e.Path == "" && parentType != nil { + pkgPath = parentType.PkgPath + typ, ok = c.typesByIdent[IdPath(e.Name, parentType.PkgPath).String()] + } if ok { - return c.isDefaultComparable(typ.typ.Type, interfacePointerDefault) + tInfo := &TypeInfo{ + Type: typ.typ, + PkgPath: pkgPath, + Exported: isExported(e.Name, pkgPath), + Fabricated: false, + } + return c.isDefaultComparable( + typ.typ.Type, tInfo, interfacePointerDefault, genericType) } - // Builtin type? - if e.Path == "" { - // error is the one builtin type that may not be comparable (it's + // Builtin or generic type? + if e.Path == "" || (parentType != nil && parentType.Type != nil && e.Path == parentType.Type.Name.Path) { + // Precedence is given to a generic type + gType := c.findGenericType(parentType, e.Name) + if gType != nil { + return c.isDefaultComparable(gType, parentType, interfacePointerDefault, true) + } + + // error is a builtin type that may not be comparable (it's // an interface so return the same result as an interface) if e.Name == "error" { - return interfacePointerDefault, nil + return subInterfaceDefault, nil + } + + // any is an alias for interface{}, so again the default + if e.Name == "any" { + return subInterfaceDefault, nil } return true, nil @@ -412,14 +486,22 @@ func (c *Cache) isDefaultComparable(expr dst.Expr, interfacePointerDefault bool) typ, ok = c.typesByIdent[e.String()] if ok { - return c.isDefaultComparable(typ.typ.Type, interfacePointerDefault) + tInfo := &TypeInfo{ + Type: typ.typ, + PkgPath: e.Path, + Exported: isExported(e.Name, e.Path), + Fabricated: false, + } + return c.isDefaultComparable(typ.typ.Type, tInfo, interfacePointerDefault, genericType) } return true, nil + case *dst.MapType: + return false, nil case *dst.SelectorExpr: ex, ok := e.X.(*dst.Ident) if !ok { - return false, fmt.Errorf("%q: %w", e.X, ErrInvalidType) + return false, fmt.Errorf("selector expression %q: %w", e.X, ErrInvalidType) } path := ex.Name _, err := c.loadPackage(path, false) @@ -429,23 +511,105 @@ func (c *Cache) isDefaultComparable(expr dst.Expr, interfacePointerDefault bool) typ, ok := c.typesByIdent[IdPath(e.Sel.Name, path).String()] if ok { - return c.isDefaultComparable(typ.typ.Type, interfacePointerDefault) + return c.isDefaultComparable(typ.typ.Type, nil, interfacePointerDefault, genericType) } // Builtin type? return true, nil + case *dst.StarExpr: + return interfacePointerDefault, nil case *dst.StructType: for _, f := range e.Fields.List { - comp, err := c.isDefaultComparable(f.Type, interfacePointerDefault) + comp, err := c.isDefaultComparable(f.Type, parentType, interfacePointerDefault, genericType) if err != nil || !comp { return false, err } } + case *dst.UnaryExpr: + if e.Op != token.TILDE { + return false, fmt.Errorf( + "unexpected unary operator %s: %w", e.Op.String(), ErrInvalidType) + } + // This is a type constraint and for determining comparability, we + // don't care if the constraint is for a type or underlying types + return c.isDefaultComparable(e.X, parentType, interfacePointerDefault, genericType) } return true, nil } +func (c *Cache) findGenericType(parentType *TypeInfo, paramTypeName string) dst.Expr { + if parentType == nil || parentType.Type == nil || parentType.Type.TypeParams == nil { + return nil + } + + for _, p := range parentType.Type.TypeParams.List { + for _, n := range p.Names { + if n.Name == paramTypeName { + return p.Type + } + } + } + + return nil +} + +// func (c *Cache) findMethodGenericType(fn *dst.FuncDecl, paramTypeName string) (dst.Expr, error) { +// // Only handle methods here. Functions and structs have their Obj's intact +// // and don't need to be looked up in another declaration +// for _, r := range fn.Recv.List { +// switch idxType := r.Type.(type) { +// case *dst.IndexListExpr: +// for n, iExpr := range idxType.Indices { +// xId, ok := idxType.X.(*dst.Ident) +// if !ok { +// return nil, fmt.Errorf( +// "expecting *dst.Ident in IndexListExpr.X: %w", ErrInvalidType) +// } +// gType, err := c.findIndexedGenericType(iExpr, paramTypeName, xId, n) +// if err != nil || gType != nil { +// return gType, err +// } +// } +// case *dst.IndexExpr: +// xId, ok := idxType.X.(*dst.Ident) +// if !ok { +// return nil, fmt.Errorf( +// "expecting *dst.Ident in IndexExpr.X: %w", ErrInvalidType) +// } +// return c.findIndexedGenericType(idxType.Index, paramTypeName, xId, 0) +// default: +// return nil, fmt.Errorf( +// "unexpected index type %#v: %w", idxType, ErrInvalidType) +// } +// } +// +// return nil, nil +// } + +// func (c *Cache) findIndexedGenericType( +// iExpr dst.Expr, paramTypeName string, xId *dst.Ident, idx int, +// ) (dst.Expr, error) { +// if id, ok := iExpr.(*dst.Ident); ok && id.Name != paramTypeName { +// return nil, nil +// } +// +// if xId.Obj == nil { +// return nil, fmt.Errorf( +// "expecting Obj: %w", ErrInvalidType) +// } +// tSpec, ok := xId.Obj.Decl.(*dst.TypeSpec) +// if !ok { +// return nil, fmt.Errorf( +// "expecting *dst.TypeSpec: %w", ErrInvalidType) +// } +// if tSpec.TypeParams == nil || len(tSpec.TypeParams.List) <= idx { +// return nil, fmt.Errorf( +// "base type to method type param mismatch: %w", ErrInvalidType) +// } +// return tSpec.TypeParams.List[idx].Type, nil +// } + func (c *Cache) loadPackage(path string, testImport bool) (string, error) { indexPath := path if strings.HasPrefix(path, ".") { @@ -501,19 +665,6 @@ func (c *Cache) loadTypes(loadPkg string, testImport bool) (string, error) { } func (c *Cache) loadAST(loadPkg string, testImport bool) ([]*pkgInfo, error) { - if dp, ok := c.loadedPkgs[loadPkg]; ok { - // If we already loaded the test types or if the test types aren't - // requested, we're done - if dp.loadTestPkgs || !testImport { - // If we direct loaded, we're done - if dp.directLoaded { - c.metrics.ASTTypeCacheHitsInc() - return []*pkgInfo{dp}, nil - } - } - } - c.metrics.ASTTypeCacheMissesInc() - start := time.Now() pkgs, err := c.load(&packages.Config{ Mode: packages.NeedName | @@ -597,7 +748,7 @@ func (c *Cache) convert(pkg *packages.Package, testImport, directLoaded bool) (* start := time.Now() p.pkg.Decorator = decorator.NewDecoratorFromPackage(pkg) - p.pkg.Decorator.ResolveLocalPath = true + // p.pkg.Decorator.ResolveLocalPath = true for _, f := range pkg.Syntax { fpath := pkg.Fset.File(f.Pos()).Name() if !goFiles[fpath] { @@ -694,6 +845,14 @@ func (c *Cache) storeFuncDecl(decl *dst.FuncDecl, pkg *pkgInfo) { suffix = starGenTypeSuffix expr = sExpr.X } + if iExpr, ok := expr.(*dst.IndexExpr); ok { + suffix = indexGenTypeSuffix + expr = iExpr.X + } + if ilExpr, ok := expr.(*dst.IndexListExpr); ok { + suffix = indexListGenTypeSuffix + expr = ilExpr.X + } exprId, ok := expr.(*dst.Ident) if !ok { logs.Panicf("%s has a non-Ident (or StarExpr/Ident) receiver: %#v", diff --git a/ast/cache_test.go b/ast/cache_test.go index 7800401..3969c75 100644 --- a/ast/cache_test.go +++ b/ast/cache_test.go @@ -313,7 +313,6 @@ func TestCache(t *testing.T) { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, noExportPkg).returnResults(tc.pkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D(). @@ -372,13 +371,11 @@ func TestCache(t *testing.T) { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, exportPkg).returnResults(exportPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, "builtin").returnResults(builtinPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D().ReturnResults() @@ -412,7 +409,6 @@ func TestCache(t *testing.T) { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, replacebuiltinPkg).returnResults(replacebuiltinPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D().ReturnResults() @@ -446,7 +442,6 @@ func TestCache(t *testing.T) { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, noExportPkg).returnResults(noExportWTestsPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D(). @@ -481,7 +476,6 @@ func TestCache(t *testing.T) { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() err := errors.New("load error") loadFnMoq.onCall(loadCfg, ".").returnResults(nil, err) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() @@ -511,7 +505,6 @@ func TestCache(t *testing.T) { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, noExportPkg).returnResults(noExportPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D().ReturnResults() @@ -583,7 +576,6 @@ func TestCache(t *testing.T) { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadCfg.Tests = tc.initialTestImport loadFnMoq.onCall(loadCfg, tc.pkgName).returnResults(noExportWTestsPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() @@ -620,7 +612,6 @@ func TestCache(t *testing.T) { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, noExportPkg).returnResults(noExportPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D(). @@ -631,7 +622,6 @@ func TestCache(t *testing.T) { loadCfg.Tests = true metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, noExportPkg).returnResults(noExportWTestsPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() @@ -661,8 +651,6 @@ func TestCache(t *testing.T) { metricsMoq.OnCall().ASTPkgCacheMissesInc(). ReturnResults().Repeat(moq.Times(2)) - metricsMoq.OnCall().ASTTypeCacheMissesInc(). - ReturnResults().Repeat(moq.Times(2)) loadFnMoq.onCall(loadCfg, noExportPkg).returnResults(noExportPkgs, nil) loadFnMoq.onCall(loadCfg, "builtin").returnResults(builtinPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D(). @@ -712,7 +700,6 @@ func TestCache(t *testing.T) { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, tc.firstPath).returnResults(noExportPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTPkgCacheHitsInc().ReturnResults() @@ -755,7 +742,6 @@ func TestCache(t *testing.T) { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, ".").returnResults(noExportWTestsPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTPkgCacheHitsInc().ReturnResults() @@ -850,7 +836,7 @@ func TestCache(t *testing.T) { "func()": { comparable: false, defaultComparable: false, - structable: false, + structable: true, }, } @@ -863,6 +849,49 @@ func TestCache(t *testing.T) { return f } + loadPackages := func(t *testing.T, code map[string]string) []*packages.Package { + t.Helper() + dir, err := os.MkdirTemp("", "cache-test-*") + if err != nil { + t.Fatalf("got os.MkdirTemp err: %#v, want no error", err) + } + defer func() { + err := os.RemoveAll(dir) + if err != nil { + t.Errorf("got os.RemoveAll err: %#v, want no error", err) + } + }() + + for srcPath, src := range code { + fPath := filepath.Join(dir, srcPath) + fDir, _ := filepath.Split(fPath) + if err := os.Mkdir(fDir, fs.ModePerm); err != nil && !errors.Is(err, fs.ErrExist) { + t.Fatalf("got os.Mkdir err: %#v, want no error", err) + } + err := os.WriteFile(fPath, []byte(src), fs.ModePerm) + if err != nil { + t.Fatalf("got os.WriteFile err: %#v, want no error", err) + } + } + + pkgs, err := packages.Load(&packages.Config{ + Mode: packages.NeedName | + packages.NeedFiles | + packages.NeedCompiledGoFiles | + packages.NeedImports | + packages.NeedTypes | + packages.NeedSyntax | + packages.NeedTypesInfo | + packages.NeedTypesSizes, + Dir: dir, + Tests: false, + }, "a") + if err != nil { + t.Fatalf("got packages.Load err: %#v, want no error", err) + } + return pkgs + } + simpleExpr := func(t *testing.T, paramType string) dst.Expr { t.Helper() code := `package a @@ -917,18 +946,19 @@ func b(c %s) {} return p } + isComparable := func(c *ast.Cache, expr dst.Expr, parentType ast.TypeInfo) (bool, error) { + return c.IsComparable(expr, parentType) + } + isDefaultComparable := func(c *ast.Cache, expr dst.Expr, parentType ast.TypeInfo) (bool, error) { + return c.IsDefaultComparable(expr, parentType) + } + type compFn func(c *ast.Cache, expr dst.Expr, parentType ast.TypeInfo) (bool, error) + t.Run("simple exprs", func(t *testing.T) { for paramType, tc := range testCases { t.Run(paramType, func(t *testing.T) { - isComparable := func(c *ast.Cache, expr dst.Expr) (bool, error) { - return c.IsComparable(expr) - } - isDefaultComparable := func(c *ast.Cache, expr dst.Expr) (bool, error) { - return c.IsDefaultComparable(expr) - } - - subTestCases := map[string]struct { - compFn func(c *ast.Cache, expr dst.Expr) (bool, error) + for name, stc := range map[string]struct { + compFn compFn comparable bool }{ "IsComparable": { @@ -939,16 +969,13 @@ func b(c %s) {} compFn: isDefaultComparable, comparable: tc.defaultComparable, }, - } - - for name, stc := range subTestCases { + } { t.Run(name, func(t *testing.T) { // ASSEMBLE beforeEach(t, false) defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults().Repeat(moq.Optional()) - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults().Repeat(moq.Optional()) loadFnMoq.onCall(loadCfg, "io"). returnResults(ioPkgs, nil).repeat(moq.AnyTimes()) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults().Repeat(moq.Optional()) @@ -958,7 +985,7 @@ func b(c %s) {} expr := simpleExpr(t, paramType) // ACT - is, err := stc.compFn(cache, expr) + is, err := stc.compFn(cache, expr, ast.TypeInfo{}) // ASSERT if err != nil { t.Errorf("got %#v, want no error", err) @@ -972,21 +999,8 @@ func b(c %s) {} } }) - comparableStructCases := map[string]struct { - code string - declIdx int - }{ - "inline": { - code: `package a - -import _ "io" - -func a(b struct{ c %s }) {} -`, - declIdx: 1, - }, - "standard": { - code: `package a + t.Run("IsComparable - struct exprs", func(t *testing.T) { + code := `package a import _ "io" @@ -995,49 +1009,42 @@ type b struct { } func d(e b) {} -`, - declIdx: 2, - }, - } +` - t.Run("IsComparable - struct exprs", func(t *testing.T) { - for name, stc := range comparableStructCases { - t.Run(name, func(t *testing.T) { - for paramType, tc := range testCases { - t.Run(paramType, func(t *testing.T) { - // ASSEMBLE - if !tc.structable { - t.Skipf("%s can't be put into a struct, skipping", paramType) - } + for paramType, tc := range testCases { + t.Run(paramType, func(t *testing.T) { + // ASSEMBLE + if !tc.structable { + t.Skipf("%s can't be put into a struct, skipping", paramType) + } - beforeEach(t, false) - defer afterEach(t) + beforeEach(t, false) + defer afterEach(t) - f := parse(t, fmt.Sprintf(stc.code, paramType)) - fn, ok := f.Decls[stc.declIdx].(*dst.FuncDecl) - if !ok { - t.Fatalf("got %#v, want a function declaration", f.Decls[stc.declIdx]) - } - expr := fn.Type.Params.List[0].Type + pkgs := loadPackages(t, map[string]string{ + "code.go": fmt.Sprintf(code, paramType), + "go.mod": "module a", + }) - metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults().Repeat(moq.Optional()) - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults().Repeat(moq.Optional()) - loadFnMoq.onCall(loadCfg, "io"). - returnResults(ioPkgs, nil).repeat(moq.AnyTimes()) - metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults().Repeat(moq.Optional()) - metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D(). - ReturnResults().Repeat(moq.AnyTimes()) + metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults(). + Repeat(moq.MinTimes(1), moq.MaxTimes(2)) + loadFnMoq.onCall(loadCfg, "a"). + returnResults(pkgs, nil) + loadFnMoq.onCall(loadCfg, "io"). + returnResults(ioPkgs, nil).repeat(moq.Optional()) + metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults(). + Repeat(moq.MinTimes(1), moq.MaxTimes(2)) + metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D(). + ReturnResults().Repeat(moq.AnyTimes()) - // ACT - isComparable, err := cache.IsComparable(expr) - // ASSERT - if err != nil { - t.Errorf("got %#v, want no error", err) - } - if isComparable != tc.comparable { - t.Errorf("got %t, want %t", isComparable, tc.comparable) - } - }) + // ACT + isComparable, err := cache.IsComparable(ast.IdPath("b", "a"), ast.TypeInfo{}) + // ASSERT + if err != nil { + t.Errorf("got %#v, want no error", err) + } + if isComparable != tc.comparable { + t.Errorf("got %t, want %t", isComparable, tc.comparable) } }) } @@ -1077,12 +1084,10 @@ type e struct { ` bPkg := parseASTPackage(t, fmt.Sprintf(code2, paramType), "b") metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults().Repeat(moq.Optional()) - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults().Repeat(moq.Optional()) loadFnMoq.onCall(loadCfg, "b").returnResults(bPkg, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults().Repeat(moq.Optional()) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults().Repeat(moq.Optional()) - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults().Repeat(moq.Optional()) loadFnMoq.onCall(loadCfg, "io"). returnResults(ioPkgs, nil).repeat(moq.AnyTimes()) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults().Repeat(moq.Optional()) @@ -1090,7 +1095,7 @@ type e struct { ReturnResults().Repeat(moq.AnyTimes()) // ACT - isComparable, err := cache.IsComparable(expr) + isComparable, err := cache.IsComparable(expr, ast.TypeInfo{}) // ASSERT if err != nil { t.Errorf("got %#v, want no error", err) @@ -1101,6 +1106,330 @@ type e struct { }) } }) + + t.Run("generics", func(t *testing.T) { + for name, tc := range map[string]struct { + comparable bool + defaultComparable bool + typeConstraints string + structContents string + typeParams string + errorContains string + alterMethod func(*dst.FuncDecl) + skipNonMethodTest bool + }{ + "[T any, U comparable, V any]": { + comparable: true, + defaultComparable: true, + typeConstraints: "[T any, U comparable, V any]", + structContents: "t T; u U; v V", + typeParams: "T, U, V", + }, + "[T any, U any, V any]": { + comparable: false, + defaultComparable: false, + typeConstraints: "[T any, U any, V any]", + structContents: "t T; u U; v V", + typeParams: "T, U, V", + }, + "[U comparable]": { + comparable: true, + defaultComparable: true, + typeConstraints: "[U comparable]", + }, + "[U any]": { + comparable: false, + defaultComparable: false, + typeConstraints: "[U any]", + }, + "[U interface{}]": { + comparable: false, + defaultComparable: false, + typeConstraints: "[U interface{}]", + }, + "[U []int]": { + comparable: false, + defaultComparable: false, + typeConstraints: "[U []int]", + }, + "[U int]": { + comparable: true, + defaultComparable: true, + typeConstraints: "[U int]", + }, + "[U interface{ []int }]": { + comparable: false, + defaultComparable: false, + typeConstraints: "[U interface{ []int }]", + }, + "[U interface{ int }]": { + comparable: true, + defaultComparable: true, + typeConstraints: "[U interface{ int }]", + }, + "[U notComparable]": { + comparable: false, + defaultComparable: false, + typeConstraints: "[U notComparable]", + }, + "[U isComparable]": { + comparable: true, + defaultComparable: true, + typeConstraints: "[U isComparable]", + }, + "[U ~notComparable]": { + comparable: false, + defaultComparable: false, + typeConstraints: "[U ~notComparable]", + }, + "[U ~isComparable]": { + comparable: true, + defaultComparable: true, + typeConstraints: "[U ~isComparable]", + }, + "[U interface{ ~int | ~string }]": { + comparable: true, + defaultComparable: true, + typeConstraints: "[U interface{ ~int | ~string }]", + }, + "[U interface{ ~int | ~string | ~notComparable }]": { + comparable: false, + defaultComparable: false, + typeConstraints: "[U interface{ ~int | ~string | ~notComparable }]", + }, + "[U interface{ ~notComparable | ~int | ~string }]": { + comparable: false, + defaultComparable: false, + typeConstraints: "[U interface{ ~notComparable | ~int | ~string }]", + }, + "[U interface{ ~int | ~isComparable | ~string }]": { + comparable: true, + defaultComparable: true, + typeConstraints: "[U interface{ ~int | ~isComparable | ~string }]", + }, + "[U interface{ comparable; m() }]": { + comparable: true, + defaultComparable: true, + typeConstraints: "[U interface{ comparable; m() }]", + }, + "no type constraints on struct": { + typeConstraints: "", + errorContains: "base type to method type param mismatch", + // A generic function (not a method) doesn't depend on the + // type params on a struct. Skip + skipNonMethodTest: true, + }, + "non-id IndexListExpr.X": { + typeConstraints: "[T any, U any, V any]", + structContents: "t T; u U; v V", + typeParams: "T, U, V", + alterMethod: func(decl *dst.FuncDecl) { + decl.Recv.List[0].Type.(*dst.IndexListExpr).X = ast.Un(token.AND, ast.Id("hi")) + }, + // There is no index list for a generic function + skipNonMethodTest: true, + errorContains: "expecting *dst.Ident in IndexListExpr.X", + }, + "non-id IndexExpr.X": { + alterMethod: func(decl *dst.FuncDecl) { + decl.Recv.List[0].Type.(*dst.IndexExpr).X = ast.Un(token.AND, ast.Id("hi")) + }, + // There is no index list for a generic function + skipNonMethodTest: true, + errorContains: "expecting *dst.Ident in IndexExpr.X", + }, + "unexpected index type": { + alterMethod: func(decl *dst.FuncDecl) { + decl.Recv.List[0].Type = ast.Un(token.AND, ast.Id("hi")) + }, + // There is no index list for a generic function + skipNonMethodTest: true, + errorContains: "unexpected index type", + }, + "too many method type params": { + typeParams: "A, B, C, U", + errorContains: "base type to method type param mismatch", + // A generic function (not a method) doesn't depend on + // the type params on a struct. Skip + skipNonMethodTest: true, + }, + "no type spec": { + alterMethod: func(decl *dst.FuncDecl) { + decl.Recv.List[0].Type.(*dst.IndexExpr).X.(*dst.Ident).Obj = nil + }, + // There is no index list for a generic function + skipNonMethodTest: true, + errorContains: "expecting Obj", + }, + "non-type spec decl": { + alterMethod: func(decl *dst.FuncDecl) { + decl.Recv.List[0].Type.(*dst.IndexExpr).X.(*dst.Ident).Obj.Decl = "hi" + }, + // There is no index list for a generic function + skipNonMethodTest: true, + errorContains: "expecting *dst.TypeSpec", + }, + "bad underlying type operator": { + typeConstraints: "[U ~int]", + alterMethod: func(decl *dst.FuncDecl) { + decl.Recv.List[0]. + Type.(*dst.IndexExpr). + X.(*dst.Ident).Obj. + Decl.(*dst.TypeSpec).TypeParams.List[0]. + Type.(*dst.UnaryExpr).Op = token.AND + }, + // There is no index list for a generic function + skipNonMethodTest: true, + errorContains: "unexpected unary operator &", + }, + } { + t.Run(name, func(t *testing.T) { + for name, stc := range map[string]struct { + compFn compFn + comparable bool + structable bool + }{ + "IsComparable": { + compFn: isComparable, + comparable: tc.comparable, + structable: false, + }, + "IsDefaultComparable": { + compFn: isDefaultComparable, + comparable: tc.defaultComparable, + structable: true, + }, + } { + t.Run(name, func(t *testing.T) { + for name, fn := range map[string]func(*testing.T) ast.TypeInfo{ + // "struct context": func(t *testing.T, f *dst.File) (dst.Expr, *dst.TypeSpec) { + // if tc.skipNonMethodTest { + // t.Skip() + // } + // + // gen, ok := f.Decls[2].(*dst.GenDecl) + // if !ok { + // t.Fatalf("got %#v, want a generic declaration", f.Decls[1]) + // } + // fields := gen.Specs[0].(*dst.TypeSpec).Type.(*dst.StructType).Fields.List + // var idx int + // // A bit brittle but at least one of the + // // tests puts U in the middle of the list + // if len(fields) == 1 { + // idx = 0 + // } else { + // idx = 1 + // } + // expr := fields[idx].Type + // return expr, nil + // }, + // "method context": func(t *testing.T, f *dst.File) (dst.Expr, *dst.FuncDecl) { + // fn, ok := f.Decls[3].(*dst.FuncDecl) + // if !ok { + // t.Fatalf("got %#v, want a function declaration", f.Decls[1]) + // } + // expr := fn.Type.Params.List[0].Type + // if tc.alterMethod != nil { + // tc.alterMethod(fn) + // } + // return expr, fn + // }, + // "function context": func(t *testing.T, f *dst.File) (dst.Expr, *dst.FuncDecl) { + // if tc.skipNonMethodTest { + // t.Skip() + // } + // + // fn, ok := f.Decls[4].(*dst.FuncDecl) + // if !ok { + // t.Fatalf("got %#v, want a function declaration", f.Decls[1]) + // } + // expr := fn.Type.Params.List[0].Type + // + // return expr, fn + // }, + "type context": func(t *testing.T) ast.TypeInfo { + t.Helper() + tSpec, err := cache.Type(*ast.IdPath("b", "a"), "", false) + if err != nil { + t.Fatalf("got Type error: %#v, want no error", err) + } + + return tSpec + }, + } { + t.Run(name, func(t *testing.T) { + if tc.skipNonMethodTest { + t.Skip() + } + + // ASSEMBLE + beforeEach(t, false) + defer afterEach(t) + + code := `package a + +type notComparable []int + +type isComparable int + +type b%s struct{%s} + +func (b[%s]) c(U) {} + +func d%s(U) {} +` + structContents := tc.structContents + if structContents == "" { + structContents = "u U" + } + typeParams := tc.typeParams + if typeParams == "" { + typeParams = "U" + } + code = fmt.Sprintf(code, tc.typeConstraints, + structContents, typeParams, + tc.typeConstraints) + pkgs := loadPackages(t, map[string]string{ + "code.go": code, + "go.mod": "module a", + }) + + metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() + loadFnMoq.onCall(loadCfg, "a"). + returnResults(pkgs, nil) + metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() + metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D().ReturnResults() + + tSpec := fn(t) + + // ACT + isComp, err := stc.compFn(cache, ast.Id("U"), tSpec) + // ASSERT + if tc.errorContains == "" { + if err != nil { + t.Errorf("got %#v, want no error", err) + } + if isComp != stc.comparable { + t.Errorf("got %t, want %t", isComp, stc.comparable) + } + } else { + if err == nil { + t.Fatalf("got no error, want err") + } + if !errors.Is(err, ast.ErrInvalidType) { + t.Errorf("got %#v, want ast.ErrInvalidType", err) + } + if !strings.Contains(err.Error(), tc.errorContains) { + t.Errorf("got %s, want to contain %s", err.Error(), tc.errorContains) + } + } + }) + } + }) + } + }) + } + }) }) t.Run("DST ident not comparable", func(t *testing.T) { @@ -1111,7 +1440,6 @@ type e struct { c := ast.NewCache(packages.Load, os.Stat, os.ReadFile, metricsMoq.Mock()) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults().Repeat(moq.AnyTimes()) - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults().Repeat(moq.AnyTimes()) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D(). ReturnResults().Repeat(moq.AnyTimes()) metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D(). @@ -1133,7 +1461,7 @@ type e struct { expr := fType.Params.List[0].Type // ACT - isComparable, err := c.IsComparable(expr) + isComparable, err := c.IsComparable(expr, ast.TypeInfo{}) // ASSERT if err != nil { t.Errorf("got %#v, want no error", err) @@ -1150,7 +1478,6 @@ type e struct { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, "./testpkgs/noexport").returnResults(noExportPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D().ReturnResults() @@ -1270,7 +1597,6 @@ type e struct { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, ".").doReturnResults(packages.Load) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D().ReturnResults() @@ -1289,7 +1615,6 @@ type e struct { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() err := errors.New("load error") loadFnMoq.onCall(loadCfg, ".").returnResults(nil, err) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() @@ -1383,7 +1708,6 @@ type e struct { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, tc.pkg).returnResults(tc.pkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D().ReturnResults() @@ -1397,8 +1721,8 @@ type e struct { typs := cache.MockableTypes(tc.onlyExported) // ASSERT - if len(typs) != 5 { - t.Fatalf("got %d types, want 5", len(typs)) + if len(typs) != 7 { + t.Fatalf("got %d types, want 7", len(typs)) } typsByName := map[string]dst.Ident{} @@ -1422,6 +1746,7 @@ type e struct { if _, ok := typsByName[tc.widgetPrefix+"_starGenType"]; !ok { t.Errorf("got nothing, want %s_starGenType", tc.widgetPrefix) } + // TODO: Check new extensions }) } }) @@ -1432,7 +1757,6 @@ type e struct { defer afterEach(t) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, noExportPkg).returnResults(noExportPkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D().ReturnResults() @@ -1459,7 +1783,6 @@ type e struct { pkgs := append(exportPkgs, pkg("vendor/other-pkgs")) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, exportPkg).returnResults(pkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D().ReturnResults().Repeat(moq.AnyTimes()) @@ -1473,8 +1796,8 @@ type e struct { typs := cache.MockableTypes(true) // ASSERT - if len(typs) != 5 { - t.Fatalf("got %d types, want 5", len(typs)) + if len(typs) != 7 { + t.Fatalf("got %d types, want 7", len(typs)) } }) @@ -1489,7 +1812,6 @@ type e struct { pkg("internal")) metricsMoq.OnCall().ASTPkgCacheMissesInc().ReturnResults() - metricsMoq.OnCall().ASTTypeCacheMissesInc().ReturnResults() loadFnMoq.onCall(loadCfg, exportPkg).returnResults(pkgs, nil) metricsMoq.OnCall().ASTTotalLoadTimeInc(0).Any().D().ReturnResults() metricsMoq.OnCall().ASTTotalDecorationTimeInc(0).Any().D().ReturnResults().Repeat(moq.AnyTimes()) @@ -1503,8 +1825,8 @@ type e struct { typs := cache.MockableTypes(true) // ASSERT - if len(typs) != 5 { - t.Fatalf("got %d types, want 5", len(typs)) + if len(typs) != 7 { + t.Fatalf("got %d types, want 7", len(typs)) } }) }) diff --git a/ast/dsl.go b/ast/dsl.go index 7ae6c5c..15e8511 100644 --- a/ast/dsl.go +++ b/ast/dsl.go @@ -233,6 +233,11 @@ func (d FnDSL) Results(fields ...*dst.Field) FnDSL { return d } +func (d FnDSL) TypeParams(fieldList *dst.FieldList) FnDSL { + d.Obj.Type.TypeParams = fieldList + return d +} + // Body specifies the body for a function func (d FnDSL) Body(list ...dst.Stmt) FnDSL { d.Obj.Body = Block(list...).Obj @@ -314,25 +319,6 @@ func IdPath(name, path string) *dst.Ident { return &dst.Ident{Name: name, Path: path} } -// IncStmt creates a dst.IncDecStmt for incrementing an expression -func IncStmt(x dst.Expr) *dst.IncDecStmt { - return &dst.IncDecStmt{X: x, Tok: token.INC} -} - -// IndexDSL translates to a dst.IndexExpr -type IndexDSL struct{ Obj *dst.IndexExpr } - -// Index creates a new IndexDSL -func Index(x dst.Expr) IndexDSL { - return IndexDSL{Obj: &dst.IndexExpr{X: x}} -} - -// Sub specifies the sub-expression -func (d IndexDSL) Sub(index dst.Expr) IndexDSL { - d.Obj.Index = index - return d -} - // IfDSL translates to a dst.IfStmt type IfDSL struct{ Obj *dst.IfStmt } @@ -373,6 +359,25 @@ func IfDecs(after dst.SpaceType) IfDecsDSL { }} } +// IncStmt creates a dst.IncDecStmt for incrementing an expression +func IncStmt(x dst.Expr) *dst.IncDecStmt { + return &dst.IncDecStmt{X: x, Tok: token.INC} +} + +// IndexDSL translates to a dst.IndexListExpr +type IndexDSL struct{ Obj *dst.IndexListExpr } + +// Index creates a new IndexDSL +func Index(x dst.Expr) IndexDSL { + return IndexDSL{Obj: &dst.IndexListExpr{X: x}} +} + +// Sub specifies the sub-expression +func (d IndexDSL) Sub(index ...dst.Expr) IndexDSL { + d.Obj.Indices = index + return d +} + // KeyValueDSL translates to a dst.KeyValueExpr type KeyValueDSL struct{ Obj *dst.KeyValueExpr } @@ -587,6 +592,12 @@ func (d TypeSpecDSL) Type(typ dst.Expr) TypeSpecDSL { return d } +// TypeParams adds type parameters to TypeDeclDSL +func (d TypeSpecDSL) TypeParams(typeParams *dst.FieldList) TypeSpecDSL { + d.Obj.TypeParams = typeParams + return d +} + // TypeDeclDSL translates various types into a dst.GenDecl type TypeDeclDSL struct{ Obj *dst.GenDecl } diff --git a/ast/dsl_test.go b/ast/dsl_test.go index f1f117d..5790809 100644 --- a/ast/dsl_test.go +++ b/ast/dsl_test.go @@ -17,12 +17,15 @@ var ( id4 = dst.NewIdent("id4") id5 = dst.NewIdent("id5") id6 = dst.NewIdent("id6") + id7 = dst.NewIdent("id7") + id8 = dst.NewIdent("id8") field1 = &dst.Field{Type: id1} field2 = &dst.Field{Type: id2} - params = &dst.FieldList{List: []*dst.Field{{Type: id3}, {Type: id4}}} - results = &dst.FieldList{List: []*dst.Field{{Type: id5}, {Type: id6}}} + typeParams = &dst.FieldList{List: []*dst.Field{{Type: id7}, {Type: id8}}} + params = &dst.FieldList{List: []*dst.Field{{Type: id3}, {Type: id4}}} + results = &dst.FieldList{List: []*dst.Field{{Type: id5}, {Type: id6}}} assign1 = &dst.AssignStmt{Lhs: []dst.Expr{id1}} assign2 = &dst.AssignStmt{Lhs: []dst.Expr{id2}} @@ -449,7 +452,11 @@ func TestFn(t *testing.T) { decs := dst.FuncDeclDecorations{NodeDecs: dst.NodeDecs{Before: dst.EmptyLine}} expected := &dst.FuncDecl{ Name: dst.NewIdent("fn1"), - Type: &dst.FuncType{Params: params, Results: results}, + Type: &dst.FuncType{ + Params: params, + Results: results, + TypeParams: typeParams, + }, Recv: &dst.FieldList{List: []*dst.Field{{Type: id1}, {Type: id2}}}, Body: &dst.BlockStmt{List: []dst.Stmt{assign1, assign2}}, Decs: decs, @@ -458,6 +465,7 @@ func TestFn(t *testing.T) { // ACT actual := ast.Fn("fn1"). Recv(ast.Field(id1).Obj, ast.Field(id2).Obj). + TypeParams(typeParams). ParamList(params). ResultList(results). Body(assign1, assign2). @@ -627,7 +635,7 @@ func TestIncStmt(t *testing.T) { func TestIndex(t *testing.T) { t.Run("simple", func(t *testing.T) { // ASSEMBLE - expected := &dst.IndexExpr{X: id1} + expected := &dst.IndexListExpr{X: id1} // ACT actual := ast.Index(id1).Obj @@ -640,10 +648,10 @@ func TestIndex(t *testing.T) { t.Run("complete", func(t *testing.T) { // ASSEMBLE - expected := &dst.IndexExpr{X: id1, Index: id2} + expected := &dst.IndexListExpr{X: id1, Indices: []dst.Expr{id2, id3}} // ACT - actual := ast.Index(id1).Sub(id2).Obj + actual := ast.Index(id1).Sub(id2, id3).Obj // ASSERT if !reflect.DeepEqual(actual, expected) { @@ -1198,10 +1206,14 @@ func TestTypeSpec(t *testing.T) { t.Run("complete", func(t *testing.T) { // ASSEMBLE - expected := &dst.TypeSpec{Name: dst.NewIdent("typ"), Type: id2} + expected := &dst.TypeSpec{ + Name: dst.NewIdent("typ"), + Type: id2, + TypeParams: typeParams, + } // ACT - actual := ast.TypeSpec("typ").Type(id2).Obj + actual := ast.TypeSpec("typ").Type(id2).TypeParams(typeParams).Obj // ASSERT if !reflect.DeepEqual(actual, expected) { diff --git a/ast/testpkgs/export/generics.go b/ast/testpkgs/export/generics.go new file mode 100644 index 0000000..4b71bd4 --- /dev/null +++ b/ast/testpkgs/export/generics.go @@ -0,0 +1,21 @@ +package export + +type Generic[T any] struct{} + +func (g *Generic[T]) DoSomethingPtr() {} + +func (g *Generic[X]) DoSomethingElsePtr() {} + +func (g Generic[T]) DoSomething() {} + +func (g Generic[X]) DoSomethingElse() {} + +type GenericList[T any, V any] struct{} + +func (g *GenericList[T, V]) DoSomethingPtr() {} + +func (g *GenericList[X, Y]) DoSomethingElsePtr() {} + +func (g GenericList[T, V]) DoSomething() {} + +func (g GenericList[X, Y]) DoSomethingElse() {} diff --git a/ast/testpkgs/noexport/generics.go b/ast/testpkgs/noexport/generics.go new file mode 100644 index 0000000..f562aa1 --- /dev/null +++ b/ast/testpkgs/noexport/generics.go @@ -0,0 +1,21 @@ +package noexport + +type generic[T any] struct{} + +func (g *generic[T]) doSomethingPtr() {} + +func (g *generic[X]) doSomethingElsePtr() {} + +func (g generic[T]) doSomething() {} + +func (g generic[X]) doSomethingElse() {} + +type genericList[T any, V any] struct{} + +func (g *genericList[T, V]) doSomethingPtr() {} + +func (g *genericList[X, Y]) doSomethingElsePtr() {} + +func (g genericList[T, V]) doSomething() {} + +func (g genericList[X, Y]) doSomethingElse() {} diff --git a/generator/converter.go b/generator/converter.go index c314933..ccf6c9f 100644 --- a/generator/converter.go +++ b/generator/converter.go @@ -124,6 +124,8 @@ type Converter struct { typ Type isExported bool typeCache TypeCache + + err error } // NewConverter creates a new Converter @@ -137,21 +139,20 @@ func NewConverter(typ Type, isExported bool, typeCache TypeCache) *Converter { // Func holds on to function related data type Func struct { - Name string - Params *dst.FieldList - Results *dst.FieldList + Name string + FuncType *dst.FuncType } // BaseDecls generates the base declarations used to store the moq's state and // establish the type -func (c *Converter) BaseDecls() []dst.Decl { +func (c *Converter) BaseDecls() ([]dst.Decl, error) { mName := c.moqName() moqName := fmt.Sprintf(double, mName, mockIdent) fields := []*dst.Field{ Field(Star(c.idPath(sceneType, moqPkg))).Names(c.exportId(sceneIdent)).Obj, Field(c.idPath(configType, moqPkg)).Names(c.exportId(configIdent)).Obj, - Field(Star(Id(moqName))).Names(c.exportId(moqIdent)). + Field(Star(c.genericExpr(Id(moqName), clone))).Names(c.exportId(moqIdent)). Decs(FieldDecs(dst.None, dst.EmptyLine).Obj).Obj, } @@ -163,7 +164,8 @@ func (c *Converter) BaseDecls() []dst.Decl { fieldSuffix = sep + fn.Name } fields = append(fields, - Field(SliceType(Idf(double, typePrefix, resultsByParamsIdent))). + Field(SliceType(c.genericExpr(Idf( + double, typePrefix, resultsByParamsIdent), clone))). Names(c.exportId(resultsByParamsIdent+fieldSuffix)).Obj) } @@ -186,8 +188,10 @@ func (c *Converter) BaseDecls() []dst.Decl { if c.typ.TypeInfo.Fabricated { id = Id(id.Name) } - decls = append(decls, VarDecl(Value(id).Names(Id(blankIdent)). - Values(Call(Paren(Star(Id(moqName)))).Args(Id(nilIdent)).Obj).Obj). + decls = append(decls, VarDecl( + Value(c.genericExpr(id, typeAssertSafe)).Names(Id(blankIdent)). + Values(Call(Paren(Star(c.genericExpr(Id(moqName), typeAssertSafe)))). + Args(Id(nilIdent)).Obj).Obj). Decs(genDeclDec("// The following type assertion assures"+ " that %s is mocked completely", idStr)).Obj, ) @@ -207,22 +211,33 @@ func (c *Converter) BaseDecls() []dst.Decl { typeName, msg)).Obj) } - decls = append(decls, TypeDecl(TypeSpec(mName).Type(Struct(fields...)).Obj). + decls = append(decls, TypeDecl( + TypeSpec(mName).Type(Struct(fields...)).TypeParams(c.typeParams()).Obj). Decs(genDeclDec("// %s holds the state of a moq of the %s type", mName, typeName)).Obj) - return decls + if c.err != nil { + return nil, c.err + } + + return decls, nil } // IsolationStruct generates a struct used to isolate an interface for the moq -func (c *Converter) IsolationStruct(suffix string) *dst.GenDecl { +func (c *Converter) IsolationStruct(suffix string) (*dst.GenDecl, error) { mName := c.moqName() iName := fmt.Sprintf(double, mName, suffix) - return TypeDecl(TypeSpec(iName).Type(Struct(Field(Star(Id(mName))). - Names(c.exportId(moqIdent)).Obj)).Obj). + iStruct := TypeDecl(TypeSpec(iName).Type(Struct(Field(Star(c.genericExpr(Id(mName), clone))). + Names(c.exportId(moqIdent)).Obj)).TypeParams(c.typeParams()).Obj). Decs(genDeclDec("// %s isolates the %s interface of the %s type", iName, suffix, c.typ.TypeInfo.Type.Name.Name)).Obj + + if c.err != nil { + return nil, c.err + } + + return iStruct, nil } // MethodStructs generates a structure for storing a set of parameters or @@ -230,50 +245,48 @@ func (c *Converter) IsolationStruct(suffix string) *dst.GenDecl { func (c *Converter) MethodStructs(fn Func) ([]dst.Decl, error) { prefix := c.typePrefix(fn) - paramsStruct, err := c.paramsStructDecl(prefix, false, fn.Params) - if err != nil { - logs.Panic("Creating params struct should never generate errors", err) - } - paramsKeyStruct, err := c.paramsStructDecl(prefix, true, fn.Params) - if err != nil { - return nil, err - } - - return []dst.Decl{ - paramsStruct, - paramsKeyStruct, + decls := []dst.Decl{ + c.paramsStructDecl(prefix, false, fn.FuncType.Params), + c.paramsStructDecl(prefix, true, fn.FuncType.Params), c.resultByParamsStruct(prefix), - c.doFuncType(prefix, fn.Params), + c.doFuncType(prefix, fn.FuncType.Params), c.doReturnFuncType(prefix, fn), - c.resultsStruct(prefix, fn.Results), + c.resultsStruct(prefix, fn.FuncType.Results), c.fnRecorderStruct(prefix), c.anyParamsStruct(prefix), - }, nil + } + + if c.err != nil { + return nil, c.err + } + + return decls, nil } // NewFunc generates a function for constructing a moq -func (c *Converter) NewFunc() *dst.FuncDecl { +func (c *Converter) NewFunc() (*dst.FuncDecl, error) { fnName := c.export("newMoq" + c.typ.TypeInfo.Type.Name.Name) mName := c.moqName() - moqName := fmt.Sprintf(double, mName, mockIdent) - return Fn(fnName). + + decl := Fn(fnName). + TypeParams(c.typeParams()). Params( Field(Star(c.idPath(sceneType, moqPkg))).Names(Id(sceneIdent)).Obj, Field(Star(c.idPath(configType, moqPkg))).Names(Id(configIdent)).Obj, ). - Results(Field(Star(Id(mName))).Obj). + Results(Field(Star(c.genericExpr(Id(mName), clone))).Obj). Body( If(Bin(Id(configIdent)).Op(token.EQL).Y(Id(nilIdent)).Obj).Body( Assign(Id(configIdent)).Tok(token.ASSIGN).Rhs(Un(token.AND, Comp(c.idPath(configType, moqPkg)).Obj)).Obj).Obj, Assign(Id(moqReceiverIdent)).Tok(token.DEFINE). - Rhs(Un(token.AND, Comp(Id(mName)).Elts( + Rhs(Un(token.AND, Comp(c.genericExpr(Id(mName), clone)).Elts( Key(c.exportId(sceneIdent)). Value(Id(sceneIdent)).Decs(kvExprDec(dst.None)).Obj, Key(c.exportId(configIdent)). Value(Star(Id(configIdent))).Decs(kvExprDec(dst.None)).Obj, Key(c.exportId(moqIdent)). - Value(Un(token.AND, Comp(Id(moqName)).Obj)).Obj, + Value(Un(token.AND, Comp(c.genericExpr(Id(fmt.Sprintf(double, mName, mockIdent)), clone)).Obj)).Obj, Key(c.exportId(runtimeIdent)). Value(Comp(c.runtimeStruct()). Elts(c.runtimeValues()...).Obj).Decs(kvExprDec(dst.None)). @@ -291,41 +304,53 @@ func (c *Converter) NewFunc() *dst.FuncDecl { ). Decs(fnDeclDec("// %s creates a new moq of the %s type", fnName, c.typ.TypeInfo.Type.Name.Name)).Obj + + if c.err != nil { + return nil, c.err + } + + return decl, nil } // IsolationAccessor generates a function to access an isolation interface -func (c *Converter) IsolationAccessor(suffix, fnName string) *dst.FuncDecl { +func (c *Converter) IsolationAccessor(suffix, fnName string) (*dst.FuncDecl, error) { mName := c.moqName() - iName := fmt.Sprintf(double, mName, suffix) + iName := c.genericExpr(Id(fmt.Sprintf(double, mName, suffix)), clone) var retVal dst.Expr retVal = Sel(Id(moqReceiverIdent)).Dot(c.exportId(moqIdent)).Obj if fnName != mockFnName { - retVal = Un(token.AND, Comp(Id(iName)).Elts( + retVal = Un(token.AND, Comp(cloneExpr(iName)).Elts( Key(c.exportId(moqIdent)).Value(Id(moqReceiverIdent)). Decs(kvExprDec(dst.None)).Obj).Decs(litDec()).Obj, ) } fnName = c.export(fnName) - return Fn(fnName). - Recv(Field(Star(Id(mName))).Names(Id(moqReceiverIdent)).Obj). - Results(Field(Star(Id(iName))).Obj). + decl := Fn(fnName). + Recv(Field(Star(c.genericExpr(Id(mName), clone))).Names(Id(moqReceiverIdent)).Obj). + Results(Field(Star(iName)).Obj). Body(Return(retVal)). Decs(fnDeclDec("// %s returns the %s implementation of the %s type", fnName, suffix, c.typ.TypeInfo.Type.Name.Name)).Obj + + if c.err != nil { + return nil, c.err + } + + return decl, nil } // FuncClosure generates a mock implementation of function type wrapped in a // closure -func (c *Converter) FuncClosure(fn Func) *dst.FuncDecl { +func (c *Converter) FuncClosure(fn Func) (*dst.FuncDecl, error) { mName := c.moqName() fnLitCall := Call(Sel(Id(moqIdent)).Dot(c.exportId(fnFnName)).Obj). - Args(passthroughFields(paramPrefix, fn.Params)...). - Ellipsis(isVariadic(fn.Params)).Obj + Args(passthroughFields(paramPrefix, fn.FuncType.Params)...). + Ellipsis(isVariadic(fn.FuncType.Params)).Obj var fnLitRetStmt dst.Stmt fnLitRetStmt = Return(fnLitCall) - if fn.Results == nil { + if fn.FuncType.Results == nil { fnLitRetStmt = Expr(fnLitCall).Obj } @@ -334,15 +359,15 @@ func (c *Converter) FuncClosure(fn Func) *dst.FuncDecl { resType = Id(c.typ.TypeInfo.Type.Name.Name) } - return Fn(c.export(mockFnName)). - Recv(Field(Star(Id(mName))).Names(Id(moqReceiverIdent)).Obj). - Results(Field(resType).Obj). - Body(Return(FnLit(FnType(cloneAndNameUnnamed(paramPrefix, fn.Params)). - Results(cloneFieldList(fn.Results, true)).Obj). + decl := Fn(c.export(mockFnName)). + Recv(Field(Star(c.genericExpr(Id(mName), clone))).Names(Id(moqReceiverIdent)).Obj). + Results(Field(c.genericExpr(resType, clone)).Obj). + Body(Return(FnLit(FnType(c.cloneAndNameUnnamed(paramPrefix, fn.FuncType.Params)). + Results(c.cloneFieldList(fn.FuncType.Results, true)).Obj). Body(c.helperCallExpr(Id(moqReceiverIdent)), Assign(Id(moqIdent)).Tok(token.DEFINE).Rhs(Un( token.AND, - Comp(Idf(double, mName, mockIdent)). + Comp(c.genericExpr(Idf(double, mName, mockIdent), clone)). Elts(Key(c.exportId(moqIdent)). Value(Id(moqReceiverIdent)).Obj).Obj, )).Obj, @@ -350,12 +375,17 @@ func (c *Converter) FuncClosure(fn Func) *dst.FuncDecl { ).Obj)). Decs(fnDeclDec("// %s returns the %s implementation of the %s type", c.export(mockFnName), moqIdent, c.typ.TypeInfo.Type.Name.Name)).Obj + + if c.err != nil { + return nil, c.err + } + + return decl, nil } // MockMethod generates a mock implementation of a method -func (c *Converter) MockMethod(fn Func) *dst.FuncDecl { +func (c *Converter) MockMethod(fn Func) (*dst.FuncDecl, error) { mName := c.moqName() - recv := fmt.Sprintf(double, mName, mockIdent) fnName := fn.Name fieldSuffix := sep + fn.Name @@ -365,20 +395,24 @@ func (c *Converter) MockMethod(fn Func) *dst.FuncDecl { fieldSuffix = "" } - return Fn(fnName). - Recv(Field(Star(Id(recv))).Names(Id(moqReceiverIdent)).Obj). - ParamList(cloneAndNameUnnamed(paramPrefix, fn.Params)). - ResultList(cloneAndNameUnnamed(resultPrefix, fn.Results)). + decl := Fn(fnName). + Recv(Field(Star(c.genericExpr(Id(fmt.Sprintf(double, mName, mockIdent)), clone))).Names(Id(moqReceiverIdent)).Obj). + ParamList(c.cloneAndNameUnnamed(paramPrefix, fn.FuncType.Params)). + ResultList(c.cloneAndNameUnnamed(resultPrefix, fn.FuncType.Results)). Body(c.mockFunc(typePrefix, fieldSuffix, fn)...). Decs(stdFuncDec()).Obj + + if c.err != nil { + return nil, c.err + } + + return decl, nil } // RecorderMethods generates a recorder implementation of a method and // associated return method -func (c *Converter) RecorderMethods(fn Func) []dst.Decl { - decls := []dst.Decl{ - c.recorderFn(fn), - } +func (c *Converter) RecorderMethods(fn Func) ([]dst.Decl, error) { + decls := []dst.Decl{c.recorderFn(fn)} decls = append(decls, c.anyParamFns(fn)...) decls = append(decls, c.recorderSeqFns(fn)...) @@ -392,13 +426,15 @@ func (c *Converter) RecorderMethods(fn Func) []dst.Decl { c.paramsKeyFn(fn), ) - return decls + if c.err != nil { + return nil, c.err + } + + return decls, nil } // ResetMethod generates a method to reset the moq's state -func (c *Converter) ResetMethod() *dst.FuncDecl { - mName := c.moqName() - +func (c *Converter) ResetMethod() (*dst.FuncDecl, error) { var stmts []dst.Stmt for _, fn := range c.typ.Funcs { fieldSuffix := "" @@ -412,16 +448,20 @@ func (c *Converter) ResetMethod() *dst.FuncDecl { Rhs(Id(nilIdent)).Obj) } - return Fn(resetFnName). - Recv(Field(Star(Id(mName))).Names(Id(moqReceiverIdent)).Obj). + decl := Fn(resetFnName). + Recv(Field(Star(c.genericExpr(Id(c.moqName()), clone))).Names(Id(moqReceiverIdent)).Obj). Body(stmts...). Decs(fnDeclDec("// %s resets the state of the moq", resetFnName)).Obj + + if c.err != nil { + return nil, c.err + } + + return decl, nil } // AssertMethod generates a method to assert all expectations are met -func (c *Converter) AssertMethod() *dst.FuncDecl { - mName := c.moqName() - +func (c *Converter) AssertMethod() (*dst.FuncDecl, error) { stmts := []dst.Stmt{ c.helperCallExpr(Id(moqReceiverIdent)), } @@ -465,11 +505,17 @@ func (c *Converter) AssertMethod() *dst.FuncDecl { ).Obj) } - return Fn(assertFnName). - Recv(Field(Star(Id(mName))).Names(Id(moqReceiverIdent)).Obj). + decl := Fn(assertFnName). + Recv(Field(Star(c.genericExpr(Id(c.moqName()), clone))).Names(Id(moqReceiverIdent)).Obj). Body(stmts...). Decs(fnDeclDec("// %s asserts that all expectations have been met", assertFnName)).Obj + + if c.err != nil { + return nil, c.err + } + + return decl, nil } func (c *Converter) typePrefix(fn Func) string { @@ -503,7 +549,7 @@ func (c *Converter) paramIndexingStruct() *dst.StructType { func (c *Converter) paramIndexingFnStruct(fn Func) *dst.StructType { var piParamFields []*dst.Field count := 0 - for _, f := range fn.Params.List { + for _, f := range fn.FuncType.Params.List { if len(f.Names) == 0 { piParamFields = append(piParamFields, c.paramIndexingField(fmt.Sprintf(unnamed, paramPrefix, count+1))) @@ -529,11 +575,10 @@ func (c *Converter) runtimeValues() []dst.Expr { kvDec := dst.NewLine for _, fn := range c.typ.Funcs { if fn.Name == "" { - vals = append(vals, c.paramIndexingFnValues(fn.Params.List)...) + vals = append(vals, c.paramIndexingFnValues(fn)...) } else { - vals = append(vals, Key(Id(fn.Name)). - Value(Comp(c.paramIndexingFnStruct(fn)). - Elts(c.paramIndexingFnValues(fn.Params.List)...).Obj).Decs(kvExprDec(kvDec)).Obj) + vals = append(vals, Key(Id(fn.Name)).Value(Comp(c.paramIndexingFnStruct(fn)). + Elts(c.paramIndexingFnValues(fn)...).Obj).Decs(kvExprDec(kvDec)).Obj) } kvDec = dst.None } @@ -542,25 +587,23 @@ func (c *Converter) runtimeValues() []dst.Expr { Value(Comp(c.paramIndexingStruct()).Elts(vals...).Obj).Obj} } -func (c *Converter) paramIndexingFnValues(params []*dst.Field) []dst.Expr { +func (c *Converter) paramIndexingFnValues(fn Func) []dst.Expr { var vals []dst.Expr kvDec := dst.NewLine count := 0 - for _, f := range params { - if len(f.Names) == 0 { - val := c.paramIndexingValue(f.Type, - fmt.Sprintf(unnamed, paramPrefix, count+1), kvDec) + for _, f := range fn.FuncType.Params.List { + typ := c.resolveExpr(f.Type) - vals = append(vals, val) + if len(f.Names) == 0 { + vals = append(vals, c.paramIndexingValue( + typ, fmt.Sprintf(unnamed, paramPrefix, count+1), kvDec)) count++ kvDec = dst.None } for _, name := range f.Names { - val := c.paramIndexingValue(f.Type, - validName(name.Name, paramPrefix, count), kvDec) - - vals = append(vals, val) + vals = append(vals, c.paramIndexingValue( + typ, validName(name.Name, paramPrefix, count), kvDec)) count++ kvDec = dst.None } @@ -570,9 +613,12 @@ func (c *Converter) paramIndexingFnValues(params []*dst.Field) []dst.Expr { } func (c *Converter) paramIndexingValue(typ dst.Expr, name string, kvDec dst.SpaceType) *dst.KeyValueExpr { - comp, err := c.typeCache.IsDefaultComparable(typ) + comp, err := c.typeCache.IsDefaultComparable(typ, c.typ.TypeInfo) if err != nil { - logs.Panic("Call MethodStructs first to get a meaningful error", err) + if c.err == nil { + c.err = err + } + return nil } val := paramIndexByValueIdent @@ -585,47 +631,36 @@ func (c *Converter) paramIndexingValue(typ dst.Expr, name string, kvDec dst.Spac func (c *Converter) paramsStructDecl( prefix string, paramsKey bool, fieldList *dst.FieldList, -) (*dst.GenDecl, error) { +) *dst.GenDecl { var mStruct *dst.StructType var label, goDocDesc string if paramsKey { label = paramsKeyIdent goDocDesc = "map key params" - pStruct, err := c.methodStruct(paramsKeyIdent, fieldList) - if err != nil { - return nil, err - } - pkStruct, err := c.methodStruct(hashesIdent, fieldList) - if err != nil { - return nil, err - } - - mStruct = Struct(Field(pStruct).Names(c.exportId(paramsIdent)).Obj, - Field(pkStruct).Names(c.exportId(hashesIdent)).Obj) + mStruct = Struct(Field(c.methodStruct(paramsKeyIdent, fieldList)). + Names(c.exportId(paramsIdent)).Obj, + Field(c.methodStruct(hashesIdent, fieldList)). + Names(c.exportId(hashesIdent)).Obj) } else { label = paramsIdent goDocDesc = label - var err error - mStruct, err = c.methodStruct(paramsIdent, fieldList) - if err != nil { - return nil, err - } + mStruct = c.methodStruct(paramsIdent, fieldList) } structName := fmt.Sprintf(double, prefix, label) - return TypeDecl(TypeSpec(structName).Type(mStruct).Obj). + return TypeDecl(TypeSpec(structName).Type(mStruct).TypeParams(c.typeParams()).Obj). Decs(genDeclDec("// %s holds the %s of the %s type", - structName, goDocDesc, c.typ.TypeInfo.Type.Name.Name)).Obj, nil + structName, goDocDesc, c.typ.TypeInfo.Type.Name.Name)).Obj } -func (c *Converter) methodStruct(label string, fieldList *dst.FieldList) (*dst.StructType, error) { +func (c *Converter) methodStruct(label string, fieldList *dst.FieldList) *dst.StructType { unnamedPrefix, _ := labelDirection(label) - fieldList = cloneFieldList(fieldList, false) + fieldList = c.cloneFieldList(fieldList, false) if fieldList == nil { - return StructFromList(nil), nil + return StructFromList(nil) } count := 0 @@ -640,10 +675,7 @@ func (c *Converter) methodStruct(label string, fieldList *dst.FieldList) (*dst.S count++ } - typ, err := c.comparableType(label, f.Type) - if err != nil { - return nil, err - } + typ := c.comparableType(label, f.Type) if typ != nil { f.Type = typ fList = append(fList, f) @@ -655,37 +687,40 @@ func (c *Converter) methodStruct(label string, fieldList *dst.FieldList) (*dst.S } else { fieldList = nil } - return StructFromList(fieldList), nil + return StructFromList(fieldList) } -func (c *Converter) comparableType(label string, typ dst.Expr) (dst.Expr, error) { +func (c *Converter) comparableType(label string, typ dst.Expr) dst.Expr { switch label { case paramsIdent: case resultsIdent: case paramsKeyIdent: - comp, err := c.typeCache.IsComparable(typ) + comp, err := c.typeCache.IsComparable(typ, c.typ.TypeInfo) if err != nil { - return nil, err + if c.err == nil { + c.err = err + } + return nil } if !comp { // Non-comparable params are not represented in the params section // of the paramsKey - return nil, nil + return nil } case hashesIdent: // Everything is represented as a hash in the hashes section of the // paramsKey - return c.idPath(hashType, hashPkg), nil + return c.idPath(hashType, hashPkg) default: logs.Panicf("Unknown label: %s", label) } if ellipsis, ok := typ.(*dst.Ellipsis); ok { // Ellipsis params are represented as a slice (when not comparable) - return SliceType(ellipsis.Elt), nil + return SliceType(ellipsis.Elt) } - return typ, nil + return typ } func (c *Converter) resultByParamsStruct(prefix string) *dst.GenDecl { @@ -694,10 +729,10 @@ func (c *Converter) resultByParamsStruct(prefix string) *dst.GenDecl { return TypeDecl(TypeSpec(structName).Type(Struct( Field(Id(intType)).Names(c.exportId(anyCountIdent)).Obj, Field(Id("uint64")).Names(c.exportId(anyParamsIdent)).Obj, - Field(MapType(Id(c.export(fmt.Sprintf(double, prefix, paramsKeyIdent)))). - Value(Star(Idf(double, prefix, resultsIdent))).Obj, + Field(MapType(c.genericExpr(Id(c.export(fmt.Sprintf(double, prefix, paramsKeyIdent))), clone)). + Value(Star(c.genericExpr(Idf(double, prefix, resultsIdent), clone))).Obj, ).Names(c.exportId(resultsIdent)).Obj, - )).Obj).Decs(genDeclDec( + )).TypeParams(c.typeParams()).Obj).Decs(genDeclDec( "// %s contains the results for a given set of parameters for the %s type", structName, c.typ.TypeInfo.Type.Name.Name)).Obj @@ -706,7 +741,8 @@ func (c *Converter) resultByParamsStruct(prefix string) *dst.GenDecl { func (c *Converter) doFuncType(prefix string, params *dst.FieldList) *dst.GenDecl { fnName := fmt.Sprintf(double, prefix, doFnIdent) return TypeDecl(TypeSpec(fnName). - Type(FnType(cloneFieldList(params, false)).Obj).Obj). + Type(FnType(c.cloneFieldList(params, false)).Obj). + TypeParams(c.typeParams()).Obj). Decs(genDeclDec( "// %s defines the type of function needed when calling %s for the %s type", fnName, @@ -717,8 +753,9 @@ func (c *Converter) doFuncType(prefix string, params *dst.FieldList) *dst.GenDec func (c *Converter) doReturnFuncType(prefix string, fn Func) *dst.GenDecl { fnName := fmt.Sprintf(double, prefix, doReturnFnIdent) return TypeDecl(TypeSpec(fnName). - Type(FnType(cloneFieldList(fn.Params, false)). - Results(cloneFieldList(fn.Results, false)).Obj).Obj). + Type(FnType(c.cloneFieldList(fn.FuncType.Params, false)). + Results(c.cloneFieldList(fn.FuncType.Results, false)).Obj). + TypeParams(c.typeParams()).Obj). Decs(genDeclDec( "// %s defines the type of function needed when calling %s for the %s type", fnName, @@ -730,28 +767,28 @@ func (c *Converter) resultsStruct(prefix string, results *dst.FieldList) *dst.Ge structName := fmt.Sprintf(double, prefix, resultsIdent) return TypeDecl(TypeSpec(structName).Type(Struct( - Field(Idf(double, prefix, paramsIdent)). + Field(c.genericExpr(Idf(double, prefix, paramsIdent), clone)). Names(c.exportId(paramsIdent)).Obj, Field(SliceType(c.innerResultsStruct(prefix, results))). Names(c.exportId(resultsIdent)).Obj, Field(Id("uint32")).Names(c.exportId(indexIdent)).Obj, - Field(Star(c.idPath(repeatValType, moqPkg))).Names(c.exportId(repeatIdent)).Obj, - )).Obj).Decs(genDeclDec("// %s holds the results of the %s type", - structName, - c.typ.TypeInfo.Type.Name.Name)).Obj + Field(Star(c.idPath(repeatValType, moqPkg))). + Names(c.exportId(repeatIdent)).Obj, + )).TypeParams(c.typeParams()).Obj). + Decs(genDeclDec("// %s holds the results of the %s type", + structName, + c.typ.TypeInfo.Type.Name.Name)).Obj } func (c *Converter) innerResultsStruct(prefix string, results *dst.FieldList) *dst.StructType { - mStruct, err := c.methodStruct(resultsIdent, results) - if err != nil { - logs.Panic("Creating results struct should never generate errors", err) - } - return Struct( - Field(Star(mStruct)).Names(c.exportId(valuesIdent)).Obj, + Field(Star(c.methodStruct(resultsIdent, results))). + Names(c.exportId(valuesIdent)).Obj, Field(Id("uint32")).Names(c.exportId(sequenceIdent)).Obj, - Field(Idf(double, prefix, doFnIdent)).Names(c.exportId(doFnIdent)).Obj, - Field(Idf(double, prefix, doReturnFnIdent)).Names(c.exportId(doReturnFnIdent)).Obj, + Field(c.genericExpr(Idf(double, prefix, doFnIdent), clone)). + Names(c.exportId(doFnIdent)).Obj, + Field(c.genericExpr(Idf(double, prefix, doReturnFnIdent), clone)). + Names(c.exportId(doReturnFnIdent)).Obj, ) } @@ -759,25 +796,21 @@ func (c *Converter) fnRecorderStruct(prefix string) *dst.GenDecl { mName := c.moqName() structName := fmt.Sprintf(double, prefix, fnRecorderSuffix) return TypeDecl(TypeSpec(structName).Type(Struct( - Field(Idf(double, prefix, paramsIdent)). - Names(c.exportId(paramsIdent)).Obj, - Field(Id("uint64")). - Names(c.exportId(anyParamsIdent)).Obj, - Field(Id("bool")). - Names(c.exportId(sequenceIdent)).Obj, - Field(Star(Idf(double, prefix, resultsIdent))). - Names(c.exportId(resultsIdent)).Obj, - Field(Star(Id(mName))). - Names(c.exportId(moqIdent)).Obj, - )).Obj).Decs(genDeclDec("// %s routes recorded function calls to the %s moq", + Field(c.genericExpr(Idf(double, prefix, paramsIdent), clone)).Names(c.exportId(paramsIdent)).Obj, + Field(Id("uint64")).Names(c.exportId(anyParamsIdent)).Obj, + Field(Id("bool")).Names(c.exportId(sequenceIdent)).Obj, + Field(Star(c.genericExpr(Idf(double, prefix, resultsIdent), clone))).Names(c.exportId(resultsIdent)).Obj, + Field(Star(c.genericExpr(Id(mName), clone))).Names(c.exportId(moqIdent)).Obj, + )).TypeParams(c.typeParams()).Obj).Decs(genDeclDec( + "// %s routes recorded function calls to the %s moq", structName, mName)).Obj } func (c *Converter) anyParamsStruct(prefix string) *dst.GenDecl { structName := fmt.Sprintf(double, prefix, anyParamsIdent) - recStructName := fmt.Sprintf(double, prefix, fnRecorderSuffix) - return TypeDecl(TypeSpec(structName).Type(Struct(Field(Star(Id(recStructName))). - Names(c.exportId(recorderIdent)).Obj)).Obj). + return TypeDecl(TypeSpec(structName).Type(Struct( + Field(Star(c.genericExpr(Id(fmt.Sprintf(double, prefix, fnRecorderSuffix)), clone))). + Names(c.exportId(recorderIdent)).Obj)).TypeParams(c.typeParams()).Obj). Decs(genDeclDec("// %s isolates the any params functions of the %s type", structName, c.typ.TypeInfo.Type.Name.Name)).Obj } @@ -795,9 +828,9 @@ func (c *Converter) mockFunc(typePrefix, fieldSuffix string, fn Func) []dst.Stmt c.helperCallExpr(Sel(Id(moqReceiverIdent)).Dot(c.exportId(moqIdent)).Obj), Assign(Id(paramsIdent)). Tok(token.DEFINE). - Rhs(Comp(Idf(double, typePrefix, paramsIdent)). - Elts(c.passthroughElements(fn.Params, paramsIdent, "")...).Obj).Obj, - Var(Value(Star(Idf(double, typePrefix, resultsIdent))). + Rhs(Comp(c.genericExpr(Idf(double, typePrefix, paramsIdent), clone)). + Elts(c.passthroughElements(fn.FuncType.Params, paramsIdent, "")...).Obj).Obj, + Var(Value(Star(c.genericExpr(Idf(double, typePrefix, resultsIdent), clone))). Names(Id(resultsIdent)).Obj), Range(Sel(cloneExpr(stateSelector)). Dot(c.exportId(resultsByParamsIdent+fieldSuffix)).Obj). @@ -907,21 +940,21 @@ func (c *Converter) mockFunc(typePrefix, fieldSuffix string, fn Func) []dst.Stmt ).Obj, ).Decs(IfDecs(dst.EmptyLine).Obj).Obj) - variadic := isVariadic(fn.Params) + variadic := isVariadic(fn.FuncType.Params) stmts = append(stmts, If(Bin(Sel(Id(resultIdent)). Dot(c.exportId(doFnIdent)).Obj).Op(token.NEQ).Y(Id(nilIdent)).Obj).Body( Expr(Call(Sel(Id(resultIdent)).Dot(c.exportId(doFnIdent)).Obj). - Args(passthroughFields(paramPrefix, fn.Params)...).Ellipsis(variadic).Obj).Obj, + Args(passthroughFields(paramPrefix, fn.FuncType.Params)...).Ellipsis(variadic).Obj).Obj, ).Decs(IfDecs(dst.EmptyLine).Obj).Obj) doReturnCall := Call(Sel(Id(resultIdent)).Dot(c.exportId(doReturnFnIdent)).Obj). - Args(passthroughFields(paramPrefix, fn.Params)...).Ellipsis(variadic).Obj + Args(passthroughFields(paramPrefix, fn.FuncType.Params)...).Ellipsis(variadic).Obj var doReturnStmt dst.Stmt = Expr(doReturnCall).Obj - if fn.Results != nil { + if fn.FuncType.Results != nil { stmts = append(stmts, If(Bin(Sel(Id(resultIdent)). Dot(c.exportId(valuesIdent)).Obj).Op(token.NEQ).Y(Id(nilIdent)).Obj).Body( - c.assignResult(fn.Results)...).Obj) - doReturnStmt = Assign(passthroughFields(resultPrefix, fn.Results)...). + c.assignResult(fn.FuncType.Results)...).Obj) + doReturnStmt = Assign(passthroughFields(resultPrefix, fn.FuncType.Results)...). Tok(token.ASSIGN).Rhs(doReturnCall).Obj } @@ -939,7 +972,6 @@ func (c *Converter) recorderFn(fn Func) *dst.FuncDecl { recvType := fmt.Sprintf(double, mName, recorderIdent) fnName := fn.Name fnRecName := fmt.Sprintf(triple, mName, fn.Name, fnRecorderSuffix) - typePrefix := c.typePrefix(fn) var moqVal dst.Expr = Sel(Id(moqReceiverIdent)). Dot(c.exportId(moqIdent)).Obj if fn.Name == "" { @@ -950,10 +982,10 @@ func (c *Converter) recorderFn(fn Func) *dst.FuncDecl { } return Fn(fnName). - Recv(Field(Star(Id(recvType))).Names(Id(moqReceiverIdent)).Obj). - ParamList(cloneAndNameUnnamed(paramPrefix, fn.Params)). - Results(Field(Star(Id(fnRecName))).Obj). - Body(c.recorderFnInterfaceBody(fnRecName, typePrefix, moqVal, fn)...). + Recv(Field(Star(c.genericExpr(Id(recvType), clone))).Names(Id(moqReceiverIdent)).Obj). + ParamList(c.cloneAndNameUnnamed(paramPrefix, fn.FuncType.Params)). + Results(Field(Star(c.genericExpr(Id(fnRecName), clone))).Obj). + Body(c.recorderFnInterfaceBody(fnRecName, c.typePrefix(fn), moqVal, fn)...). Decs(stdFuncDec()).Obj } @@ -962,18 +994,17 @@ func (c *Converter) recorderFnInterfaceBody( ) []dst.Stmt { return []dst.Stmt{Return(Un( token.AND, - Comp(Id(fnRecName)). + Comp(c.genericExpr(Id(fnRecName), clone)). Elts( Key(c.exportId(paramsIdent)). - Value(Comp(Idf(double, typePrefix, paramsIdent)). - Elts(c.passthroughElements(fn.Params, paramsIdent, "")...).Obj, + Value(Comp(c.genericExpr(Idf(double, typePrefix, paramsIdent), clone)). + Elts(c.passthroughElements(fn.FuncType.Params, paramsIdent, "")...).Obj, ).Decs(kvExprDec(dst.None)).Obj, - Key(c.exportId(sequenceIdent)). - Value(Bin(Sel(Sel(moqVal). - Dot(c.exportId(configIdent)).Obj). - Dot(Id(titler.String(sequenceIdent))).Obj). - Op(token.EQL). - Y(c.idPath("SeqDefaultOn", moqPkg)).Obj). + Key(c.exportId(sequenceIdent)).Value(Bin(Sel(Sel(moqVal). + Dot(c.exportId(configIdent)).Obj). + Dot(Id(titler.String(sequenceIdent))).Obj). + Op(token.EQL). + Y(c.idPath("SeqDefaultOn", moqPkg)).Obj). Decs(kvExprDec(dst.None)).Obj, Key(c.exportId(moqIdent)). Value(cloneExpr(moqVal)).Decs(kvExprDec(dst.None)).Obj, @@ -993,7 +1024,7 @@ func (c *Converter) anyParamFns(fn Func) []dst.Decl { decls := []dst.Decl{c.anyParamAnyFn(fn, anyParamsName, fnRecName)} count := 0 - for _, param := range fn.Params.List { + for _, param := range fn.FuncType.Params.List { if len(param.Names) == 0 { pName := fmt.Sprintf(unnamed, paramPrefix, count+1) decls = append(decls, c.anyParamFn(anyParamsName, fnRecName, pName, count)) @@ -1013,8 +1044,9 @@ func (c *Converter) anyParamAnyFn(fn Func, anyParamsName, fnRecName string) *dst moqSel := Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj return Fn(c.export("any")). - Recv(Field(Star(Id(fnRecName))).Names(Id(recorderReceiverIdent)).Obj). - Results(Field(Star(Id(anyParamsName))).Obj). + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone))). + Names(Id(recorderReceiverIdent)).Obj). + Results(Field(Star(c.genericExpr(Id(anyParamsName), clone))).Obj). Body( c.helperCallExpr(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj), If(Bin(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(resultsIdent)).Obj). @@ -1032,16 +1064,17 @@ func (c *Converter) anyParamAnyFn(fn Func, anyParamsName, fnRecName string) *dst Return(Id(nilIdent))).Obj, Return(Un( token.AND, - Comp(Id(anyParamsName)).Elts(Key(c.exportId(recorderIdent)). - Value(Id(recorderReceiverIdent)).Obj).Obj)), + Comp(cloneExpr(c.genericExpr(Id(anyParamsName), clone))). + Elts(Key(c.exportId(recorderIdent)). + Value(Id(recorderReceiverIdent)).Obj).Obj)), ). Decs(stdFuncDec()).Obj } func (c *Converter) anyParamFn(anyParamsName, fnRecName, pName string, paramPos int) *dst.FuncDecl { return Fn(c.export(pName)). - Recv(Field(Star(Id(anyParamsName))).Names(Id(anyParamsReceiverIdent)).Obj). - Results(Field(Star(Id(fnRecName))).Obj). + Recv(Field(Star(c.genericExpr(Id(anyParamsName), clone))).Names(Id(anyParamsReceiverIdent)).Obj). + Results(Field(Star(c.genericExpr(Id(fnRecName), clone))).Obj). Body( Assign(Sel(Sel(Id(anyParamsReceiverIdent)). Dot(c.exportId(recorderIdent)).Obj). @@ -1054,22 +1087,17 @@ func (c *Converter) anyParamFn(anyParamsName, fnRecName, pName string, paramPos } func (c *Converter) returnResultsFn(fn Func) *dst.FuncDecl { - mStruct, err := c.methodStruct(resultsIdent, fn.Results) - if err != nil { - logs.Panic("Creating results struct should never generate errors", err) - } - - params := cloneAndNameUnnamed(resultPrefix, fn.Results) - resExprs := []dst.Expr{ - Key(c.exportId(valuesIdent)). - Value(Un(token.AND, Comp(mStruct). - Elts(c.passthroughElements(fn.Results, resultsIdent, "")...).Obj)). - Decs(kvExprDec(dst.NewLine)).Obj, - Key(c.exportId(sequenceIdent)). - Value(Id(sequenceIdent)).Decs(kvExprDec(dst.None)).Obj, - } - - return c.returnFn(returnFnName, fn, params, resExprs) + return c.returnFn(returnFnName, fn, + c.cloneAndNameUnnamed(resultPrefix, fn.FuncType.Results), []dst.Expr{ + Key(c.exportId(valuesIdent)). + Value(Un(token.AND, + Comp(c.methodStruct(resultsIdent, fn.FuncType.Results)). + Elts(c.passthroughElements( + fn.FuncType.Results, resultsIdent, "")...).Obj)). + Decs(kvExprDec(dst.NewLine)).Obj, + Key(c.exportId(sequenceIdent)). + Value(Id(sequenceIdent)).Decs(kvExprDec(dst.None)).Obj, + }) } func (c *Converter) returnFn( @@ -1085,12 +1113,12 @@ func (c *Converter) returnFn( fnRecName = fmt.Sprintf(double, mName, fnRecorderSuffix) } - resStruct := c.innerResultsStruct(c.typePrefix(fn), fn.Results) + resStruct := c.innerResultsStruct(c.typePrefix(fn), fn.FuncType.Results) return Fn(c.export(fnName)). - Recv(Field(Star(Id(fnRecName))).Names(Id(recorderReceiverIdent)).Obj). + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone))).Names(Id(recorderReceiverIdent)).Obj). ParamList(params). - Results(Field(Star(Id(fnRecName))).Obj). + Results(Field(Star(c.genericExpr(Id(fnRecName), clone))).Obj). Body( c.helperCallExpr(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj), Expr(Call(Sel(Id(recorderReceiverIdent)). @@ -1130,9 +1158,9 @@ func (c *Converter) andDoFn(fn Func) *dst.FuncDecl { fnName := fmt.Sprintf(double, typePrefix, doFnIdent) return Fn(c.export(andDoFnName)). - Recv(Field(Star(Id(fnRecName))).Names(Id(recorderReceiverIdent)).Obj). - Params(Field(Id(fnName)).Names(Id(fnFnName)).Obj). - Results(Field(Star(Id(fnRecName))).Obj).Body( + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone))).Names(Id(recorderReceiverIdent)).Obj). + Params(Field(c.genericExpr(Id(fnName), clone)).Names(Id(fnFnName)).Obj). + Results(Field(Star(c.genericExpr(Id(fnRecName), clone))).Obj).Body( c.helperCallExpr(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj), If(Bin(Sel(Id(recorderReceiverIdent)). Dot(c.exportId(resultsIdent)).Obj). @@ -1155,7 +1183,7 @@ func (c *Converter) andDoFn(fn Func) *dst.FuncDecl { func (c *Converter) doReturnResultsFn(fn Func) *dst.FuncDecl { typePrefix := c.typePrefix(fn) fnName := fmt.Sprintf(double, typePrefix, doReturnFnIdent) - params := FieldList(Field(Id(fnName)).Names(Id(fnFnName)).Obj) + params := FieldList(Field(c.genericExpr(Id(fnName), clone)).Names(Id(fnFnName)).Obj) resExprs := []dst.Expr{ Key(c.exportId(sequenceIdent)).Value(Id(sequenceIdent)).Obj, Key(c.exportId(doReturnFnIdent)).Value(Id(fnFnName)).Obj, @@ -1195,7 +1223,7 @@ func (c *Converter) findResultsFn(fn Func) *dst.FuncDecl { body = append(body, cloneStmt(incrRepeat)) return Fn(c.export(findResultsFnName)). - Recv(Field(Star(Id(fnRecName))).Names(Id(recorderReceiverIdent)).Obj). + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone))).Names(Id(recorderReceiverIdent)).Obj). Body(body...).Decs(stdFuncDec()).Obj } @@ -1224,7 +1252,7 @@ func (c *Converter) findRecorderResults(fn Func) []dst.Stmt { Sel(Id(recorderReceiverIdent)). Dot(c.exportId(anyParamsIdent)).Obj).Obj).Obj, Assign(Id(insertAtIdent)).Tok(token.DEFINE).Rhs(LitInt(-1)).Obj, - Var(Value(Star(Id(resultsByParamsType))). + Var(Value(Star(c.genericExpr(Id(resultsByParamsType), clone))). Names(Id(resultsIdent)).Obj), Range(c.selExport(moqSel, resultsByParams)). Key(Id(nIdent)). @@ -1250,15 +1278,16 @@ func (c *Converter) findRecorderResults(fn Func) []dst.Stmt { ).Obj, If(Bin(Id(resultsIdent)).Op(token.EQL).Y(Id(nilIdent)).Obj).Body( Assign(Id(resultsIdent)).Tok(token.ASSIGN).Rhs(Un( - token.AND, Comp(Id(resultsByParamsType)).Elts( + token.AND, Comp(c.genericExpr(Id(resultsByParamsType), clone)).Elts( Key(c.exportId(anyCountIdent)).Value(Id(anyCountIdent)). Decs(kvExprDec(dst.NewLine)).Obj, Key(c.exportId(anyParamsIdent)). Value(Sel(Id(recorderReceiverIdent)). Dot(c.exportId(anyParamsIdent)).Obj). Decs(kvExprDec(dst.None)).Obj, - Key(c.exportId(resultsIdent)).Value(Comp(MapType(Id(paramsKey)). - Value(Star(Id(results))).Obj).Obj). + Key(c.exportId(resultsIdent)).Value(Comp( + MapType(c.genericExpr(Id(paramsKey), clone)). + Value(Star(c.genericExpr(Id(results), clone))).Obj).Obj). Decs(kvExprDec(dst.NewLine)).Obj, ).Obj)).Obj, Assign(c.selExport(moqSel, resultsByParams)). @@ -1300,7 +1329,7 @@ func (c *Converter) findRecorderResults(fn Func) []dst.Stmt { Tok(token.ASSIGN). Rhs(Un( token.AND, - Comp(c.exportId(results)). + Comp(c.genericExpr(c.exportId(results), clone)). Elts( Key(c.exportId(paramsIdent)). Value(Sel(Id(recorderReceiverIdent)). @@ -1332,7 +1361,7 @@ func (c *Converter) recorderRepeatFn(fn Func) *dst.FuncDecl { fnRecName = fmt.Sprintf(double, mName, fnRecorderSuffix) } - lastVal := Comp(c.innerResultsStruct(c.typePrefix(fn), fn.Results)).Elts( + lastVal := Comp(c.innerResultsStruct(c.typePrefix(fn), fn.FuncType.Results)).Elts( Key(c.exportId(valuesIdent)). Value(Sel(Id(lastIdent)).Dot(c.exportId(valuesIdent)).Obj). Decs(kvExprDec(dst.NewLine)).Obj, @@ -1345,9 +1374,9 @@ func (c *Converter) recorderRepeatFn(fn Func) *dst.FuncDecl { ).Obj return Fn(c.export(repeatFnName)). - Recv(Field(Star(Id(fnRecName))).Names(Id(recorderReceiverIdent)).Obj). + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone))).Names(Id(recorderReceiverIdent)).Obj). Params(Field(Ellipsis(c.idPath(repeaterType, moqPkg))).Names(Id(repeatersIdent)).Obj). - Results(Field(Star(Id(fnRecName))).Obj). + Results(Field(Star(c.genericExpr(Id(fnRecName), clone))).Obj). Body( c.helperCallExpr(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj), If(Bin(Sel(Id(recorderReceiverIdent)). @@ -1411,7 +1440,7 @@ func (c *Converter) prettyParamsFn(fn Func) *dst.FuncDecl { } var pExprs []dst.Expr count := 0 - for _, param := range fn.Params.List { + for _, param := range fn.FuncType.Params.List { if len(param.Names) == 0 { sfmt += "%#v, " pExpr := Sel(Id(paramsIdent)). @@ -1434,8 +1463,8 @@ func (c *Converter) prettyParamsFn(fn Func) *dst.FuncDecl { sfmt += ")" pExprs = append([]dst.Expr{LitString(sfmt)}, pExprs...) return Fn(c.export(fnName)). - Recv(Field(Star(Id(mName))).Names(Id(moqReceiverIdent)).Obj). - Params(Field(Id(params)).Names(Id(paramsIdent)).Obj). + Recv(Field(Star(c.genericExpr(Id(mName), clone))).Names(Id(moqReceiverIdent)).Obj). + Params(Field(c.genericExpr(Id(params), clone)).Names(Id(paramsIdent)).Obj). Results(Field(Id("string")).Obj). Body(Return( Call(IdPath("Sprintf", "fmt")). @@ -1456,16 +1485,18 @@ func (c *Converter) paramsKeyFn(fn Func) *dst.FuncDecl { c.helperCallExpr(Id(moqReceiverIdent)), } count := 0 - for _, param := range fn.Params.List { + for _, param := range fn.FuncType.Params.List { + typ := c.resolveExpr(param.Type) + if len(param.Names) == 0 { stmts = append(stmts, c.mockFuncFindResultsParam( - fn, fmt.Sprintf(unnamed, paramPrefix, count+1), count, param.Type)...) + fn, fmt.Sprintf(unnamed, paramPrefix, count+1), count, typ)...) count++ } for _, name := range param.Names { stmts = append(stmts, - c.mockFuncFindResultsParam(fn, name.Name, count, param.Type)...) + c.mockFuncFindResultsParam(fn, name.Name, count, typ)...) count++ } } @@ -1480,27 +1511,19 @@ func (c *Converter) paramsKeyFn(fn Func) *dst.FuncDecl { fnName = paramsKeyFnName } - pStruct, err := c.methodStruct(paramsKeyIdent, fn.Params) - if err != nil { - logs.Panic("Call MethodStructs first to get a meaningful error", err) - } - pkStruct, err := c.methodStruct(hashesIdent, fn.Params) - if err != nil { - logs.Panic("Call MethodStructs first to get a meaningful error", err) - } - stmts = append(stmts, Return(Comp(Id(paramsKey)).Elts( - Key(c.exportId(paramsIdent)).Value(Comp(pStruct). - Elts(c.passthroughElements(fn.Params, paramsKeyIdent, usedSuffix)...).Obj). + stmts = append(stmts, Return(Comp(c.genericExpr(Id(paramsKey), clone)).Elts( + Key(c.exportId(paramsIdent)).Value(Comp(c.methodStruct(paramsKeyIdent, fn.FuncType.Params)). + Elts(c.passthroughElements(fn.FuncType.Params, paramsKeyIdent, usedSuffix)...).Obj). Decs(kvExprDec(dst.NewLine)).Obj, - Key(c.exportId(hashesIdent)).Value(Comp(pkStruct). - Elts(c.passthroughElements(fn.Params, hashesIdent, usedHashSuffix)...).Obj). + Key(c.exportId(hashesIdent)).Value(Comp(c.methodStruct(hashesIdent, fn.FuncType.Params)). + Elts(c.passthroughElements(fn.FuncType.Params, hashesIdent, usedHashSuffix)...).Obj). Decs(kvExprDec(dst.NewLine)).Obj).Obj)) return Fn(c.export(fnName)). - Recv(Field(Star(Id(mName))).Names(Id(moqReceiverIdent)).Obj). - Params(Field(Id(params)).Names(Id(paramsIdent)).Obj, + Recv(Field(Star(c.genericExpr(Id(mName), clone))).Names(Id(moqReceiverIdent)).Obj). + Params(Field(c.genericExpr(Id(params), clone)).Names(Id(paramsIdent)).Obj, Field(Id("uint64")).Names(Id(anyParamsIdent)).Obj). - Results(Field(Id(paramsKey)).Obj). + Results(Field(c.genericExpr(Id(paramsKey), clone)).Obj). Body(stmts...). Decs(stdFuncDec()).Obj } @@ -1508,9 +1531,12 @@ func (c *Converter) paramsKeyFn(fn Func) *dst.FuncDecl { func (c *Converter) mockFuncFindResultsParam( fn Func, pName string, paramPos int, typ dst.Expr, ) []dst.Stmt { - comp, err := c.typeCache.IsComparable(typ) + comp, err := c.typeCache.IsComparable(typ, c.typ.TypeInfo) if err != nil { - logs.Panic("Call MethodStructs first to get a meaningful error", err) + if c.err == nil { + c.err = err + } + return nil } vName := validName(pName, paramPrefix, paramPos) @@ -1608,8 +1634,8 @@ func (c *Converter) recorderSeqFn(fn Func, fnName, assign string) *dst.FuncDecl fnName = c.export(fnName) return Fn(fnName). - Results(Field(Star(Id(fnRecName))).Obj). - Recv(Field(Star(Id(fnRecName))).Names(Id(recorderReceiverIdent)).Obj). + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone))).Names(Id(recorderReceiverIdent)).Obj). + Results(Field(Star(c.genericExpr(Id(fnRecName), clone))).Obj). Body( c.helperCallExpr(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj), If(Bin(Sel(Id(recorderReceiverIdent)). @@ -1638,6 +1664,46 @@ func (c *Converter) recorderSeqFn(fn Func, fnName, assign string) *dst.FuncDecl ).Decs(stdFuncDec()).Obj } +func (c *Converter) typeParams() *dst.FieldList { + return c.cloneFieldList(c.typ.TypeInfo.Type.TypeParams, false) +} + +type genericExprMode int + +const ( + // clone clones the generic expression as-is + clone genericExprMode = iota + // typeAssertSafe makes the expression safe for use in a type assertion + // (omitNames is implied) + typeAssertSafe +) + +func (c *Converter) genericExpr(in dst.Expr, mode genericExprMode) dst.Expr { + if c.typ.TypeInfo.Type.TypeParams == nil || len(c.typ.TypeInfo.Type.TypeParams.List) == 0 { + return in + } + + var subs []dst.Expr + for _, p := range c.typ.TypeInfo.Type.TypeParams.List { + for _, n := range p.Names { + var sub dst.Expr + if mode == clone { + sub = Id(n.Name) + } else { + sub = cloneExpr(p.Type) + if mode == typeAssertSafe { + if un, ok := sub.(*dst.UnaryExpr); ok && un.Op == token.TILDE { + sub = un.X + } + } + } + subs = append(subs, c.resolveExpr(sub)) + } + } + + return Index(in).Sub(subs...).Obj +} + func (c *Converter) callPrettyParams(fn Func, moqExpr, paramsExpr dst.Expr) *dst.CallExpr { prettyParamsFn := prettyParamsFnName if fn.Name != "" { @@ -1658,9 +1724,12 @@ func (c *Converter) passthroughElements(fl *dst.FieldList, label, valSuffix stri beforeDec := dst.NewLine count := 0 for _, field := range fl.List { - comp, err := c.typeCache.IsComparable(field.Type) + comp, err := c.typeCache.IsComparable(c.resolveExpr(field.Type), c.typ.TypeInfo) if err != nil { - logs.Panic("Call MethodStructs first to get a meaningful error", err) + if c.err == nil { + c.err = err + } + return nil } if len(field.Names) == 0 { @@ -1748,8 +1817,8 @@ func (c *Converter) assignResult(resFL *dst.FieldList) []dst.Stmt { return assigns } -func cloneAndNameUnnamed(prefix string, fieldList *dst.FieldList) *dst.FieldList { - fieldList = cloneFieldList(fieldList, false) +func (c *Converter) cloneAndNameUnnamed(prefix string, fieldList *dst.FieldList) *dst.FieldList { + fieldList = c.cloneFieldList(fieldList, false) if fieldList != nil { count := 0 for _, f := range fieldList.List { @@ -1814,7 +1883,7 @@ func (c *Converter) selExport(x dst.Expr, sel string) dst.Expr { case *dst.SelectorExpr: return Sel(cloneSelect(v)).Dot(c.exportId(sel)).Obj case *dst.Ident: - return Sel(cloneIdent(v)).Dot(c.exportId(sel)).Obj + return Sel(cloneExpr(v)).Dot(c.exportId(sel)).Obj default: logs.Panicf("unsupported selector type: %#v", v) return nil @@ -1859,12 +1928,7 @@ func isVariadic(fl *dst.FieldList) bool { return false } -func cloneIdent(i *dst.Ident) dst.Expr { - //nolint:forcetypeassert // if dst.Clone returns a different type, panic - return dst.Clone(i).(*dst.Ident) -} - -func cloneFieldList(fl *dst.FieldList, removeNames bool) *dst.FieldList { +func (c *Converter) cloneFieldList(fl *dst.FieldList, removeNames bool) *dst.FieldList { if fl != nil { //nolint:forcetypeassert // if dst.Clone returns a different type, panic fl = dst.Clone(fl).(*dst.FieldList) @@ -1876,6 +1940,8 @@ func cloneFieldList(fl *dst.FieldList, removeNames bool) *dst.FieldList { id.Path = "" } } + + field.Type = c.resolveExpr(field.Type) } if removeNames { for _, field := range fl.List { @@ -1888,6 +1954,39 @@ func cloneFieldList(fl *dst.FieldList, removeNames bool) *dst.FieldList { return fl } +func (c *Converter) resolveExpr(expr dst.Expr) dst.Expr { + switch e := expr.(type) { + case *dst.ArrayType: + typ := c.resolveExpr(e.Elt) + e.Elt = typ + case *dst.Ident: + if e.Path == "" && c.typ.TypeInfo.Type.TypeParams != nil { + // Priority is always highest for type params + for _, f := range c.typ.TypeInfo.Type.TypeParams.List { + for _, n := range f.Names { + if n.Name == e.Name { + // So just use the name as is with no path + return e + } + } + } + } + typ, err := c.typeCache.Type(*e, c.typ.TypeInfo.PkgPath, false) + if err != nil { + if c.err == nil { + c.err = err + } + return nil + } + return IdPath(typ.Type.Name.Name, typ.PkgPath) + case *dst.StarExpr: + typ := c.resolveExpr(e.X) + e.X = typ + } + + return expr +} + func cloneSelect(sel *dst.SelectorExpr) dst.Expr { //nolint:forcetypeassert // if dst.Clone returns a different type, panic return dst.Clone(sel).(*dst.SelectorExpr) diff --git a/generator/converter_test.go b/generator/converter_test.go index 4a135a8..f896029 100644 --- a/generator/converter_test.go +++ b/generator/converter_test.go @@ -19,10 +19,10 @@ func TestConverter(t *testing.T) { scene *moq.Scene typeCacheMoq *moqTypeCache - func1Param1 dst.Expr - func1Param2 dst.Expr - func1Param3 dst.Expr - func1Param4 dst.Expr + func1Param1 *dst.Ident + func1Param2 *dst.Ident + func1Param3 *dst.Ident + func1Param4 *dst.Ident func1Params *dst.FieldList func1Results *dst.FieldList @@ -90,13 +90,17 @@ func TestConverter(t *testing.T) { } iSpecFuncs = []generator.Func{ { - Name: "Func1", - Params: func1Params, - Results: func1Results, + Name: "Func1", + FuncType: &dst.FuncType{ + Params: func1Params, + Results: func1Results, + }, }, { - Name: "func2", - Params: &dst.FieldList{List: nil}, + Name: "func2", + FuncType: &dst.FuncType{ + Params: &dst.FieldList{List: nil}, + }, }, } @@ -109,8 +113,10 @@ func TestConverter(t *testing.T) { } fnSpecFuncs = []generator.Func{ { - Params: func1Params, - Results: func1Results, + FuncType: &dst.FuncType{ + Params: func1Params, + Results: func1Results, + }, }, } } @@ -151,9 +157,11 @@ func TestConverter(t *testing.T) { converter := generator.NewConverter(typ, isExported, typeCacheMoq.mock()) // ACT - decls := converter.BaseDecls() - + decls, err := converter.BaseDecls() // ASSERT + if err != nil { + t.Fatalf("got %#v, want no error", err) + } if len(decls) != 2 { t.Fatalf("got %#v, want 1 decl", decls) } @@ -189,9 +197,11 @@ func TestConverter(t *testing.T) { converter := generator.NewConverter(typ, isExported, typeCacheMoq.mock()) // ACT - decls := converter.BaseDecls() - + decls, err := converter.BaseDecls() // ASSERT + if err != nil { + t.Fatalf("got %#v, want no error", err) + } if len(decls) != 1 { t.Fatalf("got %#v, want 1 decl", decls) } @@ -222,9 +232,11 @@ func TestConverter(t *testing.T) { converter := generator.NewConverter(typ, isExported, typeCacheMoq.mock()) // ACT - decls := converter.BaseDecls() - + decls, err := converter.BaseDecls() // ASSERT + if err != nil { + t.Fatalf("got %#v, want no error", err) + } if len(decls) != 3 { t.Fatalf("got %#v, want 3 decl", decls) } @@ -270,9 +282,11 @@ func TestConverter(t *testing.T) { converter := generator.NewConverter(typ, isExported, typeCacheMoq.mock()) // ACT - decls := converter.BaseDecls() - + decls, err := converter.BaseDecls() // ASSERT + if err != nil { + t.Fatalf("got %#v, want no error", err) + } if len(decls) != 2 { t.Fatalf("got %#v, want 1 decl", decls) } @@ -305,9 +319,11 @@ func TestConverter(t *testing.T) { converter := generator.NewConverter(typ, isExported, typeCacheMoq.mock()) // ACT - decl := converter.IsolationStruct("mock") - + decl, err := converter.IsolationStruct("mock") // ASSERT + if err != nil { + t.Fatalf("got %#v, want no error", err) + } if len(decl.Decs.Start) < 1 { t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) } @@ -339,18 +355,47 @@ func TestConverter(t *testing.T) { Name: "Hash", } fn := generator.Func{ - Name: "Func1", - Params: func1Params, - Results: func1Results, + Name: "Func1", + FuncType: &dst.FuncType{ + Params: func1Params, + Results: func1Results, + }, } - typeCacheMoq.onCall().IsComparable(func1Param1). + typeCacheMoq.onCall().Type(*func1Param1, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: func1Param1}, + }, nil).repeat(moq.AnyTimes()) + typeCacheMoq.onCall().Type(*func1Param2, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: func1Param2}, + }, nil).repeat(moq.AnyTimes()) + typeCacheMoq.onCall().Type(*func1Param3, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: func1Param3}, + }, nil).repeat(moq.AnyTimes()) + typeCacheMoq.onCall().Type(*func1Param4, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: func1Param4}, + }, nil).repeat(moq.AnyTimes()) + tInfo := ast.TypeInfo{Type: iSpec} + typeCacheMoq.onCall().IsComparable(func1Param1, tInfo). returnResults(false, nil) - typeCacheMoq.onCall().IsComparable(func1Param2). + typeCacheMoq.onCall().IsComparable(func1Param2, tInfo). returnResults(true, nil) - typeCacheMoq.onCall().IsComparable(func1Param3). + typeCacheMoq.onCall().IsComparable(func1Param3, tInfo). returnResults(false, nil) - typeCacheMoq.onCall().IsComparable(func1Param4). + typeCacheMoq.onCall().IsComparable(func1Param4, tInfo). returnResults(true, nil) + id := ast.Id("string") + typeCacheMoq.onCall().Type(*id, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: id}, + }, nil).repeat(moq.AnyTimes()) + id = ast.Id("error") + typeCacheMoq.onCall().Type(*id, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: id}, + }, nil).repeat(moq.AnyTimes()) typ := generator.Type{ TypeInfo: ast.TypeInfo{Type: iSpec}, @@ -508,13 +553,22 @@ func TestConverter(t *testing.T) { defer afterEach(t) fn := generator.Func{ - Name: "Func1", - Params: func1Params, - Results: func1Results, + Name: "Func1", + FuncType: &dst.FuncType{ + Params: func1Params, + Results: func1Results, + }, } expectedErr := errors.New("type error") - typeCacheMoq.onCall().IsComparable(func1Param1). - returnResults(false, expectedErr) + typeCacheMoq.onCall().Type(*func1Param1, "", false). + returnResults(ast.TypeInfo{}, expectedErr).repeat(moq.AnyTimes()) + typeCacheMoq.onCall().Type(dst.Ident{}, "", false).any().id(). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: func1Param1}, + }, nil).repeat(moq.AnyTimes()) + typeCacheMoq.onCall().IsComparable(nil, ast.TypeInfo{}). + any().expr().any().parentType(). + returnResults(false, nil).repeat(moq.AnyTimes()) typ := generator.Type{ TypeInfo: ast.TypeInfo{Type: iSpec}, @@ -546,9 +600,11 @@ func TestConverter(t *testing.T) { converter := generator.NewConverter(typ, isExported, typeCacheMoq.mock()) // ACT - decl := converter.NewFunc() - + decl, err := converter.NewFunc() // ASSERT + if err != nil { + t.Errorf("got error %#v, want no error", err) + } if len(decl.Decs.Start) < 1 { t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) } @@ -570,9 +626,11 @@ func TestConverter(t *testing.T) { converter := generator.NewConverter(typ, isExported, typeCacheMoq.mock()) // ACT - decl := converter.NewFunc() - + decl, err := converter.NewFunc() // ASSERT + if err != nil { + t.Errorf("got error %#v, want no error", err) + } if len(decl.Decs.Start) < 1 { t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) } @@ -598,9 +656,11 @@ func TestConverter(t *testing.T) { converter := generator.NewConverter(typ, isExported, typeCacheMoq.mock()) // ACT - decl := converter.IsolationAccessor("recorder", "onCall") - + decl, err := converter.IsolationAccessor("recorder", "onCall") // ASSERT + if err != nil { + t.Fatalf("got error %#v, want no error", err) + } if len(decl.Decs.Start) < 1 { t.Errorf("got len %d, wanted > 0", len(decl.Decs.Start)) } @@ -623,10 +683,39 @@ func TestConverter(t *testing.T) { } converter := generator.NewConverter(typ, isExported, typeCacheMoq.mock()) - // ACT - decl := converter.FuncClosure(fnSpecFuncs[0]) + typeCacheMoq.onCall().Type(*func1Param1, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: func1Param1}, + }, nil).repeat(moq.AnyTimes()) + typeCacheMoq.onCall().Type(*func1Param2, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: func1Param2}, + }, nil).repeat(moq.AnyTimes()) + typeCacheMoq.onCall().Type(*func1Param3, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: func1Param3}, + }, nil).repeat(moq.AnyTimes()) + typeCacheMoq.onCall().Type(*func1Param4, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: func1Param4}, + }, nil).repeat(moq.AnyTimes()) + id := ast.Id("string") + typeCacheMoq.onCall().Type(*id, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: id}, + }, nil).repeat(moq.AnyTimes()) + id = ast.Id("error") + typeCacheMoq.onCall().Type(*id, "", false). + returnResults(ast.TypeInfo{ + Type: &dst.TypeSpec{Name: id}, + }, nil).repeat(moq.AnyTimes()) + // ACT + decl, err := converter.FuncClosure(fnSpecFuncs[0]) // ASSERT + if err != nil { + t.Fatalf("got %#v, want no error", err) + } if len(decl.Decs.Start) < 1 { t.Errorf("got len %d, wanted > 0", len(decl.Decs.Start)) } diff --git a/generator/generator.go b/generator/generator.go index a8d645b..c7b7779 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -4,7 +4,6 @@ package generator import ( "errors" "fmt" - "io/ioutil" "os" "path/filepath" "time" @@ -65,8 +64,8 @@ func Generate(reqs ...GenerateRequest) error { // TypeCache defines the interface to the Cache type type TypeCache interface { Type(id dst.Ident, contextPkg string, testImport bool) (ast.TypeInfo, error) - IsComparable(expr dst.Expr) (bool, error) - IsDefaultComparable(expr dst.Expr) (bool, error) + IsComparable(expr dst.Expr, parentType ast.TypeInfo) (bool, error) + IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) (bool, error) FindPackage(dir string) (string, error) } @@ -94,7 +93,7 @@ func GenerateWithTypeCache(cache TypeCache, req GenerateRequest) error { } } - tempFile, err := ioutil.TempFile(destDir, "*.go-gen") + tempFile, err := os.CreateTemp(destDir, "*.go-gen") if err != nil { return fmt.Errorf("error creating temp file: %w", err) } diff --git a/generator/generator_test.go b/generator/generator_test.go index 2aa1c08..27bbf5e 100644 --- a/generator/generator_test.go +++ b/generator/generator_test.go @@ -49,7 +49,19 @@ func TestGenerating(t *testing.T) { "PassByReferenceFn", "InterfaceParamFn", "InterfaceResultFn", + "GenericParamsFn", + "PartialGenericParamsFn", + "GenericResultsFn", + "PartialGenericResultsFn", + "GenericInterfaceParamFn", + "GenericInterfaceResultFn", "Usual", + "GenericParams", + "PartialGenericParams", + "GenericResults", + "PartialGenericResults", + "GenericInterfaceParam", + "GenericInterfaceResult", } err := generator.Generate( diff --git a/generator/moq_converterer_test.go b/generator/moq_converterer_test.go index a03d580..5360d2c 100644 --- a/generator/moq_converterer_test.go +++ b/generator/moq_converterer_test.go @@ -98,13 +98,16 @@ type moqConverterer_BaseDecls_doFn func() // moqConverterer_BaseDecls_doReturnFn defines the type of function needed when // calling doReturnResults for the Converterer type -type moqConverterer_BaseDecls_doReturnFn func() (baseDecls []dst.Decl) +type moqConverterer_BaseDecls_doReturnFn func() (baseDecls []dst.Decl, err error) // moqConverterer_BaseDecls_results holds the results of the Converterer type type moqConverterer_BaseDecls_results struct { params moqConverterer_BaseDecls_params results []struct { - values *struct{ baseDecls []dst.Decl } + values *struct { + baseDecls []dst.Decl + err error + } sequence uint32 doFn moqConverterer_BaseDecls_doFn doReturnFn moqConverterer_BaseDecls_doReturnFn @@ -154,14 +157,17 @@ type moqConverterer_IsolationStruct_doFn func(suffix string) // moqConverterer_IsolationStruct_doReturnFn defines the type of function // needed when calling doReturnResults for the Converterer type -type moqConverterer_IsolationStruct_doReturnFn func(suffix string) (structDecl *dst.GenDecl) +type moqConverterer_IsolationStruct_doReturnFn func(suffix string) (structDecl *dst.GenDecl, err error) // moqConverterer_IsolationStruct_results holds the results of the Converterer // type type moqConverterer_IsolationStruct_results struct { params moqConverterer_IsolationStruct_params results []struct { - values *struct{ structDecl *dst.GenDecl } + values *struct { + structDecl *dst.GenDecl + err error + } sequence uint32 doFn moqConverterer_IsolationStruct_doFn doReturnFn moqConverterer_IsolationStruct_doReturnFn @@ -269,13 +275,16 @@ type moqConverterer_NewFunc_doFn func() // moqConverterer_NewFunc_doReturnFn defines the type of function needed when // calling doReturnResults for the Converterer type -type moqConverterer_NewFunc_doReturnFn func() (funcDecl *dst.FuncDecl) +type moqConverterer_NewFunc_doReturnFn func() (funcDecl *dst.FuncDecl, err error) // moqConverterer_NewFunc_results holds the results of the Converterer type type moqConverterer_NewFunc_results struct { params moqConverterer_NewFunc_params results []struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_NewFunc_doFn doReturnFn moqConverterer_NewFunc_doReturnFn @@ -325,14 +334,17 @@ type moqConverterer_IsolationAccessor_doFn func(suffix, fnName string) // moqConverterer_IsolationAccessor_doReturnFn defines the type of function // needed when calling doReturnResults for the Converterer type -type moqConverterer_IsolationAccessor_doReturnFn func(suffix, fnName string) (funcDecl *dst.FuncDecl) +type moqConverterer_IsolationAccessor_doReturnFn func(suffix, fnName string) (funcDecl *dst.FuncDecl, err error) // moqConverterer_IsolationAccessor_results holds the results of the // Converterer type type moqConverterer_IsolationAccessor_results struct { params moqConverterer_IsolationAccessor_params results []struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_IsolationAccessor_doFn doReturnFn moqConverterer_IsolationAccessor_doReturnFn @@ -381,13 +393,16 @@ type moqConverterer_FuncClosure_doFn func(fn generator.Func) // moqConverterer_FuncClosure_doReturnFn defines the type of function needed // when calling doReturnResults for the Converterer type -type moqConverterer_FuncClosure_doReturnFn func(fn generator.Func) (funcDecl *dst.FuncDecl) +type moqConverterer_FuncClosure_doReturnFn func(fn generator.Func) (funcDecl *dst.FuncDecl, err error) // moqConverterer_FuncClosure_results holds the results of the Converterer type type moqConverterer_FuncClosure_results struct { params moqConverterer_FuncClosure_params results []struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_FuncClosure_doFn doReturnFn moqConverterer_FuncClosure_doReturnFn @@ -436,13 +451,16 @@ type moqConverterer_MockMethod_doFn func(fn generator.Func) // moqConverterer_MockMethod_doReturnFn defines the type of function needed // when calling doReturnResults for the Converterer type -type moqConverterer_MockMethod_doReturnFn func(fn generator.Func) (funcDecl *dst.FuncDecl) +type moqConverterer_MockMethod_doReturnFn func(fn generator.Func) (funcDecl *dst.FuncDecl, err error) // moqConverterer_MockMethod_results holds the results of the Converterer type type moqConverterer_MockMethod_results struct { params moqConverterer_MockMethod_params results []struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_MockMethod_doFn doReturnFn moqConverterer_MockMethod_doReturnFn @@ -492,14 +510,17 @@ type moqConverterer_RecorderMethods_doFn func(fn generator.Func) // moqConverterer_RecorderMethods_doReturnFn defines the type of function // needed when calling doReturnResults for the Converterer type -type moqConverterer_RecorderMethods_doReturnFn func(fn generator.Func) (funcDecls []dst.Decl) +type moqConverterer_RecorderMethods_doReturnFn func(fn generator.Func) (funcDecls []dst.Decl, err error) // moqConverterer_RecorderMethods_results holds the results of the Converterer // type type moqConverterer_RecorderMethods_results struct { params moqConverterer_RecorderMethods_params results []struct { - values *struct{ funcDecls []dst.Decl } + values *struct { + funcDecls []dst.Decl + err error + } sequence uint32 doFn moqConverterer_RecorderMethods_doFn doReturnFn moqConverterer_RecorderMethods_doReturnFn @@ -548,13 +569,16 @@ type moqConverterer_ResetMethod_doFn func() // moqConverterer_ResetMethod_doReturnFn defines the type of function needed // when calling doReturnResults for the Converterer type -type moqConverterer_ResetMethod_doReturnFn func() (funcDecl *dst.FuncDecl) +type moqConverterer_ResetMethod_doReturnFn func() (funcDecl *dst.FuncDecl, err error) // moqConverterer_ResetMethod_results holds the results of the Converterer type type moqConverterer_ResetMethod_results struct { params moqConverterer_ResetMethod_params results []struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_ResetMethod_doFn doReturnFn moqConverterer_ResetMethod_doReturnFn @@ -603,14 +627,17 @@ type moqConverterer_AssertMethod_doFn func() // moqConverterer_AssertMethod_doReturnFn defines the type of function needed // when calling doReturnResults for the Converterer type -type moqConverterer_AssertMethod_doReturnFn func() (funcDecl *dst.FuncDecl) +type moqConverterer_AssertMethod_doReturnFn func() (funcDecl *dst.FuncDecl, err error) // moqConverterer_AssertMethod_results holds the results of the Converterer // type type moqConverterer_AssertMethod_results struct { params moqConverterer_AssertMethod_params results []struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_AssertMethod_doFn doReturnFn moqConverterer_AssertMethod_doReturnFn @@ -743,7 +770,7 @@ func newMoqConverterer(scene *moq.Scene, config *moq.Config) *moqConverterer { // mock returns the mock implementation of the Converterer type func (m *moqConverterer) mock() *moqConverterer_mock { return m.moq } -func (m *moqConverterer_mock) BaseDecls() (baseDecls []dst.Decl) { +func (m *moqConverterer_mock) BaseDecls() (baseDecls []dst.Decl, err error) { m.moq.scene.T.Helper() params := moqConverterer_BaseDecls_params{} var results *moqConverterer_BaseDecls_results @@ -787,14 +814,15 @@ func (m *moqConverterer_mock) BaseDecls() (baseDecls []dst.Decl) { if result.values != nil { baseDecls = result.values.baseDecls + err = result.values.err } if result.doReturnFn != nil { - baseDecls = result.doReturnFn() + baseDecls, err = result.doReturnFn() } return } -func (m *moqConverterer_mock) IsolationStruct(suffix string) (structDecl *dst.GenDecl) { +func (m *moqConverterer_mock) IsolationStruct(suffix string) (structDecl *dst.GenDecl, err error) { m.moq.scene.T.Helper() params := moqConverterer_IsolationStruct_params{ suffix: suffix, @@ -840,9 +868,10 @@ func (m *moqConverterer_mock) IsolationStruct(suffix string) (structDecl *dst.Ge if result.values != nil { structDecl = result.values.structDecl + err = result.values.err } if result.doReturnFn != nil { - structDecl = result.doReturnFn(suffix) + structDecl, err = result.doReturnFn(suffix) } return } @@ -901,7 +930,7 @@ func (m *moqConverterer_mock) MethodStructs(fn generator.Func) (structDecls []ds return } -func (m *moqConverterer_mock) NewFunc() (funcDecl *dst.FuncDecl) { +func (m *moqConverterer_mock) NewFunc() (funcDecl *dst.FuncDecl, err error) { m.moq.scene.T.Helper() params := moqConverterer_NewFunc_params{} var results *moqConverterer_NewFunc_results @@ -945,14 +974,15 @@ func (m *moqConverterer_mock) NewFunc() (funcDecl *dst.FuncDecl) { if result.values != nil { funcDecl = result.values.funcDecl + err = result.values.err } if result.doReturnFn != nil { - funcDecl = result.doReturnFn() + funcDecl, err = result.doReturnFn() } return } -func (m *moqConverterer_mock) IsolationAccessor(suffix, fnName string) (funcDecl *dst.FuncDecl) { +func (m *moqConverterer_mock) IsolationAccessor(suffix, fnName string) (funcDecl *dst.FuncDecl, err error) { m.moq.scene.T.Helper() params := moqConverterer_IsolationAccessor_params{ suffix: suffix, @@ -999,14 +1029,15 @@ func (m *moqConverterer_mock) IsolationAccessor(suffix, fnName string) (funcDecl if result.values != nil { funcDecl = result.values.funcDecl + err = result.values.err } if result.doReturnFn != nil { - funcDecl = result.doReturnFn(suffix, fnName) + funcDecl, err = result.doReturnFn(suffix, fnName) } return } -func (m *moqConverterer_mock) FuncClosure(fn generator.Func) (funcDecl *dst.FuncDecl) { +func (m *moqConverterer_mock) FuncClosure(fn generator.Func) (funcDecl *dst.FuncDecl, err error) { m.moq.scene.T.Helper() params := moqConverterer_FuncClosure_params{ fn: fn, @@ -1052,14 +1083,15 @@ func (m *moqConverterer_mock) FuncClosure(fn generator.Func) (funcDecl *dst.Func if result.values != nil { funcDecl = result.values.funcDecl + err = result.values.err } if result.doReturnFn != nil { - funcDecl = result.doReturnFn(fn) + funcDecl, err = result.doReturnFn(fn) } return } -func (m *moqConverterer_mock) MockMethod(fn generator.Func) (funcDecl *dst.FuncDecl) { +func (m *moqConverterer_mock) MockMethod(fn generator.Func) (funcDecl *dst.FuncDecl, err error) { m.moq.scene.T.Helper() params := moqConverterer_MockMethod_params{ fn: fn, @@ -1105,14 +1137,15 @@ func (m *moqConverterer_mock) MockMethod(fn generator.Func) (funcDecl *dst.FuncD if result.values != nil { funcDecl = result.values.funcDecl + err = result.values.err } if result.doReturnFn != nil { - funcDecl = result.doReturnFn(fn) + funcDecl, err = result.doReturnFn(fn) } return } -func (m *moqConverterer_mock) RecorderMethods(fn generator.Func) (funcDecls []dst.Decl) { +func (m *moqConverterer_mock) RecorderMethods(fn generator.Func) (funcDecls []dst.Decl, err error) { m.moq.scene.T.Helper() params := moqConverterer_RecorderMethods_params{ fn: fn, @@ -1158,14 +1191,15 @@ func (m *moqConverterer_mock) RecorderMethods(fn generator.Func) (funcDecls []ds if result.values != nil { funcDecls = result.values.funcDecls + err = result.values.err } if result.doReturnFn != nil { - funcDecls = result.doReturnFn(fn) + funcDecls, err = result.doReturnFn(fn) } return } -func (m *moqConverterer_mock) ResetMethod() (funcDecl *dst.FuncDecl) { +func (m *moqConverterer_mock) ResetMethod() (funcDecl *dst.FuncDecl, err error) { m.moq.scene.T.Helper() params := moqConverterer_ResetMethod_params{} var results *moqConverterer_ResetMethod_results @@ -1209,14 +1243,15 @@ func (m *moqConverterer_mock) ResetMethod() (funcDecl *dst.FuncDecl) { if result.values != nil { funcDecl = result.values.funcDecl + err = result.values.err } if result.doReturnFn != nil { - funcDecl = result.doReturnFn() + funcDecl, err = result.doReturnFn() } return } -func (m *moqConverterer_mock) AssertMethod() (funcDecl *dst.FuncDecl) { +func (m *moqConverterer_mock) AssertMethod() (funcDecl *dst.FuncDecl, err error) { m.moq.scene.T.Helper() params := moqConverterer_AssertMethod_params{} var results *moqConverterer_AssertMethod_results @@ -1260,9 +1295,10 @@ func (m *moqConverterer_mock) AssertMethod() (funcDecl *dst.FuncDecl) { if result.values != nil { funcDecl = result.values.funcDecl + err = result.values.err } if result.doReturnFn != nil { - funcDecl = result.doReturnFn() + funcDecl, err = result.doReturnFn() } return } @@ -1311,7 +1347,7 @@ func (r *moqConverterer_BaseDecls_fnRecorder) noSeq() *moqConverterer_BaseDecls_ return r } -func (r *moqConverterer_BaseDecls_fnRecorder) returnResults(baseDecls []dst.Decl) *moqConverterer_BaseDecls_fnRecorder { +func (r *moqConverterer_BaseDecls_fnRecorder) returnResults(baseDecls []dst.Decl, err error) *moqConverterer_BaseDecls_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -1321,13 +1357,20 @@ func (r *moqConverterer_BaseDecls_fnRecorder) returnResults(baseDecls []dst.Decl } r.results.results = append(r.results.results, struct { - values *struct{ baseDecls []dst.Decl } + values *struct { + baseDecls []dst.Decl + err error + } sequence uint32 doFn moqConverterer_BaseDecls_doFn doReturnFn moqConverterer_BaseDecls_doReturnFn }{ - values: &struct{ baseDecls []dst.Decl }{ + values: &struct { + baseDecls []dst.Decl + err error + }{ baseDecls: baseDecls, + err: err, }, sequence: sequence, }) @@ -1355,7 +1398,10 @@ func (r *moqConverterer_BaseDecls_fnRecorder) doReturnResults(fn moqConverterer_ } r.results.results = append(r.results.results, struct { - values *struct{ baseDecls []dst.Decl } + values *struct { + baseDecls []dst.Decl + err error + } sequence uint32 doFn moqConverterer_BaseDecls_doFn doReturnFn moqConverterer_BaseDecls_doReturnFn @@ -1423,7 +1469,10 @@ func (r *moqConverterer_BaseDecls_fnRecorder) repeat(repeaters ...moq.Repeater) for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{ baseDecls []dst.Decl } + values *struct { + baseDecls []dst.Decl + err error + } sequence uint32 doFn moqConverterer_BaseDecls_doFn doReturnFn moqConverterer_BaseDecls_doReturnFn @@ -1493,7 +1542,7 @@ func (r *moqConverterer_IsolationStruct_fnRecorder) noSeq() *moqConverterer_Isol return r } -func (r *moqConverterer_IsolationStruct_fnRecorder) returnResults(structDecl *dst.GenDecl) *moqConverterer_IsolationStruct_fnRecorder { +func (r *moqConverterer_IsolationStruct_fnRecorder) returnResults(structDecl *dst.GenDecl, err error) *moqConverterer_IsolationStruct_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -1503,13 +1552,20 @@ func (r *moqConverterer_IsolationStruct_fnRecorder) returnResults(structDecl *ds } r.results.results = append(r.results.results, struct { - values *struct{ structDecl *dst.GenDecl } + values *struct { + structDecl *dst.GenDecl + err error + } sequence uint32 doFn moqConverterer_IsolationStruct_doFn doReturnFn moqConverterer_IsolationStruct_doReturnFn }{ - values: &struct{ structDecl *dst.GenDecl }{ + values: &struct { + structDecl *dst.GenDecl + err error + }{ structDecl: structDecl, + err: err, }, sequence: sequence, }) @@ -1537,7 +1593,10 @@ func (r *moqConverterer_IsolationStruct_fnRecorder) doReturnResults(fn moqConver } r.results.results = append(r.results.results, struct { - values *struct{ structDecl *dst.GenDecl } + values *struct { + structDecl *dst.GenDecl + err error + } sequence uint32 doFn moqConverterer_IsolationStruct_doFn doReturnFn moqConverterer_IsolationStruct_doReturnFn @@ -1605,7 +1664,10 @@ func (r *moqConverterer_IsolationStruct_fnRecorder) repeat(repeaters ...moq.Repe for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{ structDecl *dst.GenDecl } + values *struct { + structDecl *dst.GenDecl + err error + } sequence uint32 doFn moqConverterer_IsolationStruct_doFn doReturnFn moqConverterer_IsolationStruct_doReturnFn @@ -1889,7 +1951,7 @@ func (r *moqConverterer_NewFunc_fnRecorder) noSeq() *moqConverterer_NewFunc_fnRe return r } -func (r *moqConverterer_NewFunc_fnRecorder) returnResults(funcDecl *dst.FuncDecl) *moqConverterer_NewFunc_fnRecorder { +func (r *moqConverterer_NewFunc_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_NewFunc_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -1899,13 +1961,20 @@ func (r *moqConverterer_NewFunc_fnRecorder) returnResults(funcDecl *dst.FuncDecl } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_NewFunc_doFn doReturnFn moqConverterer_NewFunc_doReturnFn }{ - values: &struct{ funcDecl *dst.FuncDecl }{ + values: &struct { + funcDecl *dst.FuncDecl + err error + }{ funcDecl: funcDecl, + err: err, }, sequence: sequence, }) @@ -1933,7 +2002,10 @@ func (r *moqConverterer_NewFunc_fnRecorder) doReturnResults(fn moqConverterer_Ne } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_NewFunc_doFn doReturnFn moqConverterer_NewFunc_doReturnFn @@ -2001,7 +2073,10 @@ func (r *moqConverterer_NewFunc_fnRecorder) repeat(repeaters ...moq.Repeater) *m for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_NewFunc_doFn doReturnFn moqConverterer_NewFunc_doReturnFn @@ -2077,7 +2152,7 @@ func (r *moqConverterer_IsolationAccessor_fnRecorder) noSeq() *moqConverterer_Is return r } -func (r *moqConverterer_IsolationAccessor_fnRecorder) returnResults(funcDecl *dst.FuncDecl) *moqConverterer_IsolationAccessor_fnRecorder { +func (r *moqConverterer_IsolationAccessor_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_IsolationAccessor_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -2087,13 +2162,20 @@ func (r *moqConverterer_IsolationAccessor_fnRecorder) returnResults(funcDecl *ds } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_IsolationAccessor_doFn doReturnFn moqConverterer_IsolationAccessor_doReturnFn }{ - values: &struct{ funcDecl *dst.FuncDecl }{ + values: &struct { + funcDecl *dst.FuncDecl + err error + }{ funcDecl: funcDecl, + err: err, }, sequence: sequence, }) @@ -2121,7 +2203,10 @@ func (r *moqConverterer_IsolationAccessor_fnRecorder) doReturnResults(fn moqConv } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_IsolationAccessor_doFn doReturnFn moqConverterer_IsolationAccessor_doReturnFn @@ -2189,7 +2274,10 @@ func (r *moqConverterer_IsolationAccessor_fnRecorder) repeat(repeaters ...moq.Re for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_IsolationAccessor_doFn doReturnFn moqConverterer_IsolationAccessor_doReturnFn @@ -2283,7 +2371,7 @@ func (r *moqConverterer_FuncClosure_fnRecorder) noSeq() *moqConverterer_FuncClos return r } -func (r *moqConverterer_FuncClosure_fnRecorder) returnResults(funcDecl *dst.FuncDecl) *moqConverterer_FuncClosure_fnRecorder { +func (r *moqConverterer_FuncClosure_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_FuncClosure_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -2293,13 +2381,20 @@ func (r *moqConverterer_FuncClosure_fnRecorder) returnResults(funcDecl *dst.Func } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_FuncClosure_doFn doReturnFn moqConverterer_FuncClosure_doReturnFn }{ - values: &struct{ funcDecl *dst.FuncDecl }{ + values: &struct { + funcDecl *dst.FuncDecl + err error + }{ funcDecl: funcDecl, + err: err, }, sequence: sequence, }) @@ -2327,7 +2422,10 @@ func (r *moqConverterer_FuncClosure_fnRecorder) doReturnResults(fn moqConvertere } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_FuncClosure_doFn doReturnFn moqConverterer_FuncClosure_doReturnFn @@ -2395,7 +2493,10 @@ func (r *moqConverterer_FuncClosure_fnRecorder) repeat(repeaters ...moq.Repeater for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_FuncClosure_doFn doReturnFn moqConverterer_FuncClosure_doReturnFn @@ -2478,7 +2579,7 @@ func (r *moqConverterer_MockMethod_fnRecorder) noSeq() *moqConverterer_MockMetho return r } -func (r *moqConverterer_MockMethod_fnRecorder) returnResults(funcDecl *dst.FuncDecl) *moqConverterer_MockMethod_fnRecorder { +func (r *moqConverterer_MockMethod_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_MockMethod_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -2488,13 +2589,20 @@ func (r *moqConverterer_MockMethod_fnRecorder) returnResults(funcDecl *dst.FuncD } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_MockMethod_doFn doReturnFn moqConverterer_MockMethod_doReturnFn }{ - values: &struct{ funcDecl *dst.FuncDecl }{ + values: &struct { + funcDecl *dst.FuncDecl + err error + }{ funcDecl: funcDecl, + err: err, }, sequence: sequence, }) @@ -2522,7 +2630,10 @@ func (r *moqConverterer_MockMethod_fnRecorder) doReturnResults(fn moqConverterer } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_MockMethod_doFn doReturnFn moqConverterer_MockMethod_doReturnFn @@ -2590,7 +2701,10 @@ func (r *moqConverterer_MockMethod_fnRecorder) repeat(repeaters ...moq.Repeater) for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_MockMethod_doFn doReturnFn moqConverterer_MockMethod_doReturnFn @@ -2673,7 +2787,7 @@ func (r *moqConverterer_RecorderMethods_fnRecorder) noSeq() *moqConverterer_Reco return r } -func (r *moqConverterer_RecorderMethods_fnRecorder) returnResults(funcDecls []dst.Decl) *moqConverterer_RecorderMethods_fnRecorder { +func (r *moqConverterer_RecorderMethods_fnRecorder) returnResults(funcDecls []dst.Decl, err error) *moqConverterer_RecorderMethods_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -2683,13 +2797,20 @@ func (r *moqConverterer_RecorderMethods_fnRecorder) returnResults(funcDecls []ds } r.results.results = append(r.results.results, struct { - values *struct{ funcDecls []dst.Decl } + values *struct { + funcDecls []dst.Decl + err error + } sequence uint32 doFn moqConverterer_RecorderMethods_doFn doReturnFn moqConverterer_RecorderMethods_doReturnFn }{ - values: &struct{ funcDecls []dst.Decl }{ + values: &struct { + funcDecls []dst.Decl + err error + }{ funcDecls: funcDecls, + err: err, }, sequence: sequence, }) @@ -2717,7 +2838,10 @@ func (r *moqConverterer_RecorderMethods_fnRecorder) doReturnResults(fn moqConver } r.results.results = append(r.results.results, struct { - values *struct{ funcDecls []dst.Decl } + values *struct { + funcDecls []dst.Decl + err error + } sequence uint32 doFn moqConverterer_RecorderMethods_doFn doReturnFn moqConverterer_RecorderMethods_doReturnFn @@ -2785,7 +2909,10 @@ func (r *moqConverterer_RecorderMethods_fnRecorder) repeat(repeaters ...moq.Repe for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{ funcDecls []dst.Decl } + values *struct { + funcDecls []dst.Decl + err error + } sequence uint32 doFn moqConverterer_RecorderMethods_doFn doReturnFn moqConverterer_RecorderMethods_doReturnFn @@ -2861,7 +2988,7 @@ func (r *moqConverterer_ResetMethod_fnRecorder) noSeq() *moqConverterer_ResetMet return r } -func (r *moqConverterer_ResetMethod_fnRecorder) returnResults(funcDecl *dst.FuncDecl) *moqConverterer_ResetMethod_fnRecorder { +func (r *moqConverterer_ResetMethod_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_ResetMethod_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -2871,13 +2998,20 @@ func (r *moqConverterer_ResetMethod_fnRecorder) returnResults(funcDecl *dst.Func } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_ResetMethod_doFn doReturnFn moqConverterer_ResetMethod_doReturnFn }{ - values: &struct{ funcDecl *dst.FuncDecl }{ + values: &struct { + funcDecl *dst.FuncDecl + err error + }{ funcDecl: funcDecl, + err: err, }, sequence: sequence, }) @@ -2905,7 +3039,10 @@ func (r *moqConverterer_ResetMethod_fnRecorder) doReturnResults(fn moqConvertere } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_ResetMethod_doFn doReturnFn moqConverterer_ResetMethod_doReturnFn @@ -2973,7 +3110,10 @@ func (r *moqConverterer_ResetMethod_fnRecorder) repeat(repeaters ...moq.Repeater for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_ResetMethod_doFn doReturnFn moqConverterer_ResetMethod_doReturnFn @@ -3036,7 +3176,7 @@ func (r *moqConverterer_AssertMethod_fnRecorder) noSeq() *moqConverterer_AssertM return r } -func (r *moqConverterer_AssertMethod_fnRecorder) returnResults(funcDecl *dst.FuncDecl) *moqConverterer_AssertMethod_fnRecorder { +func (r *moqConverterer_AssertMethod_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_AssertMethod_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -3046,13 +3186,20 @@ func (r *moqConverterer_AssertMethod_fnRecorder) returnResults(funcDecl *dst.Fun } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_AssertMethod_doFn doReturnFn moqConverterer_AssertMethod_doReturnFn }{ - values: &struct{ funcDecl *dst.FuncDecl }{ + values: &struct { + funcDecl *dst.FuncDecl + err error + }{ funcDecl: funcDecl, + err: err, }, sequence: sequence, }) @@ -3080,7 +3227,10 @@ func (r *moqConverterer_AssertMethod_fnRecorder) doReturnResults(fn moqConverter } r.results.results = append(r.results.results, struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_AssertMethod_doFn doReturnFn moqConverterer_AssertMethod_doReturnFn @@ -3148,7 +3298,10 @@ func (r *moqConverterer_AssertMethod_fnRecorder) repeat(repeaters ...moq.Repeate for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{ funcDecl *dst.FuncDecl } + values *struct { + funcDecl *dst.FuncDecl + err error + } sequence uint32 doFn moqConverterer_AssertMethod_doFn doReturnFn moqConverterer_AssertMethod_doReturnFn diff --git a/generator/moq_typecache_test.go b/generator/moq_typecache_test.go index 88e9c61..1f638d8 100644 --- a/generator/moq_typecache_test.go +++ b/generator/moq_typecache_test.go @@ -37,10 +37,12 @@ type moqTypeCache struct { testImport moq.ParamIndexing } IsComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } IsDefaultComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } FindPackage struct { dir moq.ParamIndexing @@ -128,13 +130,22 @@ type moqTypeCache_Type_anyParams struct { } // moqTypeCache_IsComparable_params holds the params of the TypeCache type -type moqTypeCache_IsComparable_params struct{ expr dst.Expr } +type moqTypeCache_IsComparable_params struct { + expr dst.Expr + parentType ast.TypeInfo +} // moqTypeCache_IsComparable_paramsKey holds the map key params of the // TypeCache type type moqTypeCache_IsComparable_paramsKey struct { - params struct{ expr dst.Expr } - hashes struct{ expr hash.Hash } + params struct { + expr dst.Expr + parentType ast.TypeInfo + } + hashes struct { + expr hash.Hash + parentType hash.Hash + } } // moqTypeCache_IsComparable_resultsByParams contains the results for a given @@ -147,11 +158,11 @@ type moqTypeCache_IsComparable_resultsByParams struct { // moqTypeCache_IsComparable_doFn defines the type of function needed when // calling andDo for the TypeCache type -type moqTypeCache_IsComparable_doFn func(expr dst.Expr) +type moqTypeCache_IsComparable_doFn func(expr dst.Expr, parentType ast.TypeInfo) // moqTypeCache_IsComparable_doReturnFn defines the type of function needed // when calling doReturnResults for the TypeCache type -type moqTypeCache_IsComparable_doReturnFn func(expr dst.Expr) (bool, error) +type moqTypeCache_IsComparable_doReturnFn func(expr dst.Expr, parentType ast.TypeInfo) (bool, error) // moqTypeCache_IsComparable_results holds the results of the TypeCache type type moqTypeCache_IsComparable_results struct { @@ -187,13 +198,22 @@ type moqTypeCache_IsComparable_anyParams struct { // moqTypeCache_IsDefaultComparable_params holds the params of the TypeCache // type -type moqTypeCache_IsDefaultComparable_params struct{ expr dst.Expr } +type moqTypeCache_IsDefaultComparable_params struct { + expr dst.Expr + parentType ast.TypeInfo +} // moqTypeCache_IsDefaultComparable_paramsKey holds the map key params of the // TypeCache type type moqTypeCache_IsDefaultComparable_paramsKey struct { - params struct{ expr dst.Expr } - hashes struct{ expr hash.Hash } + params struct { + expr dst.Expr + parentType ast.TypeInfo + } + hashes struct { + expr hash.Hash + parentType hash.Hash + } } // moqTypeCache_IsDefaultComparable_resultsByParams contains the results for a @@ -206,11 +226,11 @@ type moqTypeCache_IsDefaultComparable_resultsByParams struct { // moqTypeCache_IsDefaultComparable_doFn defines the type of function needed // when calling andDo for the TypeCache type -type moqTypeCache_IsDefaultComparable_doFn func(expr dst.Expr) +type moqTypeCache_IsDefaultComparable_doFn func(expr dst.Expr, parentType ast.TypeInfo) // moqTypeCache_IsDefaultComparable_doReturnFn defines the type of function // needed when calling doReturnResults for the TypeCache type -type moqTypeCache_IsDefaultComparable_doReturnFn func(expr dst.Expr) (bool, error) +type moqTypeCache_IsDefaultComparable_doReturnFn func(expr dst.Expr, parentType ast.TypeInfo) (bool, error) // moqTypeCache_IsDefaultComparable_results holds the results of the TypeCache // type @@ -321,10 +341,12 @@ func newMoqTypeCache(scene *moq.Scene, config *moq.Config) *moqTypeCache { testImport moq.ParamIndexing } IsComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } IsDefaultComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } FindPackage struct { dir moq.ParamIndexing @@ -337,10 +359,12 @@ func newMoqTypeCache(scene *moq.Scene, config *moq.Config) *moqTypeCache { testImport moq.ParamIndexing } IsComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } IsDefaultComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } FindPackage struct { dir moq.ParamIndexing @@ -356,14 +380,18 @@ func newMoqTypeCache(scene *moq.Scene, config *moq.Config) *moqTypeCache { testImport: moq.ParamIndexByValue, }, IsComparable: struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing }{ - expr: moq.ParamIndexByHash, + expr: moq.ParamIndexByHash, + parentType: moq.ParamIndexByHash, }, IsDefaultComparable: struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing }{ - expr: moq.ParamIndexByHash, + expr: moq.ParamIndexByHash, + parentType: moq.ParamIndexByHash, }, FindPackage: struct { dir moq.ParamIndexing @@ -437,10 +465,11 @@ func (m *moqTypeCache_mock) Type(id dst.Ident, contextPkg string, testImport boo return } -func (m *moqTypeCache_mock) IsComparable(expr dst.Expr) (result1 bool, result2 error) { +func (m *moqTypeCache_mock) IsComparable(expr dst.Expr, parentType ast.TypeInfo) (result1 bool, result2 error) { m.moq.scene.T.Helper() params := moqTypeCache_IsComparable_params{ - expr: expr, + expr: expr, + parentType: parentType, } var results *moqTypeCache_IsComparable_results for _, resultsByParams := range m.moq.resultsByParams_IsComparable { @@ -478,7 +507,7 @@ func (m *moqTypeCache_mock) IsComparable(expr dst.Expr) (result1 bool, result2 e } if result.doFn != nil { - result.doFn(expr) + result.doFn(expr, parentType) } if result.values != nil { @@ -486,15 +515,16 @@ func (m *moqTypeCache_mock) IsComparable(expr dst.Expr) (result1 bool, result2 e result2 = result.values.result2 } if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(expr) + result1, result2 = result.doReturnFn(expr, parentType) } return } -func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr) (result1 bool, result2 error) { +func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) (result1 bool, result2 error) { m.moq.scene.T.Helper() params := moqTypeCache_IsDefaultComparable_params{ - expr: expr, + expr: expr, + parentType: parentType, } var results *moqTypeCache_IsDefaultComparable_results for _, resultsByParams := range m.moq.resultsByParams_IsDefaultComparable { @@ -532,7 +562,7 @@ func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr) (result1 bool, re } if result.doFn != nil { - result.doFn(expr) + result.doFn(expr, parentType) } if result.values != nil { @@ -540,7 +570,7 @@ func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr) (result1 bool, re result2 = result.values.result2 } if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(expr) + result1, result2 = result.doReturnFn(expr, parentType) } return } @@ -852,10 +882,11 @@ func (m *moqTypeCache) paramsKey_Type(params moqTypeCache_Type_params, anyParams } } -func (m *moqTypeCache_recorder) IsComparable(expr dst.Expr) *moqTypeCache_IsComparable_fnRecorder { +func (m *moqTypeCache_recorder) IsComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsComparable_fnRecorder { return &moqTypeCache_IsComparable_fnRecorder{ params: moqTypeCache_IsComparable_params{ - expr: expr, + expr: expr, + parentType: parentType, }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, @@ -876,6 +907,11 @@ func (a *moqTypeCache_IsComparable_anyParams) expr() *moqTypeCache_IsComparable_ return a.recorder } +func (a *moqTypeCache_IsComparable_anyParams) parentType() *moqTypeCache_IsComparable_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + func (r *moqTypeCache_IsComparable_fnRecorder) seq() *moqTypeCache_IsComparable_fnRecorder { r.moq.scene.T.Helper() if r.results != nil { @@ -1036,7 +1072,7 @@ func (r *moqTypeCache_IsComparable_fnRecorder) repeat(repeaters ...moq.Repeater) } func (m *moqTypeCache) prettyParams_IsComparable(params moqTypeCache_IsComparable_params) string { - return fmt.Sprintf("IsComparable(%#v)", params.expr) + return fmt.Sprintf("IsComparable(%#v, %#v)", params.expr, params.parentType) } func (m *moqTypeCache) paramsKey_IsComparable(params moqTypeCache_IsComparable_params, anyParams uint64) moqTypeCache_IsComparable_paramsKey { @@ -1050,20 +1086,38 @@ func (m *moqTypeCache) paramsKey_IsComparable(params moqTypeCache_IsComparable_p exprUsedHash = hash.DeepHash(params.expr) } } + var parentTypeUsed ast.TypeInfo + var parentTypeUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.IsComparable.parentType == moq.ParamIndexByValue { + parentTypeUsed = params.parentType + } else { + parentTypeUsedHash = hash.DeepHash(params.parentType) + } + } return moqTypeCache_IsComparable_paramsKey{ - params: struct{ expr dst.Expr }{ - expr: exprUsed, + params: struct { + expr dst.Expr + parentType ast.TypeInfo + }{ + expr: exprUsed, + parentType: parentTypeUsed, }, - hashes: struct{ expr hash.Hash }{ - expr: exprUsedHash, + hashes: struct { + expr hash.Hash + parentType hash.Hash + }{ + expr: exprUsedHash, + parentType: parentTypeUsedHash, }, } } -func (m *moqTypeCache_recorder) IsDefaultComparable(expr dst.Expr) *moqTypeCache_IsDefaultComparable_fnRecorder { +func (m *moqTypeCache_recorder) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsDefaultComparable_fnRecorder { return &moqTypeCache_IsDefaultComparable_fnRecorder{ params: moqTypeCache_IsDefaultComparable_params{ - expr: expr, + expr: expr, + parentType: parentType, }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, @@ -1084,6 +1138,11 @@ func (a *moqTypeCache_IsDefaultComparable_anyParams) expr() *moqTypeCache_IsDefa return a.recorder } +func (a *moqTypeCache_IsDefaultComparable_anyParams) parentType() *moqTypeCache_IsDefaultComparable_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + func (r *moqTypeCache_IsDefaultComparable_fnRecorder) seq() *moqTypeCache_IsDefaultComparable_fnRecorder { r.moq.scene.T.Helper() if r.results != nil { @@ -1244,7 +1303,7 @@ func (r *moqTypeCache_IsDefaultComparable_fnRecorder) repeat(repeaters ...moq.Re } func (m *moqTypeCache) prettyParams_IsDefaultComparable(params moqTypeCache_IsDefaultComparable_params) string { - return fmt.Sprintf("IsDefaultComparable(%#v)", params.expr) + return fmt.Sprintf("IsDefaultComparable(%#v, %#v)", params.expr, params.parentType) } func (m *moqTypeCache) paramsKey_IsDefaultComparable(params moqTypeCache_IsDefaultComparable_params, anyParams uint64) moqTypeCache_IsDefaultComparable_paramsKey { @@ -1258,12 +1317,29 @@ func (m *moqTypeCache) paramsKey_IsDefaultComparable(params moqTypeCache_IsDefau exprUsedHash = hash.DeepHash(params.expr) } } + var parentTypeUsed ast.TypeInfo + var parentTypeUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.IsDefaultComparable.parentType == moq.ParamIndexByValue { + parentTypeUsed = params.parentType + } else { + parentTypeUsedHash = hash.DeepHash(params.parentType) + } + } return moqTypeCache_IsDefaultComparable_paramsKey{ - params: struct{ expr dst.Expr }{ - expr: exprUsed, + params: struct { + expr dst.Expr + parentType ast.TypeInfo + }{ + expr: exprUsed, + parentType: parentTypeUsed, }, - hashes: struct{ expr hash.Hash }{ - expr: exprUsedHash, + hashes: struct { + expr hash.Hash + parentType hash.Hash + }{ + expr: exprUsedHash, + parentType: parentTypeUsedHash, }, } } diff --git a/generator/moqgen.go b/generator/moqgen.go index ea0ad45..e9496b2 100644 --- a/generator/moqgen.go +++ b/generator/moqgen.go @@ -51,16 +51,16 @@ type NewConverterFunc func(typ Type, export bool) Converterer // Converterer is the interface used by MoqGenerator to invoke a Converter type Converterer interface { - BaseDecls() (baseDecls []dst.Decl) - IsolationStruct(suffix string) (structDecl *dst.GenDecl) + BaseDecls() (baseDecls []dst.Decl, err error) + IsolationStruct(suffix string) (structDecl *dst.GenDecl, err error) MethodStructs(fn Func) (structDecls []dst.Decl, err error) - NewFunc() (funcDecl *dst.FuncDecl) - IsolationAccessor(suffix, fnName string) (funcDecl *dst.FuncDecl) - FuncClosure(fn Func) (funcDecl *dst.FuncDecl) - MockMethod(fn Func) (funcDecl *dst.FuncDecl) - RecorderMethods(fn Func) (funcDecls []dst.Decl) - ResetMethod() (funcDecl *dst.FuncDecl) - AssertMethod() (funcDecl *dst.FuncDecl) + NewFunc() (funcDecl *dst.FuncDecl, err error) + IsolationAccessor(suffix, fnName string) (funcDecl *dst.FuncDecl, err error) + FuncClosure(fn Func) (funcDecl *dst.FuncDecl, err error) + MockMethod(fn Func) (funcDecl *dst.FuncDecl, err error) + RecorderMethods(fn Func) (funcDecls []dst.Decl, err error) + ResetMethod() (funcDecl *dst.FuncDecl, err error) + AssertMethod() (funcDecl *dst.FuncDecl, err error) } // MoqGenerator generates moqs @@ -123,7 +123,7 @@ func (g *MoqGenerator) Generate(req GenerateRequest) (MoqResponse, error) { } fInfo := &funcInfo{excludeNonExported: req.ExcludeNonExported, fabricated: typeInfo.Fabricated} - tErr := g.findFuncs(typeInfo.Type, fInfo) + tErr := g.findFuncs(typeInfo, fInfo) if tErr != nil { return MoqResponse{}, tErr } @@ -153,13 +153,29 @@ func (g *MoqGenerator) Generate(req GenerateRequest) (MoqResponse, error) { } decls = append(decls, structs...) - decls = append(decls, converter.NewFunc()) + decl, err := converter.NewFunc() + if err != nil { + return MoqResponse{}, err + } + decls = append(decls, decl) - decls = append(decls, g.methods(converter, typ, fInfo.funcs)...) + meths, err := g.methods(converter, typ, fInfo.funcs) + if err != nil { + return MoqResponse{}, err + } + decls = append(decls, meths...) - decls = append(decls, converter.ResetMethod()) + decl, err = converter.ResetMethod() + if err != nil { + return MoqResponse{}, err + } + decls = append(decls, decl) - decls = append(decls, converter.AssertMethod()) + decl, err = converter.AssertMethod() + if err != nil { + return MoqResponse{}, err + } + decls = append(decls, decl) } file.Decls = decls @@ -200,6 +216,7 @@ func (g *MoqGenerator) outPackagePath(req GenerateRequest, relPath string) (stri destDir = filepath.Join(destDir, req.Destination) } if strings.HasSuffix(destDir, ".go") { + // TODO: maybe should be more definitive as in always call filepath.Dir if Destination is defined destDir = filepath.Dir(destDir) } outPkgPath, err := g.typeCache.FindPackage(destDir) @@ -208,6 +225,13 @@ func (g *MoqGenerator) outPackagePath(req GenerateRequest, relPath string) (stri } if req.Package == "" || req.Package == "." { if !req.Export { + // TODO: Just because the package wasn't specified and the mock + // isn't going to be exported, we assume the mock is going in + // the test package? What if someone is putting their tests in + // the regular package? Maybe they should specify the package + // instead of leaving it blank and maybe this is a non-issue. + // Make sure this is documented properly at least (and maybe + // leave an explanatory comment here in place of this TODO). outPkgPath += testPkgSuffix } } else { @@ -290,31 +314,28 @@ type funcInfo struct { fabricated bool } -func (g *MoqGenerator) findFuncs(typeSpec *dst.TypeSpec, fInfo *funcInfo) error { - switch typ := typeSpec.Type.(type) { +func (g *MoqGenerator) findFuncs(typeInfo ast.TypeInfo, fInfo *funcInfo) error { + switch typ := typeInfo.Type.Type.(type) { case *dst.InterfaceType: - return g.loadNestedInterfaces(typ, typeSpec.Name.Path, fInfo) + return g.loadNestedInterfaces(typ, typeInfo.PkgPath, fInfo) case *dst.FuncType: - fn := Func{ - Params: typ.Params, - Results: typ.Results, - } - fully, err := g.isFnFullyExported(fn, typeSpec.Name.Path) + fn := Func{FuncType: typ} + fully, err := g.isFnFullyExported(fn, typeInfo.PkgPath) if err != nil { return err } if fInfo.excludeNonExported && !fully { - return fmt.Errorf("%w: %s mocked type is not exported", - ErrNonExported, typeSpec.Name.String()) + return fmt.Errorf("%w: %s (%s) mocked type is not exported", + ErrNonExported, typeInfo.Type.Name.String(), typeInfo.PkgPath) } fInfo.funcs = append(fInfo.funcs, fn) return nil case *dst.Ident: - return g.loadTypeEquivalent(typ, typeSpec.Name.Path, fInfo) + return g.loadTypeEquivalent(typ, typeInfo.PkgPath, fInfo) default: - logs.Panicf("Unknown type: %v", typeSpec.Type) + logs.Panicf("Unknown type: %v", typeInfo) panic("unreachable") } } @@ -331,9 +352,8 @@ func (g *MoqGenerator) loadNestedInterfaces(iType *dst.InterfaceType, contextPkg } fn := Func{ - Name: name, - Params: typ.Params, - Results: typ.Results, + Name: name, + FuncType: typ, } if fInfo.excludeNonExported { @@ -379,7 +399,7 @@ func (g *MoqGenerator) loadTypeEquivalent(id *dst.Ident, contextPkg string, fInf return nil } - err = g.findFuncs(nestedType.Type, fInfo) + err = g.findFuncs(nestedType, fInfo) if err != nil { return err } @@ -392,11 +412,11 @@ func (g *MoqGenerator) isFnFullyExported(fn Func, contextPkg string) (bool, erro return false, nil } - ex, err := g.isFieldListFullyExported(fn.Params, contextPkg) + ex, err := g.isFieldListFullyExported(fn.FuncType.Params, contextPkg) if err != nil || !ex { return ex, err } - ex, err = g.isFieldListFullyExported(fn.Results, contextPkg) + ex, err = g.isFieldListFullyExported(fn.FuncType.Results, contextPkg) if err != nil || !ex { return ex, err } @@ -467,13 +487,24 @@ func (g *MoqGenerator) isExprFullyExported(expr dst.Expr, contextPkg string) (bo } func (g *MoqGenerator) structs(converter Converterer, typ Type) ([]dst.Decl, error) { - decls := converter.BaseDecls() - decls = append(decls, converter.IsolationStruct(mockIdent)) + decls, err := converter.BaseDecls() + if err != nil { + return nil, err + } + mockIsolStruct, err := converter.IsolationStruct(mockIdent) + if err != nil { + return nil, err + } + decls = append(decls, mockIsolStruct) _, iOk := typ.TypeInfo.Type.Type.(*dst.InterfaceType) _, aOk := typ.TypeInfo.Type.Type.(*dst.Ident) if iOk || aOk { - decls = append(decls, converter.IsolationStruct(recorderIdent)) + recIsolStruct, err := converter.IsolationStruct(recorderIdent) + if err != nil { + return nil, err + } + decls = append(decls, recIsolStruct) } for _, fn := range typ.Funcs { @@ -489,23 +520,37 @@ func (g *MoqGenerator) structs(converter Converterer, typ Type) ([]dst.Decl, err func (g *MoqGenerator) methods( converter Converterer, typ Type, funcs []Func, -) []dst.Decl { +) ([]dst.Decl, error) { var decls []dst.Decl switch typ.TypeInfo.Type.Type.(type) { case *dst.InterfaceType, *dst.Ident: - decls = append( - decls, converter.IsolationAccessor(mockIdent, mockFnName)) + decl, err := converter.IsolationAccessor(mockIdent, mockFnName) + if err != nil { + return nil, err + } + decls = append(decls, decl) for _, fn := range funcs { - decls = append(decls, converter.MockMethod(fn)) + meth, err := converter.MockMethod(fn) + if err != nil { + return nil, err + } + decls = append(decls, meth) } - decls = append( - decls, converter.IsolationAccessor(recorderIdent, onCallFnName)) + decl, err = converter.IsolationAccessor(recorderIdent, onCallFnName) + if err != nil { + return nil, err + } + decls = append(decls, decl) for _, fn := range funcs { - decls = append(decls, converter.RecorderMethods(fn)...) + meths, err := converter.RecorderMethods(fn) + if err != nil { + return nil, err + } + decls = append(decls, meths...) } case *dst.FuncType: if len(funcs) != 1 { @@ -513,17 +558,26 @@ func (g *MoqGenerator) methods( len(funcs)) } - decls = append( - decls, converter.FuncClosure(funcs[0])) + fnClos, err := converter.FuncClosure(funcs[0]) + if err != nil { + return nil, err + } + decls = append(decls, fnClos) - decls = append( - decls, converter.MockMethod(funcs[0])) + meth, err := converter.MockMethod(funcs[0]) + if err != nil { + return nil, err + } + decls = append(decls, meth) - decls = append( - decls, converter.RecorderMethods(funcs[0])...) + meths, err := converter.RecorderMethods(funcs[0]) + if err != nil { + return nil, err + } + decls = append(decls, meths...) default: logs.Panicf("Unknown type: %v", typ.TypeInfo.Type.Type) } - return decls + return decls, nil } diff --git a/generator/moqgen_test.go b/generator/moqgen_test.go index 89473a3..eafe84f 100644 --- a/generator/moqgen_test.go +++ b/generator/moqgen_test.go @@ -2,6 +2,7 @@ package generator_test import ( "errors" + "fmt" "testing" "github.com/dave/dst" @@ -48,7 +49,15 @@ func TestMoqGenerator(t *testing.T) { getwdFnMoq = newMoqGetwdFunc(scene, nil) newConverterFnMoq = newMoqNewConverterFunc(scene, nil) converter1Moq = newMoqConverterer(scene, nil) + converter1Moq.runtime.parameterIndexing.MethodStructs.fn = moq.ParamIndexByHash + converter1Moq.runtime.parameterIndexing.MockMethod.fn = moq.ParamIndexByHash + converter1Moq.runtime.parameterIndexing.RecorderMethods.fn = moq.ParamIndexByHash + converter1Moq.runtime.parameterIndexing.FuncClosure.fn = moq.ParamIndexByHash converter2Moq = newMoqConverterer(scene, nil) + converter2Moq.runtime.parameterIndexing.MethodStructs.fn = moq.ParamIndexByHash + converter2Moq.runtime.parameterIndexing.MockMethod.fn = moq.ParamIndexByHash + converter2Moq.runtime.parameterIndexing.RecorderMethods.fn = moq.ParamIndexByHash + converter2Moq.runtime.parameterIndexing.FuncClosure.fn = moq.ParamIndexByHash gen = generator.New( typeCacheMoq.mock(), @@ -505,18 +514,20 @@ func TestMoqGenerator(t *testing.T) { typeCacheMoq.onCall().Type( *ast.IdPath("privateInterface", genPkg), genPkg, false). returnResults(ifaceInfo2, nil) - typeCacheMoq.onCall().Type(*ast.IdPath("Reader", "io"), "", false). + typeCacheMoq.onCall().Type(*ast.IdPath("Reader", "io"), genPkg, false). returnResults(readerInfo, nil) typeCacheMoq.onCall().Type(*ast.IdPath("privateInterface", tc.typePath), tc.typePath, false). returnResults(ifaceInfo2, nil) - typeCacheMoq.onCall().Type(*ast.IdPath("Reader", "io"), "", false). + typeCacheMoq.onCall().Type(*ast.IdPath("Reader", "io"), genPkg, false). returnResults(readerInfo, nil) ifaceFuncs := []generator.Func{ - {Name: "Func1", Params: func1Params}, + {Name: "Func1", FuncType: &dst.FuncType{Params: func1Params}}, { - Name: "Read", - Params: readFnType.Params, - Results: readFnType.Results, + Name: "Read", + FuncType: &dst.FuncType{ + Params: readFnType.Params, + Results: readFnType.Results, + }, }, } newConverterFnMoq.onCall(generator.Type{ @@ -530,37 +541,39 @@ func TestMoqGenerator(t *testing.T) { }, tc.request.Export).returnResults(converter1Moq.mock()) converter1Moq.onCall().BaseDecls().returnResults([]dst.Decl{&dst.GenDecl{ Specs: []dst.Spec{&dst.TypeSpec{Name: dst.NewIdent("pub-decl")}}, - }}) + }}, nil) converter1Moq.onCall().IsolationStruct("mock"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationStruct("recorder"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().MethodStructs(ifaceFuncs[0]). returnResults(nil, nil) converter1Moq.onCall().MethodStructs(ifaceFuncs[1]). returnResults(nil, nil) converter1Moq.onCall().NewFunc(). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationAccessor("mock", "mock"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().MockMethod(ifaceFuncs[0]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().MockMethod(ifaceFuncs[1]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationAccessor("recorder", "onCall"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().RecorderMethods(ifaceFuncs[0]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().RecorderMethods(ifaceFuncs[1]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().ResetMethod(). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().AssertMethod(). - returnResults(nil) + returnResults(nil, nil) iface2Funcs := []generator.Func{{ - Name: "Read", - Params: readFnType.Params, - Results: readFnType.Results, + Name: "Read", + FuncType: &dst.FuncType{ + Params: readFnType.Params, + Results: readFnType.Results, + }, }} newConverterFnMoq.onCall(generator.Type{ TypeInfo: ast.TypeInfo{ @@ -570,27 +583,27 @@ func TestMoqGenerator(t *testing.T) { Funcs: iface2Funcs, OutPkgPath: tc.outPkgPath, }, tc.request.Export).returnResults(converter2Moq.mock()) - converter2Moq.onCall().BaseDecls().returnResults(nil) + converter2Moq.onCall().BaseDecls().returnResults(nil, nil) converter2Moq.onCall().IsolationStruct("mock"). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().IsolationStruct("recorder"). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().MethodStructs(iface2Funcs[0]). returnResults(nil, nil) converter2Moq.onCall().NewFunc(). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().IsolationAccessor("mock", "mock"). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().MockMethod(iface2Funcs[0]). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().IsolationAccessor("recorder", "onCall"). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().RecorderMethods(iface2Funcs[0]). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().ResetMethod(). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().AssertMethod(). - returnResults(nil) + returnResults(nil, nil) // ACT resp, err := gen.Generate(tc.request) @@ -682,7 +695,7 @@ func TestMoqGenerator(t *testing.T) { typeCacheMoq.onCall().Type(*ast.IdPath("string", ""), genPkg, false). returnResults(ast.TypeInfo{Exported: true}, nil) ifaceFuncs := []generator.Func{ - {Name: "Func1", Params: func1Params}, + {Name: "Func1", FuncType: &dst.FuncType{Params: func1Params}}, } // The method list is reduced back to normal by the time we create // the converter @@ -698,27 +711,27 @@ func TestMoqGenerator(t *testing.T) { }, true).returnResults(converter1Moq.mock()) converter1Moq.onCall().BaseDecls().returnResults([]dst.Decl{&dst.GenDecl{ Specs: []dst.Spec{&dst.TypeSpec{Name: dst.NewIdent("pub-decl")}}, - }}) + }}, nil) converter1Moq.onCall().IsolationStruct("mock"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationStruct("recorder"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().MethodStructs(ifaceFuncs[0]). returnResults(nil, nil) converter1Moq.onCall().NewFunc(). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationAccessor("mock", "mock"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().MockMethod(ifaceFuncs[0]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationAccessor("recorder", "onCall"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().RecorderMethods(ifaceFuncs[0]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().ResetMethod(). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().AssertMethod(). - returnResults(nil) + returnResults(nil, nil) req := generator.GenerateRequest{ Types: []string{"MyInterface"}, Export: true, @@ -1096,7 +1109,7 @@ func TestMoqGenerator(t *testing.T) { typeCacheMoq.onCall().Type(*ast.IdPath("MyFunc", "."), ".", false). returnResults(fnInfo, nil) - typeCacheMoq.onCall().Type(*ast.IdPath("string", ""), "", false). + typeCacheMoq.onCall().Type(*ast.IdPath("string", ""), genPkg, false). returnResults(ast.TypeInfo{Exported: false}, nil) req := generator.GenerateRequest{ Types: []string{"MyFunc"}, @@ -1116,7 +1129,8 @@ func TestMoqGenerator(t *testing.T) { if err == nil { t.Fatal("got no error, wanted error") } - expectedMsg := "non-exported types: PublicFn mocked type is not exported" + expectedMsg := fmt.Sprintf("non-exported types: PublicFn (%s) mocked type is not exported", + genPkg) if err.Error() != expectedMsg { t.Errorf("got %s, want %s", err.Error(), expectedMsg) } @@ -1153,14 +1167,16 @@ func TestMoqGenerator(t *testing.T) { typeCacheMoq.onCall().Type(*ast.IdPath("AliasType", "."), ".", false). returnResults(ifaceInfo, nil) - typeCacheMoq.onCall().Type(*ast.IdPath("Reader", "io"), "thatpkg", false). + typeCacheMoq.onCall().Type(*ast.IdPath("Reader", "io"), genPkg, false). returnResults(readerInfo, nil) ifaceFuncs := []generator.Func{ { - Name: "Read", - Params: readFnType.Params, - Results: readFnType.Results, + Name: "Read", + FuncType: &dst.FuncType{ + Params: readFnType.Params, + Results: readFnType.Results, + }, }, } newConverterFnMoq.onCall(generator.Type{ @@ -1171,27 +1187,27 @@ func TestMoqGenerator(t *testing.T) { Funcs: ifaceFuncs, OutPkgPath: "thispkg_test", }, false).returnResults(converter1Moq.mock()) - converter1Moq.onCall().BaseDecls().returnResults(nil) + converter1Moq.onCall().BaseDecls().returnResults(nil, nil) converter1Moq.onCall().IsolationStruct("mock"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationStruct("recorder"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().MethodStructs(ifaceFuncs[0]). returnResults(nil, nil) converter1Moq.onCall().NewFunc(). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationAccessor("mock", "mock"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().MockMethod(ifaceFuncs[0]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationAccessor("recorder", "onCall"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().RecorderMethods(ifaceFuncs[0]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().ResetMethod(). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().AssertMethod(). - returnResults(nil) + returnResults(nil, nil) req := generator.GenerateRequest{ Types: []string{"AliasType"}, @@ -1305,7 +1321,9 @@ func TestMoqGenerator(t *testing.T) { getwdFnMoq.onCall().returnResults("/some-nice-path", nil) typeCacheMoq.onCall().Type(*ast.IdPath("PublicInterface", "."), ".", false). returnResults(ifaceInfo1, nil) - ifaceFuncs := []generator.Func{{Name: "Func1", Params: func1Params}} + ifaceFuncs := []generator.Func{{ + Name: "Func1", FuncType: &dst.FuncType{Params: func1Params}, + }} newConverterFnMoq.onCall(generator.Type{ TypeInfo: ast.TypeInfo{ Type: ifaceInfo1.Type, @@ -1317,11 +1335,11 @@ func TestMoqGenerator(t *testing.T) { }, false).returnResults(converter1Moq.mock()) converter1Moq.onCall().BaseDecls().returnResults([]dst.Decl{&dst.GenDecl{ Specs: []dst.Spec{&dst.TypeSpec{Name: dst.NewIdent("pub-decl")}}, - }}) + }}, nil) converter1Moq.onCall().IsolationStruct("mock"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationStruct("recorder"). - returnResults(nil) + returnResults(nil, nil) expectedErr := errors.New("bad convertor") converter1Moq.onCall().MethodStructs(ifaceFuncs[0]). returnResults(nil, expectedErr) @@ -1366,7 +1384,9 @@ func TestMoqGenerator(t *testing.T) { typeCacheMoq.onCall().Type(*ast.IdPath("privateInterface", "."), ".", true). returnResults(ifaceInfo2, nil) - iface1Funcs := []generator.Func{{Name: "Func1", Params: func1Params}} + iface1Funcs := []generator.Func{{ + Name: "Func1", FuncType: &dst.FuncType{Params: func1Params}, + }} newConverterFnMoq.onCall(generator.Type{ TypeInfo: ast.TypeInfo{ Type: ifaceInfo1.Type, @@ -1376,27 +1396,27 @@ func TestMoqGenerator(t *testing.T) { Funcs: iface1Funcs, OutPkgPath: "thispkg_test", }, false).returnResults(converter1Moq.mock()) - converter1Moq.onCall().BaseDecls().returnResults(nil) + converter1Moq.onCall().BaseDecls().returnResults(nil, nil) converter1Moq.onCall().IsolationStruct("mock"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationStruct("recorder"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().MethodStructs(iface1Funcs[0]). returnResults(nil, nil) converter1Moq.onCall().NewFunc(). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationAccessor("mock", "mock"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().MockMethod(iface1Funcs[0]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().IsolationAccessor("recorder", "onCall"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().RecorderMethods(iface1Funcs[0]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().ResetMethod(). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().AssertMethod(). - returnResults(nil) + returnResults(nil, nil) var iface2Funcs []generator.Func newConverterFnMoq.onCall(generator.Type{ @@ -1407,21 +1427,21 @@ func TestMoqGenerator(t *testing.T) { Funcs: iface2Funcs, OutPkgPath: "thispkg_test", }, false).returnResults(converter2Moq.mock()) - converter2Moq.onCall().BaseDecls().returnResults(nil) + converter2Moq.onCall().BaseDecls().returnResults(nil, nil) converter2Moq.onCall().IsolationStruct("mock"). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().IsolationStruct("recorder"). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().NewFunc(). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().IsolationAccessor("mock", "mock"). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().IsolationAccessor("recorder", "onCall"). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().ResetMethod(). - returnResults(nil) + returnResults(nil, nil) converter2Moq.onCall().AssertMethod(). - returnResults(nil) + returnResults(nil, nil) req := generator.GenerateRequest{ Types: []string{"PublicInterface", "privateInterface"}, @@ -1554,7 +1574,7 @@ func TestMoqGenerator(t *testing.T) { typeCacheMoq.onCall().Type(*ast.IdPath("privateInterface", genPkg), genPkg, false). returnResults(ifaceInfo2, nil) expectedErr := errors.New("bad cache") - typeCacheMoq.onCall().Type(*ast.IdPath("Reader", "io"), "", false). + typeCacheMoq.onCall().Type(*ast.IdPath("Reader", "io"), genPkg, false). returnResults(ast.TypeInfo{}, expectedErr) req := generator.GenerateRequest{ @@ -1592,16 +1612,16 @@ func TestMoqGenerator(t *testing.T) { typeCacheMoq.onCall().FindPackage(".").returnResults("thispkg", nil) getwdFnMoq.onCall().returnResults("/some-nice-path", nil) - fnInfo.Type.Name.Path = "where-the-fn-lives" + fnInfo.PkgPath = "where-the-fn-lives" typeCacheMoq.onCall().Type(*ast.IdPath("PublicFn", "."), ".", false). returnResults(fnInfo, nil) typeCacheMoq.onCall().Type(*ast.IdPath("string", ""), "where-the-fn-lives", false). returnResults(ast.TypeInfo{Exported: true}, nil) - fnFuncs := []generator.Func{{Params: func1Params}} + fnFuncs := []generator.Func{{FuncType: &dst.FuncType{Params: func1Params}}} newConverterFnMoq.onCall(generator.Type{ TypeInfo: ast.TypeInfo{ Type: fnInfo.Type, - PkgPath: genPkg, + PkgPath: "where-the-fn-lives", Exported: true, }, Funcs: fnFuncs, @@ -1609,23 +1629,23 @@ func TestMoqGenerator(t *testing.T) { }, false).returnResults(converter1Moq.mock()) converter1Moq.onCall().BaseDecls().returnResults([]dst.Decl{&dst.GenDecl{ Specs: []dst.Spec{&dst.TypeSpec{Name: dst.NewIdent("pub-decl")}}, - }}) + }}, nil) converter1Moq.onCall().IsolationStruct("mock"). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().MethodStructs(fnFuncs[0]). returnResults(nil, nil) converter1Moq.onCall().NewFunc(). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().FuncClosure(fnFuncs[0]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().MockMethod(fnFuncs[0]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().RecorderMethods(fnFuncs[0]). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().ResetMethod(). - returnResults(nil) + returnResults(nil, nil) converter1Moq.onCall().AssertMethod(). - returnResults(nil) + returnResults(nil, nil) req := generator.GenerateRequest{ Types: []string{"PublicFn"}, diff --git a/generator/testmoqs/exported/moq_exported_testmoqs.go b/generator/testmoqs/exported/moq_exported_testmoqs.go index 95f9541..87ac1cf 100644 --- a/generator/testmoqs/exported/moq_exported_testmoqs.go +++ b/generator/testmoqs/exported/moq_exported_testmoqs.go @@ -5422,1172 +5422,956 @@ func (m *MoqInterfaceResultFn) AssertExpectationsMet() { } } -// The following type assertion assures that testmoqs.Usual is mocked -// completely -var _ testmoqs.Usual = (*MoqUsual_mock)(nil) - -// MoqUsual holds the state of a moq of the Usual type -type MoqUsual struct { +// MoqGenericParamsFn holds the state of a moq of the GenericParamsFn type +type MoqGenericParamsFn[S, B any] struct { Scene *moq.Scene Config moq.Config - Moq *MoqUsual_mock + Moq *MoqGenericParamsFn_mock[S, B] - ResultsByParams_Usual []MoqUsual_Usual_resultsByParams - ResultsByParams_NoNames []MoqUsual_NoNames_resultsByParams - ResultsByParams_NoResults []MoqUsual_NoResults_resultsByParams - ResultsByParams_NoParams []MoqUsual_NoParams_resultsByParams - ResultsByParams_Nothing []MoqUsual_Nothing_resultsByParams - ResultsByParams_Variadic []MoqUsual_Variadic_resultsByParams - ResultsByParams_RepeatedIds []MoqUsual_RepeatedIds_resultsByParams - ResultsByParams_Times []MoqUsual_Times_resultsByParams - ResultsByParams_DifficultParamNames []MoqUsual_DifficultParamNames_resultsByParams - ResultsByParams_DifficultResultNames []MoqUsual_DifficultResultNames_resultsByParams - ResultsByParams_PassByReference []MoqUsual_PassByReference_resultsByParams - ResultsByParams_InterfaceParam []MoqUsual_InterfaceParam_resultsByParams - ResultsByParams_InterfaceResult []MoqUsual_InterfaceResult_resultsByParams - ResultsByParams_FnParam []MoqUsual_FnParam_resultsByParams + ResultsByParams []MoqGenericParamsFn_resultsByParams[S, B] Runtime struct { ParameterIndexing struct { - Usual struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - NoNames struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - NoResults struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - NoParams struct{} - Nothing struct{} - Variadic struct { - Other moq.ParamIndexing - Args moq.ParamIndexing - } - RepeatedIds struct { - SParam1 moq.ParamIndexing - SParam2 moq.ParamIndexing - BParam moq.ParamIndexing - } - Times struct { - SParam moq.ParamIndexing - Times moq.ParamIndexing - } - DifficultParamNames struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - Param3 moq.ParamIndexing - Param moq.ParamIndexing - Param5 moq.ParamIndexing - Param6 moq.ParamIndexing - Param7 moq.ParamIndexing - Param8 moq.ParamIndexing - Param9 moq.ParamIndexing - } - DifficultResultNames struct{} - PassByReference struct { - P moq.ParamIndexing - } - InterfaceParam struct { - W moq.ParamIndexing - } - InterfaceResult struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - FnParam struct { - Fn moq.ParamIndexing - } + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } } - // MoqUsual_mock isolates the mock interface of the Usual type -} - -type MoqUsual_mock struct { - Moq *MoqUsual } -// MoqUsual_recorder isolates the recorder interface of the Usual type -type MoqUsual_recorder struct { - Moq *MoqUsual +// MoqGenericParamsFn_mock isolates the mock interface of the GenericParamsFn +// type +type MoqGenericParamsFn_mock[S, B any] struct { + Moq *MoqGenericParamsFn[S, B] } -// MoqUsual_Usual_params holds the params of the Usual type -type MoqUsual_Usual_params struct { - SParam string - BParam bool +// MoqGenericParamsFn_params holds the params of the GenericParamsFn type +type MoqGenericParamsFn_params[S, B any] struct { + Param1 S + Param2 B } -// MoqUsual_Usual_paramsKey holds the map key params of the Usual type -type MoqUsual_Usual_paramsKey struct { - Params struct { - SParam string - BParam bool - } +// MoqGenericParamsFn_paramsKey holds the map key params of the GenericParamsFn +// type +type MoqGenericParamsFn_paramsKey[S, B any] struct { + Params struct{} Hashes struct { - SParam hash.Hash - BParam hash.Hash + Param1 hash.Hash + Param2 hash.Hash } } -// MoqUsual_Usual_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_Usual_resultsByParams struct { +// MoqGenericParamsFn_resultsByParams contains the results for a given set of +// parameters for the GenericParamsFn type +type MoqGenericParamsFn_resultsByParams[S, B any] struct { AnyCount int AnyParams uint64 - Results map[MoqUsual_Usual_paramsKey]*MoqUsual_Usual_results + Results map[MoqGenericParamsFn_paramsKey[S, B]]*MoqGenericParamsFn_results[S, B] } -// MoqUsual_Usual_doFn defines the type of function needed when calling AndDo -// for the Usual type -type MoqUsual_Usual_doFn func(sParam string, bParam bool) +// MoqGenericParamsFn_doFn defines the type of function needed when calling +// AndDo for the GenericParamsFn type +type MoqGenericParamsFn_doFn[S, B any] func(S, B) -// MoqUsual_Usual_doReturnFn defines the type of function needed when calling -// DoReturnResults for the Usual type -type MoqUsual_Usual_doReturnFn func(sParam string, bParam bool) (sResult string, err error) +// MoqGenericParamsFn_doReturnFn defines the type of function needed when +// calling DoReturnResults for the GenericParamsFn type +type MoqGenericParamsFn_doReturnFn[S, B any] func(S, B) (string, error) -// MoqUsual_Usual_results holds the results of the Usual type -type MoqUsual_Usual_results struct { - Params MoqUsual_Usual_params +// MoqGenericParamsFn_results holds the results of the GenericParamsFn type +type MoqGenericParamsFn_results[S, B any] struct { + Params MoqGenericParamsFn_params[S, B] Results []struct { Values *struct { - SResult string - Err error + Result1 string + Result2 error } Sequence uint32 - DoFn MoqUsual_Usual_doFn - DoReturnFn MoqUsual_Usual_doReturnFn + DoFn MoqGenericParamsFn_doFn[S, B] + DoReturnFn MoqGenericParamsFn_doReturnFn[S, B] } Index uint32 Repeat *moq.RepeatVal } -// MoqUsual_Usual_fnRecorder routes recorded function calls to the MoqUsual moq -type MoqUsual_Usual_fnRecorder struct { - Params MoqUsual_Usual_params +// MoqGenericParamsFn_fnRecorder routes recorded function calls to the +// MoqGenericParamsFn moq +type MoqGenericParamsFn_fnRecorder[S, B any] struct { + Params MoqGenericParamsFn_params[S, B] AnyParams uint64 Sequence bool - Results *MoqUsual_Usual_results - Moq *MoqUsual -} - -// MoqUsual_Usual_anyParams isolates the any params functions of the Usual type -type MoqUsual_Usual_anyParams struct { - Recorder *MoqUsual_Usual_fnRecorder + Results *MoqGenericParamsFn_results[S, B] + Moq *MoqGenericParamsFn[S, B] } -// MoqUsual_NoNames_params holds the params of the Usual type -type MoqUsual_NoNames_params struct { - Param1 string - Param2 bool +// MoqGenericParamsFn_anyParams isolates the any params functions of the +// GenericParamsFn type +type MoqGenericParamsFn_anyParams[S, B any] struct { + Recorder *MoqGenericParamsFn_fnRecorder[S, B] } -// MoqUsual_NoNames_paramsKey holds the map key params of the Usual type -type MoqUsual_NoNames_paramsKey struct { - Params struct { - Param1 string - Param2 bool +// NewMoqGenericParamsFn creates a new moq of the GenericParamsFn type +func NewMoqGenericParamsFn[S, B any](scene *moq.Scene, config *moq.Config) *MoqGenericParamsFn[S, B] { + if config == nil { + config = &moq.Config{} } - Hashes struct { - Param1 hash.Hash - Param2 hash.Hash + m := &MoqGenericParamsFn[S, B]{ + Scene: scene, + Config: *config, + Moq: &MoqGenericParamsFn_mock[S, B]{}, + + Runtime: struct { + ParameterIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + }{ParameterIndexing: struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + }{ + Param1: moq.ParamIndexByHash, + Param2: moq.ParamIndexByHash, + }}, } + m.Moq.Moq = m + + scene.AddMoq(m) + return m } -// MoqUsual_NoNames_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_NoNames_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_NoNames_paramsKey]*MoqUsual_NoNames_results +// Mock returns the moq implementation of the GenericParamsFn type +func (m *MoqGenericParamsFn[S, B]) Mock() testmoqs.GenericParamsFn[S, B] { + return func(param1 S, param2 B) (string, error) { + m.Scene.T.Helper() + moq := &MoqGenericParamsFn_mock[S, B]{Moq: m} + return moq.Fn(param1, param2) + } } -// MoqUsual_NoNames_doFn defines the type of function needed when calling AndDo -// for the Usual type -type MoqUsual_NoNames_doFn func(string, bool) +func (m *MoqGenericParamsFn_mock[S, B]) Fn(param1 S, param2 B) (result1 string, result2 error) { + m.Moq.Scene.T.Helper() + params := MoqGenericParamsFn_params[S, B]{ + Param1: param1, + Param2: param2, + } + var results *MoqGenericParamsFn_results[S, B] + for _, resultsByParams := range m.Moq.ResultsByParams { + paramsKey := m.Moq.ParamsKey(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams(params)) + } + return + } -// MoqUsual_NoNames_doReturnFn defines the type of function needed when calling -// DoReturnResults for the Usual type -type MoqUsual_NoNames_doReturnFn func(string, bool) (string, error) + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } -// MoqUsual_NoNames_results holds the results of the Usual type -type MoqUsual_NoNames_results struct { - Params MoqUsual_NoNames_params - Results []struct { - Values *struct { - Result1 string - Result2 error + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams(params)) } - Sequence uint32 - DoFn MoqUsual_NoNames_doFn - DoReturnFn MoqUsual_NoNames_doReturnFn } - Index uint32 - Repeat *moq.RepeatVal -} -// MoqUsual_NoNames_fnRecorder routes recorded function calls to the MoqUsual -// moq -type MoqUsual_NoNames_fnRecorder struct { - Params MoqUsual_NoNames_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_NoNames_results - Moq *MoqUsual -} + if result.DoFn != nil { + result.DoFn(param1, param2) + } -// MoqUsual_NoNames_anyParams isolates the any params functions of the Usual -// type -type MoqUsual_NoNames_anyParams struct { - Recorder *MoqUsual_NoNames_fnRecorder + if result.Values != nil { + result1 = result.Values.Result1 + result2 = result.Values.Result2 + } + if result.DoReturnFn != nil { + result1, result2 = result.DoReturnFn(param1, param2) + } + return } -// MoqUsual_NoResults_params holds the params of the Usual type -type MoqUsual_NoResults_params struct { - SParam string - BParam bool +func (m *MoqGenericParamsFn[S, B]) OnCall(param1 S, param2 B) *MoqGenericParamsFn_fnRecorder[S, B] { + return &MoqGenericParamsFn_fnRecorder[S, B]{ + Params: MoqGenericParamsFn_params[S, B]{ + Param1: param1, + Param2: param2, + }, + Sequence: m.Config.Sequence == moq.SeqDefaultOn, + Moq: m, + } } -// MoqUsual_NoResults_paramsKey holds the map key params of the Usual type -type MoqUsual_NoResults_paramsKey struct { - Params struct { - SParam string - BParam bool - } - Hashes struct { - SParam hash.Hash - BParam hash.Hash +func (r *MoqGenericParamsFn_fnRecorder[S, B]) Any() *MoqGenericParamsFn_anyParams[S, B] { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) + return nil } + return &MoqGenericParamsFn_anyParams[S, B]{Recorder: r} } -// MoqUsual_NoResults_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_NoResults_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_NoResults_paramsKey]*MoqUsual_NoResults_results +func (a *MoqGenericParamsFn_anyParams[S, B]) Param1() *MoqGenericParamsFn_fnRecorder[S, B] { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder } -// MoqUsual_NoResults_doFn defines the type of function needed when calling -// AndDo for the Usual type -type MoqUsual_NoResults_doFn func(sParam string, bParam bool) - -// MoqUsual_NoResults_doReturnFn defines the type of function needed when -// calling DoReturnResults for the Usual type -type MoqUsual_NoResults_doReturnFn func(sParam string, bParam bool) +func (a *MoqGenericParamsFn_anyParams[S, B]) Param2() *MoqGenericParamsFn_fnRecorder[S, B] { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} -// MoqUsual_NoResults_results holds the results of the Usual type -type MoqUsual_NoResults_results struct { - Params MoqUsual_NoResults_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqUsual_NoResults_doFn - DoReturnFn MoqUsual_NoResults_doReturnFn +func (r *MoqGenericParamsFn_fnRecorder[S, B]) Seq() *MoqGenericParamsFn_fnRecorder[S, B] { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) + return nil } - Index uint32 - Repeat *moq.RepeatVal + r.Sequence = true + return r } -// MoqUsual_NoResults_fnRecorder routes recorded function calls to the MoqUsual -// moq -type MoqUsual_NoResults_fnRecorder struct { - Params MoqUsual_NoResults_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_NoResults_results - Moq *MoqUsual +func (r *MoqGenericParamsFn_fnRecorder[S, B]) NoSeq() *MoqGenericParamsFn_fnRecorder[S, B] { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) + return nil + } + r.Sequence = false + return r } -// MoqUsual_NoResults_anyParams isolates the any params functions of the Usual -// type -type MoqUsual_NoResults_anyParams struct { - Recorder *MoqUsual_NoResults_fnRecorder -} +func (r *MoqGenericParamsFn_fnRecorder[S, B]) ReturnResults(result1 string, result2 error) *MoqGenericParamsFn_fnRecorder[S, B] { + r.Moq.Scene.T.Helper() + r.FindResults() -// MoqUsual_NoParams_params holds the params of the Usual type -type MoqUsual_NoParams_params struct{} + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } -// MoqUsual_NoParams_paramsKey holds the map key params of the Usual type -type MoqUsual_NoParams_paramsKey struct { - Params struct{} - Hashes struct{} + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + Result1 string + Result2 error + } + Sequence uint32 + DoFn MoqGenericParamsFn_doFn[S, B] + DoReturnFn MoqGenericParamsFn_doReturnFn[S, B] + }{ + Values: &struct { + Result1 string + Result2 error + }{ + Result1: result1, + Result2: result2, + }, + Sequence: sequence, + }) + return r } -// MoqUsual_NoParams_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_NoParams_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_NoParams_paramsKey]*MoqUsual_NoParams_results +func (r *MoqGenericParamsFn_fnRecorder[S, B]) AndDo(fn MoqGenericParamsFn_doFn[S, B]) *MoqGenericParamsFn_fnRecorder[S, B] { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r } -// MoqUsual_NoParams_doFn defines the type of function needed when calling -// AndDo for the Usual type -type MoqUsual_NoParams_doFn func() +func (r *MoqGenericParamsFn_fnRecorder[S, B]) DoReturnResults(fn MoqGenericParamsFn_doReturnFn[S, B]) *MoqGenericParamsFn_fnRecorder[S, B] { + r.Moq.Scene.T.Helper() + r.FindResults() -// MoqUsual_NoParams_doReturnFn defines the type of function needed when -// calling DoReturnResults for the Usual type -type MoqUsual_NoParams_doReturnFn func() (sResult string, err error) + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } -// MoqUsual_NoParams_results holds the results of the Usual type -type MoqUsual_NoParams_results struct { - Params MoqUsual_NoParams_params - Results []struct { + r.Results.Results = append(r.Results.Results, struct { Values *struct { - SResult string - Err error + Result1 string + Result2 error } Sequence uint32 - DoFn MoqUsual_NoParams_doFn - DoReturnFn MoqUsual_NoParams_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal + DoFn MoqGenericParamsFn_doFn[S, B] + DoReturnFn MoqGenericParamsFn_doReturnFn[S, B] + }{Sequence: sequence, DoReturnFn: fn}) + return r } -// MoqUsual_NoParams_fnRecorder routes recorded function calls to the MoqUsual -// moq -type MoqUsual_NoParams_fnRecorder struct { - Params MoqUsual_NoParams_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_NoParams_results - Moq *MoqUsual -} +func (r *MoqGenericParamsFn_fnRecorder[S, B]) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } -// MoqUsual_NoParams_anyParams isolates the any params functions of the Usual -// type -type MoqUsual_NoParams_anyParams struct { - Recorder *MoqUsual_NoParams_fnRecorder -} + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqGenericParamsFn_resultsByParams[S, B] + for n, res := range r.Moq.ResultsByParams { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqGenericParamsFn_resultsByParams[S, B]{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqGenericParamsFn_paramsKey[S, B]]*MoqGenericParamsFn_results[S, B]{}, + } + r.Moq.ResultsByParams = append(r.Moq.ResultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams) { + copy(r.Moq.ResultsByParams[insertAt+1:], r.Moq.ResultsByParams[insertAt:0]) + r.Moq.ResultsByParams[insertAt] = *results + } + } -// MoqUsual_Nothing_params holds the params of the Usual type -type MoqUsual_Nothing_params struct{} + paramsKey := r.Moq.ParamsKey(r.Params, r.AnyParams) -// MoqUsual_Nothing_paramsKey holds the map key params of the Usual type -type MoqUsual_Nothing_paramsKey struct { - Params struct{} - Hashes struct{} -} + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqGenericParamsFn_results[S, B]{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } -// MoqUsual_Nothing_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_Nothing_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_Nothing_paramsKey]*MoqUsual_Nothing_results + r.Results.Repeat.Increment(r.Moq.Scene.T) } -// MoqUsual_Nothing_doFn defines the type of function needed when calling AndDo -// for the Usual type -type MoqUsual_Nothing_doFn func() - -// MoqUsual_Nothing_doReturnFn defines the type of function needed when calling -// DoReturnResults for the Usual type -type MoqUsual_Nothing_doReturnFn func() - -// MoqUsual_Nothing_results holds the results of the Usual type -type MoqUsual_Nothing_results struct { - Params MoqUsual_Nothing_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqUsual_Nothing_doFn - DoReturnFn MoqUsual_Nothing_doReturnFn +func (r *MoqGenericParamsFn_fnRecorder[S, B]) Repeat(repeaters ...moq.Repeater) *MoqGenericParamsFn_fnRecorder[S, B] { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsual_Nothing_fnRecorder routes recorded function calls to the MoqUsual -// moq -type MoqUsual_Nothing_fnRecorder struct { - Params MoqUsual_Nothing_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_Nothing_results - Moq *MoqUsual + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct { + Result1 string + Result2 error + } + Sequence uint32 + DoFn MoqGenericParamsFn_doFn[S, B] + DoReturnFn MoqGenericParamsFn_doReturnFn[S, B] + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r } -// MoqUsual_Nothing_anyParams isolates the any params functions of the Usual -// type -type MoqUsual_Nothing_anyParams struct { - Recorder *MoqUsual_Nothing_fnRecorder +func (m *MoqGenericParamsFn[S, B]) PrettyParams(params MoqGenericParamsFn_params[S, B]) string { + return fmt.Sprintf("GenericParamsFn(%#v, %#v)", params.Param1, params.Param2) } -// MoqUsual_Variadic_params holds the params of the Usual type -type MoqUsual_Variadic_params struct { - Other bool - Args []string -} - -// MoqUsual_Variadic_paramsKey holds the map key params of the Usual type -type MoqUsual_Variadic_paramsKey struct { - Params struct{ Other bool } - Hashes struct { - Other hash.Hash - Args hash.Hash +func (m *MoqGenericParamsFn[S, B]) ParamsKey(params MoqGenericParamsFn_params[S, B], anyParams uint64) MoqGenericParamsFn_paramsKey[S, B] { + m.Scene.T.Helper() + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.Param1 == moq.ParamIndexByValue { + m.Scene.T.Fatalf("The param1 parameter can't be indexed by value") + } + param1UsedHash = hash.DeepHash(params.Param1) + } + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.Param2 == moq.ParamIndexByValue { + m.Scene.T.Fatalf("The param2 parameter can't be indexed by value") + } + param2UsedHash = hash.DeepHash(params.Param2) + } + return MoqGenericParamsFn_paramsKey[S, B]{ + Params: struct{}{}, + Hashes: struct { + Param1 hash.Hash + Param2 hash.Hash + }{ + Param1: param1UsedHash, + Param2: param2UsedHash, + }, } } -// MoqUsual_Variadic_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_Variadic_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_Variadic_paramsKey]*MoqUsual_Variadic_results +// Reset resets the state of the moq +func (m *MoqGenericParamsFn[S, B]) Reset() { m.ResultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqGenericParamsFn[S, B]) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams(results.Params)) + } + } + } } -// MoqUsual_Variadic_doFn defines the type of function needed when calling -// AndDo for the Usual type -type MoqUsual_Variadic_doFn func(other bool, args ...string) +// MoqPartialGenericParamsFn holds the state of a moq of the +// PartialGenericParamsFn type +type MoqPartialGenericParamsFn[S any] struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqPartialGenericParamsFn_mock[S] -// MoqUsual_Variadic_doReturnFn defines the type of function needed when -// calling DoReturnResults for the Usual type -type MoqUsual_Variadic_doReturnFn func(other bool, args ...string) (sResult string, err error) + ResultsByParams []MoqPartialGenericParamsFn_resultsByParams[S] -// MoqUsual_Variadic_results holds the results of the Usual type -type MoqUsual_Variadic_results struct { - Params MoqUsual_Variadic_params - Results []struct { - Values *struct { - SResult string - Err error + Runtime struct { + ParameterIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } - Sequence uint32 - DoFn MoqUsual_Variadic_doFn - DoReturnFn MoqUsual_Variadic_doReturnFn } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsual_Variadic_fnRecorder routes recorded function calls to the MoqUsual -// moq -type MoqUsual_Variadic_fnRecorder struct { - Params MoqUsual_Variadic_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_Variadic_results - Moq *MoqUsual } -// MoqUsual_Variadic_anyParams isolates the any params functions of the Usual -// type -type MoqUsual_Variadic_anyParams struct { - Recorder *MoqUsual_Variadic_fnRecorder +// MoqPartialGenericParamsFn_mock isolates the mock interface of the +// PartialGenericParamsFn type +type MoqPartialGenericParamsFn_mock[S any] struct { + Moq *MoqPartialGenericParamsFn[S] } -// MoqUsual_RepeatedIds_params holds the params of the Usual type -type MoqUsual_RepeatedIds_params struct { - SParam1, SParam2 string - BParam bool +// MoqPartialGenericParamsFn_params holds the params of the +// PartialGenericParamsFn type +type MoqPartialGenericParamsFn_params[S any] struct { + Param1 S + Param2 bool } -// MoqUsual_RepeatedIds_paramsKey holds the map key params of the Usual type -type MoqUsual_RepeatedIds_paramsKey struct { - Params struct { - SParam1, SParam2 string - BParam bool - } +// MoqPartialGenericParamsFn_paramsKey holds the map key params of the +// PartialGenericParamsFn type +type MoqPartialGenericParamsFn_paramsKey[S any] struct { + Params struct{ Param2 bool } Hashes struct { - SParam1, SParam2 hash.Hash - BParam hash.Hash + Param1 hash.Hash + Param2 hash.Hash } } -// MoqUsual_RepeatedIds_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_RepeatedIds_resultsByParams struct { +// MoqPartialGenericParamsFn_resultsByParams contains the results for a given +// set of parameters for the PartialGenericParamsFn type +type MoqPartialGenericParamsFn_resultsByParams[S any] struct { AnyCount int AnyParams uint64 - Results map[MoqUsual_RepeatedIds_paramsKey]*MoqUsual_RepeatedIds_results + Results map[MoqPartialGenericParamsFn_paramsKey[S]]*MoqPartialGenericParamsFn_results[S] } -// MoqUsual_RepeatedIds_doFn defines the type of function needed when calling -// AndDo for the Usual type -type MoqUsual_RepeatedIds_doFn func(sParam1, sParam2 string, bParam bool) +// MoqPartialGenericParamsFn_doFn defines the type of function needed when +// calling AndDo for the PartialGenericParamsFn type +type MoqPartialGenericParamsFn_doFn[S any] func(S, bool) -// MoqUsual_RepeatedIds_doReturnFn defines the type of function needed when -// calling DoReturnResults for the Usual type -type MoqUsual_RepeatedIds_doReturnFn func(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) +// MoqPartialGenericParamsFn_doReturnFn defines the type of function needed +// when calling DoReturnResults for the PartialGenericParamsFn type +type MoqPartialGenericParamsFn_doReturnFn[S any] func(S, bool) (string, error) -// MoqUsual_RepeatedIds_results holds the results of the Usual type -type MoqUsual_RepeatedIds_results struct { - Params MoqUsual_RepeatedIds_params +// MoqPartialGenericParamsFn_results holds the results of the +// PartialGenericParamsFn type +type MoqPartialGenericParamsFn_results[S any] struct { + Params MoqPartialGenericParamsFn_params[S] Results []struct { Values *struct { - SResult1, SResult2 string - Err error + Result1 string + Result2 error } Sequence uint32 - DoFn MoqUsual_RepeatedIds_doFn - DoReturnFn MoqUsual_RepeatedIds_doReturnFn + DoFn MoqPartialGenericParamsFn_doFn[S] + DoReturnFn MoqPartialGenericParamsFn_doReturnFn[S] } Index uint32 Repeat *moq.RepeatVal } -// MoqUsual_RepeatedIds_fnRecorder routes recorded function calls to the -// MoqUsual moq -type MoqUsual_RepeatedIds_fnRecorder struct { - Params MoqUsual_RepeatedIds_params +// MoqPartialGenericParamsFn_fnRecorder routes recorded function calls to the +// MoqPartialGenericParamsFn moq +type MoqPartialGenericParamsFn_fnRecorder[S any] struct { + Params MoqPartialGenericParamsFn_params[S] AnyParams uint64 Sequence bool - Results *MoqUsual_RepeatedIds_results - Moq *MoqUsual -} - -// MoqUsual_RepeatedIds_anyParams isolates the any params functions of the -// Usual type -type MoqUsual_RepeatedIds_anyParams struct { - Recorder *MoqUsual_RepeatedIds_fnRecorder + Results *MoqPartialGenericParamsFn_results[S] + Moq *MoqPartialGenericParamsFn[S] } -// MoqUsual_Times_params holds the params of the Usual type -type MoqUsual_Times_params struct { - SParam string - Times bool +// MoqPartialGenericParamsFn_anyParams isolates the any params functions of the +// PartialGenericParamsFn type +type MoqPartialGenericParamsFn_anyParams[S any] struct { + Recorder *MoqPartialGenericParamsFn_fnRecorder[S] } -// MoqUsual_Times_paramsKey holds the map key params of the Usual type -type MoqUsual_Times_paramsKey struct { - Params struct { - SParam string - Times bool +// NewMoqPartialGenericParamsFn creates a new moq of the PartialGenericParamsFn +// type +func NewMoqPartialGenericParamsFn[S any](scene *moq.Scene, config *moq.Config) *MoqPartialGenericParamsFn[S] { + if config == nil { + config = &moq.Config{} } - Hashes struct { - SParam hash.Hash - Times hash.Hash + m := &MoqPartialGenericParamsFn[S]{ + Scene: scene, + Config: *config, + Moq: &MoqPartialGenericParamsFn_mock[S]{}, + + Runtime: struct { + ParameterIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + }{ParameterIndexing: struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + }{ + Param1: moq.ParamIndexByHash, + Param2: moq.ParamIndexByValue, + }}, } + m.Moq.Moq = m + + scene.AddMoq(m) + return m } -// MoqUsual_Times_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_Times_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_Times_paramsKey]*MoqUsual_Times_results +// Mock returns the moq implementation of the PartialGenericParamsFn type +func (m *MoqPartialGenericParamsFn[S]) Mock() testmoqs.PartialGenericParamsFn[S] { + return func(param1 S, param2 bool) (string, error) { + m.Scene.T.Helper() + moq := &MoqPartialGenericParamsFn_mock[S]{Moq: m} + return moq.Fn(param1, param2) + } } -// MoqUsual_Times_doFn defines the type of function needed when calling AndDo -// for the Usual type -type MoqUsual_Times_doFn func(sParam string, times bool) +func (m *MoqPartialGenericParamsFn_mock[S]) Fn(param1 S, param2 bool) (result1 string, result2 error) { + m.Moq.Scene.T.Helper() + params := MoqPartialGenericParamsFn_params[S]{ + Param1: param1, + Param2: param2, + } + var results *MoqPartialGenericParamsFn_results[S] + for _, resultsByParams := range m.Moq.ResultsByParams { + paramsKey := m.Moq.ParamsKey(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams(params)) + } + return + } -// MoqUsual_Times_doReturnFn defines the type of function needed when calling -// DoReturnResults for the Usual type -type MoqUsual_Times_doReturnFn func(sParam string, times bool) (sResult string, err error) + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } -// MoqUsual_Times_results holds the results of the Usual type -type MoqUsual_Times_results struct { - Params MoqUsual_Times_params - Results []struct { - Values *struct { - SResult string - Err error + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams(params)) } - Sequence uint32 - DoFn MoqUsual_Times_doFn - DoReturnFn MoqUsual_Times_doReturnFn } - Index uint32 - Repeat *moq.RepeatVal -} -// MoqUsual_Times_fnRecorder routes recorded function calls to the MoqUsual moq -type MoqUsual_Times_fnRecorder struct { - Params MoqUsual_Times_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_Times_results - Moq *MoqUsual + if result.DoFn != nil { + result.DoFn(param1, param2) + } + + if result.Values != nil { + result1 = result.Values.Result1 + result2 = result.Values.Result2 + } + if result.DoReturnFn != nil { + result1, result2 = result.DoReturnFn(param1, param2) + } + return } -// MoqUsual_Times_anyParams isolates the any params functions of the Usual type -type MoqUsual_Times_anyParams struct { - Recorder *MoqUsual_Times_fnRecorder +func (m *MoqPartialGenericParamsFn[S]) OnCall(param1 S, param2 bool) *MoqPartialGenericParamsFn_fnRecorder[S] { + return &MoqPartialGenericParamsFn_fnRecorder[S]{ + Params: MoqPartialGenericParamsFn_params[S]{ + Param1: param1, + Param2: param2, + }, + Sequence: m.Config.Sequence == moq.SeqDefaultOn, + Moq: m, + } } -// MoqUsual_DifficultParamNames_params holds the params of the Usual type -type MoqUsual_DifficultParamNames_params struct { - Param1, Param2 bool - Param3 string - Param, Param5, Param6 int - Param7, Param8, Param9 float32 -} - -// MoqUsual_DifficultParamNames_paramsKey holds the map key params of the Usual -// type -type MoqUsual_DifficultParamNames_paramsKey struct { - Params struct { - Param1, Param2 bool - Param3 string - Param, Param5, Param6 int - Param7, Param8, Param9 float32 - } - Hashes struct { - Param1, Param2 hash.Hash - Param3 hash.Hash - Param, Param5, Param6 hash.Hash - Param7, Param8, Param9 hash.Hash +func (r *MoqPartialGenericParamsFn_fnRecorder[S]) Any() *MoqPartialGenericParamsFn_anyParams[S] { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) + return nil } + return &MoqPartialGenericParamsFn_anyParams[S]{Recorder: r} } -// MoqUsual_DifficultParamNames_resultsByParams contains the results for a -// given set of parameters for the Usual type -type MoqUsual_DifficultParamNames_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_DifficultParamNames_paramsKey]*MoqUsual_DifficultParamNames_results +func (a *MoqPartialGenericParamsFn_anyParams[S]) Param1() *MoqPartialGenericParamsFn_fnRecorder[S] { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder } -// MoqUsual_DifficultParamNames_doFn defines the type of function needed when -// calling AndDo for the Usual type -type MoqUsual_DifficultParamNames_doFn func(m, r bool, sequence string, param, params, i int, result, results, _ float32) - -// MoqUsual_DifficultParamNames_doReturnFn defines the type of function needed -// when calling DoReturnResults for the Usual type -type MoqUsual_DifficultParamNames_doReturnFn func(m, r bool, sequence string, param, params, i int, result, results, _ float32) +func (a *MoqPartialGenericParamsFn_anyParams[S]) Param2() *MoqPartialGenericParamsFn_fnRecorder[S] { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} -// MoqUsual_DifficultParamNames_results holds the results of the Usual type -type MoqUsual_DifficultParamNames_results struct { - Params MoqUsual_DifficultParamNames_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqUsual_DifficultParamNames_doFn - DoReturnFn MoqUsual_DifficultParamNames_doReturnFn +func (r *MoqPartialGenericParamsFn_fnRecorder[S]) Seq() *MoqPartialGenericParamsFn_fnRecorder[S] { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) + return nil } - Index uint32 - Repeat *moq.RepeatVal + r.Sequence = true + return r } -// MoqUsual_DifficultParamNames_fnRecorder routes recorded function calls to -// the MoqUsual moq -type MoqUsual_DifficultParamNames_fnRecorder struct { - Params MoqUsual_DifficultParamNames_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_DifficultParamNames_results - Moq *MoqUsual +func (r *MoqPartialGenericParamsFn_fnRecorder[S]) NoSeq() *MoqPartialGenericParamsFn_fnRecorder[S] { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) + return nil + } + r.Sequence = false + return r } -// MoqUsual_DifficultParamNames_anyParams isolates the any params functions of -// the Usual type -type MoqUsual_DifficultParamNames_anyParams struct { - Recorder *MoqUsual_DifficultParamNames_fnRecorder -} +func (r *MoqPartialGenericParamsFn_fnRecorder[S]) ReturnResults(result1 string, result2 error) *MoqPartialGenericParamsFn_fnRecorder[S] { + r.Moq.Scene.T.Helper() + r.FindResults() -// MoqUsual_DifficultResultNames_params holds the params of the Usual type -type MoqUsual_DifficultResultNames_params struct{} + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } -// MoqUsual_DifficultResultNames_paramsKey holds the map key params of the -// Usual type -type MoqUsual_DifficultResultNames_paramsKey struct { - Params struct{} - Hashes struct{} + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + Result1 string + Result2 error + } + Sequence uint32 + DoFn MoqPartialGenericParamsFn_doFn[S] + DoReturnFn MoqPartialGenericParamsFn_doReturnFn[S] + }{ + Values: &struct { + Result1 string + Result2 error + }{ + Result1: result1, + Result2: result2, + }, + Sequence: sequence, + }) + return r } -// MoqUsual_DifficultResultNames_resultsByParams contains the results for a -// given set of parameters for the Usual type -type MoqUsual_DifficultResultNames_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_DifficultResultNames_paramsKey]*MoqUsual_DifficultResultNames_results +func (r *MoqPartialGenericParamsFn_fnRecorder[S]) AndDo(fn MoqPartialGenericParamsFn_doFn[S]) *MoqPartialGenericParamsFn_fnRecorder[S] { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r } -// MoqUsual_DifficultResultNames_doFn defines the type of function needed when -// calling AndDo for the Usual type -type MoqUsual_DifficultResultNames_doFn func() +func (r *MoqPartialGenericParamsFn_fnRecorder[S]) DoReturnResults(fn MoqPartialGenericParamsFn_doReturnFn[S]) *MoqPartialGenericParamsFn_fnRecorder[S] { + r.Moq.Scene.T.Helper() + r.FindResults() -// MoqUsual_DifficultResultNames_doReturnFn defines the type of function needed -// when calling DoReturnResults for the Usual type -type MoqUsual_DifficultResultNames_doReturnFn func() (m, r string, sequence error, param, params, i int, result, results, _ float32) + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } -// MoqUsual_DifficultResultNames_results holds the results of the Usual type -type MoqUsual_DifficultResultNames_results struct { - Params MoqUsual_DifficultResultNames_params - Results []struct { + r.Results.Results = append(r.Results.Results, struct { Values *struct { - Result1, Result2 string - Result3 error - Param, Result5, Result6 int - Result7, Result8, Result9 float32 + Result1 string + Result2 error } Sequence uint32 - DoFn MoqUsual_DifficultResultNames_doFn - DoReturnFn MoqUsual_DifficultResultNames_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsual_DifficultResultNames_fnRecorder routes recorded function calls to -// the MoqUsual moq -type MoqUsual_DifficultResultNames_fnRecorder struct { - Params MoqUsual_DifficultResultNames_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_DifficultResultNames_results - Moq *MoqUsual -} - -// MoqUsual_DifficultResultNames_anyParams isolates the any params functions of -// the Usual type -type MoqUsual_DifficultResultNames_anyParams struct { - Recorder *MoqUsual_DifficultResultNames_fnRecorder -} - -// MoqUsual_PassByReference_params holds the params of the Usual type -type MoqUsual_PassByReference_params struct { - P *testmoqs.PassByReferenceParams + DoFn MoqPartialGenericParamsFn_doFn[S] + DoReturnFn MoqPartialGenericParamsFn_doReturnFn[S] + }{Sequence: sequence, DoReturnFn: fn}) + return r } -// MoqUsual_PassByReference_paramsKey holds the map key params of the Usual -// type -type MoqUsual_PassByReference_paramsKey struct { - Params struct { - P *testmoqs.PassByReferenceParams +func (r *MoqPartialGenericParamsFn_fnRecorder[S]) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return } - Hashes struct{ P hash.Hash } -} - -// MoqUsual_PassByReference_resultsByParams contains the results for a given -// set of parameters for the Usual type -type MoqUsual_PassByReference_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_PassByReference_paramsKey]*MoqUsual_PassByReference_results -} -// MoqUsual_PassByReference_doFn defines the type of function needed when -// calling AndDo for the Usual type -type MoqUsual_PassByReference_doFn func(p *testmoqs.PassByReferenceParams) + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqPartialGenericParamsFn_resultsByParams[S] + for n, res := range r.Moq.ResultsByParams { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqPartialGenericParamsFn_resultsByParams[S]{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqPartialGenericParamsFn_paramsKey[S]]*MoqPartialGenericParamsFn_results[S]{}, + } + r.Moq.ResultsByParams = append(r.Moq.ResultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams) { + copy(r.Moq.ResultsByParams[insertAt+1:], r.Moq.ResultsByParams[insertAt:0]) + r.Moq.ResultsByParams[insertAt] = *results + } + } -// MoqUsual_PassByReference_doReturnFn defines the type of function needed when -// calling DoReturnResults for the Usual type -type MoqUsual_PassByReference_doReturnFn func(p *testmoqs.PassByReferenceParams) (sResult string, err error) + paramsKey := r.Moq.ParamsKey(r.Params, r.AnyParams) -// MoqUsual_PassByReference_results holds the results of the Usual type -type MoqUsual_PassByReference_results struct { - Params MoqUsual_PassByReference_params - Results []struct { - Values *struct { - SResult string - Err error + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqPartialGenericParamsFn_results[S]{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, } - Sequence uint32 - DoFn MoqUsual_PassByReference_doFn - DoReturnFn MoqUsual_PassByReference_doReturnFn + results.Results[paramsKey] = r.Results } - Index uint32 - Repeat *moq.RepeatVal -} -// MoqUsual_PassByReference_fnRecorder routes recorded function calls to the -// MoqUsual moq -type MoqUsual_PassByReference_fnRecorder struct { - Params MoqUsual_PassByReference_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_PassByReference_results - Moq *MoqUsual + r.Results.Repeat.Increment(r.Moq.Scene.T) } -// MoqUsual_PassByReference_anyParams isolates the any params functions of the -// Usual type -type MoqUsual_PassByReference_anyParams struct { - Recorder *MoqUsual_PassByReference_fnRecorder -} - -// MoqUsual_InterfaceParam_params holds the params of the Usual type -type MoqUsual_InterfaceParam_params struct{ W io.Writer } - -// MoqUsual_InterfaceParam_paramsKey holds the map key params of the Usual type -type MoqUsual_InterfaceParam_paramsKey struct { - Params struct{ W io.Writer } - Hashes struct{ W hash.Hash } -} - -// MoqUsual_InterfaceParam_resultsByParams contains the results for a given set -// of parameters for the Usual type -type MoqUsual_InterfaceParam_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_InterfaceParam_paramsKey]*MoqUsual_InterfaceParam_results -} - -// MoqUsual_InterfaceParam_doFn defines the type of function needed when -// calling AndDo for the Usual type -type MoqUsual_InterfaceParam_doFn func(w io.Writer) - -// MoqUsual_InterfaceParam_doReturnFn defines the type of function needed when -// calling DoReturnResults for the Usual type -type MoqUsual_InterfaceParam_doReturnFn func(w io.Writer) (sResult string, err error) - -// MoqUsual_InterfaceParam_results holds the results of the Usual type -type MoqUsual_InterfaceParam_results struct { - Params MoqUsual_InterfaceParam_params - Results []struct { - Values *struct { - SResult string - Err error +func (r *MoqPartialGenericParamsFn_fnRecorder[S]) Repeat(repeaters ...moq.Repeater) *MoqPartialGenericParamsFn_fnRecorder[S] { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct { + Result1 string + Result2 error + } + Sequence uint32 + DoFn MoqPartialGenericParamsFn_doFn[S] + DoReturnFn MoqPartialGenericParamsFn_doReturnFn[S] + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } } - Sequence uint32 - DoFn MoqUsual_InterfaceParam_doFn - DoReturnFn MoqUsual_InterfaceParam_doReturnFn + r.Results.Results = append(r.Results.Results, last) } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsual_InterfaceParam_fnRecorder routes recorded function calls to the -// MoqUsual moq -type MoqUsual_InterfaceParam_fnRecorder struct { - Params MoqUsual_InterfaceParam_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_InterfaceParam_results - Moq *MoqUsual -} - -// MoqUsual_InterfaceParam_anyParams isolates the any params functions of the -// Usual type -type MoqUsual_InterfaceParam_anyParams struct { - Recorder *MoqUsual_InterfaceParam_fnRecorder + return r } -// MoqUsual_InterfaceResult_params holds the params of the Usual type -type MoqUsual_InterfaceResult_params struct { - SParam string - BParam bool +func (m *MoqPartialGenericParamsFn[S]) PrettyParams(params MoqPartialGenericParamsFn_params[S]) string { + return fmt.Sprintf("PartialGenericParamsFn(%#v, %#v)", params.Param1, params.Param2) } -// MoqUsual_InterfaceResult_paramsKey holds the map key params of the Usual -// type -type MoqUsual_InterfaceResult_paramsKey struct { - Params struct { - SParam string - BParam bool +func (m *MoqPartialGenericParamsFn[S]) ParamsKey(params MoqPartialGenericParamsFn_params[S], anyParams uint64) MoqPartialGenericParamsFn_paramsKey[S] { + m.Scene.T.Helper() + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.Param1 == moq.ParamIndexByValue { + m.Scene.T.Fatalf("The param1 parameter can't be indexed by value") + } + param1UsedHash = hash.DeepHash(params.Param1) } - Hashes struct { - SParam hash.Hash - BParam hash.Hash + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.Param2 == moq.ParamIndexByValue { + param2Used = params.Param2 + } else { + param2UsedHash = hash.DeepHash(params.Param2) + } + } + return MoqPartialGenericParamsFn_paramsKey[S]{ + Params: struct{ Param2 bool }{ + Param2: param2Used, + }, + Hashes: struct { + Param1 hash.Hash + Param2 hash.Hash + }{ + Param1: param1UsedHash, + Param2: param2UsedHash, + }, } } -// MoqUsual_InterfaceResult_resultsByParams contains the results for a given -// set of parameters for the Usual type -type MoqUsual_InterfaceResult_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_InterfaceResult_paramsKey]*MoqUsual_InterfaceResult_results +// Reset resets the state of the moq +func (m *MoqPartialGenericParamsFn[S]) Reset() { m.ResultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqPartialGenericParamsFn[S]) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams(results.Params)) + } + } + } } -// MoqUsual_InterfaceResult_doFn defines the type of function needed when -// calling AndDo for the Usual type -type MoqUsual_InterfaceResult_doFn func(sParam string, bParam bool) +// MoqGenericResultsFn holds the state of a moq of the GenericResultsFn type +type MoqGenericResultsFn[S ~string, E error] struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqGenericResultsFn_mock[S, E] -// MoqUsual_InterfaceResult_doReturnFn defines the type of function needed when -// calling DoReturnResults for the Usual type -type MoqUsual_InterfaceResult_doReturnFn func(sParam string, bParam bool) (r io.Reader) + ResultsByParams []MoqGenericResultsFn_resultsByParams[S, E] -// MoqUsual_InterfaceResult_results holds the results of the Usual type -type MoqUsual_InterfaceResult_results struct { - Params MoqUsual_InterfaceResult_params - Results []struct { - Values *struct{ Result1 io.Reader } - Sequence uint32 - DoFn MoqUsual_InterfaceResult_doFn - DoReturnFn MoqUsual_InterfaceResult_doReturnFn + Runtime struct { + ParameterIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } } - Index uint32 - Repeat *moq.RepeatVal } -// MoqUsual_InterfaceResult_fnRecorder routes recorded function calls to the -// MoqUsual moq -type MoqUsual_InterfaceResult_fnRecorder struct { - Params MoqUsual_InterfaceResult_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_InterfaceResult_results - Moq *MoqUsual +// MoqGenericResultsFn_mock isolates the mock interface of the GenericResultsFn +// type +type MoqGenericResultsFn_mock[S ~string, E error] struct { + Moq *MoqGenericResultsFn[S, E] } -// MoqUsual_InterfaceResult_anyParams isolates the any params functions of the -// Usual type -type MoqUsual_InterfaceResult_anyParams struct { - Recorder *MoqUsual_InterfaceResult_fnRecorder +// MoqGenericResultsFn_params holds the params of the GenericResultsFn type +type MoqGenericResultsFn_params[S ~string, E error] struct { + Param1 string + Param2 bool } -// MoqUsual_FnParam_params holds the params of the Usual type -type MoqUsual_FnParam_params struct{ Fn func() } - -// MoqUsual_FnParam_paramsKey holds the map key params of the Usual type -type MoqUsual_FnParam_paramsKey struct { - Params struct{} - Hashes struct{ Fn hash.Hash } +// MoqGenericResultsFn_paramsKey holds the map key params of the +// GenericResultsFn type +type MoqGenericResultsFn_paramsKey[S ~string, E error] struct { + Params struct { + Param1 string + Param2 bool + } + Hashes struct { + Param1 hash.Hash + Param2 hash.Hash + } } -// MoqUsual_FnParam_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_FnParam_resultsByParams struct { +// MoqGenericResultsFn_resultsByParams contains the results for a given set of +// parameters for the GenericResultsFn type +type MoqGenericResultsFn_resultsByParams[S ~string, E error] struct { AnyCount int AnyParams uint64 - Results map[MoqUsual_FnParam_paramsKey]*MoqUsual_FnParam_results + Results map[MoqGenericResultsFn_paramsKey[S, E]]*MoqGenericResultsFn_results[S, E] } -// MoqUsual_FnParam_doFn defines the type of function needed when calling AndDo -// for the Usual type -type MoqUsual_FnParam_doFn func(fn func()) +// MoqGenericResultsFn_doFn defines the type of function needed when calling +// AndDo for the GenericResultsFn type +type MoqGenericResultsFn_doFn[S ~string, E error] func(string, bool) -// MoqUsual_FnParam_doReturnFn defines the type of function needed when calling -// DoReturnResults for the Usual type -type MoqUsual_FnParam_doReturnFn func(fn func()) +// MoqGenericResultsFn_doReturnFn defines the type of function needed when +// calling DoReturnResults for the GenericResultsFn type +type MoqGenericResultsFn_doReturnFn[S ~string, E error] func(string, bool) (S, E) -// MoqUsual_FnParam_results holds the results of the Usual type -type MoqUsual_FnParam_results struct { - Params MoqUsual_FnParam_params +// MoqGenericResultsFn_results holds the results of the GenericResultsFn type +type MoqGenericResultsFn_results[S ~string, E error] struct { + Params MoqGenericResultsFn_params[S, E] Results []struct { - Values *struct{} + Values *struct { + Result1 S + Result2 E + } Sequence uint32 - DoFn MoqUsual_FnParam_doFn - DoReturnFn MoqUsual_FnParam_doReturnFn + DoFn MoqGenericResultsFn_doFn[S, E] + DoReturnFn MoqGenericResultsFn_doReturnFn[S, E] } Index uint32 Repeat *moq.RepeatVal } -// MoqUsual_FnParam_fnRecorder routes recorded function calls to the MoqUsual -// moq -type MoqUsual_FnParam_fnRecorder struct { - Params MoqUsual_FnParam_params +// MoqGenericResultsFn_fnRecorder routes recorded function calls to the +// MoqGenericResultsFn moq +type MoqGenericResultsFn_fnRecorder[S ~string, E error] struct { + Params MoqGenericResultsFn_params[S, E] AnyParams uint64 Sequence bool - Results *MoqUsual_FnParam_results - Moq *MoqUsual + Results *MoqGenericResultsFn_results[S, E] + Moq *MoqGenericResultsFn[S, E] } -// MoqUsual_FnParam_anyParams isolates the any params functions of the Usual -// type -type MoqUsual_FnParam_anyParams struct { - Recorder *MoqUsual_FnParam_fnRecorder +// MoqGenericResultsFn_anyParams isolates the any params functions of the +// GenericResultsFn type +type MoqGenericResultsFn_anyParams[S ~string, E error] struct { + Recorder *MoqGenericResultsFn_fnRecorder[S, E] } -// NewMoqUsual creates a new moq of the Usual type -func NewMoqUsual(scene *moq.Scene, config *moq.Config) *MoqUsual { +// NewMoqGenericResultsFn creates a new moq of the GenericResultsFn type +func NewMoqGenericResultsFn[S ~string, E error](scene *moq.Scene, config *moq.Config) *MoqGenericResultsFn[S, E] { if config == nil { config = &moq.Config{} } - m := &MoqUsual{ + m := &MoqGenericResultsFn[S, E]{ Scene: scene, Config: *config, - Moq: &MoqUsual_mock{}, + Moq: &MoqGenericResultsFn_mock[S, E]{}, Runtime: struct { ParameterIndexing struct { - Usual struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - NoNames struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - NoResults struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - NoParams struct{} - Nothing struct{} - Variadic struct { - Other moq.ParamIndexing - Args moq.ParamIndexing - } - RepeatedIds struct { - SParam1 moq.ParamIndexing - SParam2 moq.ParamIndexing - BParam moq.ParamIndexing - } - Times struct { - SParam moq.ParamIndexing - Times moq.ParamIndexing - } - DifficultParamNames struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - Param3 moq.ParamIndexing - Param moq.ParamIndexing - Param5 moq.ParamIndexing - Param6 moq.ParamIndexing - Param7 moq.ParamIndexing - Param8 moq.ParamIndexing - Param9 moq.ParamIndexing - } - DifficultResultNames struct{} - PassByReference struct { - P moq.ParamIndexing - } - InterfaceParam struct { - W moq.ParamIndexing - } - InterfaceResult struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - FnParam struct { - Fn moq.ParamIndexing - } - } - }{ParameterIndexing: struct { - Usual struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - NoNames struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - NoResults struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - NoParams struct{} - Nothing struct{} - Variadic struct { - Other moq.ParamIndexing - Args moq.ParamIndexing - } - RepeatedIds struct { - SParam1 moq.ParamIndexing - SParam2 moq.ParamIndexing - BParam moq.ParamIndexing - } - Times struct { - SParam moq.ParamIndexing - Times moq.ParamIndexing - } - DifficultParamNames struct { Param1 moq.ParamIndexing Param2 moq.ParamIndexing - Param3 moq.ParamIndexing - Param moq.ParamIndexing - Param5 moq.ParamIndexing - Param6 moq.ParamIndexing - Param7 moq.ParamIndexing - Param8 moq.ParamIndexing - Param9 moq.ParamIndexing - } - DifficultResultNames struct{} - PassByReference struct { - P moq.ParamIndexing - } - InterfaceParam struct { - W moq.ParamIndexing - } - InterfaceResult struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - FnParam struct { - Fn moq.ParamIndexing } + }{ParameterIndexing: struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing }{ - Usual: struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - }{ - SParam: moq.ParamIndexByValue, - BParam: moq.ParamIndexByValue, - }, - NoNames: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - }{ - Param1: moq.ParamIndexByValue, - Param2: moq.ParamIndexByValue, - }, - NoResults: struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - }{ - SParam: moq.ParamIndexByValue, - BParam: moq.ParamIndexByValue, - }, - NoParams: struct{}{}, - Nothing: struct{}{}, - Variadic: struct { - Other moq.ParamIndexing - Args moq.ParamIndexing - }{ - Other: moq.ParamIndexByValue, - Args: moq.ParamIndexByHash, - }, - RepeatedIds: struct { - SParam1 moq.ParamIndexing - SParam2 moq.ParamIndexing - BParam moq.ParamIndexing - }{ - SParam1: moq.ParamIndexByValue, - SParam2: moq.ParamIndexByValue, - BParam: moq.ParamIndexByValue, - }, - Times: struct { - SParam moq.ParamIndexing - Times moq.ParamIndexing - }{ - SParam: moq.ParamIndexByValue, - Times: moq.ParamIndexByValue, - }, - DifficultParamNames: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - Param3 moq.ParamIndexing - Param moq.ParamIndexing - Param5 moq.ParamIndexing - Param6 moq.ParamIndexing - Param7 moq.ParamIndexing - Param8 moq.ParamIndexing - Param9 moq.ParamIndexing - }{ - Param1: moq.ParamIndexByValue, - Param2: moq.ParamIndexByValue, - Param3: moq.ParamIndexByValue, - Param: moq.ParamIndexByValue, - Param5: moq.ParamIndexByValue, - Param6: moq.ParamIndexByValue, - Param7: moq.ParamIndexByValue, - Param8: moq.ParamIndexByValue, - Param9: moq.ParamIndexByValue, - }, - DifficultResultNames: struct{}{}, - PassByReference: struct { - P moq.ParamIndexing - }{ - P: moq.ParamIndexByHash, - }, - InterfaceParam: struct { - W moq.ParamIndexing - }{ - W: moq.ParamIndexByHash, - }, - InterfaceResult: struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - }{ - SParam: moq.ParamIndexByValue, - BParam: moq.ParamIndexByValue, - }, - FnParam: struct { - Fn moq.ParamIndexing - }{ - Fn: moq.ParamIndexByHash, - }, + Param1: moq.ParamIndexByValue, + Param2: moq.ParamIndexByValue, }}, } m.Moq.Moq = m @@ -6596,73 +6380,24 @@ func NewMoqUsual(scene *moq.Scene, config *moq.Config) *MoqUsual { return m } -// Mock returns the mock implementation of the Usual type -func (m *MoqUsual) Mock() *MoqUsual_mock { return m.Moq } - -func (m *MoqUsual_mock) Usual(sParam string, bParam bool) (sResult string, err error) { - m.Moq.Scene.T.Helper() - params := MoqUsual_Usual_params{ - SParam: sParam, - BParam: bParam, - } - var results *MoqUsual_Usual_results - for _, resultsByParams := range m.Moq.ResultsByParams_Usual { - paramsKey := m.Moq.ParamsKey_Usual(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Usual(params)) - } - return - } - - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Usual(params)) - } - return - } - i = results.Repeat.ResultCount - 1 - } - - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Usual(params)) - } - } - - if result.DoFn != nil { - result.DoFn(sParam, bParam) - } - - if result.Values != nil { - sResult = result.Values.SResult - err = result.Values.Err - } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn(sParam, bParam) +// Mock returns the moq implementation of the GenericResultsFn type +func (m *MoqGenericResultsFn[S, E]) Mock() testmoqs.GenericResultsFn[S, E] { + return func(param1 string, param2 bool) (S, E) { + m.Scene.T.Helper() + moq := &MoqGenericResultsFn_mock[S, E]{Moq: m} + return moq.Fn(param1, param2) } - return } -func (m *MoqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, result2 error) { +func (m *MoqGenericResultsFn_mock[S, E]) Fn(param1 string, param2 bool) (result1 S, result2 E) { m.Moq.Scene.T.Helper() - params := MoqUsual_NoNames_params{ + params := MoqGenericResultsFn_params[S, E]{ Param1: param1, Param2: param2, } - var results *MoqUsual_NoNames_results - for _, resultsByParams := range m.Moq.ResultsByParams_NoNames { - paramsKey := m.Moq.ParamsKey_NoNames(params, resultsByParams.AnyParams) + var results *MoqGenericResultsFn_results[S, E] + for _, resultsByParams := range m.Moq.ResultsByParams { + paramsKey := m.Moq.ParamsKey(params, resultsByParams.AnyParams) var ok bool results, ok = resultsByParams.Results[paramsKey] if ok { @@ -6671,7 +6406,7 @@ func (m *MoqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, res } if results == nil { if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_NoNames(params)) + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams(params)) } return } @@ -6680,7 +6415,7 @@ func (m *MoqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, res if i >= results.Repeat.ResultCount { if !results.Repeat.AnyTimes { if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_NoNames(params)) + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams(params)) } return } @@ -6691,7 +6426,7 @@ func (m *MoqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, res if result.Sequence != 0 { sequence := m.Moq.Scene.NextMockSequence() if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_NoNames(params)) + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams(params)) } } @@ -6709,388 +6444,393 @@ func (m *MoqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, res return } -func (m *MoqUsual_mock) NoResults(sParam string, bParam bool) { - m.Moq.Scene.T.Helper() - params := MoqUsual_NoResults_params{ - SParam: sParam, - BParam: bParam, - } - var results *MoqUsual_NoResults_results - for _, resultsByParams := range m.Moq.ResultsByParams_NoResults { - paramsKey := m.Moq.ParamsKey_NoResults(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_NoResults(params)) - } - return +func (m *MoqGenericResultsFn[S, E]) OnCall(param1 string, param2 bool) *MoqGenericResultsFn_fnRecorder[S, E] { + return &MoqGenericResultsFn_fnRecorder[S, E]{ + Params: MoqGenericResultsFn_params[S, E]{ + Param1: param1, + Param2: param2, + }, + Sequence: m.Config.Sequence == moq.SeqDefaultOn, + Moq: m, } +} - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_NoResults(params)) - } - return - } - i = results.Repeat.ResultCount - 1 +func (r *MoqGenericResultsFn_fnRecorder[S, E]) Any() *MoqGenericResultsFn_anyParams[S, E] { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) + return nil } + return &MoqGenericResultsFn_anyParams[S, E]{Recorder: r} +} - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_NoResults(params)) - } - } +func (a *MoqGenericResultsFn_anyParams[S, E]) Param1() *MoqGenericResultsFn_fnRecorder[S, E] { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder +} - if result.DoFn != nil { - result.DoFn(sParam, bParam) - } +func (a *MoqGenericResultsFn_anyParams[S, E]) Param2() *MoqGenericResultsFn_fnRecorder[S, E] { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} - if result.DoReturnFn != nil { - result.DoReturnFn(sParam, bParam) +func (r *MoqGenericResultsFn_fnRecorder[S, E]) Seq() *MoqGenericResultsFn_fnRecorder[S, E] { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) + return nil } - return + r.Sequence = true + return r } -func (m *MoqUsual_mock) NoParams() (sResult string, err error) { - m.Moq.Scene.T.Helper() - params := MoqUsual_NoParams_params{} - var results *MoqUsual_NoParams_results - for _, resultsByParams := range m.Moq.ResultsByParams_NoParams { - paramsKey := m.Moq.ParamsKey_NoParams(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_NoParams(params)) - } - return +func (r *MoqGenericResultsFn_fnRecorder[S, E]) NoSeq() *MoqGenericResultsFn_fnRecorder[S, E] { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) + return nil } + r.Sequence = false + return r +} - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_NoParams(params)) - } - return - } - i = results.Repeat.ResultCount - 1 - } +func (r *MoqGenericResultsFn_fnRecorder[S, E]) ReturnResults(result1 S, result2 E) *MoqGenericResultsFn_fnRecorder[S, E] { + r.Moq.Scene.T.Helper() + r.FindResults() - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_NoParams(params)) - } + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() } - if result.DoFn != nil { - result.DoFn() - } + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + Result1 S + Result2 E + } + Sequence uint32 + DoFn MoqGenericResultsFn_doFn[S, E] + DoReturnFn MoqGenericResultsFn_doReturnFn[S, E] + }{ + Values: &struct { + Result1 S + Result2 E + }{ + Result1: result1, + Result2: result2, + }, + Sequence: sequence, + }) + return r +} - if result.Values != nil { - sResult = result.Values.SResult - err = result.Values.Err - } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn() +func (r *MoqGenericResultsFn_fnRecorder[S, E]) AndDo(fn MoqGenericResultsFn_doFn[S, E]) *MoqGenericResultsFn_fnRecorder[S, E] { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil } - return + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r } -func (m *MoqUsual_mock) Nothing() { - m.Moq.Scene.T.Helper() - params := MoqUsual_Nothing_params{} - var results *MoqUsual_Nothing_results - for _, resultsByParams := range m.Moq.ResultsByParams_Nothing { - paramsKey := m.Moq.ParamsKey_Nothing(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Nothing(params)) - } - return - } +func (r *MoqGenericResultsFn_fnRecorder[S, E]) DoReturnResults(fn MoqGenericResultsFn_doReturnFn[S, E]) *MoqGenericResultsFn_fnRecorder[S, E] { + r.Moq.Scene.T.Helper() + r.FindResults() - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Nothing(params)) - } - return - } - i = results.Repeat.ResultCount - 1 + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() } - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Nothing(params)) + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + Result1 S + Result2 E } - } - - if result.DoFn != nil { - result.DoFn() - } - - if result.DoReturnFn != nil { - result.DoReturnFn() - } - return + Sequence uint32 + DoFn MoqGenericResultsFn_doFn[S, E] + DoReturnFn MoqGenericResultsFn_doReturnFn[S, E] + }{Sequence: sequence, DoReturnFn: fn}) + return r } -func (m *MoqUsual_mock) Variadic(other bool, args ...string) (sResult string, err error) { - m.Moq.Scene.T.Helper() - params := MoqUsual_Variadic_params{ - Other: other, - Args: args, +func (r *MoqGenericResultsFn_fnRecorder[S, E]) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return } - var results *MoqUsual_Variadic_results - for _, resultsByParams := range m.Moq.ResultsByParams_Variadic { - paramsKey := m.Moq.ParamsKey_Variadic(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqGenericResultsFn_resultsByParams[S, E] + for n, res := range r.Moq.ResultsByParams { + if res.AnyParams == r.AnyParams { + results = &res break } + if res.AnyCount > anyCount { + insertAt = n + } } if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Variadic(params)) + results = &MoqGenericResultsFn_resultsByParams[S, E]{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqGenericResultsFn_paramsKey[S, E]]*MoqGenericResultsFn_results[S, E]{}, } - return - } - - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Variadic(params)) - } - return + r.Moq.ResultsByParams = append(r.Moq.ResultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams) { + copy(r.Moq.ResultsByParams[insertAt+1:], r.Moq.ResultsByParams[insertAt:0]) + r.Moq.ResultsByParams[insertAt] = *results } - i = results.Repeat.ResultCount - 1 } - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Variadic(params)) + paramsKey := r.Moq.ParamsKey(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqGenericResultsFn_results[S, E]{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, } + results.Results[paramsKey] = r.Results } - if result.DoFn != nil { - result.DoFn(other, args...) - } + r.Results.Repeat.Increment(r.Moq.Scene.T) +} - if result.Values != nil { - sResult = result.Values.SResult - err = result.Values.Err +func (r *MoqGenericResultsFn_fnRecorder[S, E]) Repeat(repeaters ...moq.Repeater) *MoqGenericResultsFn_fnRecorder[S, E] { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn(other, args...) + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct { + Result1 S + Result2 E + } + Sequence uint32 + DoFn MoqGenericResultsFn_doFn[S, E] + DoReturnFn MoqGenericResultsFn_doReturnFn[S, E] + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) } - return + return r } -func (m *MoqUsual_mock) RepeatedIds(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) { - m.Moq.Scene.T.Helper() - params := MoqUsual_RepeatedIds_params{ - SParam1: sParam1, - SParam2: sParam2, - BParam: bParam, - } - var results *MoqUsual_RepeatedIds_results - for _, resultsByParams := range m.Moq.ResultsByParams_RepeatedIds { - paramsKey := m.Moq.ParamsKey_RepeatedIds(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break +func (m *MoqGenericResultsFn[S, E]) PrettyParams(params MoqGenericResultsFn_params[S, E]) string { + return fmt.Sprintf("GenericResultsFn(%#v, %#v)", params.Param1, params.Param2) +} + +func (m *MoqGenericResultsFn[S, E]) ParamsKey(params MoqGenericResultsFn_params[S, E], anyParams uint64) MoqGenericResultsFn_paramsKey[S, E] { + m.Scene.T.Helper() + var param1Used string + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.Param1 == moq.ParamIndexByValue { + param1Used = params.Param1 + } else { + param1UsedHash = hash.DeepHash(params.Param1) } } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_RepeatedIds(params)) + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.Param2 == moq.ParamIndexByValue { + param2Used = params.Param2 + } else { + param2UsedHash = hash.DeepHash(params.Param2) } - return } + return MoqGenericResultsFn_paramsKey[S, E]{ + Params: struct { + Param1 string + Param2 bool + }{ + Param1: param1Used, + Param2: param2Used, + }, + Hashes: struct { + Param1 hash.Hash + Param2 hash.Hash + }{ + Param1: param1UsedHash, + Param2: param2UsedHash, + }, + } +} - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_RepeatedIds(params)) +// Reset resets the state of the moq +func (m *MoqGenericResultsFn[S, E]) Reset() { m.ResultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqGenericResultsFn[S, E]) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams(results.Params)) } - return } - i = results.Repeat.ResultCount - 1 } +} - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_RepeatedIds(params)) +// MoqPartialGenericResultsFn holds the state of a moq of the +// PartialGenericResultsFn type +type MoqPartialGenericResultsFn[S ~string] struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqPartialGenericResultsFn_mock[S] + + ResultsByParams []MoqPartialGenericResultsFn_resultsByParams[S] + + Runtime struct { + ParameterIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } } +} - if result.DoFn != nil { - result.DoFn(sParam1, sParam2, bParam) - } +// MoqPartialGenericResultsFn_mock isolates the mock interface of the +// PartialGenericResultsFn type +type MoqPartialGenericResultsFn_mock[S ~string] struct { + Moq *MoqPartialGenericResultsFn[S] +} - if result.Values != nil { - sResult1 = result.Values.SResult1 - sResult2 = result.Values.SResult2 - err = result.Values.Err - } - if result.DoReturnFn != nil { - sResult1, sResult2, err = result.DoReturnFn(sParam1, sParam2, bParam) - } - return +// MoqPartialGenericResultsFn_params holds the params of the +// PartialGenericResultsFn type +type MoqPartialGenericResultsFn_params[S ~string] struct { + Param1 string + Param2 bool } -func (m *MoqUsual_mock) Times(sParam string, times bool) (sResult string, err error) { - m.Moq.Scene.T.Helper() - params := MoqUsual_Times_params{ - SParam: sParam, - Times: times, - } - var results *MoqUsual_Times_results - for _, resultsByParams := range m.Moq.ResultsByParams_Times { - paramsKey := m.Moq.ParamsKey_Times(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } +// MoqPartialGenericResultsFn_paramsKey holds the map key params of the +// PartialGenericResultsFn type +type MoqPartialGenericResultsFn_paramsKey[S ~string] struct { + Params struct { + Param1 string + Param2 bool } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Times(params)) - } - return + Hashes struct { + Param1 hash.Hash + Param2 hash.Hash } +} - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Times(params)) - } - return - } - i = results.Repeat.ResultCount - 1 - } +// MoqPartialGenericResultsFn_resultsByParams contains the results for a given +// set of parameters for the PartialGenericResultsFn type +type MoqPartialGenericResultsFn_resultsByParams[S ~string] struct { + AnyCount int + AnyParams uint64 + Results map[MoqPartialGenericResultsFn_paramsKey[S]]*MoqPartialGenericResultsFn_results[S] +} - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Times(params)) +// MoqPartialGenericResultsFn_doFn defines the type of function needed when +// calling AndDo for the PartialGenericResultsFn type +type MoqPartialGenericResultsFn_doFn[S ~string] func(string, bool) + +// MoqPartialGenericResultsFn_doReturnFn defines the type of function needed +// when calling DoReturnResults for the PartialGenericResultsFn type +type MoqPartialGenericResultsFn_doReturnFn[S ~string] func(string, bool) (S, error) + +// MoqPartialGenericResultsFn_results holds the results of the +// PartialGenericResultsFn type +type MoqPartialGenericResultsFn_results[S ~string] struct { + Params MoqPartialGenericResultsFn_params[S] + Results []struct { + Values *struct { + Result1 S + Result2 error } + Sequence uint32 + DoFn MoqPartialGenericResultsFn_doFn[S] + DoReturnFn MoqPartialGenericResultsFn_doReturnFn[S] } + Index uint32 + Repeat *moq.RepeatVal +} - if result.DoFn != nil { - result.DoFn(sParam, times) - } +// MoqPartialGenericResultsFn_fnRecorder routes recorded function calls to the +// MoqPartialGenericResultsFn moq +type MoqPartialGenericResultsFn_fnRecorder[S ~string] struct { + Params MoqPartialGenericResultsFn_params[S] + AnyParams uint64 + Sequence bool + Results *MoqPartialGenericResultsFn_results[S] + Moq *MoqPartialGenericResultsFn[S] +} - if result.Values != nil { - sResult = result.Values.SResult - err = result.Values.Err - } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn(sParam, times) - } - return +// MoqPartialGenericResultsFn_anyParams isolates the any params functions of +// the PartialGenericResultsFn type +type MoqPartialGenericResultsFn_anyParams[S ~string] struct { + Recorder *MoqPartialGenericResultsFn_fnRecorder[S] } -func (m *MoqUsual_mock) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) { - m.Moq.Scene.T.Helper() - params := MoqUsual_DifficultParamNames_params{ - Param1: param1, - Param2: param2, - Param3: param3, - Param: param, - Param5: param5, - Param6: param6, - Param7: param7, - Param8: param8, - Param9: param9, - } - var results *MoqUsual_DifficultParamNames_results - for _, resultsByParams := range m.Moq.ResultsByParams_DifficultParamNames { - paramsKey := m.Moq.ParamsKey_DifficultParamNames(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_DifficultParamNames(params)) - } - return +// NewMoqPartialGenericResultsFn creates a new moq of the +// PartialGenericResultsFn type +func NewMoqPartialGenericResultsFn[S ~string](scene *moq.Scene, config *moq.Config) *MoqPartialGenericResultsFn[S] { + if config == nil { + config = &moq.Config{} } + m := &MoqPartialGenericResultsFn[S]{ + Scene: scene, + Config: *config, + Moq: &MoqPartialGenericResultsFn_mock[S]{}, - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_DifficultParamNames(params)) + Runtime: struct { + ParameterIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } - return - } - i = results.Repeat.ResultCount - 1 - } - - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_DifficultParamNames(params)) - } + }{ParameterIndexing: struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + }{ + Param1: moq.ParamIndexByValue, + Param2: moq.ParamIndexByValue, + }}, } + m.Moq.Moq = m - if result.DoFn != nil { - result.DoFn(param1, param2, param3, param, param5, param6, param7, param8, param9) - } + scene.AddMoq(m) + return m +} - if result.DoReturnFn != nil { - result.DoReturnFn(param1, param2, param3, param, param5, param6, param7, param8, param9) +// Mock returns the moq implementation of the PartialGenericResultsFn type +func (m *MoqPartialGenericResultsFn[S]) Mock() testmoqs.PartialGenericResultsFn[S] { + return func(param1 string, param2 bool) (S, error) { + m.Scene.T.Helper() + moq := &MoqPartialGenericResultsFn_mock[S]{Moq: m} + return moq.Fn(param1, param2) } - return } -func (m *MoqUsual_mock) DifficultResultNames() (result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) { +func (m *MoqPartialGenericResultsFn_mock[S]) Fn(param1 string, param2 bool) (result1 S, result2 error) { m.Moq.Scene.T.Helper() - params := MoqUsual_DifficultResultNames_params{} - var results *MoqUsual_DifficultResultNames_results - for _, resultsByParams := range m.Moq.ResultsByParams_DifficultResultNames { - paramsKey := m.Moq.ParamsKey_DifficultResultNames(params, resultsByParams.AnyParams) + params := MoqPartialGenericResultsFn_params[S]{ + Param1: param1, + Param2: param2, + } + var results *MoqPartialGenericResultsFn_results[S] + for _, resultsByParams := range m.Moq.ResultsByParams { + paramsKey := m.Moq.ParamsKey(params, resultsByParams.AnyParams) var ok bool results, ok = resultsByParams.Results[paramsKey] if ok { @@ -7099,7 +6839,7 @@ func (m *MoqUsual_mock) DifficultResultNames() (result1, result2 string, result3 } if results == nil { if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_DifficultResultNames(params)) + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams(params)) } return } @@ -7108,7 +6848,7 @@ func (m *MoqUsual_mock) DifficultResultNames() (result1, result2 string, result3 if i >= results.Repeat.ResultCount { if !results.Repeat.AnyTimes { if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_DifficultResultNames(params)) + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams(params)) } return } @@ -7119,301 +6859,75 @@ func (m *MoqUsual_mock) DifficultResultNames() (result1, result2 string, result3 if result.Sequence != 0 { sequence := m.Moq.Scene.NextMockSequence() if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_DifficultResultNames(params)) + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams(params)) } } if result.DoFn != nil { - result.DoFn() + result.DoFn(param1, param2) } if result.Values != nil { result1 = result.Values.Result1 result2 = result.Values.Result2 - result3 = result.Values.Result3 - param = result.Values.Param - result5 = result.Values.Result5 - result6 = result.Values.Result6 - result7 = result.Values.Result7 - result8 = result.Values.Result8 - result9 = result.Values.Result9 } if result.DoReturnFn != nil { - result1, result2, result3, param, result5, result6, result7, result8, result9 = result.DoReturnFn() + result1, result2 = result.DoReturnFn(param1, param2) } return } -func (m *MoqUsual_mock) PassByReference(p *testmoqs.PassByReferenceParams) (sResult string, err error) { - m.Moq.Scene.T.Helper() - params := MoqUsual_PassByReference_params{ - P: p, - } - var results *MoqUsual_PassByReference_results - for _, resultsByParams := range m.Moq.ResultsByParams_PassByReference { - paramsKey := m.Moq.ParamsKey_PassByReference(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_PassByReference(params)) - } - return - } - - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_PassByReference(params)) - } - return - } - i = results.Repeat.ResultCount - 1 - } - - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_PassByReference(params)) - } - } - - if result.DoFn != nil { - result.DoFn(p) - } - - if result.Values != nil { - sResult = result.Values.SResult - err = result.Values.Err - } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn(p) - } - return -} - -func (m *MoqUsual_mock) InterfaceParam(w io.Writer) (sResult string, err error) { - m.Moq.Scene.T.Helper() - params := MoqUsual_InterfaceParam_params{ - W: w, - } - var results *MoqUsual_InterfaceParam_results - for _, resultsByParams := range m.Moq.ResultsByParams_InterfaceParam { - paramsKey := m.Moq.ParamsKey_InterfaceParam(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_InterfaceParam(params)) - } - return - } - - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_InterfaceParam(params)) - } - return - } - i = results.Repeat.ResultCount - 1 - } - - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_InterfaceParam(params)) - } - } - - if result.DoFn != nil { - result.DoFn(w) - } - - if result.Values != nil { - sResult = result.Values.SResult - err = result.Values.Err - } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn(w) - } - return -} - -func (m *MoqUsual_mock) InterfaceResult(sParam string, bParam bool) (result1 io.Reader) { - m.Moq.Scene.T.Helper() - params := MoqUsual_InterfaceResult_params{ - SParam: sParam, - BParam: bParam, - } - var results *MoqUsual_InterfaceResult_results - for _, resultsByParams := range m.Moq.ResultsByParams_InterfaceResult { - paramsKey := m.Moq.ParamsKey_InterfaceResult(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_InterfaceResult(params)) - } - return - } - - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_InterfaceResult(params)) - } - return - } - i = results.Repeat.ResultCount - 1 - } - - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_InterfaceResult(params)) - } - } - - if result.DoFn != nil { - result.DoFn(sParam, bParam) - } - - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(sParam, bParam) - } - return -} - -func (m *MoqUsual_mock) FnParam(fn func()) { - m.Moq.Scene.T.Helper() - params := MoqUsual_FnParam_params{ - Fn: fn, - } - var results *MoqUsual_FnParam_results - for _, resultsByParams := range m.Moq.ResultsByParams_FnParam { - paramsKey := m.Moq.ParamsKey_FnParam(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_FnParam(params)) - } - return - } - - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_FnParam(params)) - } - return - } - i = results.Repeat.ResultCount - 1 - } - - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_FnParam(params)) - } - } - - if result.DoFn != nil { - result.DoFn(fn) - } - - if result.DoReturnFn != nil { - result.DoReturnFn(fn) - } - return -} - -// OnCall returns the recorder implementation of the Usual type -func (m *MoqUsual) OnCall() *MoqUsual_recorder { - return &MoqUsual_recorder{ - Moq: m, - } -} - -func (m *MoqUsual_recorder) Usual(sParam string, bParam bool) *MoqUsual_Usual_fnRecorder { - return &MoqUsual_Usual_fnRecorder{ - Params: MoqUsual_Usual_params{ - SParam: sParam, - BParam: bParam, +func (m *MoqPartialGenericResultsFn[S]) OnCall(param1 string, param2 bool) *MoqPartialGenericResultsFn_fnRecorder[S] { + return &MoqPartialGenericResultsFn_fnRecorder[S]{ + Params: MoqPartialGenericResultsFn_params[S]{ + Param1: param1, + Param2: param2, }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + Sequence: m.Config.Sequence == moq.SeqDefaultOn, + Moq: m, } } -func (r *MoqUsual_Usual_fnRecorder) Any() *MoqUsual_Usual_anyParams { +func (r *MoqPartialGenericResultsFn_fnRecorder[S]) Any() *MoqPartialGenericResultsFn_anyParams[S] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) return nil } - return &MoqUsual_Usual_anyParams{Recorder: r} + return &MoqPartialGenericResultsFn_anyParams[S]{Recorder: r} } -func (a *MoqUsual_Usual_anyParams) SParam() *MoqUsual_Usual_fnRecorder { +func (a *MoqPartialGenericResultsFn_anyParams[S]) Param1() *MoqPartialGenericResultsFn_fnRecorder[S] { a.Recorder.AnyParams |= 1 << 0 return a.Recorder } -func (a *MoqUsual_Usual_anyParams) BParam() *MoqUsual_Usual_fnRecorder { +func (a *MoqPartialGenericResultsFn_anyParams[S]) Param2() *MoqPartialGenericResultsFn_fnRecorder[S] { a.Recorder.AnyParams |= 1 << 1 return a.Recorder } -func (r *MoqUsual_Usual_fnRecorder) Seq() *MoqUsual_Usual_fnRecorder { +func (r *MoqPartialGenericResultsFn_fnRecorder[S]) Seq() *MoqPartialGenericResultsFn_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_Usual_fnRecorder) NoSeq() *MoqUsual_Usual_fnRecorder { +func (r *MoqPartialGenericResultsFn_fnRecorder[S]) NoSeq() *MoqPartialGenericResultsFn_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_Usual_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_Usual_fnRecorder { +func (r *MoqPartialGenericResultsFn_fnRecorder[S]) ReturnResults(result1 S, result2 error) *MoqPartialGenericResultsFn_fnRecorder[S] { r.Moq.Scene.T.Helper() r.FindResults() @@ -7424,26 +6938,26 @@ func (r *MoqUsual_Usual_fnRecorder) ReturnResults(sResult string, err error) *Mo r.Results.Results = append(r.Results.Results, struct { Values *struct { - SResult string - Err error + Result1 S + Result2 error } Sequence uint32 - DoFn MoqUsual_Usual_doFn - DoReturnFn MoqUsual_Usual_doReturnFn + DoFn MoqPartialGenericResultsFn_doFn[S] + DoReturnFn MoqPartialGenericResultsFn_doReturnFn[S] }{ Values: &struct { - SResult string - Err error + Result1 S + Result2 error }{ - SResult: sResult, - Err: err, + Result1: result1, + Result2: result2, }, Sequence: sequence, }) return r } -func (r *MoqUsual_Usual_fnRecorder) AndDo(fn MoqUsual_Usual_doFn) *MoqUsual_Usual_fnRecorder { +func (r *MoqPartialGenericResultsFn_fnRecorder[S]) AndDo(fn MoqPartialGenericResultsFn_doFn[S]) *MoqPartialGenericResultsFn_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -7454,7 +6968,7 @@ func (r *MoqUsual_Usual_fnRecorder) AndDo(fn MoqUsual_Usual_doFn) *MoqUsual_Usua return r } -func (r *MoqUsual_Usual_fnRecorder) DoReturnResults(fn MoqUsual_Usual_doReturnFn) *MoqUsual_Usual_fnRecorder { +func (r *MoqPartialGenericResultsFn_fnRecorder[S]) DoReturnResults(fn MoqPartialGenericResultsFn_doReturnFn[S]) *MoqPartialGenericResultsFn_fnRecorder[S] { r.Moq.Scene.T.Helper() r.FindResults() @@ -7465,17 +6979,17 @@ func (r *MoqUsual_Usual_fnRecorder) DoReturnResults(fn MoqUsual_Usual_doReturnFn r.Results.Results = append(r.Results.Results, struct { Values *struct { - SResult string - Err error + Result1 S + Result2 error } Sequence uint32 - DoFn MoqUsual_Usual_doFn - DoReturnFn MoqUsual_Usual_doReturnFn + DoFn MoqPartialGenericResultsFn_doFn[S] + DoReturnFn MoqPartialGenericResultsFn_doReturnFn[S] }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_Usual_fnRecorder) FindResults() { +func (r *MoqPartialGenericResultsFn_fnRecorder[S]) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -7484,8 +6998,8 @@ func (r *MoqUsual_Usual_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_Usual_resultsByParams - for n, res := range r.Moq.ResultsByParams_Usual { + var results *MoqPartialGenericResultsFn_resultsByParams[S] + for n, res := range r.Moq.ResultsByParams { if res.AnyParams == r.AnyParams { results = &res break @@ -7495,24 +7009,24 @@ func (r *MoqUsual_Usual_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_Usual_resultsByParams{ + results = &MoqPartialGenericResultsFn_resultsByParams[S]{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_Usual_paramsKey]*MoqUsual_Usual_results{}, + Results: map[MoqPartialGenericResultsFn_paramsKey[S]]*MoqPartialGenericResultsFn_results[S]{}, } - r.Moq.ResultsByParams_Usual = append(r.Moq.ResultsByParams_Usual, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Usual) { - copy(r.Moq.ResultsByParams_Usual[insertAt+1:], r.Moq.ResultsByParams_Usual[insertAt:0]) - r.Moq.ResultsByParams_Usual[insertAt] = *results + r.Moq.ResultsByParams = append(r.Moq.ResultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams) { + copy(r.Moq.ResultsByParams[insertAt+1:], r.Moq.ResultsByParams[insertAt:0]) + r.Moq.ResultsByParams[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_Usual(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_Usual_results{ + r.Results = &MoqPartialGenericResultsFn_results[S]{ Params: r.Params, Results: nil, Index: 0, @@ -7524,7 +7038,7 @@ func (r *MoqUsual_Usual_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_Usual_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Usual_fnRecorder { +func (r *MoqPartialGenericResultsFn_fnRecorder[S]) Repeat(repeaters ...moq.Repeater) *MoqPartialGenericResultsFn_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -7536,12 +7050,12 @@ func (r *MoqUsual_Usual_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_ if r.Sequence { last = struct { Values *struct { - SResult string - Err error + Result1 S + Result2 error } Sequence uint32 - DoFn MoqUsual_Usual_doFn - DoReturnFn MoqUsual_Usual_doReturnFn + DoFn MoqPartialGenericResultsFn_doFn[S] + DoReturnFn MoqPartialGenericResultsFn_doReturnFn[S] }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -7552,99 +7066,281 @@ func (r *MoqUsual_Usual_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_ return r } -func (m *MoqUsual) PrettyParams_Usual(params MoqUsual_Usual_params) string { - return fmt.Sprintf("Usual(%#v, %#v)", params.SParam, params.BParam) +func (m *MoqPartialGenericResultsFn[S]) PrettyParams(params MoqPartialGenericResultsFn_params[S]) string { + return fmt.Sprintf("PartialGenericResultsFn(%#v, %#v)", params.Param1, params.Param2) } -func (m *MoqUsual) ParamsKey_Usual(params MoqUsual_Usual_params, anyParams uint64) MoqUsual_Usual_paramsKey { +func (m *MoqPartialGenericResultsFn[S]) ParamsKey(params MoqPartialGenericResultsFn_params[S], anyParams uint64) MoqPartialGenericResultsFn_paramsKey[S] { m.Scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash + var param1Used string + var param1UsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.Usual.SParam == moq.ParamIndexByValue { - sParamUsed = params.SParam + if m.Runtime.ParameterIndexing.Param1 == moq.ParamIndexByValue { + param1Used = params.Param1 } else { - sParamUsedHash = hash.DeepHash(params.SParam) + param1UsedHash = hash.DeepHash(params.Param1) } } - var bParamUsed bool - var bParamUsedHash hash.Hash + var param2Used bool + var param2UsedHash hash.Hash if anyParams&(1<<1) == 0 { - if m.Runtime.ParameterIndexing.Usual.BParam == moq.ParamIndexByValue { - bParamUsed = params.BParam + if m.Runtime.ParameterIndexing.Param2 == moq.ParamIndexByValue { + param2Used = params.Param2 } else { - bParamUsedHash = hash.DeepHash(params.BParam) + param2UsedHash = hash.DeepHash(params.Param2) } } - return MoqUsual_Usual_paramsKey{ + return MoqPartialGenericResultsFn_paramsKey[S]{ Params: struct { - SParam string - BParam bool + Param1 string + Param2 bool }{ - SParam: sParamUsed, - BParam: bParamUsed, + Param1: param1Used, + Param2: param2Used, }, Hashes: struct { - SParam hash.Hash - BParam hash.Hash + Param1 hash.Hash + Param2 hash.Hash }{ - SParam: sParamUsedHash, - BParam: bParamUsedHash, + Param1: param1UsedHash, + Param2: param2UsedHash, }, } } -func (m *MoqUsual_recorder) NoNames(param1 string, param2 bool) *MoqUsual_NoNames_fnRecorder { - return &MoqUsual_NoNames_fnRecorder{ - Params: MoqUsual_NoNames_params{ - Param1: param1, - Param2: param2, +// Reset resets the state of the moq +func (m *MoqPartialGenericResultsFn[S]) Reset() { m.ResultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqPartialGenericResultsFn[S]) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams(results.Params)) + } + } + } +} + +// MoqGenericInterfaceParamFn holds the state of a moq of the +// GenericInterfaceParamFn type +type MoqGenericInterfaceParamFn[W testmoqs.MyWriter] struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqGenericInterfaceParamFn_mock[W] + + ResultsByParams []MoqGenericInterfaceParamFn_resultsByParams[W] + + Runtime struct { + ParameterIndexing struct { + W moq.ParamIndexing + } + } +} + +// MoqGenericInterfaceParamFn_mock isolates the mock interface of the +// GenericInterfaceParamFn type +type MoqGenericInterfaceParamFn_mock[W testmoqs.MyWriter] struct { + Moq *MoqGenericInterfaceParamFn[W] +} + +// MoqGenericInterfaceParamFn_params holds the params of the +// GenericInterfaceParamFn type +type MoqGenericInterfaceParamFn_params[W testmoqs.MyWriter] struct{ W W } + +// MoqGenericInterfaceParamFn_paramsKey holds the map key params of the +// GenericInterfaceParamFn type +type MoqGenericInterfaceParamFn_paramsKey[W testmoqs.MyWriter] struct { + Params struct{} + Hashes struct{ W hash.Hash } +} + +// MoqGenericInterfaceParamFn_resultsByParams contains the results for a given +// set of parameters for the GenericInterfaceParamFn type +type MoqGenericInterfaceParamFn_resultsByParams[W testmoqs.MyWriter] struct { + AnyCount int + AnyParams uint64 + Results map[MoqGenericInterfaceParamFn_paramsKey[W]]*MoqGenericInterfaceParamFn_results[W] +} + +// MoqGenericInterfaceParamFn_doFn defines the type of function needed when +// calling AndDo for the GenericInterfaceParamFn type +type MoqGenericInterfaceParamFn_doFn[W testmoqs.MyWriter] func(w W) + +// MoqGenericInterfaceParamFn_doReturnFn defines the type of function needed +// when calling DoReturnResults for the GenericInterfaceParamFn type +type MoqGenericInterfaceParamFn_doReturnFn[W testmoqs.MyWriter] func(w W) (sResult string, err error) + +// MoqGenericInterfaceParamFn_results holds the results of the +// GenericInterfaceParamFn type +type MoqGenericInterfaceParamFn_results[W testmoqs.MyWriter] struct { + Params MoqGenericInterfaceParamFn_params[W] + Results []struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqGenericInterfaceParamFn_doFn[W] + DoReturnFn MoqGenericInterfaceParamFn_doReturnFn[W] + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqGenericInterfaceParamFn_fnRecorder routes recorded function calls to the +// MoqGenericInterfaceParamFn moq +type MoqGenericInterfaceParamFn_fnRecorder[W testmoqs.MyWriter] struct { + Params MoqGenericInterfaceParamFn_params[W] + AnyParams uint64 + Sequence bool + Results *MoqGenericInterfaceParamFn_results[W] + Moq *MoqGenericInterfaceParamFn[W] +} + +// MoqGenericInterfaceParamFn_anyParams isolates the any params functions of +// the GenericInterfaceParamFn type +type MoqGenericInterfaceParamFn_anyParams[W testmoqs.MyWriter] struct { + Recorder *MoqGenericInterfaceParamFn_fnRecorder[W] +} + +// NewMoqGenericInterfaceParamFn creates a new moq of the +// GenericInterfaceParamFn type +func NewMoqGenericInterfaceParamFn[W testmoqs.MyWriter](scene *moq.Scene, config *moq.Config) *MoqGenericInterfaceParamFn[W] { + if config == nil { + config = &moq.Config{} + } + m := &MoqGenericInterfaceParamFn[W]{ + Scene: scene, + Config: *config, + Moq: &MoqGenericInterfaceParamFn_mock[W]{}, + + Runtime: struct { + ParameterIndexing struct { + W moq.ParamIndexing + } + }{ParameterIndexing: struct { + W moq.ParamIndexing + }{ + W: moq.ParamIndexByHash, + }}, + } + m.Moq.Moq = m + + scene.AddMoq(m) + return m +} + +// Mock returns the moq implementation of the GenericInterfaceParamFn type +func (m *MoqGenericInterfaceParamFn[W]) Mock() testmoqs.GenericInterfaceParamFn[W] { + return func(w W) (_ string, _ error) { + m.Scene.T.Helper() + moq := &MoqGenericInterfaceParamFn_mock[W]{Moq: m} + return moq.Fn(w) + } +} + +func (m *MoqGenericInterfaceParamFn_mock[W]) Fn(w W) (sResult string, err error) { + m.Moq.Scene.T.Helper() + params := MoqGenericInterfaceParamFn_params[W]{ + W: w, + } + var results *MoqGenericInterfaceParamFn_results[W] + for _, resultsByParams := range m.Moq.ResultsByParams { + paramsKey := m.Moq.ParamsKey(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams(params)) + } + } + + if result.DoFn != nil { + result.DoFn(w) + } + + if result.Values != nil { + sResult = result.Values.SResult + err = result.Values.Err + } + if result.DoReturnFn != nil { + sResult, err = result.DoReturnFn(w) + } + return +} + +func (m *MoqGenericInterfaceParamFn[W]) OnCall(w W) *MoqGenericInterfaceParamFn_fnRecorder[W] { + return &MoqGenericInterfaceParamFn_fnRecorder[W]{ + Params: MoqGenericInterfaceParamFn_params[W]{ + W: w, }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + Sequence: m.Config.Sequence == moq.SeqDefaultOn, + Moq: m, } } -func (r *MoqUsual_NoNames_fnRecorder) Any() *MoqUsual_NoNames_anyParams { +func (r *MoqGenericInterfaceParamFn_fnRecorder[W]) Any() *MoqGenericInterfaceParamFn_anyParams[W] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoNames(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) return nil } - return &MoqUsual_NoNames_anyParams{Recorder: r} + return &MoqGenericInterfaceParamFn_anyParams[W]{Recorder: r} } -func (a *MoqUsual_NoNames_anyParams) Param1() *MoqUsual_NoNames_fnRecorder { +func (a *MoqGenericInterfaceParamFn_anyParams[W]) W() *MoqGenericInterfaceParamFn_fnRecorder[W] { a.Recorder.AnyParams |= 1 << 0 return a.Recorder } -func (a *MoqUsual_NoNames_anyParams) Param2() *MoqUsual_NoNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 - return a.Recorder -} - -func (r *MoqUsual_NoNames_fnRecorder) Seq() *MoqUsual_NoNames_fnRecorder { +func (r *MoqGenericInterfaceParamFn_fnRecorder[W]) Seq() *MoqGenericInterfaceParamFn_fnRecorder[W] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoNames(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_NoNames_fnRecorder) NoSeq() *MoqUsual_NoNames_fnRecorder { +func (r *MoqGenericInterfaceParamFn_fnRecorder[W]) NoSeq() *MoqGenericInterfaceParamFn_fnRecorder[W] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoNames(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_NoNames_fnRecorder) ReturnResults(result1 string, result2 error) *MoqUsual_NoNames_fnRecorder { +func (r *MoqGenericInterfaceParamFn_fnRecorder[W]) ReturnResults(sResult string, err error) *MoqGenericInterfaceParamFn_fnRecorder[W] { r.Moq.Scene.T.Helper() r.FindResults() @@ -7655,26 +7351,26 @@ func (r *MoqUsual_NoNames_fnRecorder) ReturnResults(result1 string, result2 erro r.Results.Results = append(r.Results.Results, struct { Values *struct { - Result1 string - Result2 error + SResult string + Err error } Sequence uint32 - DoFn MoqUsual_NoNames_doFn - DoReturnFn MoqUsual_NoNames_doReturnFn + DoFn MoqGenericInterfaceParamFn_doFn[W] + DoReturnFn MoqGenericInterfaceParamFn_doReturnFn[W] }{ Values: &struct { - Result1 string - Result2 error + SResult string + Err error }{ - Result1: result1, - Result2: result2, + SResult: sResult, + Err: err, }, Sequence: sequence, }) return r } -func (r *MoqUsual_NoNames_fnRecorder) AndDo(fn MoqUsual_NoNames_doFn) *MoqUsual_NoNames_fnRecorder { +func (r *MoqGenericInterfaceParamFn_fnRecorder[W]) AndDo(fn MoqGenericInterfaceParamFn_doFn[W]) *MoqGenericInterfaceParamFn_fnRecorder[W] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -7685,7 +7381,7 @@ func (r *MoqUsual_NoNames_fnRecorder) AndDo(fn MoqUsual_NoNames_doFn) *MoqUsual_ return r } -func (r *MoqUsual_NoNames_fnRecorder) DoReturnResults(fn MoqUsual_NoNames_doReturnFn) *MoqUsual_NoNames_fnRecorder { +func (r *MoqGenericInterfaceParamFn_fnRecorder[W]) DoReturnResults(fn MoqGenericInterfaceParamFn_doReturnFn[W]) *MoqGenericInterfaceParamFn_fnRecorder[W] { r.Moq.Scene.T.Helper() r.FindResults() @@ -7696,17 +7392,17 @@ func (r *MoqUsual_NoNames_fnRecorder) DoReturnResults(fn MoqUsual_NoNames_doRetu r.Results.Results = append(r.Results.Results, struct { Values *struct { - Result1 string - Result2 error + SResult string + Err error } Sequence uint32 - DoFn MoqUsual_NoNames_doFn - DoReturnFn MoqUsual_NoNames_doReturnFn + DoFn MoqGenericInterfaceParamFn_doFn[W] + DoReturnFn MoqGenericInterfaceParamFn_doReturnFn[W] }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_NoNames_fnRecorder) FindResults() { +func (r *MoqGenericInterfaceParamFn_fnRecorder[W]) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -7715,8 +7411,8 @@ func (r *MoqUsual_NoNames_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_NoNames_resultsByParams - for n, res := range r.Moq.ResultsByParams_NoNames { + var results *MoqGenericInterfaceParamFn_resultsByParams[W] + for n, res := range r.Moq.ResultsByParams { if res.AnyParams == r.AnyParams { results = &res break @@ -7726,24 +7422,24 @@ func (r *MoqUsual_NoNames_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_NoNames_resultsByParams{ + results = &MoqGenericInterfaceParamFn_resultsByParams[W]{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_NoNames_paramsKey]*MoqUsual_NoNames_results{}, + Results: map[MoqGenericInterfaceParamFn_paramsKey[W]]*MoqGenericInterfaceParamFn_results[W]{}, } - r.Moq.ResultsByParams_NoNames = append(r.Moq.ResultsByParams_NoNames, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_NoNames) { - copy(r.Moq.ResultsByParams_NoNames[insertAt+1:], r.Moq.ResultsByParams_NoNames[insertAt:0]) - r.Moq.ResultsByParams_NoNames[insertAt] = *results + r.Moq.ResultsByParams = append(r.Moq.ResultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams) { + copy(r.Moq.ResultsByParams[insertAt+1:], r.Moq.ResultsByParams[insertAt:0]) + r.Moq.ResultsByParams[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_NoNames(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_NoNames_results{ + r.Results = &MoqGenericInterfaceParamFn_results[W]{ Params: r.Params, Results: nil, Index: 0, @@ -7755,7 +7451,7 @@ func (r *MoqUsual_NoNames_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_NoNames_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_NoNames_fnRecorder { +func (r *MoqGenericInterfaceParamFn_fnRecorder[W]) Repeat(repeaters ...moq.Repeater) *MoqGenericInterfaceParamFn_fnRecorder[W] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -7767,12 +7463,12 @@ func (r *MoqUsual_NoNames_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsua if r.Sequence { last = struct { Values *struct { - Result1 string - Result2 error + SResult string + Err error } Sequence uint32 - DoFn MoqUsual_NoNames_doFn - DoReturnFn MoqUsual_NoNames_doReturnFn + DoFn MoqGenericInterfaceParamFn_doFn[W] + DoReturnFn MoqGenericInterfaceParamFn_doReturnFn[W] }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -7783,99 +7479,276 @@ func (r *MoqUsual_NoNames_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsua return r } -func (m *MoqUsual) PrettyParams_NoNames(params MoqUsual_NoNames_params) string { - return fmt.Sprintf("NoNames(%#v, %#v)", params.Param1, params.Param2) +func (m *MoqGenericInterfaceParamFn[W]) PrettyParams(params MoqGenericInterfaceParamFn_params[W]) string { + return fmt.Sprintf("GenericInterfaceParamFn(%#v)", params.W) } -func (m *MoqUsual) ParamsKey_NoNames(params MoqUsual_NoNames_params, anyParams uint64) MoqUsual_NoNames_paramsKey { +func (m *MoqGenericInterfaceParamFn[W]) ParamsKey(params MoqGenericInterfaceParamFn_params[W], anyParams uint64) MoqGenericInterfaceParamFn_paramsKey[W] { m.Scene.T.Helper() - var param1Used string - var param1UsedHash hash.Hash + var wUsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.NoNames.Param1 == moq.ParamIndexByValue { - param1Used = params.Param1 - } else { - param1UsedHash = hash.DeepHash(params.Param1) + if m.Runtime.ParameterIndexing.W == moq.ParamIndexByValue { + m.Scene.T.Fatalf("The w parameter can't be indexed by value") } + wUsedHash = hash.DeepHash(params.W) } - var param2Used bool - var param2UsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.Runtime.ParameterIndexing.NoNames.Param2 == moq.ParamIndexByValue { - param2Used = params.Param2 - } else { - param2UsedHash = hash.DeepHash(params.Param2) + return MoqGenericInterfaceParamFn_paramsKey[W]{ + Params: struct{}{}, + Hashes: struct{ W hash.Hash }{ + W: wUsedHash, + }, + } +} + +// Reset resets the state of the moq +func (m *MoqGenericInterfaceParamFn[W]) Reset() { m.ResultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqGenericInterfaceParamFn[W]) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams(results.Params)) + } } } - return MoqUsual_NoNames_paramsKey{ - Params: struct { - Param1 string - Param2 bool - }{ - Param1: param1Used, - Param2: param2Used, - }, - Hashes: struct { - Param1 hash.Hash - Param2 hash.Hash +} + +// MoqGenericInterfaceResultFn holds the state of a moq of the +// GenericInterfaceResultFn type +type MoqGenericInterfaceResultFn[R testmoqs.MyReader] struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqGenericInterfaceResultFn_mock[R] + + ResultsByParams []MoqGenericInterfaceResultFn_resultsByParams[R] + + Runtime struct { + ParameterIndexing struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + } +} + +// MoqGenericInterfaceResultFn_mock isolates the mock interface of the +// GenericInterfaceResultFn type +type MoqGenericInterfaceResultFn_mock[R testmoqs.MyReader] struct { + Moq *MoqGenericInterfaceResultFn[R] +} + +// MoqGenericInterfaceResultFn_params holds the params of the +// GenericInterfaceResultFn type +type MoqGenericInterfaceResultFn_params[R testmoqs.MyReader] struct { + SParam string + BParam bool +} + +// MoqGenericInterfaceResultFn_paramsKey holds the map key params of the +// GenericInterfaceResultFn type +type MoqGenericInterfaceResultFn_paramsKey[R testmoqs.MyReader] struct { + Params struct { + SParam string + BParam bool + } + Hashes struct { + SParam hash.Hash + BParam hash.Hash + } +} + +// MoqGenericInterfaceResultFn_resultsByParams contains the results for a given +// set of parameters for the GenericInterfaceResultFn type +type MoqGenericInterfaceResultFn_resultsByParams[R testmoqs.MyReader] struct { + AnyCount int + AnyParams uint64 + Results map[MoqGenericInterfaceResultFn_paramsKey[R]]*MoqGenericInterfaceResultFn_results[R] +} + +// MoqGenericInterfaceResultFn_doFn defines the type of function needed when +// calling AndDo for the GenericInterfaceResultFn type +type MoqGenericInterfaceResultFn_doFn[R testmoqs.MyReader] func(sParam string, bParam bool) + +// MoqGenericInterfaceResultFn_doReturnFn defines the type of function needed +// when calling DoReturnResults for the GenericInterfaceResultFn type +type MoqGenericInterfaceResultFn_doReturnFn[R testmoqs.MyReader] func(sParam string, bParam bool) (r R) + +// MoqGenericInterfaceResultFn_results holds the results of the +// GenericInterfaceResultFn type +type MoqGenericInterfaceResultFn_results[R testmoqs.MyReader] struct { + Params MoqGenericInterfaceResultFn_params[R] + Results []struct { + Values *struct{ Result1 R } + Sequence uint32 + DoFn MoqGenericInterfaceResultFn_doFn[R] + DoReturnFn MoqGenericInterfaceResultFn_doReturnFn[R] + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqGenericInterfaceResultFn_fnRecorder routes recorded function calls to the +// MoqGenericInterfaceResultFn moq +type MoqGenericInterfaceResultFn_fnRecorder[R testmoqs.MyReader] struct { + Params MoqGenericInterfaceResultFn_params[R] + AnyParams uint64 + Sequence bool + Results *MoqGenericInterfaceResultFn_results[R] + Moq *MoqGenericInterfaceResultFn[R] +} + +// MoqGenericInterfaceResultFn_anyParams isolates the any params functions of +// the GenericInterfaceResultFn type +type MoqGenericInterfaceResultFn_anyParams[R testmoqs.MyReader] struct { + Recorder *MoqGenericInterfaceResultFn_fnRecorder[R] +} + +// NewMoqGenericInterfaceResultFn creates a new moq of the +// GenericInterfaceResultFn type +func NewMoqGenericInterfaceResultFn[R testmoqs.MyReader](scene *moq.Scene, config *moq.Config) *MoqGenericInterfaceResultFn[R] { + if config == nil { + config = &moq.Config{} + } + m := &MoqGenericInterfaceResultFn[R]{ + Scene: scene, + Config: *config, + Moq: &MoqGenericInterfaceResultFn_mock[R]{}, + + Runtime: struct { + ParameterIndexing struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + }{ParameterIndexing: struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing }{ - Param1: param1UsedHash, - Param2: param2UsedHash, - }, + SParam: moq.ParamIndexByValue, + BParam: moq.ParamIndexByValue, + }}, } + m.Moq.Moq = m + + scene.AddMoq(m) + return m } -func (m *MoqUsual_recorder) NoResults(sParam string, bParam bool) *MoqUsual_NoResults_fnRecorder { - return &MoqUsual_NoResults_fnRecorder{ - Params: MoqUsual_NoResults_params{ +// Mock returns the moq implementation of the GenericInterfaceResultFn type +func (m *MoqGenericInterfaceResultFn[R]) Mock() testmoqs.GenericInterfaceResultFn[R] { + return func(sParam string, bParam bool) (_ R) { + m.Scene.T.Helper() + moq := &MoqGenericInterfaceResultFn_mock[R]{Moq: m} + return moq.Fn(sParam, bParam) + } +} + +func (m *MoqGenericInterfaceResultFn_mock[R]) Fn(sParam string, bParam bool) (result1 R) { + m.Moq.Scene.T.Helper() + params := MoqGenericInterfaceResultFn_params[R]{ + SParam: sParam, + BParam: bParam, + } + var results *MoqGenericInterfaceResultFn_results[R] + for _, resultsByParams := range m.Moq.ResultsByParams { + paramsKey := m.Moq.ParamsKey(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams(params)) + } + } + + if result.DoFn != nil { + result.DoFn(sParam, bParam) + } + + if result.Values != nil { + result1 = result.Values.Result1 + } + if result.DoReturnFn != nil { + result1 = result.DoReturnFn(sParam, bParam) + } + return +} + +func (m *MoqGenericInterfaceResultFn[R]) OnCall(sParam string, bParam bool) *MoqGenericInterfaceResultFn_fnRecorder[R] { + return &MoqGenericInterfaceResultFn_fnRecorder[R]{ + Params: MoqGenericInterfaceResultFn_params[R]{ SParam: sParam, BParam: bParam, }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + Sequence: m.Config.Sequence == moq.SeqDefaultOn, + Moq: m, } } -func (r *MoqUsual_NoResults_fnRecorder) Any() *MoqUsual_NoResults_anyParams { +func (r *MoqGenericInterfaceResultFn_fnRecorder[R]) Any() *MoqGenericInterfaceResultFn_anyParams[R] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoResults(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) return nil } - return &MoqUsual_NoResults_anyParams{Recorder: r} + return &MoqGenericInterfaceResultFn_anyParams[R]{Recorder: r} } -func (a *MoqUsual_NoResults_anyParams) SParam() *MoqUsual_NoResults_fnRecorder { +func (a *MoqGenericInterfaceResultFn_anyParams[R]) SParam() *MoqGenericInterfaceResultFn_fnRecorder[R] { a.Recorder.AnyParams |= 1 << 0 return a.Recorder } -func (a *MoqUsual_NoResults_anyParams) BParam() *MoqUsual_NoResults_fnRecorder { +func (a *MoqGenericInterfaceResultFn_anyParams[R]) BParam() *MoqGenericInterfaceResultFn_fnRecorder[R] { a.Recorder.AnyParams |= 1 << 1 return a.Recorder } -func (r *MoqUsual_NoResults_fnRecorder) Seq() *MoqUsual_NoResults_fnRecorder { +func (r *MoqGenericInterfaceResultFn_fnRecorder[R]) Seq() *MoqGenericInterfaceResultFn_fnRecorder[R] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoResults(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_NoResults_fnRecorder) NoSeq() *MoqUsual_NoResults_fnRecorder { +func (r *MoqGenericInterfaceResultFn_fnRecorder[R]) NoSeq() *MoqGenericInterfaceResultFn_fnRecorder[R] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoResults(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_NoResults_fnRecorder) ReturnResults() *MoqUsual_NoResults_fnRecorder { +func (r *MoqGenericInterfaceResultFn_fnRecorder[R]) ReturnResults(result1 R) *MoqGenericInterfaceResultFn_fnRecorder[R] { r.Moq.Scene.T.Helper() r.FindResults() @@ -7885,18 +7758,20 @@ func (r *MoqUsual_NoResults_fnRecorder) ReturnResults() *MoqUsual_NoResults_fnRe } r.Results.Results = append(r.Results.Results, struct { - Values *struct{} + Values *struct{ Result1 R } Sequence uint32 - DoFn MoqUsual_NoResults_doFn - DoReturnFn MoqUsual_NoResults_doReturnFn + DoFn MoqGenericInterfaceResultFn_doFn[R] + DoReturnFn MoqGenericInterfaceResultFn_doReturnFn[R] }{ - Values: &struct{}{}, + Values: &struct{ Result1 R }{ + Result1: result1, + }, Sequence: sequence, }) return r } -func (r *MoqUsual_NoResults_fnRecorder) AndDo(fn MoqUsual_NoResults_doFn) *MoqUsual_NoResults_fnRecorder { +func (r *MoqGenericInterfaceResultFn_fnRecorder[R]) AndDo(fn MoqGenericInterfaceResultFn_doFn[R]) *MoqGenericInterfaceResultFn_fnRecorder[R] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -7907,7 +7782,7 @@ func (r *MoqUsual_NoResults_fnRecorder) AndDo(fn MoqUsual_NoResults_doFn) *MoqUs return r } -func (r *MoqUsual_NoResults_fnRecorder) DoReturnResults(fn MoqUsual_NoResults_doReturnFn) *MoqUsual_NoResults_fnRecorder { +func (r *MoqGenericInterfaceResultFn_fnRecorder[R]) DoReturnResults(fn MoqGenericInterfaceResultFn_doReturnFn[R]) *MoqGenericInterfaceResultFn_fnRecorder[R] { r.Moq.Scene.T.Helper() r.FindResults() @@ -7917,15 +7792,15 @@ func (r *MoqUsual_NoResults_fnRecorder) DoReturnResults(fn MoqUsual_NoResults_do } r.Results.Results = append(r.Results.Results, struct { - Values *struct{} + Values *struct{ Result1 R } Sequence uint32 - DoFn MoqUsual_NoResults_doFn - DoReturnFn MoqUsual_NoResults_doReturnFn + DoFn MoqGenericInterfaceResultFn_doFn[R] + DoReturnFn MoqGenericInterfaceResultFn_doReturnFn[R] }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_NoResults_fnRecorder) FindResults() { +func (r *MoqGenericInterfaceResultFn_fnRecorder[R]) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -7934,8 +7809,8 @@ func (r *MoqUsual_NoResults_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_NoResults_resultsByParams - for n, res := range r.Moq.ResultsByParams_NoResults { + var results *MoqGenericInterfaceResultFn_resultsByParams[R] + for n, res := range r.Moq.ResultsByParams { if res.AnyParams == r.AnyParams { results = &res break @@ -7945,24 +7820,24 @@ func (r *MoqUsual_NoResults_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_NoResults_resultsByParams{ + results = &MoqGenericInterfaceResultFn_resultsByParams[R]{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_NoResults_paramsKey]*MoqUsual_NoResults_results{}, + Results: map[MoqGenericInterfaceResultFn_paramsKey[R]]*MoqGenericInterfaceResultFn_results[R]{}, } - r.Moq.ResultsByParams_NoResults = append(r.Moq.ResultsByParams_NoResults, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_NoResults) { - copy(r.Moq.ResultsByParams_NoResults[insertAt+1:], r.Moq.ResultsByParams_NoResults[insertAt:0]) - r.Moq.ResultsByParams_NoResults[insertAt] = *results + r.Moq.ResultsByParams = append(r.Moq.ResultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams) { + copy(r.Moq.ResultsByParams[insertAt+1:], r.Moq.ResultsByParams[insertAt:0]) + r.Moq.ResultsByParams[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_NoResults(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_NoResults_results{ + r.Results = &MoqGenericInterfaceResultFn_results[R]{ Params: r.Params, Results: nil, Index: 0, @@ -7974,7 +7849,7 @@ func (r *MoqUsual_NoResults_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_NoResults_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_NoResults_fnRecorder { +func (r *MoqGenericInterfaceResultFn_fnRecorder[R]) Repeat(repeaters ...moq.Repeater) *MoqGenericInterfaceResultFn_fnRecorder[R] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -7985,10 +7860,10 @@ func (r *MoqUsual_NoResults_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUs for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { if r.Sequence { last = struct { - Values *struct{} + Values *struct{ Result1 R } Sequence uint32 - DoFn MoqUsual_NoResults_doFn - DoReturnFn MoqUsual_NoResults_doReturnFn + DoFn MoqGenericInterfaceResultFn_doFn[R] + DoReturnFn MoqGenericInterfaceResultFn_doReturnFn[R] }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -7999,16 +7874,16 @@ func (r *MoqUsual_NoResults_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUs return r } -func (m *MoqUsual) PrettyParams_NoResults(params MoqUsual_NoResults_params) string { - return fmt.Sprintf("NoResults(%#v, %#v)", params.SParam, params.BParam) +func (m *MoqGenericInterfaceResultFn[R]) PrettyParams(params MoqGenericInterfaceResultFn_params[R]) string { + return fmt.Sprintf("GenericInterfaceResultFn(%#v, %#v)", params.SParam, params.BParam) } -func (m *MoqUsual) ParamsKey_NoResults(params MoqUsual_NoResults_params, anyParams uint64) MoqUsual_NoResults_paramsKey { +func (m *MoqGenericInterfaceResultFn[R]) ParamsKey(params MoqGenericInterfaceResultFn_params[R], anyParams uint64) MoqGenericInterfaceResultFn_paramsKey[R] { m.Scene.T.Helper() var sParamUsed string var sParamUsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.NoResults.SParam == moq.ParamIndexByValue { + if m.Runtime.ParameterIndexing.SParam == moq.ParamIndexByValue { sParamUsed = params.SParam } else { sParamUsedHash = hash.DeepHash(params.SParam) @@ -8017,13 +7892,13 @@ func (m *MoqUsual) ParamsKey_NoResults(params MoqUsual_NoResults_params, anyPara var bParamUsed bool var bParamUsedHash hash.Hash if anyParams&(1<<1) == 0 { - if m.Runtime.ParameterIndexing.NoResults.BParam == moq.ParamIndexByValue { + if m.Runtime.ParameterIndexing.BParam == moq.ParamIndexByValue { bParamUsed = params.BParam } else { bParamUsedHash = hash.DeepHash(params.BParam) } } - return MoqUsual_NoResults_paramsKey{ + return MoqGenericInterfaceResultFn_paramsKey[R]{ Params: struct { SParam string BParam bool @@ -8041,44 +7916,4504 @@ func (m *MoqUsual) ParamsKey_NoResults(params MoqUsual_NoResults_params, anyPara } } -func (m *MoqUsual_recorder) NoParams() *MoqUsual_NoParams_fnRecorder { - return &MoqUsual_NoParams_fnRecorder{ +// Reset resets the state of the moq +func (m *MoqGenericInterfaceResultFn[R]) Reset() { m.ResultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqGenericInterfaceResultFn[R]) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams(results.Params)) + } + } + } +} + +// The following type assertion assures that testmoqs.Usual is mocked +// completely +var _ testmoqs.Usual = (*MoqUsual_mock)(nil) + +// MoqUsual holds the state of a moq of the Usual type +type MoqUsual struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqUsual_mock + + ResultsByParams_Usual []MoqUsual_Usual_resultsByParams + ResultsByParams_NoNames []MoqUsual_NoNames_resultsByParams + ResultsByParams_NoResults []MoqUsual_NoResults_resultsByParams + ResultsByParams_NoParams []MoqUsual_NoParams_resultsByParams + ResultsByParams_Nothing []MoqUsual_Nothing_resultsByParams + ResultsByParams_Variadic []MoqUsual_Variadic_resultsByParams + ResultsByParams_RepeatedIds []MoqUsual_RepeatedIds_resultsByParams + ResultsByParams_Times []MoqUsual_Times_resultsByParams + ResultsByParams_DifficultParamNames []MoqUsual_DifficultParamNames_resultsByParams + ResultsByParams_DifficultResultNames []MoqUsual_DifficultResultNames_resultsByParams + ResultsByParams_PassByReference []MoqUsual_PassByReference_resultsByParams + ResultsByParams_InterfaceParam []MoqUsual_InterfaceParam_resultsByParams + ResultsByParams_InterfaceResult []MoqUsual_InterfaceResult_resultsByParams + ResultsByParams_FnParam []MoqUsual_FnParam_resultsByParams + + Runtime struct { + ParameterIndexing struct { + Usual struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + NoNames struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + NoResults struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + NoParams struct{} + Nothing struct{} + Variadic struct { + Other moq.ParamIndexing + Args moq.ParamIndexing + } + RepeatedIds struct { + SParam1 moq.ParamIndexing + SParam2 moq.ParamIndexing + BParam moq.ParamIndexing + } + Times struct { + SParam moq.ParamIndexing + Times moq.ParamIndexing + } + DifficultParamNames struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + Param3 moq.ParamIndexing + Param moq.ParamIndexing + Param5 moq.ParamIndexing + Param6 moq.ParamIndexing + Param7 moq.ParamIndexing + Param8 moq.ParamIndexing + Param9 moq.ParamIndexing + } + DifficultResultNames struct{} + PassByReference struct { + P moq.ParamIndexing + } + InterfaceParam struct { + W moq.ParamIndexing + } + InterfaceResult struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + FnParam struct { + Fn moq.ParamIndexing + } + } + } + // MoqUsual_mock isolates the mock interface of the Usual type +} + +type MoqUsual_mock struct { + Moq *MoqUsual +} + +// MoqUsual_recorder isolates the recorder interface of the Usual type +type MoqUsual_recorder struct { + Moq *MoqUsual +} + +// MoqUsual_Usual_params holds the params of the Usual type +type MoqUsual_Usual_params struct { + SParam string + BParam bool +} + +// MoqUsual_Usual_paramsKey holds the map key params of the Usual type +type MoqUsual_Usual_paramsKey struct { + Params struct { + SParam string + BParam bool + } + Hashes struct { + SParam hash.Hash + BParam hash.Hash + } +} + +// MoqUsual_Usual_resultsByParams contains the results for a given set of +// parameters for the Usual type +type MoqUsual_Usual_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_Usual_paramsKey]*MoqUsual_Usual_results +} + +// MoqUsual_Usual_doFn defines the type of function needed when calling AndDo +// for the Usual type +type MoqUsual_Usual_doFn func(sParam string, bParam bool) + +// MoqUsual_Usual_doReturnFn defines the type of function needed when calling +// DoReturnResults for the Usual type +type MoqUsual_Usual_doReturnFn func(sParam string, bParam bool) (sResult string, err error) + +// MoqUsual_Usual_results holds the results of the Usual type +type MoqUsual_Usual_results struct { + Params MoqUsual_Usual_params + Results []struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Usual_doFn + DoReturnFn MoqUsual_Usual_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_Usual_fnRecorder routes recorded function calls to the MoqUsual moq +type MoqUsual_Usual_fnRecorder struct { + Params MoqUsual_Usual_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_Usual_results + Moq *MoqUsual +} + +// MoqUsual_Usual_anyParams isolates the any params functions of the Usual type +type MoqUsual_Usual_anyParams struct { + Recorder *MoqUsual_Usual_fnRecorder +} + +// MoqUsual_NoNames_params holds the params of the Usual type +type MoqUsual_NoNames_params struct { + Param1 string + Param2 bool +} + +// MoqUsual_NoNames_paramsKey holds the map key params of the Usual type +type MoqUsual_NoNames_paramsKey struct { + Params struct { + Param1 string + Param2 bool + } + Hashes struct { + Param1 hash.Hash + Param2 hash.Hash + } +} + +// MoqUsual_NoNames_resultsByParams contains the results for a given set of +// parameters for the Usual type +type MoqUsual_NoNames_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_NoNames_paramsKey]*MoqUsual_NoNames_results +} + +// MoqUsual_NoNames_doFn defines the type of function needed when calling AndDo +// for the Usual type +type MoqUsual_NoNames_doFn func(string, bool) + +// MoqUsual_NoNames_doReturnFn defines the type of function needed when calling +// DoReturnResults for the Usual type +type MoqUsual_NoNames_doReturnFn func(string, bool) (string, error) + +// MoqUsual_NoNames_results holds the results of the Usual type +type MoqUsual_NoNames_results struct { + Params MoqUsual_NoNames_params + Results []struct { + Values *struct { + Result1 string + Result2 error + } + Sequence uint32 + DoFn MoqUsual_NoNames_doFn + DoReturnFn MoqUsual_NoNames_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_NoNames_fnRecorder routes recorded function calls to the MoqUsual +// moq +type MoqUsual_NoNames_fnRecorder struct { + Params MoqUsual_NoNames_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_NoNames_results + Moq *MoqUsual +} + +// MoqUsual_NoNames_anyParams isolates the any params functions of the Usual +// type +type MoqUsual_NoNames_anyParams struct { + Recorder *MoqUsual_NoNames_fnRecorder +} + +// MoqUsual_NoResults_params holds the params of the Usual type +type MoqUsual_NoResults_params struct { + SParam string + BParam bool +} + +// MoqUsual_NoResults_paramsKey holds the map key params of the Usual type +type MoqUsual_NoResults_paramsKey struct { + Params struct { + SParam string + BParam bool + } + Hashes struct { + SParam hash.Hash + BParam hash.Hash + } +} + +// MoqUsual_NoResults_resultsByParams contains the results for a given set of +// parameters for the Usual type +type MoqUsual_NoResults_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_NoResults_paramsKey]*MoqUsual_NoResults_results +} + +// MoqUsual_NoResults_doFn defines the type of function needed when calling +// AndDo for the Usual type +type MoqUsual_NoResults_doFn func(sParam string, bParam bool) + +// MoqUsual_NoResults_doReturnFn defines the type of function needed when +// calling DoReturnResults for the Usual type +type MoqUsual_NoResults_doReturnFn func(sParam string, bParam bool) + +// MoqUsual_NoResults_results holds the results of the Usual type +type MoqUsual_NoResults_results struct { + Params MoqUsual_NoResults_params + Results []struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_NoResults_doFn + DoReturnFn MoqUsual_NoResults_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_NoResults_fnRecorder routes recorded function calls to the MoqUsual +// moq +type MoqUsual_NoResults_fnRecorder struct { + Params MoqUsual_NoResults_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_NoResults_results + Moq *MoqUsual +} + +// MoqUsual_NoResults_anyParams isolates the any params functions of the Usual +// type +type MoqUsual_NoResults_anyParams struct { + Recorder *MoqUsual_NoResults_fnRecorder +} + +// MoqUsual_NoParams_params holds the params of the Usual type +type MoqUsual_NoParams_params struct{} + +// MoqUsual_NoParams_paramsKey holds the map key params of the Usual type +type MoqUsual_NoParams_paramsKey struct { + Params struct{} + Hashes struct{} +} + +// MoqUsual_NoParams_resultsByParams contains the results for a given set of +// parameters for the Usual type +type MoqUsual_NoParams_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_NoParams_paramsKey]*MoqUsual_NoParams_results +} + +// MoqUsual_NoParams_doFn defines the type of function needed when calling +// AndDo for the Usual type +type MoqUsual_NoParams_doFn func() + +// MoqUsual_NoParams_doReturnFn defines the type of function needed when +// calling DoReturnResults for the Usual type +type MoqUsual_NoParams_doReturnFn func() (sResult string, err error) + +// MoqUsual_NoParams_results holds the results of the Usual type +type MoqUsual_NoParams_results struct { + Params MoqUsual_NoParams_params + Results []struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_NoParams_doFn + DoReturnFn MoqUsual_NoParams_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_NoParams_fnRecorder routes recorded function calls to the MoqUsual +// moq +type MoqUsual_NoParams_fnRecorder struct { + Params MoqUsual_NoParams_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_NoParams_results + Moq *MoqUsual +} + +// MoqUsual_NoParams_anyParams isolates the any params functions of the Usual +// type +type MoqUsual_NoParams_anyParams struct { + Recorder *MoqUsual_NoParams_fnRecorder +} + +// MoqUsual_Nothing_params holds the params of the Usual type +type MoqUsual_Nothing_params struct{} + +// MoqUsual_Nothing_paramsKey holds the map key params of the Usual type +type MoqUsual_Nothing_paramsKey struct { + Params struct{} + Hashes struct{} +} + +// MoqUsual_Nothing_resultsByParams contains the results for a given set of +// parameters for the Usual type +type MoqUsual_Nothing_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_Nothing_paramsKey]*MoqUsual_Nothing_results +} + +// MoqUsual_Nothing_doFn defines the type of function needed when calling AndDo +// for the Usual type +type MoqUsual_Nothing_doFn func() + +// MoqUsual_Nothing_doReturnFn defines the type of function needed when calling +// DoReturnResults for the Usual type +type MoqUsual_Nothing_doReturnFn func() + +// MoqUsual_Nothing_results holds the results of the Usual type +type MoqUsual_Nothing_results struct { + Params MoqUsual_Nothing_params + Results []struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_Nothing_doFn + DoReturnFn MoqUsual_Nothing_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_Nothing_fnRecorder routes recorded function calls to the MoqUsual +// moq +type MoqUsual_Nothing_fnRecorder struct { + Params MoqUsual_Nothing_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_Nothing_results + Moq *MoqUsual +} + +// MoqUsual_Nothing_anyParams isolates the any params functions of the Usual +// type +type MoqUsual_Nothing_anyParams struct { + Recorder *MoqUsual_Nothing_fnRecorder +} + +// MoqUsual_Variadic_params holds the params of the Usual type +type MoqUsual_Variadic_params struct { + Other bool + Args []string +} + +// MoqUsual_Variadic_paramsKey holds the map key params of the Usual type +type MoqUsual_Variadic_paramsKey struct { + Params struct{ Other bool } + Hashes struct { + Other hash.Hash + Args hash.Hash + } +} + +// MoqUsual_Variadic_resultsByParams contains the results for a given set of +// parameters for the Usual type +type MoqUsual_Variadic_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_Variadic_paramsKey]*MoqUsual_Variadic_results +} + +// MoqUsual_Variadic_doFn defines the type of function needed when calling +// AndDo for the Usual type +type MoqUsual_Variadic_doFn func(other bool, args ...string) + +// MoqUsual_Variadic_doReturnFn defines the type of function needed when +// calling DoReturnResults for the Usual type +type MoqUsual_Variadic_doReturnFn func(other bool, args ...string) (sResult string, err error) + +// MoqUsual_Variadic_results holds the results of the Usual type +type MoqUsual_Variadic_results struct { + Params MoqUsual_Variadic_params + Results []struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Variadic_doFn + DoReturnFn MoqUsual_Variadic_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_Variadic_fnRecorder routes recorded function calls to the MoqUsual +// moq +type MoqUsual_Variadic_fnRecorder struct { + Params MoqUsual_Variadic_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_Variadic_results + Moq *MoqUsual +} + +// MoqUsual_Variadic_anyParams isolates the any params functions of the Usual +// type +type MoqUsual_Variadic_anyParams struct { + Recorder *MoqUsual_Variadic_fnRecorder +} + +// MoqUsual_RepeatedIds_params holds the params of the Usual type +type MoqUsual_RepeatedIds_params struct { + SParam1, SParam2 string + BParam bool +} + +// MoqUsual_RepeatedIds_paramsKey holds the map key params of the Usual type +type MoqUsual_RepeatedIds_paramsKey struct { + Params struct { + SParam1, SParam2 string + BParam bool + } + Hashes struct { + SParam1, SParam2 hash.Hash + BParam hash.Hash + } +} + +// MoqUsual_RepeatedIds_resultsByParams contains the results for a given set of +// parameters for the Usual type +type MoqUsual_RepeatedIds_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_RepeatedIds_paramsKey]*MoqUsual_RepeatedIds_results +} + +// MoqUsual_RepeatedIds_doFn defines the type of function needed when calling +// AndDo for the Usual type +type MoqUsual_RepeatedIds_doFn func(sParam1, sParam2 string, bParam bool) + +// MoqUsual_RepeatedIds_doReturnFn defines the type of function needed when +// calling DoReturnResults for the Usual type +type MoqUsual_RepeatedIds_doReturnFn func(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) + +// MoqUsual_RepeatedIds_results holds the results of the Usual type +type MoqUsual_RepeatedIds_results struct { + Params MoqUsual_RepeatedIds_params + Results []struct { + Values *struct { + SResult1, SResult2 string + Err error + } + Sequence uint32 + DoFn MoqUsual_RepeatedIds_doFn + DoReturnFn MoqUsual_RepeatedIds_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_RepeatedIds_fnRecorder routes recorded function calls to the +// MoqUsual moq +type MoqUsual_RepeatedIds_fnRecorder struct { + Params MoqUsual_RepeatedIds_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_RepeatedIds_results + Moq *MoqUsual +} + +// MoqUsual_RepeatedIds_anyParams isolates the any params functions of the +// Usual type +type MoqUsual_RepeatedIds_anyParams struct { + Recorder *MoqUsual_RepeatedIds_fnRecorder +} + +// MoqUsual_Times_params holds the params of the Usual type +type MoqUsual_Times_params struct { + SParam string + Times bool +} + +// MoqUsual_Times_paramsKey holds the map key params of the Usual type +type MoqUsual_Times_paramsKey struct { + Params struct { + SParam string + Times bool + } + Hashes struct { + SParam hash.Hash + Times hash.Hash + } +} + +// MoqUsual_Times_resultsByParams contains the results for a given set of +// parameters for the Usual type +type MoqUsual_Times_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_Times_paramsKey]*MoqUsual_Times_results +} + +// MoqUsual_Times_doFn defines the type of function needed when calling AndDo +// for the Usual type +type MoqUsual_Times_doFn func(sParam string, times bool) + +// MoqUsual_Times_doReturnFn defines the type of function needed when calling +// DoReturnResults for the Usual type +type MoqUsual_Times_doReturnFn func(sParam string, times bool) (sResult string, err error) + +// MoqUsual_Times_results holds the results of the Usual type +type MoqUsual_Times_results struct { + Params MoqUsual_Times_params + Results []struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Times_doFn + DoReturnFn MoqUsual_Times_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_Times_fnRecorder routes recorded function calls to the MoqUsual moq +type MoqUsual_Times_fnRecorder struct { + Params MoqUsual_Times_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_Times_results + Moq *MoqUsual +} + +// MoqUsual_Times_anyParams isolates the any params functions of the Usual type +type MoqUsual_Times_anyParams struct { + Recorder *MoqUsual_Times_fnRecorder +} + +// MoqUsual_DifficultParamNames_params holds the params of the Usual type +type MoqUsual_DifficultParamNames_params struct { + Param1, Param2 bool + Param3 string + Param, Param5, Param6 int + Param7, Param8, Param9 float32 +} + +// MoqUsual_DifficultParamNames_paramsKey holds the map key params of the Usual +// type +type MoqUsual_DifficultParamNames_paramsKey struct { + Params struct { + Param1, Param2 bool + Param3 string + Param, Param5, Param6 int + Param7, Param8, Param9 float32 + } + Hashes struct { + Param1, Param2 hash.Hash + Param3 hash.Hash + Param, Param5, Param6 hash.Hash + Param7, Param8, Param9 hash.Hash + } +} + +// MoqUsual_DifficultParamNames_resultsByParams contains the results for a +// given set of parameters for the Usual type +type MoqUsual_DifficultParamNames_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_DifficultParamNames_paramsKey]*MoqUsual_DifficultParamNames_results +} + +// MoqUsual_DifficultParamNames_doFn defines the type of function needed when +// calling AndDo for the Usual type +type MoqUsual_DifficultParamNames_doFn func(m, r bool, sequence string, param, params, i int, result, results, _ float32) + +// MoqUsual_DifficultParamNames_doReturnFn defines the type of function needed +// when calling DoReturnResults for the Usual type +type MoqUsual_DifficultParamNames_doReturnFn func(m, r bool, sequence string, param, params, i int, result, results, _ float32) + +// MoqUsual_DifficultParamNames_results holds the results of the Usual type +type MoqUsual_DifficultParamNames_results struct { + Params MoqUsual_DifficultParamNames_params + Results []struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_DifficultParamNames_doFn + DoReturnFn MoqUsual_DifficultParamNames_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_DifficultParamNames_fnRecorder routes recorded function calls to +// the MoqUsual moq +type MoqUsual_DifficultParamNames_fnRecorder struct { + Params MoqUsual_DifficultParamNames_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_DifficultParamNames_results + Moq *MoqUsual +} + +// MoqUsual_DifficultParamNames_anyParams isolates the any params functions of +// the Usual type +type MoqUsual_DifficultParamNames_anyParams struct { + Recorder *MoqUsual_DifficultParamNames_fnRecorder +} + +// MoqUsual_DifficultResultNames_params holds the params of the Usual type +type MoqUsual_DifficultResultNames_params struct{} + +// MoqUsual_DifficultResultNames_paramsKey holds the map key params of the +// Usual type +type MoqUsual_DifficultResultNames_paramsKey struct { + Params struct{} + Hashes struct{} +} + +// MoqUsual_DifficultResultNames_resultsByParams contains the results for a +// given set of parameters for the Usual type +type MoqUsual_DifficultResultNames_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_DifficultResultNames_paramsKey]*MoqUsual_DifficultResultNames_results +} + +// MoqUsual_DifficultResultNames_doFn defines the type of function needed when +// calling AndDo for the Usual type +type MoqUsual_DifficultResultNames_doFn func() + +// MoqUsual_DifficultResultNames_doReturnFn defines the type of function needed +// when calling DoReturnResults for the Usual type +type MoqUsual_DifficultResultNames_doReturnFn func() (m, r string, sequence error, param, params, i int, result, results, _ float32) + +// MoqUsual_DifficultResultNames_results holds the results of the Usual type +type MoqUsual_DifficultResultNames_results struct { + Params MoqUsual_DifficultResultNames_params + Results []struct { + Values *struct { + Result1, Result2 string + Result3 error + Param, Result5, Result6 int + Result7, Result8, Result9 float32 + } + Sequence uint32 + DoFn MoqUsual_DifficultResultNames_doFn + DoReturnFn MoqUsual_DifficultResultNames_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_DifficultResultNames_fnRecorder routes recorded function calls to +// the MoqUsual moq +type MoqUsual_DifficultResultNames_fnRecorder struct { + Params MoqUsual_DifficultResultNames_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_DifficultResultNames_results + Moq *MoqUsual +} + +// MoqUsual_DifficultResultNames_anyParams isolates the any params functions of +// the Usual type +type MoqUsual_DifficultResultNames_anyParams struct { + Recorder *MoqUsual_DifficultResultNames_fnRecorder +} + +// MoqUsual_PassByReference_params holds the params of the Usual type +type MoqUsual_PassByReference_params struct { + P *testmoqs.PassByReferenceParams +} + +// MoqUsual_PassByReference_paramsKey holds the map key params of the Usual +// type +type MoqUsual_PassByReference_paramsKey struct { + Params struct { + P *testmoqs.PassByReferenceParams + } + Hashes struct{ P hash.Hash } +} + +// MoqUsual_PassByReference_resultsByParams contains the results for a given +// set of parameters for the Usual type +type MoqUsual_PassByReference_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_PassByReference_paramsKey]*MoqUsual_PassByReference_results +} + +// MoqUsual_PassByReference_doFn defines the type of function needed when +// calling AndDo for the Usual type +type MoqUsual_PassByReference_doFn func(p *testmoqs.PassByReferenceParams) + +// MoqUsual_PassByReference_doReturnFn defines the type of function needed when +// calling DoReturnResults for the Usual type +type MoqUsual_PassByReference_doReturnFn func(p *testmoqs.PassByReferenceParams) (sResult string, err error) + +// MoqUsual_PassByReference_results holds the results of the Usual type +type MoqUsual_PassByReference_results struct { + Params MoqUsual_PassByReference_params + Results []struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_PassByReference_doFn + DoReturnFn MoqUsual_PassByReference_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_PassByReference_fnRecorder routes recorded function calls to the +// MoqUsual moq +type MoqUsual_PassByReference_fnRecorder struct { + Params MoqUsual_PassByReference_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_PassByReference_results + Moq *MoqUsual +} + +// MoqUsual_PassByReference_anyParams isolates the any params functions of the +// Usual type +type MoqUsual_PassByReference_anyParams struct { + Recorder *MoqUsual_PassByReference_fnRecorder +} + +// MoqUsual_InterfaceParam_params holds the params of the Usual type +type MoqUsual_InterfaceParam_params struct{ W io.Writer } + +// MoqUsual_InterfaceParam_paramsKey holds the map key params of the Usual type +type MoqUsual_InterfaceParam_paramsKey struct { + Params struct{ W io.Writer } + Hashes struct{ W hash.Hash } +} + +// MoqUsual_InterfaceParam_resultsByParams contains the results for a given set +// of parameters for the Usual type +type MoqUsual_InterfaceParam_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_InterfaceParam_paramsKey]*MoqUsual_InterfaceParam_results +} + +// MoqUsual_InterfaceParam_doFn defines the type of function needed when +// calling AndDo for the Usual type +type MoqUsual_InterfaceParam_doFn func(w io.Writer) + +// MoqUsual_InterfaceParam_doReturnFn defines the type of function needed when +// calling DoReturnResults for the Usual type +type MoqUsual_InterfaceParam_doReturnFn func(w io.Writer) (sResult string, err error) + +// MoqUsual_InterfaceParam_results holds the results of the Usual type +type MoqUsual_InterfaceParam_results struct { + Params MoqUsual_InterfaceParam_params + Results []struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_InterfaceParam_doFn + DoReturnFn MoqUsual_InterfaceParam_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_InterfaceParam_fnRecorder routes recorded function calls to the +// MoqUsual moq +type MoqUsual_InterfaceParam_fnRecorder struct { + Params MoqUsual_InterfaceParam_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_InterfaceParam_results + Moq *MoqUsual +} + +// MoqUsual_InterfaceParam_anyParams isolates the any params functions of the +// Usual type +type MoqUsual_InterfaceParam_anyParams struct { + Recorder *MoqUsual_InterfaceParam_fnRecorder +} + +// MoqUsual_InterfaceResult_params holds the params of the Usual type +type MoqUsual_InterfaceResult_params struct { + SParam string + BParam bool +} + +// MoqUsual_InterfaceResult_paramsKey holds the map key params of the Usual +// type +type MoqUsual_InterfaceResult_paramsKey struct { + Params struct { + SParam string + BParam bool + } + Hashes struct { + SParam hash.Hash + BParam hash.Hash + } +} + +// MoqUsual_InterfaceResult_resultsByParams contains the results for a given +// set of parameters for the Usual type +type MoqUsual_InterfaceResult_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_InterfaceResult_paramsKey]*MoqUsual_InterfaceResult_results +} + +// MoqUsual_InterfaceResult_doFn defines the type of function needed when +// calling AndDo for the Usual type +type MoqUsual_InterfaceResult_doFn func(sParam string, bParam bool) + +// MoqUsual_InterfaceResult_doReturnFn defines the type of function needed when +// calling DoReturnResults for the Usual type +type MoqUsual_InterfaceResult_doReturnFn func(sParam string, bParam bool) (r io.Reader) + +// MoqUsual_InterfaceResult_results holds the results of the Usual type +type MoqUsual_InterfaceResult_results struct { + Params MoqUsual_InterfaceResult_params + Results []struct { + Values *struct{ Result1 io.Reader } + Sequence uint32 + DoFn MoqUsual_InterfaceResult_doFn + DoReturnFn MoqUsual_InterfaceResult_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_InterfaceResult_fnRecorder routes recorded function calls to the +// MoqUsual moq +type MoqUsual_InterfaceResult_fnRecorder struct { + Params MoqUsual_InterfaceResult_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_InterfaceResult_results + Moq *MoqUsual +} + +// MoqUsual_InterfaceResult_anyParams isolates the any params functions of the +// Usual type +type MoqUsual_InterfaceResult_anyParams struct { + Recorder *MoqUsual_InterfaceResult_fnRecorder +} + +// MoqUsual_FnParam_params holds the params of the Usual type +type MoqUsual_FnParam_params struct{ Fn func() } + +// MoqUsual_FnParam_paramsKey holds the map key params of the Usual type +type MoqUsual_FnParam_paramsKey struct { + Params struct{} + Hashes struct{ Fn hash.Hash } +} + +// MoqUsual_FnParam_resultsByParams contains the results for a given set of +// parameters for the Usual type +type MoqUsual_FnParam_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqUsual_FnParam_paramsKey]*MoqUsual_FnParam_results +} + +// MoqUsual_FnParam_doFn defines the type of function needed when calling AndDo +// for the Usual type +type MoqUsual_FnParam_doFn func(fn func()) + +// MoqUsual_FnParam_doReturnFn defines the type of function needed when calling +// DoReturnResults for the Usual type +type MoqUsual_FnParam_doReturnFn func(fn func()) + +// MoqUsual_FnParam_results holds the results of the Usual type +type MoqUsual_FnParam_results struct { + Params MoqUsual_FnParam_params + Results []struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_FnParam_doFn + DoReturnFn MoqUsual_FnParam_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqUsual_FnParam_fnRecorder routes recorded function calls to the MoqUsual +// moq +type MoqUsual_FnParam_fnRecorder struct { + Params MoqUsual_FnParam_params + AnyParams uint64 + Sequence bool + Results *MoqUsual_FnParam_results + Moq *MoqUsual +} + +// MoqUsual_FnParam_anyParams isolates the any params functions of the Usual +// type +type MoqUsual_FnParam_anyParams struct { + Recorder *MoqUsual_FnParam_fnRecorder +} + +// NewMoqUsual creates a new moq of the Usual type +func NewMoqUsual(scene *moq.Scene, config *moq.Config) *MoqUsual { + if config == nil { + config = &moq.Config{} + } + m := &MoqUsual{ + Scene: scene, + Config: *config, + Moq: &MoqUsual_mock{}, + + Runtime: struct { + ParameterIndexing struct { + Usual struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + NoNames struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + NoResults struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + NoParams struct{} + Nothing struct{} + Variadic struct { + Other moq.ParamIndexing + Args moq.ParamIndexing + } + RepeatedIds struct { + SParam1 moq.ParamIndexing + SParam2 moq.ParamIndexing + BParam moq.ParamIndexing + } + Times struct { + SParam moq.ParamIndexing + Times moq.ParamIndexing + } + DifficultParamNames struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + Param3 moq.ParamIndexing + Param moq.ParamIndexing + Param5 moq.ParamIndexing + Param6 moq.ParamIndexing + Param7 moq.ParamIndexing + Param8 moq.ParamIndexing + Param9 moq.ParamIndexing + } + DifficultResultNames struct{} + PassByReference struct { + P moq.ParamIndexing + } + InterfaceParam struct { + W moq.ParamIndexing + } + InterfaceResult struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + FnParam struct { + Fn moq.ParamIndexing + } + } + }{ParameterIndexing: struct { + Usual struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + NoNames struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + NoResults struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + NoParams struct{} + Nothing struct{} + Variadic struct { + Other moq.ParamIndexing + Args moq.ParamIndexing + } + RepeatedIds struct { + SParam1 moq.ParamIndexing + SParam2 moq.ParamIndexing + BParam moq.ParamIndexing + } + Times struct { + SParam moq.ParamIndexing + Times moq.ParamIndexing + } + DifficultParamNames struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + Param3 moq.ParamIndexing + Param moq.ParamIndexing + Param5 moq.ParamIndexing + Param6 moq.ParamIndexing + Param7 moq.ParamIndexing + Param8 moq.ParamIndexing + Param9 moq.ParamIndexing + } + DifficultResultNames struct{} + PassByReference struct { + P moq.ParamIndexing + } + InterfaceParam struct { + W moq.ParamIndexing + } + InterfaceResult struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + FnParam struct { + Fn moq.ParamIndexing + } + }{ + Usual: struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + }{ + SParam: moq.ParamIndexByValue, + BParam: moq.ParamIndexByValue, + }, + NoNames: struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + }{ + Param1: moq.ParamIndexByValue, + Param2: moq.ParamIndexByValue, + }, + NoResults: struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + }{ + SParam: moq.ParamIndexByValue, + BParam: moq.ParamIndexByValue, + }, + NoParams: struct{}{}, + Nothing: struct{}{}, + Variadic: struct { + Other moq.ParamIndexing + Args moq.ParamIndexing + }{ + Other: moq.ParamIndexByValue, + Args: moq.ParamIndexByHash, + }, + RepeatedIds: struct { + SParam1 moq.ParamIndexing + SParam2 moq.ParamIndexing + BParam moq.ParamIndexing + }{ + SParam1: moq.ParamIndexByValue, + SParam2: moq.ParamIndexByValue, + BParam: moq.ParamIndexByValue, + }, + Times: struct { + SParam moq.ParamIndexing + Times moq.ParamIndexing + }{ + SParam: moq.ParamIndexByValue, + Times: moq.ParamIndexByValue, + }, + DifficultParamNames: struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + Param3 moq.ParamIndexing + Param moq.ParamIndexing + Param5 moq.ParamIndexing + Param6 moq.ParamIndexing + Param7 moq.ParamIndexing + Param8 moq.ParamIndexing + Param9 moq.ParamIndexing + }{ + Param1: moq.ParamIndexByValue, + Param2: moq.ParamIndexByValue, + Param3: moq.ParamIndexByValue, + Param: moq.ParamIndexByValue, + Param5: moq.ParamIndexByValue, + Param6: moq.ParamIndexByValue, + Param7: moq.ParamIndexByValue, + Param8: moq.ParamIndexByValue, + Param9: moq.ParamIndexByValue, + }, + DifficultResultNames: struct{}{}, + PassByReference: struct { + P moq.ParamIndexing + }{ + P: moq.ParamIndexByHash, + }, + InterfaceParam: struct { + W moq.ParamIndexing + }{ + W: moq.ParamIndexByHash, + }, + InterfaceResult: struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + }{ + SParam: moq.ParamIndexByValue, + BParam: moq.ParamIndexByValue, + }, + FnParam: struct { + Fn moq.ParamIndexing + }{ + Fn: moq.ParamIndexByHash, + }, + }}, + } + m.Moq.Moq = m + + scene.AddMoq(m) + return m +} + +// Mock returns the mock implementation of the Usual type +func (m *MoqUsual) Mock() *MoqUsual_mock { return m.Moq } + +func (m *MoqUsual_mock) Usual(sParam string, bParam bool) (sResult string, err error) { + m.Moq.Scene.T.Helper() + params := MoqUsual_Usual_params{ + SParam: sParam, + BParam: bParam, + } + var results *MoqUsual_Usual_results + for _, resultsByParams := range m.Moq.ResultsByParams_Usual { + paramsKey := m.Moq.ParamsKey_Usual(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Usual(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Usual(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Usual(params)) + } + } + + if result.DoFn != nil { + result.DoFn(sParam, bParam) + } + + if result.Values != nil { + sResult = result.Values.SResult + err = result.Values.Err + } + if result.DoReturnFn != nil { + sResult, err = result.DoReturnFn(sParam, bParam) + } + return +} + +func (m *MoqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, result2 error) { + m.Moq.Scene.T.Helper() + params := MoqUsual_NoNames_params{ + Param1: param1, + Param2: param2, + } + var results *MoqUsual_NoNames_results + for _, resultsByParams := range m.Moq.ResultsByParams_NoNames { + paramsKey := m.Moq.ParamsKey_NoNames(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_NoNames(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_NoNames(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_NoNames(params)) + } + } + + if result.DoFn != nil { + result.DoFn(param1, param2) + } + + if result.Values != nil { + result1 = result.Values.Result1 + result2 = result.Values.Result2 + } + if result.DoReturnFn != nil { + result1, result2 = result.DoReturnFn(param1, param2) + } + return +} + +func (m *MoqUsual_mock) NoResults(sParam string, bParam bool) { + m.Moq.Scene.T.Helper() + params := MoqUsual_NoResults_params{ + SParam: sParam, + BParam: bParam, + } + var results *MoqUsual_NoResults_results + for _, resultsByParams := range m.Moq.ResultsByParams_NoResults { + paramsKey := m.Moq.ParamsKey_NoResults(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_NoResults(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_NoResults(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_NoResults(params)) + } + } + + if result.DoFn != nil { + result.DoFn(sParam, bParam) + } + + if result.DoReturnFn != nil { + result.DoReturnFn(sParam, bParam) + } + return +} + +func (m *MoqUsual_mock) NoParams() (sResult string, err error) { + m.Moq.Scene.T.Helper() + params := MoqUsual_NoParams_params{} + var results *MoqUsual_NoParams_results + for _, resultsByParams := range m.Moq.ResultsByParams_NoParams { + paramsKey := m.Moq.ParamsKey_NoParams(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_NoParams(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_NoParams(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_NoParams(params)) + } + } + + if result.DoFn != nil { + result.DoFn() + } + + if result.Values != nil { + sResult = result.Values.SResult + err = result.Values.Err + } + if result.DoReturnFn != nil { + sResult, err = result.DoReturnFn() + } + return +} + +func (m *MoqUsual_mock) Nothing() { + m.Moq.Scene.T.Helper() + params := MoqUsual_Nothing_params{} + var results *MoqUsual_Nothing_results + for _, resultsByParams := range m.Moq.ResultsByParams_Nothing { + paramsKey := m.Moq.ParamsKey_Nothing(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Nothing(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Nothing(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Nothing(params)) + } + } + + if result.DoFn != nil { + result.DoFn() + } + + if result.DoReturnFn != nil { + result.DoReturnFn() + } + return +} + +func (m *MoqUsual_mock) Variadic(other bool, args ...string) (sResult string, err error) { + m.Moq.Scene.T.Helper() + params := MoqUsual_Variadic_params{ + Other: other, + Args: args, + } + var results *MoqUsual_Variadic_results + for _, resultsByParams := range m.Moq.ResultsByParams_Variadic { + paramsKey := m.Moq.ParamsKey_Variadic(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Variadic(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Variadic(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Variadic(params)) + } + } + + if result.DoFn != nil { + result.DoFn(other, args...) + } + + if result.Values != nil { + sResult = result.Values.SResult + err = result.Values.Err + } + if result.DoReturnFn != nil { + sResult, err = result.DoReturnFn(other, args...) + } + return +} + +func (m *MoqUsual_mock) RepeatedIds(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) { + m.Moq.Scene.T.Helper() + params := MoqUsual_RepeatedIds_params{ + SParam1: sParam1, + SParam2: sParam2, + BParam: bParam, + } + var results *MoqUsual_RepeatedIds_results + for _, resultsByParams := range m.Moq.ResultsByParams_RepeatedIds { + paramsKey := m.Moq.ParamsKey_RepeatedIds(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_RepeatedIds(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_RepeatedIds(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_RepeatedIds(params)) + } + } + + if result.DoFn != nil { + result.DoFn(sParam1, sParam2, bParam) + } + + if result.Values != nil { + sResult1 = result.Values.SResult1 + sResult2 = result.Values.SResult2 + err = result.Values.Err + } + if result.DoReturnFn != nil { + sResult1, sResult2, err = result.DoReturnFn(sParam1, sParam2, bParam) + } + return +} + +func (m *MoqUsual_mock) Times(sParam string, times bool) (sResult string, err error) { + m.Moq.Scene.T.Helper() + params := MoqUsual_Times_params{ + SParam: sParam, + Times: times, + } + var results *MoqUsual_Times_results + for _, resultsByParams := range m.Moq.ResultsByParams_Times { + paramsKey := m.Moq.ParamsKey_Times(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Times(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Times(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Times(params)) + } + } + + if result.DoFn != nil { + result.DoFn(sParam, times) + } + + if result.Values != nil { + sResult = result.Values.SResult + err = result.Values.Err + } + if result.DoReturnFn != nil { + sResult, err = result.DoReturnFn(sParam, times) + } + return +} + +func (m *MoqUsual_mock) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) { + m.Moq.Scene.T.Helper() + params := MoqUsual_DifficultParamNames_params{ + Param1: param1, + Param2: param2, + Param3: param3, + Param: param, + Param5: param5, + Param6: param6, + Param7: param7, + Param8: param8, + Param9: param9, + } + var results *MoqUsual_DifficultParamNames_results + for _, resultsByParams := range m.Moq.ResultsByParams_DifficultParamNames { + paramsKey := m.Moq.ParamsKey_DifficultParamNames(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_DifficultParamNames(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_DifficultParamNames(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_DifficultParamNames(params)) + } + } + + if result.DoFn != nil { + result.DoFn(param1, param2, param3, param, param5, param6, param7, param8, param9) + } + + if result.DoReturnFn != nil { + result.DoReturnFn(param1, param2, param3, param, param5, param6, param7, param8, param9) + } + return +} + +func (m *MoqUsual_mock) DifficultResultNames() (result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) { + m.Moq.Scene.T.Helper() + params := MoqUsual_DifficultResultNames_params{} + var results *MoqUsual_DifficultResultNames_results + for _, resultsByParams := range m.Moq.ResultsByParams_DifficultResultNames { + paramsKey := m.Moq.ParamsKey_DifficultResultNames(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_DifficultResultNames(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_DifficultResultNames(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_DifficultResultNames(params)) + } + } + + if result.DoFn != nil { + result.DoFn() + } + + if result.Values != nil { + result1 = result.Values.Result1 + result2 = result.Values.Result2 + result3 = result.Values.Result3 + param = result.Values.Param + result5 = result.Values.Result5 + result6 = result.Values.Result6 + result7 = result.Values.Result7 + result8 = result.Values.Result8 + result9 = result.Values.Result9 + } + if result.DoReturnFn != nil { + result1, result2, result3, param, result5, result6, result7, result8, result9 = result.DoReturnFn() + } + return +} + +func (m *MoqUsual_mock) PassByReference(p *testmoqs.PassByReferenceParams) (sResult string, err error) { + m.Moq.Scene.T.Helper() + params := MoqUsual_PassByReference_params{ + P: p, + } + var results *MoqUsual_PassByReference_results + for _, resultsByParams := range m.Moq.ResultsByParams_PassByReference { + paramsKey := m.Moq.ParamsKey_PassByReference(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_PassByReference(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_PassByReference(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_PassByReference(params)) + } + } + + if result.DoFn != nil { + result.DoFn(p) + } + + if result.Values != nil { + sResult = result.Values.SResult + err = result.Values.Err + } + if result.DoReturnFn != nil { + sResult, err = result.DoReturnFn(p) + } + return +} + +func (m *MoqUsual_mock) InterfaceParam(w io.Writer) (sResult string, err error) { + m.Moq.Scene.T.Helper() + params := MoqUsual_InterfaceParam_params{ + W: w, + } + var results *MoqUsual_InterfaceParam_results + for _, resultsByParams := range m.Moq.ResultsByParams_InterfaceParam { + paramsKey := m.Moq.ParamsKey_InterfaceParam(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_InterfaceParam(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_InterfaceParam(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_InterfaceParam(params)) + } + } + + if result.DoFn != nil { + result.DoFn(w) + } + + if result.Values != nil { + sResult = result.Values.SResult + err = result.Values.Err + } + if result.DoReturnFn != nil { + sResult, err = result.DoReturnFn(w) + } + return +} + +func (m *MoqUsual_mock) InterfaceResult(sParam string, bParam bool) (result1 io.Reader) { + m.Moq.Scene.T.Helper() + params := MoqUsual_InterfaceResult_params{ + SParam: sParam, + BParam: bParam, + } + var results *MoqUsual_InterfaceResult_results + for _, resultsByParams := range m.Moq.ResultsByParams_InterfaceResult { + paramsKey := m.Moq.ParamsKey_InterfaceResult(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_InterfaceResult(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_InterfaceResult(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_InterfaceResult(params)) + } + } + + if result.DoFn != nil { + result.DoFn(sParam, bParam) + } + + if result.Values != nil { + result1 = result.Values.Result1 + } + if result.DoReturnFn != nil { + result1 = result.DoReturnFn(sParam, bParam) + } + return +} + +func (m *MoqUsual_mock) FnParam(fn func()) { + m.Moq.Scene.T.Helper() + params := MoqUsual_FnParam_params{ + Fn: fn, + } + var results *MoqUsual_FnParam_results + for _, resultsByParams := range m.Moq.ResultsByParams_FnParam { + paramsKey := m.Moq.ParamsKey_FnParam(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_FnParam(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_FnParam(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_FnParam(params)) + } + } + + if result.DoFn != nil { + result.DoFn(fn) + } + + if result.DoReturnFn != nil { + result.DoReturnFn(fn) + } + return +} + +// OnCall returns the recorder implementation of the Usual type +func (m *MoqUsual) OnCall() *MoqUsual_recorder { + return &MoqUsual_recorder{ + Moq: m, + } +} + +func (m *MoqUsual_recorder) Usual(sParam string, bParam bool) *MoqUsual_Usual_fnRecorder { + return &MoqUsual_Usual_fnRecorder{ + Params: MoqUsual_Usual_params{ + SParam: sParam, + BParam: bParam, + }, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqUsual_Usual_fnRecorder) Any() *MoqUsual_Usual_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) + return nil + } + return &MoqUsual_Usual_anyParams{Recorder: r} +} + +func (a *MoqUsual_Usual_anyParams) SParam() *MoqUsual_Usual_fnRecorder { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder +} + +func (a *MoqUsual_Usual_anyParams) BParam() *MoqUsual_Usual_fnRecorder { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (r *MoqUsual_Usual_fnRecorder) Seq() *MoqUsual_Usual_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqUsual_Usual_fnRecorder) NoSeq() *MoqUsual_Usual_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqUsual_Usual_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_Usual_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Usual_doFn + DoReturnFn MoqUsual_Usual_doReturnFn + }{ + Values: &struct { + SResult string + Err error + }{ + SResult: sResult, + Err: err, + }, + Sequence: sequence, + }) + return r +} + +func (r *MoqUsual_Usual_fnRecorder) AndDo(fn MoqUsual_Usual_doFn) *MoqUsual_Usual_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqUsual_Usual_fnRecorder) DoReturnResults(fn MoqUsual_Usual_doReturnFn) *MoqUsual_Usual_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Usual_doFn + DoReturnFn MoqUsual_Usual_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqUsual_Usual_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqUsual_Usual_resultsByParams + for n, res := range r.Moq.ResultsByParams_Usual { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqUsual_Usual_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqUsual_Usual_paramsKey]*MoqUsual_Usual_results{}, + } + r.Moq.ResultsByParams_Usual = append(r.Moq.ResultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Usual) { + copy(r.Moq.ResultsByParams_Usual[insertAt+1:], r.Moq.ResultsByParams_Usual[insertAt:0]) + r.Moq.ResultsByParams_Usual[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_Usual(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqUsual_Usual_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqUsual_Usual_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Usual_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Usual_doFn + DoReturnFn MoqUsual_Usual_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqUsual) PrettyParams_Usual(params MoqUsual_Usual_params) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.SParam, params.BParam) +} + +func (m *MoqUsual) ParamsKey_Usual(params MoqUsual_Usual_params, anyParams uint64) MoqUsual_Usual_paramsKey { + m.Scene.T.Helper() + var sParamUsed string + var sParamUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.Usual.SParam == moq.ParamIndexByValue { + sParamUsed = params.SParam + } else { + sParamUsedHash = hash.DeepHash(params.SParam) + } + } + var bParamUsed bool + var bParamUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.Usual.BParam == moq.ParamIndexByValue { + bParamUsed = params.BParam + } else { + bParamUsedHash = hash.DeepHash(params.BParam) + } + } + return MoqUsual_Usual_paramsKey{ + Params: struct { + SParam string + BParam bool + }{ + SParam: sParamUsed, + BParam: bParamUsed, + }, + Hashes: struct { + SParam hash.Hash + BParam hash.Hash + }{ + SParam: sParamUsedHash, + BParam: bParamUsedHash, + }, + } +} + +func (m *MoqUsual_recorder) NoNames(param1 string, param2 bool) *MoqUsual_NoNames_fnRecorder { + return &MoqUsual_NoNames_fnRecorder{ + Params: MoqUsual_NoNames_params{ + Param1: param1, + Param2: param2, + }, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqUsual_NoNames_fnRecorder) Any() *MoqUsual_NoNames_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoNames(r.Params)) + return nil + } + return &MoqUsual_NoNames_anyParams{Recorder: r} +} + +func (a *MoqUsual_NoNames_anyParams) Param1() *MoqUsual_NoNames_fnRecorder { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder +} + +func (a *MoqUsual_NoNames_anyParams) Param2() *MoqUsual_NoNames_fnRecorder { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (r *MoqUsual_NoNames_fnRecorder) Seq() *MoqUsual_NoNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoNames(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqUsual_NoNames_fnRecorder) NoSeq() *MoqUsual_NoNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoNames(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqUsual_NoNames_fnRecorder) ReturnResults(result1 string, result2 error) *MoqUsual_NoNames_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + Result1 string + Result2 error + } + Sequence uint32 + DoFn MoqUsual_NoNames_doFn + DoReturnFn MoqUsual_NoNames_doReturnFn + }{ + Values: &struct { + Result1 string + Result2 error + }{ + Result1: result1, + Result2: result2, + }, + Sequence: sequence, + }) + return r +} + +func (r *MoqUsual_NoNames_fnRecorder) AndDo(fn MoqUsual_NoNames_doFn) *MoqUsual_NoNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqUsual_NoNames_fnRecorder) DoReturnResults(fn MoqUsual_NoNames_doReturnFn) *MoqUsual_NoNames_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + Result1 string + Result2 error + } + Sequence uint32 + DoFn MoqUsual_NoNames_doFn + DoReturnFn MoqUsual_NoNames_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqUsual_NoNames_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqUsual_NoNames_resultsByParams + for n, res := range r.Moq.ResultsByParams_NoNames { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqUsual_NoNames_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqUsual_NoNames_paramsKey]*MoqUsual_NoNames_results{}, + } + r.Moq.ResultsByParams_NoNames = append(r.Moq.ResultsByParams_NoNames, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_NoNames) { + copy(r.Moq.ResultsByParams_NoNames[insertAt+1:], r.Moq.ResultsByParams_NoNames[insertAt:0]) + r.Moq.ResultsByParams_NoNames[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_NoNames(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqUsual_NoNames_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqUsual_NoNames_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_NoNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct { + Result1 string + Result2 error + } + Sequence uint32 + DoFn MoqUsual_NoNames_doFn + DoReturnFn MoqUsual_NoNames_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqUsual) PrettyParams_NoNames(params MoqUsual_NoNames_params) string { + return fmt.Sprintf("NoNames(%#v, %#v)", params.Param1, params.Param2) +} + +func (m *MoqUsual) ParamsKey_NoNames(params MoqUsual_NoNames_params, anyParams uint64) MoqUsual_NoNames_paramsKey { + m.Scene.T.Helper() + var param1Used string + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.NoNames.Param1 == moq.ParamIndexByValue { + param1Used = params.Param1 + } else { + param1UsedHash = hash.DeepHash(params.Param1) + } + } + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.NoNames.Param2 == moq.ParamIndexByValue { + param2Used = params.Param2 + } else { + param2UsedHash = hash.DeepHash(params.Param2) + } + } + return MoqUsual_NoNames_paramsKey{ + Params: struct { + Param1 string + Param2 bool + }{ + Param1: param1Used, + Param2: param2Used, + }, + Hashes: struct { + Param1 hash.Hash + Param2 hash.Hash + }{ + Param1: param1UsedHash, + Param2: param2UsedHash, + }, + } +} + +func (m *MoqUsual_recorder) NoResults(sParam string, bParam bool) *MoqUsual_NoResults_fnRecorder { + return &MoqUsual_NoResults_fnRecorder{ + Params: MoqUsual_NoResults_params{ + SParam: sParam, + BParam: bParam, + }, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqUsual_NoResults_fnRecorder) Any() *MoqUsual_NoResults_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoResults(r.Params)) + return nil + } + return &MoqUsual_NoResults_anyParams{Recorder: r} +} + +func (a *MoqUsual_NoResults_anyParams) SParam() *MoqUsual_NoResults_fnRecorder { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder +} + +func (a *MoqUsual_NoResults_anyParams) BParam() *MoqUsual_NoResults_fnRecorder { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (r *MoqUsual_NoResults_fnRecorder) Seq() *MoqUsual_NoResults_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoResults(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqUsual_NoResults_fnRecorder) NoSeq() *MoqUsual_NoResults_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoResults(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqUsual_NoResults_fnRecorder) ReturnResults() *MoqUsual_NoResults_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_NoResults_doFn + DoReturnFn MoqUsual_NoResults_doReturnFn + }{ + Values: &struct{}{}, + Sequence: sequence, + }) + return r +} + +func (r *MoqUsual_NoResults_fnRecorder) AndDo(fn MoqUsual_NoResults_doFn) *MoqUsual_NoResults_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqUsual_NoResults_fnRecorder) DoReturnResults(fn MoqUsual_NoResults_doReturnFn) *MoqUsual_NoResults_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_NoResults_doFn + DoReturnFn MoqUsual_NoResults_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqUsual_NoResults_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqUsual_NoResults_resultsByParams + for n, res := range r.Moq.ResultsByParams_NoResults { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqUsual_NoResults_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqUsual_NoResults_paramsKey]*MoqUsual_NoResults_results{}, + } + r.Moq.ResultsByParams_NoResults = append(r.Moq.ResultsByParams_NoResults, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_NoResults) { + copy(r.Moq.ResultsByParams_NoResults[insertAt+1:], r.Moq.ResultsByParams_NoResults[insertAt:0]) + r.Moq.ResultsByParams_NoResults[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_NoResults(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqUsual_NoResults_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqUsual_NoResults_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_NoResults_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_NoResults_doFn + DoReturnFn MoqUsual_NoResults_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqUsual) PrettyParams_NoResults(params MoqUsual_NoResults_params) string { + return fmt.Sprintf("NoResults(%#v, %#v)", params.SParam, params.BParam) +} + +func (m *MoqUsual) ParamsKey_NoResults(params MoqUsual_NoResults_params, anyParams uint64) MoqUsual_NoResults_paramsKey { + m.Scene.T.Helper() + var sParamUsed string + var sParamUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.NoResults.SParam == moq.ParamIndexByValue { + sParamUsed = params.SParam + } else { + sParamUsedHash = hash.DeepHash(params.SParam) + } + } + var bParamUsed bool + var bParamUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.NoResults.BParam == moq.ParamIndexByValue { + bParamUsed = params.BParam + } else { + bParamUsedHash = hash.DeepHash(params.BParam) + } + } + return MoqUsual_NoResults_paramsKey{ + Params: struct { + SParam string + BParam bool + }{ + SParam: sParamUsed, + BParam: bParamUsed, + }, + Hashes: struct { + SParam hash.Hash + BParam hash.Hash + }{ + SParam: sParamUsedHash, + BParam: bParamUsedHash, + }, + } +} + +func (m *MoqUsual_recorder) NoParams() *MoqUsual_NoParams_fnRecorder { + return &MoqUsual_NoParams_fnRecorder{ Params: MoqUsual_NoParams_params{}, Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, Moq: m.Moq, } } -func (r *MoqUsual_NoParams_fnRecorder) Any() *MoqUsual_NoParams_anyParams { +func (r *MoqUsual_NoParams_fnRecorder) Any() *MoqUsual_NoParams_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoParams(r.Params)) + return nil + } + return &MoqUsual_NoParams_anyParams{Recorder: r} +} + +func (r *MoqUsual_NoParams_fnRecorder) Seq() *MoqUsual_NoParams_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoParams(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqUsual_NoParams_fnRecorder) NoSeq() *MoqUsual_NoParams_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoParams(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqUsual_NoParams_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_NoParams_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_NoParams_doFn + DoReturnFn MoqUsual_NoParams_doReturnFn + }{ + Values: &struct { + SResult string + Err error + }{ + SResult: sResult, + Err: err, + }, + Sequence: sequence, + }) + return r +} + +func (r *MoqUsual_NoParams_fnRecorder) AndDo(fn MoqUsual_NoParams_doFn) *MoqUsual_NoParams_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqUsual_NoParams_fnRecorder) DoReturnResults(fn MoqUsual_NoParams_doReturnFn) *MoqUsual_NoParams_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_NoParams_doFn + DoReturnFn MoqUsual_NoParams_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqUsual_NoParams_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqUsual_NoParams_resultsByParams + for n, res := range r.Moq.ResultsByParams_NoParams { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqUsual_NoParams_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqUsual_NoParams_paramsKey]*MoqUsual_NoParams_results{}, + } + r.Moq.ResultsByParams_NoParams = append(r.Moq.ResultsByParams_NoParams, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_NoParams) { + copy(r.Moq.ResultsByParams_NoParams[insertAt+1:], r.Moq.ResultsByParams_NoParams[insertAt:0]) + r.Moq.ResultsByParams_NoParams[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_NoParams(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqUsual_NoParams_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqUsual_NoParams_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_NoParams_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_NoParams_doFn + DoReturnFn MoqUsual_NoParams_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqUsual) PrettyParams_NoParams(params MoqUsual_NoParams_params) string { + return fmt.Sprintf("NoParams()") +} + +func (m *MoqUsual) ParamsKey_NoParams(params MoqUsual_NoParams_params, anyParams uint64) MoqUsual_NoParams_paramsKey { + m.Scene.T.Helper() + return MoqUsual_NoParams_paramsKey{ + Params: struct{}{}, + Hashes: struct{}{}, + } +} + +func (m *MoqUsual_recorder) Nothing() *MoqUsual_Nothing_fnRecorder { + return &MoqUsual_Nothing_fnRecorder{ + Params: MoqUsual_Nothing_params{}, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqUsual_Nothing_fnRecorder) Any() *MoqUsual_Nothing_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Nothing(r.Params)) + return nil + } + return &MoqUsual_Nothing_anyParams{Recorder: r} +} + +func (r *MoqUsual_Nothing_fnRecorder) Seq() *MoqUsual_Nothing_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Nothing(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqUsual_Nothing_fnRecorder) NoSeq() *MoqUsual_Nothing_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Nothing(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqUsual_Nothing_fnRecorder) ReturnResults() *MoqUsual_Nothing_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_Nothing_doFn + DoReturnFn MoqUsual_Nothing_doReturnFn + }{ + Values: &struct{}{}, + Sequence: sequence, + }) + return r +} + +func (r *MoqUsual_Nothing_fnRecorder) AndDo(fn MoqUsual_Nothing_doFn) *MoqUsual_Nothing_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqUsual_Nothing_fnRecorder) DoReturnResults(fn MoqUsual_Nothing_doReturnFn) *MoqUsual_Nothing_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_Nothing_doFn + DoReturnFn MoqUsual_Nothing_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqUsual_Nothing_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqUsual_Nothing_resultsByParams + for n, res := range r.Moq.ResultsByParams_Nothing { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqUsual_Nothing_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqUsual_Nothing_paramsKey]*MoqUsual_Nothing_results{}, + } + r.Moq.ResultsByParams_Nothing = append(r.Moq.ResultsByParams_Nothing, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Nothing) { + copy(r.Moq.ResultsByParams_Nothing[insertAt+1:], r.Moq.ResultsByParams_Nothing[insertAt:0]) + r.Moq.ResultsByParams_Nothing[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_Nothing(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqUsual_Nothing_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqUsual_Nothing_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Nothing_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_Nothing_doFn + DoReturnFn MoqUsual_Nothing_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqUsual) PrettyParams_Nothing(params MoqUsual_Nothing_params) string { + return fmt.Sprintf("Nothing()") +} + +func (m *MoqUsual) ParamsKey_Nothing(params MoqUsual_Nothing_params, anyParams uint64) MoqUsual_Nothing_paramsKey { + m.Scene.T.Helper() + return MoqUsual_Nothing_paramsKey{ + Params: struct{}{}, + Hashes: struct{}{}, + } +} + +func (m *MoqUsual_recorder) Variadic(other bool, args ...string) *MoqUsual_Variadic_fnRecorder { + return &MoqUsual_Variadic_fnRecorder{ + Params: MoqUsual_Variadic_params{ + Other: other, + Args: args, + }, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqUsual_Variadic_fnRecorder) Any() *MoqUsual_Variadic_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Variadic(r.Params)) + return nil + } + return &MoqUsual_Variadic_anyParams{Recorder: r} +} + +func (a *MoqUsual_Variadic_anyParams) Other() *MoqUsual_Variadic_fnRecorder { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder +} + +func (a *MoqUsual_Variadic_anyParams) Args() *MoqUsual_Variadic_fnRecorder { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (r *MoqUsual_Variadic_fnRecorder) Seq() *MoqUsual_Variadic_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Variadic(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqUsual_Variadic_fnRecorder) NoSeq() *MoqUsual_Variadic_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Variadic(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqUsual_Variadic_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_Variadic_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Variadic_doFn + DoReturnFn MoqUsual_Variadic_doReturnFn + }{ + Values: &struct { + SResult string + Err error + }{ + SResult: sResult, + Err: err, + }, + Sequence: sequence, + }) + return r +} + +func (r *MoqUsual_Variadic_fnRecorder) AndDo(fn MoqUsual_Variadic_doFn) *MoqUsual_Variadic_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqUsual_Variadic_fnRecorder) DoReturnResults(fn MoqUsual_Variadic_doReturnFn) *MoqUsual_Variadic_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Variadic_doFn + DoReturnFn MoqUsual_Variadic_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqUsual_Variadic_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqUsual_Variadic_resultsByParams + for n, res := range r.Moq.ResultsByParams_Variadic { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqUsual_Variadic_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqUsual_Variadic_paramsKey]*MoqUsual_Variadic_results{}, + } + r.Moq.ResultsByParams_Variadic = append(r.Moq.ResultsByParams_Variadic, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Variadic) { + copy(r.Moq.ResultsByParams_Variadic[insertAt+1:], r.Moq.ResultsByParams_Variadic[insertAt:0]) + r.Moq.ResultsByParams_Variadic[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_Variadic(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqUsual_Variadic_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqUsual_Variadic_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Variadic_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Variadic_doFn + DoReturnFn MoqUsual_Variadic_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqUsual) PrettyParams_Variadic(params MoqUsual_Variadic_params) string { + return fmt.Sprintf("Variadic(%#v, %#v)", params.Other, params.Args) +} + +func (m *MoqUsual) ParamsKey_Variadic(params MoqUsual_Variadic_params, anyParams uint64) MoqUsual_Variadic_paramsKey { + m.Scene.T.Helper() + var otherUsed bool + var otherUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.Variadic.Other == moq.ParamIndexByValue { + otherUsed = params.Other + } else { + otherUsedHash = hash.DeepHash(params.Other) + } + } + var argsUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.Variadic.Args == moq.ParamIndexByValue { + m.Scene.T.Fatalf("The args parameter of the Variadic function can't be indexed by value") + } + argsUsedHash = hash.DeepHash(params.Args) + } + return MoqUsual_Variadic_paramsKey{ + Params: struct{ Other bool }{ + Other: otherUsed, + }, + Hashes: struct { + Other hash.Hash + Args hash.Hash + }{ + Other: otherUsedHash, + Args: argsUsedHash, + }, + } +} + +func (m *MoqUsual_recorder) RepeatedIds(sParam1, sParam2 string, bParam bool) *MoqUsual_RepeatedIds_fnRecorder { + return &MoqUsual_RepeatedIds_fnRecorder{ + Params: MoqUsual_RepeatedIds_params{ + SParam1: sParam1, + SParam2: sParam2, + BParam: bParam, + }, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqUsual_RepeatedIds_fnRecorder) Any() *MoqUsual_RepeatedIds_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_RepeatedIds(r.Params)) + return nil + } + return &MoqUsual_RepeatedIds_anyParams{Recorder: r} +} + +func (a *MoqUsual_RepeatedIds_anyParams) SParam1() *MoqUsual_RepeatedIds_fnRecorder { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder +} + +func (a *MoqUsual_RepeatedIds_anyParams) SParam2() *MoqUsual_RepeatedIds_fnRecorder { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (a *MoqUsual_RepeatedIds_anyParams) BParam() *MoqUsual_RepeatedIds_fnRecorder { + a.Recorder.AnyParams |= 1 << 2 + return a.Recorder +} + +func (r *MoqUsual_RepeatedIds_fnRecorder) Seq() *MoqUsual_RepeatedIds_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_RepeatedIds(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqUsual_RepeatedIds_fnRecorder) NoSeq() *MoqUsual_RepeatedIds_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_RepeatedIds(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqUsual_RepeatedIds_fnRecorder) ReturnResults(sResult1, sResult2 string, err error) *MoqUsual_RepeatedIds_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult1, SResult2 string + Err error + } + Sequence uint32 + DoFn MoqUsual_RepeatedIds_doFn + DoReturnFn MoqUsual_RepeatedIds_doReturnFn + }{ + Values: &struct { + SResult1, SResult2 string + Err error + }{ + SResult1: sResult1, + SResult2: sResult2, + Err: err, + }, + Sequence: sequence, + }) + return r +} + +func (r *MoqUsual_RepeatedIds_fnRecorder) AndDo(fn MoqUsual_RepeatedIds_doFn) *MoqUsual_RepeatedIds_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqUsual_RepeatedIds_fnRecorder) DoReturnResults(fn MoqUsual_RepeatedIds_doReturnFn) *MoqUsual_RepeatedIds_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult1, SResult2 string + Err error + } + Sequence uint32 + DoFn MoqUsual_RepeatedIds_doFn + DoReturnFn MoqUsual_RepeatedIds_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqUsual_RepeatedIds_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqUsual_RepeatedIds_resultsByParams + for n, res := range r.Moq.ResultsByParams_RepeatedIds { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqUsual_RepeatedIds_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqUsual_RepeatedIds_paramsKey]*MoqUsual_RepeatedIds_results{}, + } + r.Moq.ResultsByParams_RepeatedIds = append(r.Moq.ResultsByParams_RepeatedIds, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_RepeatedIds) { + copy(r.Moq.ResultsByParams_RepeatedIds[insertAt+1:], r.Moq.ResultsByParams_RepeatedIds[insertAt:0]) + r.Moq.ResultsByParams_RepeatedIds[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_RepeatedIds(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqUsual_RepeatedIds_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqUsual_RepeatedIds_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_RepeatedIds_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct { + SResult1, SResult2 string + Err error + } + Sequence uint32 + DoFn MoqUsual_RepeatedIds_doFn + DoReturnFn MoqUsual_RepeatedIds_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqUsual) PrettyParams_RepeatedIds(params MoqUsual_RepeatedIds_params) string { + return fmt.Sprintf("RepeatedIds(%#v, %#v, %#v)", params.SParam1, params.SParam2, params.BParam) +} + +func (m *MoqUsual) ParamsKey_RepeatedIds(params MoqUsual_RepeatedIds_params, anyParams uint64) MoqUsual_RepeatedIds_paramsKey { + m.Scene.T.Helper() + var sParam1Used string + var sParam1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.RepeatedIds.SParam1 == moq.ParamIndexByValue { + sParam1Used = params.SParam1 + } else { + sParam1UsedHash = hash.DeepHash(params.SParam1) + } + } + var sParam2Used string + var sParam2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.RepeatedIds.SParam2 == moq.ParamIndexByValue { + sParam2Used = params.SParam2 + } else { + sParam2UsedHash = hash.DeepHash(params.SParam2) + } + } + var bParamUsed bool + var bParamUsedHash hash.Hash + if anyParams&(1<<2) == 0 { + if m.Runtime.ParameterIndexing.RepeatedIds.BParam == moq.ParamIndexByValue { + bParamUsed = params.BParam + } else { + bParamUsedHash = hash.DeepHash(params.BParam) + } + } + return MoqUsual_RepeatedIds_paramsKey{ + Params: struct { + SParam1, SParam2 string + BParam bool + }{ + SParam1: sParam1Used, + SParam2: sParam2Used, + BParam: bParamUsed, + }, + Hashes: struct { + SParam1, SParam2 hash.Hash + BParam hash.Hash + }{ + SParam1: sParam1UsedHash, + SParam2: sParam2UsedHash, + BParam: bParamUsedHash, + }, + } +} + +func (m *MoqUsual_recorder) Times(sParam string, times bool) *MoqUsual_Times_fnRecorder { + return &MoqUsual_Times_fnRecorder{ + Params: MoqUsual_Times_params{ + SParam: sParam, + Times: times, + }, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqUsual_Times_fnRecorder) Any() *MoqUsual_Times_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Times(r.Params)) + return nil + } + return &MoqUsual_Times_anyParams{Recorder: r} +} + +func (a *MoqUsual_Times_anyParams) SParam() *MoqUsual_Times_fnRecorder { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder +} + +func (a *MoqUsual_Times_anyParams) Times() *MoqUsual_Times_fnRecorder { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (r *MoqUsual_Times_fnRecorder) Seq() *MoqUsual_Times_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Times(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqUsual_Times_fnRecorder) NoSeq() *MoqUsual_Times_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Times(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqUsual_Times_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_Times_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Times_doFn + DoReturnFn MoqUsual_Times_doReturnFn + }{ + Values: &struct { + SResult string + Err error + }{ + SResult: sResult, + Err: err, + }, + Sequence: sequence, + }) + return r +} + +func (r *MoqUsual_Times_fnRecorder) AndDo(fn MoqUsual_Times_doFn) *MoqUsual_Times_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqUsual_Times_fnRecorder) DoReturnResults(fn MoqUsual_Times_doReturnFn) *MoqUsual_Times_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Times_doFn + DoReturnFn MoqUsual_Times_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqUsual_Times_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqUsual_Times_resultsByParams + for n, res := range r.Moq.ResultsByParams_Times { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqUsual_Times_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqUsual_Times_paramsKey]*MoqUsual_Times_results{}, + } + r.Moq.ResultsByParams_Times = append(r.Moq.ResultsByParams_Times, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Times) { + copy(r.Moq.ResultsByParams_Times[insertAt+1:], r.Moq.ResultsByParams_Times[insertAt:0]) + r.Moq.ResultsByParams_Times[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_Times(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqUsual_Times_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqUsual_Times_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Times_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_Times_doFn + DoReturnFn MoqUsual_Times_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqUsual) PrettyParams_Times(params MoqUsual_Times_params) string { + return fmt.Sprintf("Times(%#v, %#v)", params.SParam, params.Times) +} + +func (m *MoqUsual) ParamsKey_Times(params MoqUsual_Times_params, anyParams uint64) MoqUsual_Times_paramsKey { + m.Scene.T.Helper() + var sParamUsed string + var sParamUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.Times.SParam == moq.ParamIndexByValue { + sParamUsed = params.SParam + } else { + sParamUsedHash = hash.DeepHash(params.SParam) + } + } + var timesUsed bool + var timesUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.Times.Times == moq.ParamIndexByValue { + timesUsed = params.Times + } else { + timesUsedHash = hash.DeepHash(params.Times) + } + } + return MoqUsual_Times_paramsKey{ + Params: struct { + SParam string + Times bool + }{ + SParam: sParamUsed, + Times: timesUsed, + }, + Hashes: struct { + SParam hash.Hash + Times hash.Hash + }{ + SParam: sParamUsedHash, + Times: timesUsedHash, + }, + } +} + +func (m *MoqUsual_recorder) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) *MoqUsual_DifficultParamNames_fnRecorder { + return &MoqUsual_DifficultParamNames_fnRecorder{ + Params: MoqUsual_DifficultParamNames_params{ + Param1: param1, + Param2: param2, + Param3: param3, + Param: param, + Param5: param5, + Param6: param6, + Param7: param7, + Param8: param8, + Param9: param9, + }, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqUsual_DifficultParamNames_fnRecorder) Any() *MoqUsual_DifficultParamNames_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultParamNames(r.Params)) + return nil + } + return &MoqUsual_DifficultParamNames_anyParams{Recorder: r} +} + +func (a *MoqUsual_DifficultParamNames_anyParams) Param1() *MoqUsual_DifficultParamNames_fnRecorder { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder +} + +func (a *MoqUsual_DifficultParamNames_anyParams) Param2() *MoqUsual_DifficultParamNames_fnRecorder { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (a *MoqUsual_DifficultParamNames_anyParams) Param3() *MoqUsual_DifficultParamNames_fnRecorder { + a.Recorder.AnyParams |= 1 << 2 + return a.Recorder +} + +func (a *MoqUsual_DifficultParamNames_anyParams) Param() *MoqUsual_DifficultParamNames_fnRecorder { + a.Recorder.AnyParams |= 1 << 3 + return a.Recorder +} + +func (a *MoqUsual_DifficultParamNames_anyParams) Param5() *MoqUsual_DifficultParamNames_fnRecorder { + a.Recorder.AnyParams |= 1 << 4 + return a.Recorder +} + +func (a *MoqUsual_DifficultParamNames_anyParams) Param6() *MoqUsual_DifficultParamNames_fnRecorder { + a.Recorder.AnyParams |= 1 << 5 + return a.Recorder +} + +func (a *MoqUsual_DifficultParamNames_anyParams) Param7() *MoqUsual_DifficultParamNames_fnRecorder { + a.Recorder.AnyParams |= 1 << 6 + return a.Recorder +} + +func (a *MoqUsual_DifficultParamNames_anyParams) Param8() *MoqUsual_DifficultParamNames_fnRecorder { + a.Recorder.AnyParams |= 1 << 7 + return a.Recorder +} + +func (a *MoqUsual_DifficultParamNames_anyParams) Param9() *MoqUsual_DifficultParamNames_fnRecorder { + a.Recorder.AnyParams |= 1 << 8 + return a.Recorder +} + +func (r *MoqUsual_DifficultParamNames_fnRecorder) Seq() *MoqUsual_DifficultParamNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultParamNames(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqUsual_DifficultParamNames_fnRecorder) NoSeq() *MoqUsual_DifficultParamNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultParamNames(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqUsual_DifficultParamNames_fnRecorder) ReturnResults() *MoqUsual_DifficultParamNames_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_DifficultParamNames_doFn + DoReturnFn MoqUsual_DifficultParamNames_doReturnFn + }{ + Values: &struct{}{}, + Sequence: sequence, + }) + return r +} + +func (r *MoqUsual_DifficultParamNames_fnRecorder) AndDo(fn MoqUsual_DifficultParamNames_doFn) *MoqUsual_DifficultParamNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqUsual_DifficultParamNames_fnRecorder) DoReturnResults(fn MoqUsual_DifficultParamNames_doReturnFn) *MoqUsual_DifficultParamNames_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_DifficultParamNames_doFn + DoReturnFn MoqUsual_DifficultParamNames_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqUsual_DifficultParamNames_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqUsual_DifficultParamNames_resultsByParams + for n, res := range r.Moq.ResultsByParams_DifficultParamNames { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqUsual_DifficultParamNames_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqUsual_DifficultParamNames_paramsKey]*MoqUsual_DifficultParamNames_results{}, + } + r.Moq.ResultsByParams_DifficultParamNames = append(r.Moq.ResultsByParams_DifficultParamNames, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_DifficultParamNames) { + copy(r.Moq.ResultsByParams_DifficultParamNames[insertAt+1:], r.Moq.ResultsByParams_DifficultParamNames[insertAt:0]) + r.Moq.ResultsByParams_DifficultParamNames[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_DifficultParamNames(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqUsual_DifficultParamNames_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqUsual_DifficultParamNames_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_DifficultParamNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct{} + Sequence uint32 + DoFn MoqUsual_DifficultParamNames_doFn + DoReturnFn MoqUsual_DifficultParamNames_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqUsual) PrettyParams_DifficultParamNames(params MoqUsual_DifficultParamNames_params) string { + return fmt.Sprintf("DifficultParamNames(%#v, %#v, %#v, %#v, %#v, %#v, %#v, %#v, %#v)", params.Param1, params.Param2, params.Param3, params.Param, params.Param5, params.Param6, params.Param7, params.Param8, params.Param9) +} + +func (m *MoqUsual) ParamsKey_DifficultParamNames(params MoqUsual_DifficultParamNames_params, anyParams uint64) MoqUsual_DifficultParamNames_paramsKey { + m.Scene.T.Helper() + var param1Used bool + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.DifficultParamNames.Param1 == moq.ParamIndexByValue { + param1Used = params.Param1 + } else { + param1UsedHash = hash.DeepHash(params.Param1) + } + } + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.DifficultParamNames.Param2 == moq.ParamIndexByValue { + param2Used = params.Param2 + } else { + param2UsedHash = hash.DeepHash(params.Param2) + } + } + var param3Used string + var param3UsedHash hash.Hash + if anyParams&(1<<2) == 0 { + if m.Runtime.ParameterIndexing.DifficultParamNames.Param3 == moq.ParamIndexByValue { + param3Used = params.Param3 + } else { + param3UsedHash = hash.DeepHash(params.Param3) + } + } + var paramUsed int + var paramUsedHash hash.Hash + if anyParams&(1<<3) == 0 { + if m.Runtime.ParameterIndexing.DifficultParamNames.Param == moq.ParamIndexByValue { + paramUsed = params.Param + } else { + paramUsedHash = hash.DeepHash(params.Param) + } + } + var param5Used int + var param5UsedHash hash.Hash + if anyParams&(1<<4) == 0 { + if m.Runtime.ParameterIndexing.DifficultParamNames.Param5 == moq.ParamIndexByValue { + param5Used = params.Param5 + } else { + param5UsedHash = hash.DeepHash(params.Param5) + } + } + var param6Used int + var param6UsedHash hash.Hash + if anyParams&(1<<5) == 0 { + if m.Runtime.ParameterIndexing.DifficultParamNames.Param6 == moq.ParamIndexByValue { + param6Used = params.Param6 + } else { + param6UsedHash = hash.DeepHash(params.Param6) + } + } + var param7Used float32 + var param7UsedHash hash.Hash + if anyParams&(1<<6) == 0 { + if m.Runtime.ParameterIndexing.DifficultParamNames.Param7 == moq.ParamIndexByValue { + param7Used = params.Param7 + } else { + param7UsedHash = hash.DeepHash(params.Param7) + } + } + var param8Used float32 + var param8UsedHash hash.Hash + if anyParams&(1<<7) == 0 { + if m.Runtime.ParameterIndexing.DifficultParamNames.Param8 == moq.ParamIndexByValue { + param8Used = params.Param8 + } else { + param8UsedHash = hash.DeepHash(params.Param8) + } + } + var param9Used float32 + var param9UsedHash hash.Hash + if anyParams&(1<<8) == 0 { + if m.Runtime.ParameterIndexing.DifficultParamNames.Param9 == moq.ParamIndexByValue { + param9Used = params.Param9 + } else { + param9UsedHash = hash.DeepHash(params.Param9) + } + } + return MoqUsual_DifficultParamNames_paramsKey{ + Params: struct { + Param1, Param2 bool + Param3 string + Param, Param5, Param6 int + Param7, Param8, Param9 float32 + }{ + Param1: param1Used, + Param2: param2Used, + Param3: param3Used, + Param: paramUsed, + Param5: param5Used, + Param6: param6Used, + Param7: param7Used, + Param8: param8Used, + Param9: param9Used, + }, + Hashes: struct { + Param1, Param2 hash.Hash + Param3 hash.Hash + Param, Param5, Param6 hash.Hash + Param7, Param8, Param9 hash.Hash + }{ + Param1: param1UsedHash, + Param2: param2UsedHash, + Param3: param3UsedHash, + Param: paramUsedHash, + Param5: param5UsedHash, + Param6: param6UsedHash, + Param7: param7UsedHash, + Param8: param8UsedHash, + Param9: param9UsedHash, + }, + } +} + +func (m *MoqUsual_recorder) DifficultResultNames() *MoqUsual_DifficultResultNames_fnRecorder { + return &MoqUsual_DifficultResultNames_fnRecorder{ + Params: MoqUsual_DifficultResultNames_params{}, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqUsual_DifficultResultNames_fnRecorder) Any() *MoqUsual_DifficultResultNames_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultResultNames(r.Params)) + return nil + } + return &MoqUsual_DifficultResultNames_anyParams{Recorder: r} +} + +func (r *MoqUsual_DifficultResultNames_fnRecorder) Seq() *MoqUsual_DifficultResultNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultResultNames(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqUsual_DifficultResultNames_fnRecorder) NoSeq() *MoqUsual_DifficultResultNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultResultNames(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqUsual_DifficultResultNames_fnRecorder) ReturnResults(result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) *MoqUsual_DifficultResultNames_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + Result1, Result2 string + Result3 error + Param, Result5, Result6 int + Result7, Result8, Result9 float32 + } + Sequence uint32 + DoFn MoqUsual_DifficultResultNames_doFn + DoReturnFn MoqUsual_DifficultResultNames_doReturnFn + }{ + Values: &struct { + Result1, Result2 string + Result3 error + Param, Result5, Result6 int + Result7, Result8, Result9 float32 + }{ + Result1: result1, + Result2: result2, + Result3: result3, + Param: param, + Result5: result5, + Result6: result6, + Result7: result7, + Result8: result8, + Result9: result9, + }, + Sequence: sequence, + }) + return r +} + +func (r *MoqUsual_DifficultResultNames_fnRecorder) AndDo(fn MoqUsual_DifficultResultNames_doFn) *MoqUsual_DifficultResultNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqUsual_DifficultResultNames_fnRecorder) DoReturnResults(fn MoqUsual_DifficultResultNames_doReturnFn) *MoqUsual_DifficultResultNames_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + Result1, Result2 string + Result3 error + Param, Result5, Result6 int + Result7, Result8, Result9 float32 + } + Sequence uint32 + DoFn MoqUsual_DifficultResultNames_doFn + DoReturnFn MoqUsual_DifficultResultNames_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqUsual_DifficultResultNames_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqUsual_DifficultResultNames_resultsByParams + for n, res := range r.Moq.ResultsByParams_DifficultResultNames { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqUsual_DifficultResultNames_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqUsual_DifficultResultNames_paramsKey]*MoqUsual_DifficultResultNames_results{}, + } + r.Moq.ResultsByParams_DifficultResultNames = append(r.Moq.ResultsByParams_DifficultResultNames, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_DifficultResultNames) { + copy(r.Moq.ResultsByParams_DifficultResultNames[insertAt+1:], r.Moq.ResultsByParams_DifficultResultNames[insertAt:0]) + r.Moq.ResultsByParams_DifficultResultNames[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_DifficultResultNames(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqUsual_DifficultResultNames_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqUsual_DifficultResultNames_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_DifficultResultNames_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct { + Result1, Result2 string + Result3 error + Param, Result5, Result6 int + Result7, Result8, Result9 float32 + } + Sequence uint32 + DoFn MoqUsual_DifficultResultNames_doFn + DoReturnFn MoqUsual_DifficultResultNames_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqUsual) PrettyParams_DifficultResultNames(params MoqUsual_DifficultResultNames_params) string { + return fmt.Sprintf("DifficultResultNames()") +} + +func (m *MoqUsual) ParamsKey_DifficultResultNames(params MoqUsual_DifficultResultNames_params, anyParams uint64) MoqUsual_DifficultResultNames_paramsKey { + m.Scene.T.Helper() + return MoqUsual_DifficultResultNames_paramsKey{ + Params: struct{}{}, + Hashes: struct{}{}, + } +} + +func (m *MoqUsual_recorder) PassByReference(p *testmoqs.PassByReferenceParams) *MoqUsual_PassByReference_fnRecorder { + return &MoqUsual_PassByReference_fnRecorder{ + Params: MoqUsual_PassByReference_params{ + P: p, + }, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqUsual_PassByReference_fnRecorder) Any() *MoqUsual_PassByReference_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_PassByReference(r.Params)) + return nil + } + return &MoqUsual_PassByReference_anyParams{Recorder: r} +} + +func (a *MoqUsual_PassByReference_anyParams) P() *MoqUsual_PassByReference_fnRecorder { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder +} + +func (r *MoqUsual_PassByReference_fnRecorder) Seq() *MoqUsual_PassByReference_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_PassByReference(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqUsual_PassByReference_fnRecorder) NoSeq() *MoqUsual_PassByReference_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_PassByReference(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqUsual_PassByReference_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_PassByReference_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_PassByReference_doFn + DoReturnFn MoqUsual_PassByReference_doReturnFn + }{ + Values: &struct { + SResult string + Err error + }{ + SResult: sResult, + Err: err, + }, + Sequence: sequence, + }) + return r +} + +func (r *MoqUsual_PassByReference_fnRecorder) AndDo(fn MoqUsual_PassByReference_doFn) *MoqUsual_PassByReference_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqUsual_PassByReference_fnRecorder) DoReturnResults(fn MoqUsual_PassByReference_doReturnFn) *MoqUsual_PassByReference_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_PassByReference_doFn + DoReturnFn MoqUsual_PassByReference_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqUsual_PassByReference_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqUsual_PassByReference_resultsByParams + for n, res := range r.Moq.ResultsByParams_PassByReference { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqUsual_PassByReference_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqUsual_PassByReference_paramsKey]*MoqUsual_PassByReference_results{}, + } + r.Moq.ResultsByParams_PassByReference = append(r.Moq.ResultsByParams_PassByReference, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_PassByReference) { + copy(r.Moq.ResultsByParams_PassByReference[insertAt+1:], r.Moq.ResultsByParams_PassByReference[insertAt:0]) + r.Moq.ResultsByParams_PassByReference[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_PassByReference(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqUsual_PassByReference_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqUsual_PassByReference_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByReference_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqUsual_PassByReference_doFn + DoReturnFn MoqUsual_PassByReference_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqUsual) PrettyParams_PassByReference(params MoqUsual_PassByReference_params) string { + return fmt.Sprintf("PassByReference(%#v)", params.P) +} + +func (m *MoqUsual) ParamsKey_PassByReference(params MoqUsual_PassByReference_params, anyParams uint64) MoqUsual_PassByReference_paramsKey { + m.Scene.T.Helper() + var pUsed *testmoqs.PassByReferenceParams + var pUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.PassByReference.P == moq.ParamIndexByValue { + pUsed = params.P + } else { + pUsedHash = hash.DeepHash(params.P) + } + } + return MoqUsual_PassByReference_paramsKey{ + Params: struct { + P *testmoqs.PassByReferenceParams + }{ + P: pUsed, + }, + Hashes: struct{ P hash.Hash }{ + P: pUsedHash, + }, + } +} + +func (m *MoqUsual_recorder) InterfaceParam(w io.Writer) *MoqUsual_InterfaceParam_fnRecorder { + return &MoqUsual_InterfaceParam_fnRecorder{ + Params: MoqUsual_InterfaceParam_params{ + W: w, + }, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqUsual_InterfaceParam_fnRecorder) Any() *MoqUsual_InterfaceParam_anyParams { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoParams(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceParam(r.Params)) return nil } - return &MoqUsual_NoParams_anyParams{Recorder: r} + return &MoqUsual_InterfaceParam_anyParams{Recorder: r} } -func (r *MoqUsual_NoParams_fnRecorder) Seq() *MoqUsual_NoParams_fnRecorder { +func (a *MoqUsual_InterfaceParam_anyParams) W() *MoqUsual_InterfaceParam_fnRecorder { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder +} + +func (r *MoqUsual_InterfaceParam_fnRecorder) Seq() *MoqUsual_InterfaceParam_fnRecorder { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoParams(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceParam(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_NoParams_fnRecorder) NoSeq() *MoqUsual_NoParams_fnRecorder { +func (r *MoqUsual_InterfaceParam_fnRecorder) NoSeq() *MoqUsual_InterfaceParam_fnRecorder { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_NoParams(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceParam(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_NoParams_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_NoParams_fnRecorder { +func (r *MoqUsual_InterfaceParam_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_InterfaceParam_fnRecorder { r.Moq.Scene.T.Helper() r.FindResults() @@ -8093,8 +12428,8 @@ func (r *MoqUsual_NoParams_fnRecorder) ReturnResults(sResult string, err error) Err error } Sequence uint32 - DoFn MoqUsual_NoParams_doFn - DoReturnFn MoqUsual_NoParams_doReturnFn + DoFn MoqUsual_InterfaceParam_doFn + DoReturnFn MoqUsual_InterfaceParam_doReturnFn }{ Values: &struct { SResult string @@ -8108,7 +12443,7 @@ func (r *MoqUsual_NoParams_fnRecorder) ReturnResults(sResult string, err error) return r } -func (r *MoqUsual_NoParams_fnRecorder) AndDo(fn MoqUsual_NoParams_doFn) *MoqUsual_NoParams_fnRecorder { +func (r *MoqUsual_InterfaceParam_fnRecorder) AndDo(fn MoqUsual_InterfaceParam_doFn) *MoqUsual_InterfaceParam_fnRecorder { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -8119,7 +12454,7 @@ func (r *MoqUsual_NoParams_fnRecorder) AndDo(fn MoqUsual_NoParams_doFn) *MoqUsua return r } -func (r *MoqUsual_NoParams_fnRecorder) DoReturnResults(fn MoqUsual_NoParams_doReturnFn) *MoqUsual_NoParams_fnRecorder { +func (r *MoqUsual_InterfaceParam_fnRecorder) DoReturnResults(fn MoqUsual_InterfaceParam_doReturnFn) *MoqUsual_InterfaceParam_fnRecorder { r.Moq.Scene.T.Helper() r.FindResults() @@ -8134,13 +12469,13 @@ func (r *MoqUsual_NoParams_fnRecorder) DoReturnResults(fn MoqUsual_NoParams_doRe Err error } Sequence uint32 - DoFn MoqUsual_NoParams_doFn - DoReturnFn MoqUsual_NoParams_doReturnFn + DoFn MoqUsual_InterfaceParam_doFn + DoReturnFn MoqUsual_InterfaceParam_doReturnFn }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_NoParams_fnRecorder) FindResults() { +func (r *MoqUsual_InterfaceParam_fnRecorder) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -8149,8 +12484,8 @@ func (r *MoqUsual_NoParams_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_NoParams_resultsByParams - for n, res := range r.Moq.ResultsByParams_NoParams { + var results *MoqUsual_InterfaceParam_resultsByParams + for n, res := range r.Moq.ResultsByParams_InterfaceParam { if res.AnyParams == r.AnyParams { results = &res break @@ -8160,24 +12495,24 @@ func (r *MoqUsual_NoParams_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_NoParams_resultsByParams{ + results = &MoqUsual_InterfaceParam_resultsByParams{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_NoParams_paramsKey]*MoqUsual_NoParams_results{}, + Results: map[MoqUsual_InterfaceParam_paramsKey]*MoqUsual_InterfaceParam_results{}, } - r.Moq.ResultsByParams_NoParams = append(r.Moq.ResultsByParams_NoParams, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_NoParams) { - copy(r.Moq.ResultsByParams_NoParams[insertAt+1:], r.Moq.ResultsByParams_NoParams[insertAt:0]) - r.Moq.ResultsByParams_NoParams[insertAt] = *results + r.Moq.ResultsByParams_InterfaceParam = append(r.Moq.ResultsByParams_InterfaceParam, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_InterfaceParam) { + copy(r.Moq.ResultsByParams_InterfaceParam[insertAt+1:], r.Moq.ResultsByParams_InterfaceParam[insertAt:0]) + r.Moq.ResultsByParams_InterfaceParam[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_NoParams(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey_InterfaceParam(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_NoParams_results{ + r.Results = &MoqUsual_InterfaceParam_results{ Params: r.Params, Results: nil, Index: 0, @@ -8189,7 +12524,7 @@ func (r *MoqUsual_NoParams_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_NoParams_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_NoParams_fnRecorder { +func (r *MoqUsual_InterfaceParam_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_InterfaceParam_fnRecorder { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -8205,8 +12540,8 @@ func (r *MoqUsual_NoParams_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsu Err error } Sequence uint32 - DoFn MoqUsual_NoParams_doFn - DoReturnFn MoqUsual_NoParams_doReturnFn + DoFn MoqUsual_InterfaceParam_doFn + DoReturnFn MoqUsual_InterfaceParam_doReturnFn }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -8217,56 +12552,82 @@ func (r *MoqUsual_NoParams_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsu return r } -func (m *MoqUsual) PrettyParams_NoParams(params MoqUsual_NoParams_params) string { - return fmt.Sprintf("NoParams()") +func (m *MoqUsual) PrettyParams_InterfaceParam(params MoqUsual_InterfaceParam_params) string { + return fmt.Sprintf("InterfaceParam(%#v)", params.W) } -func (m *MoqUsual) ParamsKey_NoParams(params MoqUsual_NoParams_params, anyParams uint64) MoqUsual_NoParams_paramsKey { +func (m *MoqUsual) ParamsKey_InterfaceParam(params MoqUsual_InterfaceParam_params, anyParams uint64) MoqUsual_InterfaceParam_paramsKey { m.Scene.T.Helper() - return MoqUsual_NoParams_paramsKey{ - Params: struct{}{}, - Hashes: struct{}{}, + var wUsed io.Writer + var wUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.InterfaceParam.W == moq.ParamIndexByValue { + wUsed = params.W + } else { + wUsedHash = hash.DeepHash(params.W) + } + } + return MoqUsual_InterfaceParam_paramsKey{ + Params: struct{ W io.Writer }{ + W: wUsed, + }, + Hashes: struct{ W hash.Hash }{ + W: wUsedHash, + }, } } -func (m *MoqUsual_recorder) Nothing() *MoqUsual_Nothing_fnRecorder { - return &MoqUsual_Nothing_fnRecorder{ - Params: MoqUsual_Nothing_params{}, +func (m *MoqUsual_recorder) InterfaceResult(sParam string, bParam bool) *MoqUsual_InterfaceResult_fnRecorder { + return &MoqUsual_InterfaceResult_fnRecorder{ + Params: MoqUsual_InterfaceResult_params{ + SParam: sParam, + BParam: bParam, + }, Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, Moq: m.Moq, } } -func (r *MoqUsual_Nothing_fnRecorder) Any() *MoqUsual_Nothing_anyParams { +func (r *MoqUsual_InterfaceResult_fnRecorder) Any() *MoqUsual_InterfaceResult_anyParams { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Nothing(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceResult(r.Params)) return nil } - return &MoqUsual_Nothing_anyParams{Recorder: r} + return &MoqUsual_InterfaceResult_anyParams{Recorder: r} } -func (r *MoqUsual_Nothing_fnRecorder) Seq() *MoqUsual_Nothing_fnRecorder { +func (a *MoqUsual_InterfaceResult_anyParams) SParam() *MoqUsual_InterfaceResult_fnRecorder { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder +} + +func (a *MoqUsual_InterfaceResult_anyParams) BParam() *MoqUsual_InterfaceResult_fnRecorder { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (r *MoqUsual_InterfaceResult_fnRecorder) Seq() *MoqUsual_InterfaceResult_fnRecorder { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Nothing(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceResult(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_Nothing_fnRecorder) NoSeq() *MoqUsual_Nothing_fnRecorder { +func (r *MoqUsual_InterfaceResult_fnRecorder) NoSeq() *MoqUsual_InterfaceResult_fnRecorder { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Nothing(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceResult(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_Nothing_fnRecorder) ReturnResults() *MoqUsual_Nothing_fnRecorder { +func (r *MoqUsual_InterfaceResult_fnRecorder) ReturnResults(result1 io.Reader) *MoqUsual_InterfaceResult_fnRecorder { r.Moq.Scene.T.Helper() r.FindResults() @@ -8276,18 +12637,20 @@ func (r *MoqUsual_Nothing_fnRecorder) ReturnResults() *MoqUsual_Nothing_fnRecord } r.Results.Results = append(r.Results.Results, struct { - Values *struct{} + Values *struct{ Result1 io.Reader } Sequence uint32 - DoFn MoqUsual_Nothing_doFn - DoReturnFn MoqUsual_Nothing_doReturnFn + DoFn MoqUsual_InterfaceResult_doFn + DoReturnFn MoqUsual_InterfaceResult_doReturnFn }{ - Values: &struct{}{}, + Values: &struct{ Result1 io.Reader }{ + Result1: result1, + }, Sequence: sequence, }) return r } -func (r *MoqUsual_Nothing_fnRecorder) AndDo(fn MoqUsual_Nothing_doFn) *MoqUsual_Nothing_fnRecorder { +func (r *MoqUsual_InterfaceResult_fnRecorder) AndDo(fn MoqUsual_InterfaceResult_doFn) *MoqUsual_InterfaceResult_fnRecorder { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -8298,7 +12661,7 @@ func (r *MoqUsual_Nothing_fnRecorder) AndDo(fn MoqUsual_Nothing_doFn) *MoqUsual_ return r } -func (r *MoqUsual_Nothing_fnRecorder) DoReturnResults(fn MoqUsual_Nothing_doReturnFn) *MoqUsual_Nothing_fnRecorder { +func (r *MoqUsual_InterfaceResult_fnRecorder) DoReturnResults(fn MoqUsual_InterfaceResult_doReturnFn) *MoqUsual_InterfaceResult_fnRecorder { r.Moq.Scene.T.Helper() r.FindResults() @@ -8308,15 +12671,15 @@ func (r *MoqUsual_Nothing_fnRecorder) DoReturnResults(fn MoqUsual_Nothing_doRetu } r.Results.Results = append(r.Results.Results, struct { - Values *struct{} + Values *struct{ Result1 io.Reader } Sequence uint32 - DoFn MoqUsual_Nothing_doFn - DoReturnFn MoqUsual_Nothing_doReturnFn + DoFn MoqUsual_InterfaceResult_doFn + DoReturnFn MoqUsual_InterfaceResult_doReturnFn }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_Nothing_fnRecorder) FindResults() { +func (r *MoqUsual_InterfaceResult_fnRecorder) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -8325,8 +12688,8 @@ func (r *MoqUsual_Nothing_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_Nothing_resultsByParams - for n, res := range r.Moq.ResultsByParams_Nothing { + var results *MoqUsual_InterfaceResult_resultsByParams + for n, res := range r.Moq.ResultsByParams_InterfaceResult { if res.AnyParams == r.AnyParams { results = &res break @@ -8336,24 +12699,24 @@ func (r *MoqUsual_Nothing_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_Nothing_resultsByParams{ + results = &MoqUsual_InterfaceResult_resultsByParams{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_Nothing_paramsKey]*MoqUsual_Nothing_results{}, + Results: map[MoqUsual_InterfaceResult_paramsKey]*MoqUsual_InterfaceResult_results{}, } - r.Moq.ResultsByParams_Nothing = append(r.Moq.ResultsByParams_Nothing, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Nothing) { - copy(r.Moq.ResultsByParams_Nothing[insertAt+1:], r.Moq.ResultsByParams_Nothing[insertAt:0]) - r.Moq.ResultsByParams_Nothing[insertAt] = *results + r.Moq.ResultsByParams_InterfaceResult = append(r.Moq.ResultsByParams_InterfaceResult, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_InterfaceResult) { + copy(r.Moq.ResultsByParams_InterfaceResult[insertAt+1:], r.Moq.ResultsByParams_InterfaceResult[insertAt:0]) + r.Moq.ResultsByParams_InterfaceResult[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_Nothing(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey_InterfaceResult(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_Nothing_results{ + r.Results = &MoqUsual_InterfaceResult_results{ Params: r.Params, Results: nil, Index: 0, @@ -8365,7 +12728,7 @@ func (r *MoqUsual_Nothing_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_Nothing_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Nothing_fnRecorder { +func (r *MoqUsual_InterfaceResult_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_InterfaceResult_fnRecorder { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -8376,10 +12739,10 @@ func (r *MoqUsual_Nothing_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsua for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { if r.Sequence { last = struct { - Values *struct{} + Values *struct{ Result1 io.Reader } Sequence uint32 - DoFn MoqUsual_Nothing_doFn - DoReturnFn MoqUsual_Nothing_doReturnFn + DoFn MoqUsual_InterfaceResult_doFn + DoReturnFn MoqUsual_InterfaceResult_doReturnFn }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -8390,69 +12753,93 @@ func (r *MoqUsual_Nothing_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsua return r } -func (m *MoqUsual) PrettyParams_Nothing(params MoqUsual_Nothing_params) string { - return fmt.Sprintf("Nothing()") +func (m *MoqUsual) PrettyParams_InterfaceResult(params MoqUsual_InterfaceResult_params) string { + return fmt.Sprintf("InterfaceResult(%#v, %#v)", params.SParam, params.BParam) } -func (m *MoqUsual) ParamsKey_Nothing(params MoqUsual_Nothing_params, anyParams uint64) MoqUsual_Nothing_paramsKey { +func (m *MoqUsual) ParamsKey_InterfaceResult(params MoqUsual_InterfaceResult_params, anyParams uint64) MoqUsual_InterfaceResult_paramsKey { m.Scene.T.Helper() - return MoqUsual_Nothing_paramsKey{ - Params: struct{}{}, - Hashes: struct{}{}, + var sParamUsed string + var sParamUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.InterfaceResult.SParam == moq.ParamIndexByValue { + sParamUsed = params.SParam + } else { + sParamUsedHash = hash.DeepHash(params.SParam) + } + } + var bParamUsed bool + var bParamUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.InterfaceResult.BParam == moq.ParamIndexByValue { + bParamUsed = params.BParam + } else { + bParamUsedHash = hash.DeepHash(params.BParam) + } + } + return MoqUsual_InterfaceResult_paramsKey{ + Params: struct { + SParam string + BParam bool + }{ + SParam: sParamUsed, + BParam: bParamUsed, + }, + Hashes: struct { + SParam hash.Hash + BParam hash.Hash + }{ + SParam: sParamUsedHash, + BParam: bParamUsedHash, + }, } } -func (m *MoqUsual_recorder) Variadic(other bool, args ...string) *MoqUsual_Variadic_fnRecorder { - return &MoqUsual_Variadic_fnRecorder{ - Params: MoqUsual_Variadic_params{ - Other: other, - Args: args, +func (m *MoqUsual_recorder) FnParam(fn func()) *MoqUsual_FnParam_fnRecorder { + return &MoqUsual_FnParam_fnRecorder{ + Params: MoqUsual_FnParam_params{ + Fn: fn, }, Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, Moq: m.Moq, } } -func (r *MoqUsual_Variadic_fnRecorder) Any() *MoqUsual_Variadic_anyParams { +func (r *MoqUsual_FnParam_fnRecorder) Any() *MoqUsual_FnParam_anyParams { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Variadic(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_FnParam(r.Params)) return nil } - return &MoqUsual_Variadic_anyParams{Recorder: r} + return &MoqUsual_FnParam_anyParams{Recorder: r} } -func (a *MoqUsual_Variadic_anyParams) Other() *MoqUsual_Variadic_fnRecorder { +func (a *MoqUsual_FnParam_anyParams) Fn() *MoqUsual_FnParam_fnRecorder { a.Recorder.AnyParams |= 1 << 0 return a.Recorder } -func (a *MoqUsual_Variadic_anyParams) Args() *MoqUsual_Variadic_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 - return a.Recorder -} - -func (r *MoqUsual_Variadic_fnRecorder) Seq() *MoqUsual_Variadic_fnRecorder { +func (r *MoqUsual_FnParam_fnRecorder) Seq() *MoqUsual_FnParam_fnRecorder { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Variadic(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_FnParam(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_Variadic_fnRecorder) NoSeq() *MoqUsual_Variadic_fnRecorder { +func (r *MoqUsual_FnParam_fnRecorder) NoSeq() *MoqUsual_FnParam_fnRecorder { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Variadic(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_FnParam(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_Variadic_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_Variadic_fnRecorder { +func (r *MoqUsual_FnParam_fnRecorder) ReturnResults() *MoqUsual_FnParam_fnRecorder { r.Moq.Scene.T.Helper() r.FindResults() @@ -8462,27 +12849,18 @@ func (r *MoqUsual_Variadic_fnRecorder) ReturnResults(sResult string, err error) } r.Results.Results = append(r.Results.Results, struct { - Values *struct { - SResult string - Err error - } + Values *struct{} Sequence uint32 - DoFn MoqUsual_Variadic_doFn - DoReturnFn MoqUsual_Variadic_doReturnFn + DoFn MoqUsual_FnParam_doFn + DoReturnFn MoqUsual_FnParam_doReturnFn }{ - Values: &struct { - SResult string - Err error - }{ - SResult: sResult, - Err: err, - }, + Values: &struct{}{}, Sequence: sequence, }) return r } -func (r *MoqUsual_Variadic_fnRecorder) AndDo(fn MoqUsual_Variadic_doFn) *MoqUsual_Variadic_fnRecorder { +func (r *MoqUsual_FnParam_fnRecorder) AndDo(fn MoqUsual_FnParam_doFn) *MoqUsual_FnParam_fnRecorder { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -8493,7 +12871,7 @@ func (r *MoqUsual_Variadic_fnRecorder) AndDo(fn MoqUsual_Variadic_doFn) *MoqUsua return r } -func (r *MoqUsual_Variadic_fnRecorder) DoReturnResults(fn MoqUsual_Variadic_doReturnFn) *MoqUsual_Variadic_fnRecorder { +func (r *MoqUsual_FnParam_fnRecorder) DoReturnResults(fn MoqUsual_FnParam_doReturnFn) *MoqUsual_FnParam_fnRecorder { r.Moq.Scene.T.Helper() r.FindResults() @@ -8503,18 +12881,15 @@ func (r *MoqUsual_Variadic_fnRecorder) DoReturnResults(fn MoqUsual_Variadic_doRe } r.Results.Results = append(r.Results.Results, struct { - Values *struct { - SResult string - Err error - } + Values *struct{} Sequence uint32 - DoFn MoqUsual_Variadic_doFn - DoReturnFn MoqUsual_Variadic_doReturnFn + DoFn MoqUsual_FnParam_doFn + DoReturnFn MoqUsual_FnParam_doReturnFn }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_Variadic_fnRecorder) FindResults() { +func (r *MoqUsual_FnParam_fnRecorder) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -8523,8 +12898,8 @@ func (r *MoqUsual_Variadic_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_Variadic_resultsByParams - for n, res := range r.Moq.ResultsByParams_Variadic { + var results *MoqUsual_FnParam_resultsByParams + for n, res := range r.Moq.ResultsByParams_FnParam { if res.AnyParams == r.AnyParams { results = &res break @@ -8534,24 +12909,24 @@ func (r *MoqUsual_Variadic_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_Variadic_resultsByParams{ + results = &MoqUsual_FnParam_resultsByParams{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_Variadic_paramsKey]*MoqUsual_Variadic_results{}, + Results: map[MoqUsual_FnParam_paramsKey]*MoqUsual_FnParam_results{}, } - r.Moq.ResultsByParams_Variadic = append(r.Moq.ResultsByParams_Variadic, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Variadic) { - copy(r.Moq.ResultsByParams_Variadic[insertAt+1:], r.Moq.ResultsByParams_Variadic[insertAt:0]) - r.Moq.ResultsByParams_Variadic[insertAt] = *results + r.Moq.ResultsByParams_FnParam = append(r.Moq.ResultsByParams_FnParam, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_FnParam) { + copy(r.Moq.ResultsByParams_FnParam[insertAt+1:], r.Moq.ResultsByParams_FnParam[insertAt:0]) + r.Moq.ResultsByParams_FnParam[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_Variadic(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey_FnParam(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_Variadic_results{ + r.Results = &MoqUsual_FnParam_results{ Params: r.Params, Results: nil, Index: 0, @@ -8563,7 +12938,7 @@ func (r *MoqUsual_Variadic_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_Variadic_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Variadic_fnRecorder { +func (r *MoqUsual_FnParam_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_FnParam_fnRecorder { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -8572,15 +12947,12 @@ func (r *MoqUsual_Variadic_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsu r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) last := r.Results.Results[len(r.Results.Results)-1] for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { - if r.Sequence { - last = struct { - Values *struct { - SResult string - Err error - } + if r.Sequence { + last = struct { + Values *struct{} Sequence uint32 - DoFn MoqUsual_Variadic_doFn - DoReturnFn MoqUsual_Variadic_doReturnFn + DoFn MoqUsual_FnParam_doFn + DoReturnFn MoqUsual_FnParam_doReturnFn }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -8591,342 +12963,413 @@ func (r *MoqUsual_Variadic_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsu return r } -func (m *MoqUsual) PrettyParams_Variadic(params MoqUsual_Variadic_params) string { - return fmt.Sprintf("Variadic(%#v, %#v)", params.Other, params.Args) +func (m *MoqUsual) PrettyParams_FnParam(params MoqUsual_FnParam_params) string { + return fmt.Sprintf("FnParam(%#v)", moq.FnString(params.Fn)) } -func (m *MoqUsual) ParamsKey_Variadic(params MoqUsual_Variadic_params, anyParams uint64) MoqUsual_Variadic_paramsKey { +func (m *MoqUsual) ParamsKey_FnParam(params MoqUsual_FnParam_params, anyParams uint64) MoqUsual_FnParam_paramsKey { m.Scene.T.Helper() - var otherUsed bool - var otherUsedHash hash.Hash + var fnUsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.Variadic.Other == moq.ParamIndexByValue { - otherUsed = params.Other - } else { - otherUsedHash = hash.DeepHash(params.Other) - } - } - var argsUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.Runtime.ParameterIndexing.Variadic.Args == moq.ParamIndexByValue { - m.Scene.T.Fatalf("The args parameter of the Variadic function can't be indexed by value") + if m.Runtime.ParameterIndexing.FnParam.Fn == moq.ParamIndexByValue { + m.Scene.T.Fatalf("The fn parameter of the FnParam function can't be indexed by value") } - argsUsedHash = hash.DeepHash(params.Args) + fnUsedHash = hash.DeepHash(params.Fn) } - return MoqUsual_Variadic_paramsKey{ - Params: struct{ Other bool }{ - Other: otherUsed, - }, - Hashes: struct { - Other hash.Hash - Args hash.Hash - }{ - Other: otherUsedHash, - Args: argsUsedHash, + return MoqUsual_FnParam_paramsKey{ + Params: struct{}{}, + Hashes: struct{ Fn hash.Hash }{ + Fn: fnUsedHash, }, } } -func (m *MoqUsual_recorder) RepeatedIds(sParam1, sParam2 string, bParam bool) *MoqUsual_RepeatedIds_fnRecorder { - return &MoqUsual_RepeatedIds_fnRecorder{ - Params: MoqUsual_RepeatedIds_params{ - SParam1: sParam1, - SParam2: sParam2, - BParam: bParam, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, - } +// Reset resets the state of the moq +func (m *MoqUsual) Reset() { + m.ResultsByParams_Usual = nil + m.ResultsByParams_NoNames = nil + m.ResultsByParams_NoResults = nil + m.ResultsByParams_NoParams = nil + m.ResultsByParams_Nothing = nil + m.ResultsByParams_Variadic = nil + m.ResultsByParams_RepeatedIds = nil + m.ResultsByParams_Times = nil + m.ResultsByParams_DifficultParamNames = nil + m.ResultsByParams_DifficultResultNames = nil + m.ResultsByParams_PassByReference = nil + m.ResultsByParams_InterfaceParam = nil + m.ResultsByParams_InterfaceResult = nil + m.ResultsByParams_FnParam = nil } -func (r *MoqUsual_RepeatedIds_fnRecorder) Any() *MoqUsual_RepeatedIds_anyParams { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_RepeatedIds(r.Params)) - return nil +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqUsual) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams_Usual { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Usual(results.Params)) + } + } } - return &MoqUsual_RepeatedIds_anyParams{Recorder: r} -} - -func (a *MoqUsual_RepeatedIds_anyParams) SParam1() *MoqUsual_RepeatedIds_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 - return a.Recorder -} - -func (a *MoqUsual_RepeatedIds_anyParams) SParam2() *MoqUsual_RepeatedIds_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 - return a.Recorder -} - -func (a *MoqUsual_RepeatedIds_anyParams) BParam() *MoqUsual_RepeatedIds_fnRecorder { - a.Recorder.AnyParams |= 1 << 2 - return a.Recorder -} - -func (r *MoqUsual_RepeatedIds_fnRecorder) Seq() *MoqUsual_RepeatedIds_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_RepeatedIds(r.Params)) - return nil + for _, res := range m.ResultsByParams_NoNames { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_NoNames(results.Params)) + } + } } - r.Sequence = true - return r -} - -func (r *MoqUsual_RepeatedIds_fnRecorder) NoSeq() *MoqUsual_RepeatedIds_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_RepeatedIds(r.Params)) - return nil + for _, res := range m.ResultsByParams_NoResults { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_NoResults(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_NoParams { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_NoParams(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_Nothing { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Nothing(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_Variadic { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Variadic(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_RepeatedIds { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_RepeatedIds(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_Times { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Times(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_DifficultParamNames { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_DifficultParamNames(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_DifficultResultNames { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_DifficultResultNames(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_PassByReference { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_PassByReference(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_InterfaceParam { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_InterfaceParam(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_InterfaceResult { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_InterfaceResult(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_FnParam { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_FnParam(results.Params)) + } + } } - r.Sequence = false - return r } -func (r *MoqUsual_RepeatedIds_fnRecorder) ReturnResults(sResult1, sResult2 string, err error) *MoqUsual_RepeatedIds_fnRecorder { - r.Moq.Scene.T.Helper() - r.FindResults() +// The following type assertion assures that testmoqs.GenericParams is mocked +// completely +var _ testmoqs.GenericParams[any, any] = (*MoqGenericParams_mock[any, any])(nil) - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() - } +// MoqGenericParams holds the state of a moq of the GenericParams type +type MoqGenericParams[S, B any] struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqGenericParams_mock[S, B] - r.Results.Results = append(r.Results.Results, struct { - Values *struct { - SResult1, SResult2 string - Err error - } - Sequence uint32 - DoFn MoqUsual_RepeatedIds_doFn - DoReturnFn MoqUsual_RepeatedIds_doReturnFn - }{ - Values: &struct { - SResult1, SResult2 string - Err error - }{ - SResult1: sResult1, - SResult2: sResult2, - Err: err, - }, - Sequence: sequence, - }) - return r + ResultsByParams_Usual []MoqGenericParams_Usual_resultsByParams[S, B] + + Runtime struct { + ParameterIndexing struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + } + } + // MoqGenericParams_mock isolates the mock interface of the GenericParams type } -func (r *MoqUsual_RepeatedIds_fnRecorder) AndDo(fn MoqUsual_RepeatedIds_doFn) *MoqUsual_RepeatedIds_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") - return nil - } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn - return r +type MoqGenericParams_mock[S, B any] struct { + Moq *MoqGenericParams[S, B] } -func (r *MoqUsual_RepeatedIds_fnRecorder) DoReturnResults(fn MoqUsual_RepeatedIds_doReturnFn) *MoqUsual_RepeatedIds_fnRecorder { - r.Moq.Scene.T.Helper() - r.FindResults() +// MoqGenericParams_recorder isolates the recorder interface of the +// GenericParams type +type MoqGenericParams_recorder[S, B any] struct { + Moq *MoqGenericParams[S, B] +} - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() +// MoqGenericParams_Usual_params holds the params of the GenericParams type +type MoqGenericParams_Usual_params[S, B any] struct { + Param1 S + Param2 B +} + +// MoqGenericParams_Usual_paramsKey holds the map key params of the +// GenericParams type +type MoqGenericParams_Usual_paramsKey[S, B any] struct { + Params struct{} + Hashes struct { + Param1 hash.Hash + Param2 hash.Hash } +} - r.Results.Results = append(r.Results.Results, struct { +// MoqGenericParams_Usual_resultsByParams contains the results for a given set +// of parameters for the GenericParams type +type MoqGenericParams_Usual_resultsByParams[S, B any] struct { + AnyCount int + AnyParams uint64 + Results map[MoqGenericParams_Usual_paramsKey[S, B]]*MoqGenericParams_Usual_results[S, B] +} + +// MoqGenericParams_Usual_doFn defines the type of function needed when calling +// AndDo for the GenericParams type +type MoqGenericParams_Usual_doFn[S, B any] func(S, B) + +// MoqGenericParams_Usual_doReturnFn defines the type of function needed when +// calling DoReturnResults for the GenericParams type +type MoqGenericParams_Usual_doReturnFn[S, B any] func(S, B) (string, error) + +// MoqGenericParams_Usual_results holds the results of the GenericParams type +type MoqGenericParams_Usual_results[S, B any] struct { + Params MoqGenericParams_Usual_params[S, B] + Results []struct { Values *struct { - SResult1, SResult2 string - Err error + Result1 string + Result2 error } Sequence uint32 - DoFn MoqUsual_RepeatedIds_doFn - DoReturnFn MoqUsual_RepeatedIds_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) - return r + DoFn MoqGenericParams_Usual_doFn[S, B] + DoReturnFn MoqGenericParams_Usual_doReturnFn[S, B] + } + Index uint32 + Repeat *moq.RepeatVal } -func (r *MoqUsual_RepeatedIds_fnRecorder) FindResults() { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Results.Repeat.Increment(r.Moq.Scene.T) - return +// MoqGenericParams_Usual_fnRecorder routes recorded function calls to the +// MoqGenericParams moq +type MoqGenericParams_Usual_fnRecorder[S, B any] struct { + Params MoqGenericParams_Usual_params[S, B] + AnyParams uint64 + Sequence bool + Results *MoqGenericParams_Usual_results[S, B] + Moq *MoqGenericParams[S, B] +} + +// MoqGenericParams_Usual_anyParams isolates the any params functions of the +// GenericParams type +type MoqGenericParams_Usual_anyParams[S, B any] struct { + Recorder *MoqGenericParams_Usual_fnRecorder[S, B] +} + +// NewMoqGenericParams creates a new moq of the GenericParams type +func NewMoqGenericParams[S, B any](scene *moq.Scene, config *moq.Config) *MoqGenericParams[S, B] { + if config == nil { + config = &moq.Config{} } + m := &MoqGenericParams[S, B]{ + Scene: scene, + Config: *config, + Moq: &MoqGenericParams_mock[S, B]{}, - anyCount := bits.OnesCount64(r.AnyParams) - insertAt := -1 - var results *MoqUsual_RepeatedIds_resultsByParams - for n, res := range r.Moq.ResultsByParams_RepeatedIds { - if res.AnyParams == r.AnyParams { - results = &res + Runtime: struct { + ParameterIndexing struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + } + }{ParameterIndexing: struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + }{ + Usual: struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + }{ + Param1: moq.ParamIndexByHash, + Param2: moq.ParamIndexByHash, + }, + }}, + } + m.Moq.Moq = m + + scene.AddMoq(m) + return m +} + +// Mock returns the mock implementation of the GenericParams type +func (m *MoqGenericParams[S, B]) Mock() *MoqGenericParams_mock[S, B] { return m.Moq } + +func (m *MoqGenericParams_mock[S, B]) Usual(param1 S, param2 B) (result1 string, result2 error) { + m.Moq.Scene.T.Helper() + params := MoqGenericParams_Usual_params[S, B]{ + Param1: param1, + Param2: param2, + } + var results *MoqGenericParams_Usual_results[S, B] + for _, resultsByParams := range m.Moq.ResultsByParams_Usual { + paramsKey := m.Moq.ParamsKey_Usual(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { break } - if res.AnyCount > anyCount { - insertAt = n - } } if results == nil { - results = &MoqUsual_RepeatedIds_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_RepeatedIds_paramsKey]*MoqUsual_RepeatedIds_results{}, - } - r.Moq.ResultsByParams_RepeatedIds = append(r.Moq.ResultsByParams_RepeatedIds, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_RepeatedIds) { - copy(r.Moq.ResultsByParams_RepeatedIds[insertAt+1:], r.Moq.ResultsByParams_RepeatedIds[insertAt:0]) - r.Moq.ResultsByParams_RepeatedIds[insertAt] = *results + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Usual(params)) } + return } - paramsKey := r.Moq.ParamsKey_RepeatedIds(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_RepeatedIds_results{ - Params: r.Params, - Results: nil, - Index: 0, - Repeat: &moq.RepeatVal{}, + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Usual(params)) + } + return } - results.Results[paramsKey] = r.Results + i = results.Repeat.ResultCount - 1 } - r.Results.Repeat.Increment(r.Moq.Scene.T) -} - -func (r *MoqUsual_RepeatedIds_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_RepeatedIds_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") - return nil - } - r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) - last := r.Results.Results[len(r.Results.Results)-1] - for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { - if r.Sequence { - last = struct { - Values *struct { - SResult1, SResult2 string - Err error - } - Sequence uint32 - DoFn MoqUsual_RepeatedIds_doFn - DoReturnFn MoqUsual_RepeatedIds_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Usual(params)) } - r.Results.Results = append(r.Results.Results, last) } - return r -} - -func (m *MoqUsual) PrettyParams_RepeatedIds(params MoqUsual_RepeatedIds_params) string { - return fmt.Sprintf("RepeatedIds(%#v, %#v, %#v)", params.SParam1, params.SParam2, params.BParam) -} -func (m *MoqUsual) ParamsKey_RepeatedIds(params MoqUsual_RepeatedIds_params, anyParams uint64) MoqUsual_RepeatedIds_paramsKey { - m.Scene.T.Helper() - var sParam1Used string - var sParam1UsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.RepeatedIds.SParam1 == moq.ParamIndexByValue { - sParam1Used = params.SParam1 - } else { - sParam1UsedHash = hash.DeepHash(params.SParam1) - } + if result.DoFn != nil { + result.DoFn(param1, param2) } - var sParam2Used string - var sParam2UsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.Runtime.ParameterIndexing.RepeatedIds.SParam2 == moq.ParamIndexByValue { - sParam2Used = params.SParam2 - } else { - sParam2UsedHash = hash.DeepHash(params.SParam2) - } + + if result.Values != nil { + result1 = result.Values.Result1 + result2 = result.Values.Result2 } - var bParamUsed bool - var bParamUsedHash hash.Hash - if anyParams&(1<<2) == 0 { - if m.Runtime.ParameterIndexing.RepeatedIds.BParam == moq.ParamIndexByValue { - bParamUsed = params.BParam - } else { - bParamUsedHash = hash.DeepHash(params.BParam) - } + if result.DoReturnFn != nil { + result1, result2 = result.DoReturnFn(param1, param2) } - return MoqUsual_RepeatedIds_paramsKey{ - Params: struct { - SParam1, SParam2 string - BParam bool - }{ - SParam1: sParam1Used, - SParam2: sParam2Used, - BParam: bParamUsed, - }, - Hashes: struct { - SParam1, SParam2 hash.Hash - BParam hash.Hash - }{ - SParam1: sParam1UsedHash, - SParam2: sParam2UsedHash, - BParam: bParamUsedHash, - }, + return +} + +// OnCall returns the recorder implementation of the GenericParams type +func (m *MoqGenericParams[S, B]) OnCall() *MoqGenericParams_recorder[S, B] { + return &MoqGenericParams_recorder[S, B]{ + Moq: m, } } -func (m *MoqUsual_recorder) Times(sParam string, times bool) *MoqUsual_Times_fnRecorder { - return &MoqUsual_Times_fnRecorder{ - Params: MoqUsual_Times_params{ - SParam: sParam, - Times: times, +func (m *MoqGenericParams_recorder[S, B]) Usual(param1 S, param2 B) *MoqGenericParams_Usual_fnRecorder[S, B] { + return &MoqGenericParams_Usual_fnRecorder[S, B]{ + Params: MoqGenericParams_Usual_params[S, B]{ + Param1: param1, + Param2: param2, }, Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, Moq: m.Moq, } } -func (r *MoqUsual_Times_fnRecorder) Any() *MoqUsual_Times_anyParams { +func (r *MoqGenericParams_Usual_fnRecorder[S, B]) Any() *MoqGenericParams_Usual_anyParams[S, B] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Times(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } - return &MoqUsual_Times_anyParams{Recorder: r} + return &MoqGenericParams_Usual_anyParams[S, B]{Recorder: r} } -func (a *MoqUsual_Times_anyParams) SParam() *MoqUsual_Times_fnRecorder { +func (a *MoqGenericParams_Usual_anyParams[S, B]) Param1() *MoqGenericParams_Usual_fnRecorder[S, B] { a.Recorder.AnyParams |= 1 << 0 return a.Recorder } -func (a *MoqUsual_Times_anyParams) Times() *MoqUsual_Times_fnRecorder { +func (a *MoqGenericParams_Usual_anyParams[S, B]) Param2() *MoqGenericParams_Usual_fnRecorder[S, B] { a.Recorder.AnyParams |= 1 << 1 return a.Recorder } -func (r *MoqUsual_Times_fnRecorder) Seq() *MoqUsual_Times_fnRecorder { +func (r *MoqGenericParams_Usual_fnRecorder[S, B]) Seq() *MoqGenericParams_Usual_fnRecorder[S, B] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Times(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_Times_fnRecorder) NoSeq() *MoqUsual_Times_fnRecorder { +func (r *MoqGenericParams_Usual_fnRecorder[S, B]) NoSeq() *MoqGenericParams_Usual_fnRecorder[S, B] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Times(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_Times_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_Times_fnRecorder { +func (r *MoqGenericParams_Usual_fnRecorder[S, B]) ReturnResults(result1 string, result2 error) *MoqGenericParams_Usual_fnRecorder[S, B] { r.Moq.Scene.T.Helper() r.FindResults() @@ -8937,26 +13380,26 @@ func (r *MoqUsual_Times_fnRecorder) ReturnResults(sResult string, err error) *Mo r.Results.Results = append(r.Results.Results, struct { Values *struct { - SResult string - Err error + Result1 string + Result2 error } - Sequence uint32 - DoFn MoqUsual_Times_doFn - DoReturnFn MoqUsual_Times_doReturnFn + Sequence uint32 + DoFn MoqGenericParams_Usual_doFn[S, B] + DoReturnFn MoqGenericParams_Usual_doReturnFn[S, B] }{ Values: &struct { - SResult string - Err error + Result1 string + Result2 error }{ - SResult: sResult, - Err: err, + Result1: result1, + Result2: result2, }, Sequence: sequence, }) return r } -func (r *MoqUsual_Times_fnRecorder) AndDo(fn MoqUsual_Times_doFn) *MoqUsual_Times_fnRecorder { +func (r *MoqGenericParams_Usual_fnRecorder[S, B]) AndDo(fn MoqGenericParams_Usual_doFn[S, B]) *MoqGenericParams_Usual_fnRecorder[S, B] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -8967,7 +13410,7 @@ func (r *MoqUsual_Times_fnRecorder) AndDo(fn MoqUsual_Times_doFn) *MoqUsual_Time return r } -func (r *MoqUsual_Times_fnRecorder) DoReturnResults(fn MoqUsual_Times_doReturnFn) *MoqUsual_Times_fnRecorder { +func (r *MoqGenericParams_Usual_fnRecorder[S, B]) DoReturnResults(fn MoqGenericParams_Usual_doReturnFn[S, B]) *MoqGenericParams_Usual_fnRecorder[S, B] { r.Moq.Scene.T.Helper() r.FindResults() @@ -8978,17 +13421,17 @@ func (r *MoqUsual_Times_fnRecorder) DoReturnResults(fn MoqUsual_Times_doReturnFn r.Results.Results = append(r.Results.Results, struct { Values *struct { - SResult string - Err error + Result1 string + Result2 error } Sequence uint32 - DoFn MoqUsual_Times_doFn - DoReturnFn MoqUsual_Times_doReturnFn + DoFn MoqGenericParams_Usual_doFn[S, B] + DoReturnFn MoqGenericParams_Usual_doReturnFn[S, B] }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_Times_fnRecorder) FindResults() { +func (r *MoqGenericParams_Usual_fnRecorder[S, B]) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -8997,8 +13440,8 @@ func (r *MoqUsual_Times_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_Times_resultsByParams - for n, res := range r.Moq.ResultsByParams_Times { + var results *MoqGenericParams_Usual_resultsByParams[S, B] + for n, res := range r.Moq.ResultsByParams_Usual { if res.AnyParams == r.AnyParams { results = &res break @@ -9008,24 +13451,24 @@ func (r *MoqUsual_Times_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_Times_resultsByParams{ + results = &MoqGenericParams_Usual_resultsByParams[S, B]{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_Times_paramsKey]*MoqUsual_Times_results{}, + Results: map[MoqGenericParams_Usual_paramsKey[S, B]]*MoqGenericParams_Usual_results[S, B]{}, } - r.Moq.ResultsByParams_Times = append(r.Moq.ResultsByParams_Times, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Times) { - copy(r.Moq.ResultsByParams_Times[insertAt+1:], r.Moq.ResultsByParams_Times[insertAt:0]) - r.Moq.ResultsByParams_Times[insertAt] = *results + r.Moq.ResultsByParams_Usual = append(r.Moq.ResultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Usual) { + copy(r.Moq.ResultsByParams_Usual[insertAt+1:], r.Moq.ResultsByParams_Usual[insertAt:0]) + r.Moq.ResultsByParams_Usual[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_Times(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey_Usual(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_Times_results{ + r.Results = &MoqGenericParams_Usual_results[S, B]{ Params: r.Params, Results: nil, Index: 0, @@ -9037,7 +13480,7 @@ func (r *MoqUsual_Times_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_Times_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Times_fnRecorder { +func (r *MoqGenericParams_Usual_fnRecorder[S, B]) Repeat(repeaters ...moq.Repeater) *MoqGenericParams_Usual_fnRecorder[S, B] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -9049,12 +13492,12 @@ func (r *MoqUsual_Times_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_ if r.Sequence { last = struct { Values *struct { - SResult string - Err error + Result1 string + Result2 error } Sequence uint32 - DoFn MoqUsual_Times_doFn - DoReturnFn MoqUsual_Times_doReturnFn + DoFn MoqGenericParams_Usual_doFn[S, B] + DoReturnFn MoqGenericParams_Usual_doReturnFn[S, B] }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -9065,425 +13508,310 @@ func (r *MoqUsual_Times_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_ return r } -func (m *MoqUsual) PrettyParams_Times(params MoqUsual_Times_params) string { - return fmt.Sprintf("Times(%#v, %#v)", params.SParam, params.Times) +func (m *MoqGenericParams[S, B]) PrettyParams_Usual(params MoqGenericParams_Usual_params[S, B]) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.Param1, params.Param2) } -func (m *MoqUsual) ParamsKey_Times(params MoqUsual_Times_params, anyParams uint64) MoqUsual_Times_paramsKey { +func (m *MoqGenericParams[S, B]) ParamsKey_Usual(params MoqGenericParams_Usual_params[S, B], anyParams uint64) MoqGenericParams_Usual_paramsKey[S, B] { m.Scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash + var param1UsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.Times.SParam == moq.ParamIndexByValue { - sParamUsed = params.SParam - } else { - sParamUsedHash = hash.DeepHash(params.SParam) + if m.Runtime.ParameterIndexing.Usual.Param1 == moq.ParamIndexByValue { + m.Scene.T.Fatalf("The param1 parameter of the Usual function can't be indexed by value") } + param1UsedHash = hash.DeepHash(params.Param1) } - var timesUsed bool - var timesUsedHash hash.Hash + var param2UsedHash hash.Hash if anyParams&(1<<1) == 0 { - if m.Runtime.ParameterIndexing.Times.Times == moq.ParamIndexByValue { - timesUsed = params.Times - } else { - timesUsedHash = hash.DeepHash(params.Times) + if m.Runtime.ParameterIndexing.Usual.Param2 == moq.ParamIndexByValue { + m.Scene.T.Fatalf("The param2 parameter of the Usual function can't be indexed by value") } + param2UsedHash = hash.DeepHash(params.Param2) } - return MoqUsual_Times_paramsKey{ - Params: struct { - SParam string - Times bool - }{ - SParam: sParamUsed, - Times: timesUsed, - }, + return MoqGenericParams_Usual_paramsKey[S, B]{ + Params: struct{}{}, Hashes: struct { - SParam hash.Hash - Times hash.Hash + Param1 hash.Hash + Param2 hash.Hash }{ - SParam: sParamUsedHash, - Times: timesUsedHash, - }, - } -} - -func (m *MoqUsual_recorder) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) *MoqUsual_DifficultParamNames_fnRecorder { - return &MoqUsual_DifficultParamNames_fnRecorder{ - Params: MoqUsual_DifficultParamNames_params{ - Param1: param1, - Param2: param2, - Param3: param3, - Param: param, - Param5: param5, - Param6: param6, - Param7: param7, - Param8: param8, - Param9: param9, + Param1: param1UsedHash, + Param2: param2UsedHash, }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, - } -} - -func (r *MoqUsual_DifficultParamNames_fnRecorder) Any() *MoqUsual_DifficultParamNames_anyParams { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultParamNames(r.Params)) - return nil - } - return &MoqUsual_DifficultParamNames_anyParams{Recorder: r} -} - -func (a *MoqUsual_DifficultParamNames_anyParams) Param1() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 - return a.Recorder -} - -func (a *MoqUsual_DifficultParamNames_anyParams) Param2() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 - return a.Recorder -} - -func (a *MoqUsual_DifficultParamNames_anyParams) Param3() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 2 - return a.Recorder -} - -func (a *MoqUsual_DifficultParamNames_anyParams) Param() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 3 - return a.Recorder -} - -func (a *MoqUsual_DifficultParamNames_anyParams) Param5() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 4 - return a.Recorder -} - -func (a *MoqUsual_DifficultParamNames_anyParams) Param6() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 5 - return a.Recorder -} - -func (a *MoqUsual_DifficultParamNames_anyParams) Param7() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 6 - return a.Recorder -} - -func (a *MoqUsual_DifficultParamNames_anyParams) Param8() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 7 - return a.Recorder -} - -func (a *MoqUsual_DifficultParamNames_anyParams) Param9() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 8 - return a.Recorder -} - -func (r *MoqUsual_DifficultParamNames_fnRecorder) Seq() *MoqUsual_DifficultParamNames_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultParamNames(r.Params)) - return nil - } - r.Sequence = true - return r -} - -func (r *MoqUsual_DifficultParamNames_fnRecorder) NoSeq() *MoqUsual_DifficultParamNames_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultParamNames(r.Params)) - return nil - } - r.Sequence = false - return r -} - -func (r *MoqUsual_DifficultParamNames_fnRecorder) ReturnResults() *MoqUsual_DifficultParamNames_fnRecorder { - r.Moq.Scene.T.Helper() - r.FindResults() - - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() - } - - r.Results.Results = append(r.Results.Results, struct { - Values *struct{} - Sequence uint32 - DoFn MoqUsual_DifficultParamNames_doFn - DoReturnFn MoqUsual_DifficultParamNames_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) - return r -} - -func (r *MoqUsual_DifficultParamNames_fnRecorder) AndDo(fn MoqUsual_DifficultParamNames_doFn) *MoqUsual_DifficultParamNames_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") - return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn - return r } -func (r *MoqUsual_DifficultParamNames_fnRecorder) DoReturnResults(fn MoqUsual_DifficultParamNames_doReturnFn) *MoqUsual_DifficultParamNames_fnRecorder { - r.Moq.Scene.T.Helper() - r.FindResults() +// Reset resets the state of the moq +func (m *MoqGenericParams[S, B]) Reset() { m.ResultsByParams_Usual = nil } - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqGenericParams[S, B]) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams_Usual { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Usual(results.Params)) + } + } } - - r.Results.Results = append(r.Results.Results, struct { - Values *struct{} - Sequence uint32 - DoFn MoqUsual_DifficultParamNames_doFn - DoReturnFn MoqUsual_DifficultParamNames_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) - return r } -func (r *MoqUsual_DifficultParamNames_fnRecorder) FindResults() { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Results.Repeat.Increment(r.Moq.Scene.T) - return - } +// The following type assertion assures that testmoqs.PartialGenericParams is +// mocked completely +var _ testmoqs.PartialGenericParams[any] = (*MoqPartialGenericParams_mock[any])(nil) - anyCount := bits.OnesCount64(r.AnyParams) - insertAt := -1 - var results *MoqUsual_DifficultParamNames_resultsByParams - for n, res := range r.Moq.ResultsByParams_DifficultParamNames { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqUsual_DifficultParamNames_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_DifficultParamNames_paramsKey]*MoqUsual_DifficultParamNames_results{}, - } - r.Moq.ResultsByParams_DifficultParamNames = append(r.Moq.ResultsByParams_DifficultParamNames, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_DifficultParamNames) { - copy(r.Moq.ResultsByParams_DifficultParamNames[insertAt+1:], r.Moq.ResultsByParams_DifficultParamNames[insertAt:0]) - r.Moq.ResultsByParams_DifficultParamNames[insertAt] = *results - } - } +// MoqPartialGenericParams holds the state of a moq of the PartialGenericParams +// type +type MoqPartialGenericParams[S any] struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqPartialGenericParams_mock[S] - paramsKey := r.Moq.ParamsKey_DifficultParamNames(r.Params, r.AnyParams) + ResultsByParams_Usual []MoqPartialGenericParams_Usual_resultsByParams[S] - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_DifficultParamNames_results{ - Params: r.Params, - Results: nil, - Index: 0, - Repeat: &moq.RepeatVal{}, + Runtime struct { + ParameterIndexing struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } } - results.Results[paramsKey] = r.Results } + // MoqPartialGenericParams_mock isolates the mock interface of the +} - r.Results.Repeat.Increment(r.Moq.Scene.T) +// PartialGenericParams type +type MoqPartialGenericParams_mock[S any] struct { + Moq *MoqPartialGenericParams[S] } -func (r *MoqUsual_DifficultParamNames_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_DifficultParamNames_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") - return nil +// MoqPartialGenericParams_recorder isolates the recorder interface of the +// PartialGenericParams type +type MoqPartialGenericParams_recorder[S any] struct { + Moq *MoqPartialGenericParams[S] +} + +// MoqPartialGenericParams_Usual_params holds the params of the +// PartialGenericParams type +type MoqPartialGenericParams_Usual_params[S any] struct { + Param1 S + Param2 bool +} + +// MoqPartialGenericParams_Usual_paramsKey holds the map key params of the +// PartialGenericParams type +type MoqPartialGenericParams_Usual_paramsKey[S any] struct { + Params struct{ Param2 bool } + Hashes struct { + Param1 hash.Hash + Param2 hash.Hash } - r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) - last := r.Results.Results[len(r.Results.Results)-1] - for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { - if r.Sequence { - last = struct { - Values *struct{} - Sequence uint32 - DoFn MoqUsual_DifficultParamNames_doFn - DoReturnFn MoqUsual_DifficultParamNames_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } +} + +// MoqPartialGenericParams_Usual_resultsByParams contains the results for a +// given set of parameters for the PartialGenericParams type +type MoqPartialGenericParams_Usual_resultsByParams[S any] struct { + AnyCount int + AnyParams uint64 + Results map[MoqPartialGenericParams_Usual_paramsKey[S]]*MoqPartialGenericParams_Usual_results[S] +} + +// MoqPartialGenericParams_Usual_doFn defines the type of function needed when +// calling AndDo for the PartialGenericParams type +type MoqPartialGenericParams_Usual_doFn[S any] func(S, bool) + +// MoqPartialGenericParams_Usual_doReturnFn defines the type of function needed +// when calling DoReturnResults for the PartialGenericParams type +type MoqPartialGenericParams_Usual_doReturnFn[S any] func(S, bool) (string, error) + +// MoqPartialGenericParams_Usual_results holds the results of the +// PartialGenericParams type +type MoqPartialGenericParams_Usual_results[S any] struct { + Params MoqPartialGenericParams_Usual_params[S] + Results []struct { + Values *struct { + Result1 string + Result2 error } - r.Results.Results = append(r.Results.Results, last) + Sequence uint32 + DoFn MoqPartialGenericParams_Usual_doFn[S] + DoReturnFn MoqPartialGenericParams_Usual_doReturnFn[S] } - return r + Index uint32 + Repeat *moq.RepeatVal } -func (m *MoqUsual) PrettyParams_DifficultParamNames(params MoqUsual_DifficultParamNames_params) string { - return fmt.Sprintf("DifficultParamNames(%#v, %#v, %#v, %#v, %#v, %#v, %#v, %#v, %#v)", params.Param1, params.Param2, params.Param3, params.Param, params.Param5, params.Param6, params.Param7, params.Param8, params.Param9) +// MoqPartialGenericParams_Usual_fnRecorder routes recorded function calls to +// the MoqPartialGenericParams moq +type MoqPartialGenericParams_Usual_fnRecorder[S any] struct { + Params MoqPartialGenericParams_Usual_params[S] + AnyParams uint64 + Sequence bool + Results *MoqPartialGenericParams_Usual_results[S] + Moq *MoqPartialGenericParams[S] } -func (m *MoqUsual) ParamsKey_DifficultParamNames(params MoqUsual_DifficultParamNames_params, anyParams uint64) MoqUsual_DifficultParamNames_paramsKey { - m.Scene.T.Helper() - var param1Used bool - var param1UsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.DifficultParamNames.Param1 == moq.ParamIndexByValue { - param1Used = params.Param1 - } else { - param1UsedHash = hash.DeepHash(params.Param1) - } +// MoqPartialGenericParams_Usual_anyParams isolates the any params functions of +// the PartialGenericParams type +type MoqPartialGenericParams_Usual_anyParams[S any] struct { + Recorder *MoqPartialGenericParams_Usual_fnRecorder[S] +} + +// NewMoqPartialGenericParams creates a new moq of the PartialGenericParams +// type +func NewMoqPartialGenericParams[S any](scene *moq.Scene, config *moq.Config) *MoqPartialGenericParams[S] { + if config == nil { + config = &moq.Config{} } - var param2Used bool - var param2UsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.Runtime.ParameterIndexing.DifficultParamNames.Param2 == moq.ParamIndexByValue { - param2Used = params.Param2 - } else { - param2UsedHash = hash.DeepHash(params.Param2) - } + m := &MoqPartialGenericParams[S]{ + Scene: scene, + Config: *config, + Moq: &MoqPartialGenericParams_mock[S]{}, + + Runtime: struct { + ParameterIndexing struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + } + }{ParameterIndexing: struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + }{ + Usual: struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + }{ + Param1: moq.ParamIndexByHash, + Param2: moq.ParamIndexByValue, + }, + }}, } - var param3Used string - var param3UsedHash hash.Hash - if anyParams&(1<<2) == 0 { - if m.Runtime.ParameterIndexing.DifficultParamNames.Param3 == moq.ParamIndexByValue { - param3Used = params.Param3 - } else { - param3UsedHash = hash.DeepHash(params.Param3) - } + m.Moq.Moq = m + + scene.AddMoq(m) + return m +} + +// Mock returns the mock implementation of the PartialGenericParams type +func (m *MoqPartialGenericParams[S]) Mock() *MoqPartialGenericParams_mock[S] { return m.Moq } + +func (m *MoqPartialGenericParams_mock[S]) Usual(param1 S, param2 bool) (result1 string, result2 error) { + m.Moq.Scene.T.Helper() + params := MoqPartialGenericParams_Usual_params[S]{ + Param1: param1, + Param2: param2, } - var paramUsed int - var paramUsedHash hash.Hash - if anyParams&(1<<3) == 0 { - if m.Runtime.ParameterIndexing.DifficultParamNames.Param == moq.ParamIndexByValue { - paramUsed = params.Param - } else { - paramUsedHash = hash.DeepHash(params.Param) + var results *MoqPartialGenericParams_Usual_results[S] + for _, resultsByParams := range m.Moq.ResultsByParams_Usual { + paramsKey := m.Moq.ParamsKey_Usual(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break } } - var param5Used int - var param5UsedHash hash.Hash - if anyParams&(1<<4) == 0 { - if m.Runtime.ParameterIndexing.DifficultParamNames.Param5 == moq.ParamIndexByValue { - param5Used = params.Param5 - } else { - param5UsedHash = hash.DeepHash(params.Param5) + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Usual(params)) } + return } - var param6Used int - var param6UsedHash hash.Hash - if anyParams&(1<<5) == 0 { - if m.Runtime.ParameterIndexing.DifficultParamNames.Param6 == moq.ParamIndexByValue { - param6Used = params.Param6 - } else { - param6UsedHash = hash.DeepHash(params.Param6) + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Usual(params)) + } + return } + i = results.Repeat.ResultCount - 1 } - var param7Used float32 - var param7UsedHash hash.Hash - if anyParams&(1<<6) == 0 { - if m.Runtime.ParameterIndexing.DifficultParamNames.Param7 == moq.ParamIndexByValue { - param7Used = params.Param7 - } else { - param7UsedHash = hash.DeepHash(params.Param7) + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Usual(params)) } } - var param8Used float32 - var param8UsedHash hash.Hash - if anyParams&(1<<7) == 0 { - if m.Runtime.ParameterIndexing.DifficultParamNames.Param8 == moq.ParamIndexByValue { - param8Used = params.Param8 - } else { - param8UsedHash = hash.DeepHash(params.Param8) - } + + if result.DoFn != nil { + result.DoFn(param1, param2) } - var param9Used float32 - var param9UsedHash hash.Hash - if anyParams&(1<<8) == 0 { - if m.Runtime.ParameterIndexing.DifficultParamNames.Param9 == moq.ParamIndexByValue { - param9Used = params.Param9 - } else { - param9UsedHash = hash.DeepHash(params.Param9) - } + + if result.Values != nil { + result1 = result.Values.Result1 + result2 = result.Values.Result2 } - return MoqUsual_DifficultParamNames_paramsKey{ - Params: struct { - Param1, Param2 bool - Param3 string - Param, Param5, Param6 int - Param7, Param8, Param9 float32 - }{ - Param1: param1Used, - Param2: param2Used, - Param3: param3Used, - Param: paramUsed, - Param5: param5Used, - Param6: param6Used, - Param7: param7Used, - Param8: param8Used, - Param9: param9Used, - }, - Hashes: struct { - Param1, Param2 hash.Hash - Param3 hash.Hash - Param, Param5, Param6 hash.Hash - Param7, Param8, Param9 hash.Hash - }{ - Param1: param1UsedHash, - Param2: param2UsedHash, - Param3: param3UsedHash, - Param: paramUsedHash, - Param5: param5UsedHash, - Param6: param6UsedHash, - Param7: param7UsedHash, - Param8: param8UsedHash, - Param9: param9UsedHash, - }, + if result.DoReturnFn != nil { + result1, result2 = result.DoReturnFn(param1, param2) } + return } -func (m *MoqUsual_recorder) DifficultResultNames() *MoqUsual_DifficultResultNames_fnRecorder { - return &MoqUsual_DifficultResultNames_fnRecorder{ - Params: MoqUsual_DifficultResultNames_params{}, +// OnCall returns the recorder implementation of the PartialGenericParams type +func (m *MoqPartialGenericParams[S]) OnCall() *MoqPartialGenericParams_recorder[S] { + return &MoqPartialGenericParams_recorder[S]{ + Moq: m, + } +} + +func (m *MoqPartialGenericParams_recorder[S]) Usual(param1 S, param2 bool) *MoqPartialGenericParams_Usual_fnRecorder[S] { + return &MoqPartialGenericParams_Usual_fnRecorder[S]{ + Params: MoqPartialGenericParams_Usual_params[S]{ + Param1: param1, + Param2: param2, + }, Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, Moq: m.Moq, } } -func (r *MoqUsual_DifficultResultNames_fnRecorder) Any() *MoqUsual_DifficultResultNames_anyParams { +func (r *MoqPartialGenericParams_Usual_fnRecorder[S]) Any() *MoqPartialGenericParams_Usual_anyParams[S] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultResultNames(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } - return &MoqUsual_DifficultResultNames_anyParams{Recorder: r} + return &MoqPartialGenericParams_Usual_anyParams[S]{Recorder: r} +} + +func (a *MoqPartialGenericParams_Usual_anyParams[S]) Param1() *MoqPartialGenericParams_Usual_fnRecorder[S] { + a.Recorder.AnyParams |= 1 << 0 + return a.Recorder } -func (r *MoqUsual_DifficultResultNames_fnRecorder) Seq() *MoqUsual_DifficultResultNames_fnRecorder { +func (a *MoqPartialGenericParams_Usual_anyParams[S]) Param2() *MoqPartialGenericParams_Usual_fnRecorder[S] { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (r *MoqPartialGenericParams_Usual_fnRecorder[S]) Seq() *MoqPartialGenericParams_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultResultNames(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_DifficultResultNames_fnRecorder) NoSeq() *MoqUsual_DifficultResultNames_fnRecorder { +func (r *MoqPartialGenericParams_Usual_fnRecorder[S]) NoSeq() *MoqPartialGenericParams_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DifficultResultNames(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_DifficultResultNames_fnRecorder) ReturnResults(result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) *MoqUsual_DifficultResultNames_fnRecorder { +func (r *MoqPartialGenericParams_Usual_fnRecorder[S]) ReturnResults(result1 string, result2 error) *MoqPartialGenericParams_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() r.FindResults() @@ -9494,37 +13822,26 @@ func (r *MoqUsual_DifficultResultNames_fnRecorder) ReturnResults(result1, result r.Results.Results = append(r.Results.Results, struct { Values *struct { - Result1, Result2 string - Result3 error - Param, Result5, Result6 int - Result7, Result8, Result9 float32 + Result1 string + Result2 error } Sequence uint32 - DoFn MoqUsual_DifficultResultNames_doFn - DoReturnFn MoqUsual_DifficultResultNames_doReturnFn + DoFn MoqPartialGenericParams_Usual_doFn[S] + DoReturnFn MoqPartialGenericParams_Usual_doReturnFn[S] }{ Values: &struct { - Result1, Result2 string - Result3 error - Param, Result5, Result6 int - Result7, Result8, Result9 float32 + Result1 string + Result2 error }{ Result1: result1, Result2: result2, - Result3: result3, - Param: param, - Result5: result5, - Result6: result6, - Result7: result7, - Result8: result8, - Result9: result9, }, Sequence: sequence, }) return r } -func (r *MoqUsual_DifficultResultNames_fnRecorder) AndDo(fn MoqUsual_DifficultResultNames_doFn) *MoqUsual_DifficultResultNames_fnRecorder { +func (r *MoqPartialGenericParams_Usual_fnRecorder[S]) AndDo(fn MoqPartialGenericParams_Usual_doFn[S]) *MoqPartialGenericParams_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -9535,7 +13852,7 @@ func (r *MoqUsual_DifficultResultNames_fnRecorder) AndDo(fn MoqUsual_DifficultRe return r } -func (r *MoqUsual_DifficultResultNames_fnRecorder) DoReturnResults(fn MoqUsual_DifficultResultNames_doReturnFn) *MoqUsual_DifficultResultNames_fnRecorder { +func (r *MoqPartialGenericParams_Usual_fnRecorder[S]) DoReturnResults(fn MoqPartialGenericParams_Usual_doReturnFn[S]) *MoqPartialGenericParams_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() r.FindResults() @@ -9546,19 +13863,17 @@ func (r *MoqUsual_DifficultResultNames_fnRecorder) DoReturnResults(fn MoqUsual_D r.Results.Results = append(r.Results.Results, struct { Values *struct { - Result1, Result2 string - Result3 error - Param, Result5, Result6 int - Result7, Result8, Result9 float32 + Result1 string + Result2 error } Sequence uint32 - DoFn MoqUsual_DifficultResultNames_doFn - DoReturnFn MoqUsual_DifficultResultNames_doReturnFn + DoFn MoqPartialGenericParams_Usual_doFn[S] + DoReturnFn MoqPartialGenericParams_Usual_doReturnFn[S] }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_DifficultResultNames_fnRecorder) FindResults() { +func (r *MoqPartialGenericParams_Usual_fnRecorder[S]) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -9567,8 +13882,8 @@ func (r *MoqUsual_DifficultResultNames_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_DifficultResultNames_resultsByParams - for n, res := range r.Moq.ResultsByParams_DifficultResultNames { + var results *MoqPartialGenericParams_Usual_resultsByParams[S] + for n, res := range r.Moq.ResultsByParams_Usual { if res.AnyParams == r.AnyParams { results = &res break @@ -9578,24 +13893,24 @@ func (r *MoqUsual_DifficultResultNames_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_DifficultResultNames_resultsByParams{ + results = &MoqPartialGenericParams_Usual_resultsByParams[S]{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_DifficultResultNames_paramsKey]*MoqUsual_DifficultResultNames_results{}, + Results: map[MoqPartialGenericParams_Usual_paramsKey[S]]*MoqPartialGenericParams_Usual_results[S]{}, } - r.Moq.ResultsByParams_DifficultResultNames = append(r.Moq.ResultsByParams_DifficultResultNames, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_DifficultResultNames) { - copy(r.Moq.ResultsByParams_DifficultResultNames[insertAt+1:], r.Moq.ResultsByParams_DifficultResultNames[insertAt:0]) - r.Moq.ResultsByParams_DifficultResultNames[insertAt] = *results + r.Moq.ResultsByParams_Usual = append(r.Moq.ResultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Usual) { + copy(r.Moq.ResultsByParams_Usual[insertAt+1:], r.Moq.ResultsByParams_Usual[insertAt:0]) + r.Moq.ResultsByParams_Usual[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_DifficultResultNames(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey_Usual(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_DifficultResultNames_results{ + r.Results = &MoqPartialGenericParams_Usual_results[S]{ Params: r.Params, Results: nil, Index: 0, @@ -9607,7 +13922,7 @@ func (r *MoqUsual_DifficultResultNames_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_DifficultResultNames_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_DifficultResultNames_fnRecorder { +func (r *MoqPartialGenericParams_Usual_fnRecorder[S]) Repeat(repeaters ...moq.Repeater) *MoqPartialGenericParams_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -9619,14 +13934,12 @@ func (r *MoqUsual_DifficultResultNames_fnRecorder) Repeat(repeaters ...moq.Repea if r.Sequence { last = struct { Values *struct { - Result1, Result2 string - Result3 error - Param, Result5, Result6 int - Result7, Result8, Result9 float32 + Result1 string + Result2 error } Sequence uint32 - DoFn MoqUsual_DifficultResultNames_doFn - DoReturnFn MoqUsual_DifficultResultNames_doReturnFn + DoFn MoqPartialGenericParams_Usual_doFn[S] + DoReturnFn MoqPartialGenericParams_Usual_doReturnFn[S] }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -9637,63 +13950,313 @@ func (r *MoqUsual_DifficultResultNames_fnRecorder) Repeat(repeaters ...moq.Repea return r } -func (m *MoqUsual) PrettyParams_DifficultResultNames(params MoqUsual_DifficultResultNames_params) string { - return fmt.Sprintf("DifficultResultNames()") +func (m *MoqPartialGenericParams[S]) PrettyParams_Usual(params MoqPartialGenericParams_Usual_params[S]) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.Param1, params.Param2) } -func (m *MoqUsual) ParamsKey_DifficultResultNames(params MoqUsual_DifficultResultNames_params, anyParams uint64) MoqUsual_DifficultResultNames_paramsKey { +func (m *MoqPartialGenericParams[S]) ParamsKey_Usual(params MoqPartialGenericParams_Usual_params[S], anyParams uint64) MoqPartialGenericParams_Usual_paramsKey[S] { m.Scene.T.Helper() - return MoqUsual_DifficultResultNames_paramsKey{ - Params: struct{}{}, - Hashes: struct{}{}, + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.Usual.Param1 == moq.ParamIndexByValue { + m.Scene.T.Fatalf("The param1 parameter of the Usual function can't be indexed by value") + } + param1UsedHash = hash.DeepHash(params.Param1) + } + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.Usual.Param2 == moq.ParamIndexByValue { + param2Used = params.Param2 + } else { + param2UsedHash = hash.DeepHash(params.Param2) + } + } + return MoqPartialGenericParams_Usual_paramsKey[S]{ + Params: struct{ Param2 bool }{ + Param2: param2Used, + }, + Hashes: struct { + Param1 hash.Hash + Param2 hash.Hash + }{ + Param1: param1UsedHash, + Param2: param2UsedHash, + }, + } +} + +// Reset resets the state of the moq +func (m *MoqPartialGenericParams[S]) Reset() { m.ResultsByParams_Usual = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqPartialGenericParams[S]) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams_Usual { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Usual(results.Params)) + } + } + } +} + +// The following type assertion assures that testmoqs.GenericResults is mocked +// completely +var _ testmoqs.GenericResults[string, error] = (*MoqGenericResults_mock[string, error])(nil) + +// MoqGenericResults holds the state of a moq of the GenericResults type +type MoqGenericResults[S ~string, E error] struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqGenericResults_mock[S, E] + + ResultsByParams_Usual []MoqGenericResults_Usual_resultsByParams[S, E] + + Runtime struct { + ParameterIndexing struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + } + } + // MoqGenericResults_mock isolates the mock interface of the GenericResults +} + +// type +type MoqGenericResults_mock[S ~string, E error] struct { + Moq *MoqGenericResults[S, E] +} + +// MoqGenericResults_recorder isolates the recorder interface of the +// GenericResults type +type MoqGenericResults_recorder[S ~string, E error] struct { + Moq *MoqGenericResults[S, E] +} + +// MoqGenericResults_Usual_params holds the params of the GenericResults type +type MoqGenericResults_Usual_params[S ~string, E error] struct { + Param1 string + Param2 bool +} + +// MoqGenericResults_Usual_paramsKey holds the map key params of the +// GenericResults type +type MoqGenericResults_Usual_paramsKey[S ~string, E error] struct { + Params struct { + Param1 string + Param2 bool + } + Hashes struct { + Param1 hash.Hash + Param2 hash.Hash + } +} + +// MoqGenericResults_Usual_resultsByParams contains the results for a given set +// of parameters for the GenericResults type +type MoqGenericResults_Usual_resultsByParams[S ~string, E error] struct { + AnyCount int + AnyParams uint64 + Results map[MoqGenericResults_Usual_paramsKey[S, E]]*MoqGenericResults_Usual_results[S, E] +} + +// MoqGenericResults_Usual_doFn defines the type of function needed when +// calling AndDo for the GenericResults type +type MoqGenericResults_Usual_doFn[S ~string, E error] func(string, bool) + +// MoqGenericResults_Usual_doReturnFn defines the type of function needed when +// calling DoReturnResults for the GenericResults type +type MoqGenericResults_Usual_doReturnFn[S ~string, E error] func(string, bool) (S, E) + +// MoqGenericResults_Usual_results holds the results of the GenericResults type +type MoqGenericResults_Usual_results[S ~string, E error] struct { + Params MoqGenericResults_Usual_params[S, E] + Results []struct { + Values *struct { + Result1 S + Result2 E + } + Sequence uint32 + DoFn MoqGenericResults_Usual_doFn[S, E] + DoReturnFn MoqGenericResults_Usual_doReturnFn[S, E] + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqGenericResults_Usual_fnRecorder routes recorded function calls to the +// MoqGenericResults moq +type MoqGenericResults_Usual_fnRecorder[S ~string, E error] struct { + Params MoqGenericResults_Usual_params[S, E] + AnyParams uint64 + Sequence bool + Results *MoqGenericResults_Usual_results[S, E] + Moq *MoqGenericResults[S, E] +} + +// MoqGenericResults_Usual_anyParams isolates the any params functions of the +// GenericResults type +type MoqGenericResults_Usual_anyParams[S ~string, E error] struct { + Recorder *MoqGenericResults_Usual_fnRecorder[S, E] +} + +// NewMoqGenericResults creates a new moq of the GenericResults type +func NewMoqGenericResults[S ~string, E error](scene *moq.Scene, config *moq.Config) *MoqGenericResults[S, E] { + if config == nil { + config = &moq.Config{} + } + m := &MoqGenericResults[S, E]{ + Scene: scene, + Config: *config, + Moq: &MoqGenericResults_mock[S, E]{}, + + Runtime: struct { + ParameterIndexing struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + } + }{ParameterIndexing: struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + }{ + Usual: struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + }{ + Param1: moq.ParamIndexByValue, + Param2: moq.ParamIndexByValue, + }, + }}, + } + m.Moq.Moq = m + + scene.AddMoq(m) + return m +} + +// Mock returns the mock implementation of the GenericResults type +func (m *MoqGenericResults[S, E]) Mock() *MoqGenericResults_mock[S, E] { return m.Moq } + +func (m *MoqGenericResults_mock[S, E]) Usual(param1 string, param2 bool) (result1 S, result2 E) { + m.Moq.Scene.T.Helper() + params := MoqGenericResults_Usual_params[S, E]{ + Param1: param1, + Param2: param2, + } + var results *MoqGenericResults_Usual_results[S, E] + for _, resultsByParams := range m.Moq.ResultsByParams_Usual { + paramsKey := m.Moq.ParamsKey_Usual(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Usual(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Usual(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Usual(params)) + } + } + + if result.DoFn != nil { + result.DoFn(param1, param2) + } + + if result.Values != nil { + result1 = result.Values.Result1 + result2 = result.Values.Result2 + } + if result.DoReturnFn != nil { + result1, result2 = result.DoReturnFn(param1, param2) + } + return +} + +// OnCall returns the recorder implementation of the GenericResults type +func (m *MoqGenericResults[S, E]) OnCall() *MoqGenericResults_recorder[S, E] { + return &MoqGenericResults_recorder[S, E]{ + Moq: m, } } -func (m *MoqUsual_recorder) PassByReference(p *testmoqs.PassByReferenceParams) *MoqUsual_PassByReference_fnRecorder { - return &MoqUsual_PassByReference_fnRecorder{ - Params: MoqUsual_PassByReference_params{ - P: p, +func (m *MoqGenericResults_recorder[S, E]) Usual(param1 string, param2 bool) *MoqGenericResults_Usual_fnRecorder[S, E] { + return &MoqGenericResults_Usual_fnRecorder[S, E]{ + Params: MoqGenericResults_Usual_params[S, E]{ + Param1: param1, + Param2: param2, }, Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, Moq: m.Moq, } } -func (r *MoqUsual_PassByReference_fnRecorder) Any() *MoqUsual_PassByReference_anyParams { +func (r *MoqGenericResults_Usual_fnRecorder[S, E]) Any() *MoqGenericResults_Usual_anyParams[S, E] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_PassByReference(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } - return &MoqUsual_PassByReference_anyParams{Recorder: r} + return &MoqGenericResults_Usual_anyParams[S, E]{Recorder: r} } -func (a *MoqUsual_PassByReference_anyParams) P() *MoqUsual_PassByReference_fnRecorder { +func (a *MoqGenericResults_Usual_anyParams[S, E]) Param1() *MoqGenericResults_Usual_fnRecorder[S, E] { a.Recorder.AnyParams |= 1 << 0 return a.Recorder } -func (r *MoqUsual_PassByReference_fnRecorder) Seq() *MoqUsual_PassByReference_fnRecorder { +func (a *MoqGenericResults_Usual_anyParams[S, E]) Param2() *MoqGenericResults_Usual_fnRecorder[S, E] { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (r *MoqGenericResults_Usual_fnRecorder[S, E]) Seq() *MoqGenericResults_Usual_fnRecorder[S, E] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_PassByReference(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_PassByReference_fnRecorder) NoSeq() *MoqUsual_PassByReference_fnRecorder { +func (r *MoqGenericResults_Usual_fnRecorder[S, E]) NoSeq() *MoqGenericResults_Usual_fnRecorder[S, E] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_PassByReference(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_PassByReference_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_PassByReference_fnRecorder { +func (r *MoqGenericResults_Usual_fnRecorder[S, E]) ReturnResults(result1 S, result2 E) *MoqGenericResults_Usual_fnRecorder[S, E] { r.Moq.Scene.T.Helper() r.FindResults() @@ -9704,26 +14267,26 @@ func (r *MoqUsual_PassByReference_fnRecorder) ReturnResults(sResult string, err r.Results.Results = append(r.Results.Results, struct { Values *struct { - SResult string - Err error + Result1 S + Result2 E } Sequence uint32 - DoFn MoqUsual_PassByReference_doFn - DoReturnFn MoqUsual_PassByReference_doReturnFn + DoFn MoqGenericResults_Usual_doFn[S, E] + DoReturnFn MoqGenericResults_Usual_doReturnFn[S, E] }{ Values: &struct { - SResult string - Err error + Result1 S + Result2 E }{ - SResult: sResult, - Err: err, + Result1: result1, + Result2: result2, }, Sequence: sequence, }) return r } -func (r *MoqUsual_PassByReference_fnRecorder) AndDo(fn MoqUsual_PassByReference_doFn) *MoqUsual_PassByReference_fnRecorder { +func (r *MoqGenericResults_Usual_fnRecorder[S, E]) AndDo(fn MoqGenericResults_Usual_doFn[S, E]) *MoqGenericResults_Usual_fnRecorder[S, E] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -9734,7 +14297,7 @@ func (r *MoqUsual_PassByReference_fnRecorder) AndDo(fn MoqUsual_PassByReference_ return r } -func (r *MoqUsual_PassByReference_fnRecorder) DoReturnResults(fn MoqUsual_PassByReference_doReturnFn) *MoqUsual_PassByReference_fnRecorder { +func (r *MoqGenericResults_Usual_fnRecorder[S, E]) DoReturnResults(fn MoqGenericResults_Usual_doReturnFn[S, E]) *MoqGenericResults_Usual_fnRecorder[S, E] { r.Moq.Scene.T.Helper() r.FindResults() @@ -9745,17 +14308,17 @@ func (r *MoqUsual_PassByReference_fnRecorder) DoReturnResults(fn MoqUsual_PassBy r.Results.Results = append(r.Results.Results, struct { Values *struct { - SResult string - Err error + Result1 S + Result2 E } Sequence uint32 - DoFn MoqUsual_PassByReference_doFn - DoReturnFn MoqUsual_PassByReference_doReturnFn + DoFn MoqGenericResults_Usual_doFn[S, E] + DoReturnFn MoqGenericResults_Usual_doReturnFn[S, E] }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_PassByReference_fnRecorder) FindResults() { +func (r *MoqGenericResults_Usual_fnRecorder[S, E]) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -9764,8 +14327,8 @@ func (r *MoqUsual_PassByReference_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_PassByReference_resultsByParams - for n, res := range r.Moq.ResultsByParams_PassByReference { + var results *MoqGenericResults_Usual_resultsByParams[S, E] + for n, res := range r.Moq.ResultsByParams_Usual { if res.AnyParams == r.AnyParams { results = &res break @@ -9775,24 +14338,24 @@ func (r *MoqUsual_PassByReference_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_PassByReference_resultsByParams{ + results = &MoqGenericResults_Usual_resultsByParams[S, E]{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_PassByReference_paramsKey]*MoqUsual_PassByReference_results{}, + Results: map[MoqGenericResults_Usual_paramsKey[S, E]]*MoqGenericResults_Usual_results[S, E]{}, } - r.Moq.ResultsByParams_PassByReference = append(r.Moq.ResultsByParams_PassByReference, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_PassByReference) { - copy(r.Moq.ResultsByParams_PassByReference[insertAt+1:], r.Moq.ResultsByParams_PassByReference[insertAt:0]) - r.Moq.ResultsByParams_PassByReference[insertAt] = *results + r.Moq.ResultsByParams_Usual = append(r.Moq.ResultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Usual) { + copy(r.Moq.ResultsByParams_Usual[insertAt+1:], r.Moq.ResultsByParams_Usual[insertAt:0]) + r.Moq.ResultsByParams_Usual[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_PassByReference(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey_Usual(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_PassByReference_results{ + r.Results = &MoqGenericResults_Usual_results[S, E]{ Params: r.Params, Results: nil, Index: 0, @@ -9804,7 +14367,7 @@ func (r *MoqUsual_PassByReference_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_PassByReference_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByReference_fnRecorder { +func (r *MoqGenericResults_Usual_fnRecorder[S, E]) Repeat(repeaters ...moq.Repeater) *MoqGenericResults_Usual_fnRecorder[S, E] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -9816,12 +14379,12 @@ func (r *MoqUsual_PassByReference_fnRecorder) Repeat(repeaters ...moq.Repeater) if r.Sequence { last = struct { Values *struct { - SResult string - Err error + Result1 S + Result2 E } Sequence uint32 - DoFn MoqUsual_PassByReference_doFn - DoReturnFn MoqUsual_PassByReference_doReturnFn + DoFn MoqGenericResults_Usual_doFn[S, E] + DoReturnFn MoqGenericResults_Usual_doReturnFn[S, E] }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -9832,78 +14395,323 @@ func (r *MoqUsual_PassByReference_fnRecorder) Repeat(repeaters ...moq.Repeater) return r } -func (m *MoqUsual) PrettyParams_PassByReference(params MoqUsual_PassByReference_params) string { - return fmt.Sprintf("PassByReference(%#v)", params.P) +func (m *MoqGenericResults[S, E]) PrettyParams_Usual(params MoqGenericResults_Usual_params[S, E]) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.Param1, params.Param2) +} + +func (m *MoqGenericResults[S, E]) ParamsKey_Usual(params MoqGenericResults_Usual_params[S, E], anyParams uint64) MoqGenericResults_Usual_paramsKey[S, E] { + m.Scene.T.Helper() + var param1Used string + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.Usual.Param1 == moq.ParamIndexByValue { + param1Used = params.Param1 + } else { + param1UsedHash = hash.DeepHash(params.Param1) + } + } + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.Usual.Param2 == moq.ParamIndexByValue { + param2Used = params.Param2 + } else { + param2UsedHash = hash.DeepHash(params.Param2) + } + } + return MoqGenericResults_Usual_paramsKey[S, E]{ + Params: struct { + Param1 string + Param2 bool + }{ + Param1: param1Used, + Param2: param2Used, + }, + Hashes: struct { + Param1 hash.Hash + Param2 hash.Hash + }{ + Param1: param1UsedHash, + Param2: param2UsedHash, + }, + } +} + +// Reset resets the state of the moq +func (m *MoqGenericResults[S, E]) Reset() { m.ResultsByParams_Usual = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqGenericResults[S, E]) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams_Usual { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Usual(results.Params)) + } + } + } +} + +// The following type assertion assures that testmoqs.PartialGenericResults is +// mocked completely +var _ testmoqs.PartialGenericResults[string] = (*MoqPartialGenericResults_mock[string])(nil) + +// MoqPartialGenericResults holds the state of a moq of the +// PartialGenericResults type +type MoqPartialGenericResults[S ~string] struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqPartialGenericResults_mock[S] + + ResultsByParams_Usual []MoqPartialGenericResults_Usual_resultsByParams[S] + + Runtime struct { + ParameterIndexing struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + } + } + // MoqPartialGenericResults_mock isolates the mock interface of the +} + +// PartialGenericResults type +type MoqPartialGenericResults_mock[S ~string] struct { + Moq *MoqPartialGenericResults[S] +} + +// MoqPartialGenericResults_recorder isolates the recorder interface of the +// PartialGenericResults type +type MoqPartialGenericResults_recorder[S ~string] struct { + Moq *MoqPartialGenericResults[S] +} + +// MoqPartialGenericResults_Usual_params holds the params of the +// PartialGenericResults type +type MoqPartialGenericResults_Usual_params[S ~string] struct { + Param1 string + Param2 bool +} + +// MoqPartialGenericResults_Usual_paramsKey holds the map key params of the +// PartialGenericResults type +type MoqPartialGenericResults_Usual_paramsKey[S ~string] struct { + Params struct { + Param1 string + Param2 bool + } + Hashes struct { + Param1 hash.Hash + Param2 hash.Hash + } +} + +// MoqPartialGenericResults_Usual_resultsByParams contains the results for a +// given set of parameters for the PartialGenericResults type +type MoqPartialGenericResults_Usual_resultsByParams[S ~string] struct { + AnyCount int + AnyParams uint64 + Results map[MoqPartialGenericResults_Usual_paramsKey[S]]*MoqPartialGenericResults_Usual_results[S] +} + +// MoqPartialGenericResults_Usual_doFn defines the type of function needed when +// calling AndDo for the PartialGenericResults type +type MoqPartialGenericResults_Usual_doFn[S ~string] func(string, bool) + +// MoqPartialGenericResults_Usual_doReturnFn defines the type of function +// needed when calling DoReturnResults for the PartialGenericResults type +type MoqPartialGenericResults_Usual_doReturnFn[S ~string] func(string, bool) (S, error) + +// MoqPartialGenericResults_Usual_results holds the results of the +// PartialGenericResults type +type MoqPartialGenericResults_Usual_results[S ~string] struct { + Params MoqPartialGenericResults_Usual_params[S] + Results []struct { + Values *struct { + Result1 S + Result2 error + } + Sequence uint32 + DoFn MoqPartialGenericResults_Usual_doFn[S] + DoReturnFn MoqPartialGenericResults_Usual_doReturnFn[S] + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqPartialGenericResults_Usual_fnRecorder routes recorded function calls to +// the MoqPartialGenericResults moq +type MoqPartialGenericResults_Usual_fnRecorder[S ~string] struct { + Params MoqPartialGenericResults_Usual_params[S] + AnyParams uint64 + Sequence bool + Results *MoqPartialGenericResults_Usual_results[S] + Moq *MoqPartialGenericResults[S] +} + +// MoqPartialGenericResults_Usual_anyParams isolates the any params functions +// of the PartialGenericResults type +type MoqPartialGenericResults_Usual_anyParams[S ~string] struct { + Recorder *MoqPartialGenericResults_Usual_fnRecorder[S] +} + +// NewMoqPartialGenericResults creates a new moq of the PartialGenericResults +// type +func NewMoqPartialGenericResults[S ~string](scene *moq.Scene, config *moq.Config) *MoqPartialGenericResults[S] { + if config == nil { + config = &moq.Config{} + } + m := &MoqPartialGenericResults[S]{ + Scene: scene, + Config: *config, + Moq: &MoqPartialGenericResults_mock[S]{}, + + Runtime: struct { + ParameterIndexing struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + } + }{ParameterIndexing: struct { + Usual struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + } + }{ + Usual: struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing + }{ + Param1: moq.ParamIndexByValue, + Param2: moq.ParamIndexByValue, + }, + }}, + } + m.Moq.Moq = m + + scene.AddMoq(m) + return m +} + +// Mock returns the mock implementation of the PartialGenericResults type +func (m *MoqPartialGenericResults[S]) Mock() *MoqPartialGenericResults_mock[S] { return m.Moq } + +func (m *MoqPartialGenericResults_mock[S]) Usual(param1 string, param2 bool) (result1 S, result2 error) { + m.Moq.Scene.T.Helper() + params := MoqPartialGenericResults_Usual_params[S]{ + Param1: param1, + Param2: param2, + } + var results *MoqPartialGenericResults_Usual_results[S] + for _, resultsByParams := range m.Moq.ResultsByParams_Usual { + paramsKey := m.Moq.ParamsKey_Usual(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Usual(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Usual(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Usual(params)) + } + } + + if result.DoFn != nil { + result.DoFn(param1, param2) + } + + if result.Values != nil { + result1 = result.Values.Result1 + result2 = result.Values.Result2 + } + if result.DoReturnFn != nil { + result1, result2 = result.DoReturnFn(param1, param2) + } + return } -func (m *MoqUsual) ParamsKey_PassByReference(params MoqUsual_PassByReference_params, anyParams uint64) MoqUsual_PassByReference_paramsKey { - m.Scene.T.Helper() - var pUsed *testmoqs.PassByReferenceParams - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.PassByReference.P == moq.ParamIndexByValue { - pUsed = params.P - } else { - pUsedHash = hash.DeepHash(params.P) - } - } - return MoqUsual_PassByReference_paramsKey{ - Params: struct { - P *testmoqs.PassByReferenceParams - }{ - P: pUsed, - }, - Hashes: struct{ P hash.Hash }{ - P: pUsedHash, - }, +// OnCall returns the recorder implementation of the PartialGenericResults type +func (m *MoqPartialGenericResults[S]) OnCall() *MoqPartialGenericResults_recorder[S] { + return &MoqPartialGenericResults_recorder[S]{ + Moq: m, } } -func (m *MoqUsual_recorder) InterfaceParam(w io.Writer) *MoqUsual_InterfaceParam_fnRecorder { - return &MoqUsual_InterfaceParam_fnRecorder{ - Params: MoqUsual_InterfaceParam_params{ - W: w, +func (m *MoqPartialGenericResults_recorder[S]) Usual(param1 string, param2 bool) *MoqPartialGenericResults_Usual_fnRecorder[S] { + return &MoqPartialGenericResults_Usual_fnRecorder[S]{ + Params: MoqPartialGenericResults_Usual_params[S]{ + Param1: param1, + Param2: param2, }, Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, Moq: m.Moq, } } -func (r *MoqUsual_InterfaceParam_fnRecorder) Any() *MoqUsual_InterfaceParam_anyParams { +func (r *MoqPartialGenericResults_Usual_fnRecorder[S]) Any() *MoqPartialGenericResults_Usual_anyParams[S] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceParam(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } - return &MoqUsual_InterfaceParam_anyParams{Recorder: r} + return &MoqPartialGenericResults_Usual_anyParams[S]{Recorder: r} } -func (a *MoqUsual_InterfaceParam_anyParams) W() *MoqUsual_InterfaceParam_fnRecorder { +func (a *MoqPartialGenericResults_Usual_anyParams[S]) Param1() *MoqPartialGenericResults_Usual_fnRecorder[S] { a.Recorder.AnyParams |= 1 << 0 return a.Recorder } -func (r *MoqUsual_InterfaceParam_fnRecorder) Seq() *MoqUsual_InterfaceParam_fnRecorder { +func (a *MoqPartialGenericResults_Usual_anyParams[S]) Param2() *MoqPartialGenericResults_Usual_fnRecorder[S] { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (r *MoqPartialGenericResults_Usual_fnRecorder[S]) Seq() *MoqPartialGenericResults_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceParam(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_InterfaceParam_fnRecorder) NoSeq() *MoqUsual_InterfaceParam_fnRecorder { +func (r *MoqPartialGenericResults_Usual_fnRecorder[S]) NoSeq() *MoqPartialGenericResults_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceParam(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_InterfaceParam_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_InterfaceParam_fnRecorder { +func (r *MoqPartialGenericResults_Usual_fnRecorder[S]) ReturnResults(result1 S, result2 error) *MoqPartialGenericResults_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() r.FindResults() @@ -9914,26 +14722,26 @@ func (r *MoqUsual_InterfaceParam_fnRecorder) ReturnResults(sResult string, err e r.Results.Results = append(r.Results.Results, struct { Values *struct { - SResult string - Err error + Result1 S + Result2 error } Sequence uint32 - DoFn MoqUsual_InterfaceParam_doFn - DoReturnFn MoqUsual_InterfaceParam_doReturnFn + DoFn MoqPartialGenericResults_Usual_doFn[S] + DoReturnFn MoqPartialGenericResults_Usual_doReturnFn[S] }{ Values: &struct { - SResult string - Err error + Result1 S + Result2 error }{ - SResult: sResult, - Err: err, + Result1: result1, + Result2: result2, }, Sequence: sequence, }) return r } -func (r *MoqUsual_InterfaceParam_fnRecorder) AndDo(fn MoqUsual_InterfaceParam_doFn) *MoqUsual_InterfaceParam_fnRecorder { +func (r *MoqPartialGenericResults_Usual_fnRecorder[S]) AndDo(fn MoqPartialGenericResults_Usual_doFn[S]) *MoqPartialGenericResults_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -9944,7 +14752,7 @@ func (r *MoqUsual_InterfaceParam_fnRecorder) AndDo(fn MoqUsual_InterfaceParam_do return r } -func (r *MoqUsual_InterfaceParam_fnRecorder) DoReturnResults(fn MoqUsual_InterfaceParam_doReturnFn) *MoqUsual_InterfaceParam_fnRecorder { +func (r *MoqPartialGenericResults_Usual_fnRecorder[S]) DoReturnResults(fn MoqPartialGenericResults_Usual_doReturnFn[S]) *MoqPartialGenericResults_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() r.FindResults() @@ -9955,17 +14763,17 @@ func (r *MoqUsual_InterfaceParam_fnRecorder) DoReturnResults(fn MoqUsual_Interfa r.Results.Results = append(r.Results.Results, struct { Values *struct { - SResult string - Err error + Result1 S + Result2 error } Sequence uint32 - DoFn MoqUsual_InterfaceParam_doFn - DoReturnFn MoqUsual_InterfaceParam_doReturnFn + DoFn MoqPartialGenericResults_Usual_doFn[S] + DoReturnFn MoqPartialGenericResults_Usual_doReturnFn[S] }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_InterfaceParam_fnRecorder) FindResults() { +func (r *MoqPartialGenericResults_Usual_fnRecorder[S]) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -9974,8 +14782,8 @@ func (r *MoqUsual_InterfaceParam_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_InterfaceParam_resultsByParams - for n, res := range r.Moq.ResultsByParams_InterfaceParam { + var results *MoqPartialGenericResults_Usual_resultsByParams[S] + for n, res := range r.Moq.ResultsByParams_Usual { if res.AnyParams == r.AnyParams { results = &res break @@ -9985,24 +14793,24 @@ func (r *MoqUsual_InterfaceParam_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_InterfaceParam_resultsByParams{ + results = &MoqPartialGenericResults_Usual_resultsByParams[S]{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_InterfaceParam_paramsKey]*MoqUsual_InterfaceParam_results{}, + Results: map[MoqPartialGenericResults_Usual_paramsKey[S]]*MoqPartialGenericResults_Usual_results[S]{}, } - r.Moq.ResultsByParams_InterfaceParam = append(r.Moq.ResultsByParams_InterfaceParam, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_InterfaceParam) { - copy(r.Moq.ResultsByParams_InterfaceParam[insertAt+1:], r.Moq.ResultsByParams_InterfaceParam[insertAt:0]) - r.Moq.ResultsByParams_InterfaceParam[insertAt] = *results + r.Moq.ResultsByParams_Usual = append(r.Moq.ResultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Usual) { + copy(r.Moq.ResultsByParams_Usual[insertAt+1:], r.Moq.ResultsByParams_Usual[insertAt:0]) + r.Moq.ResultsByParams_Usual[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_InterfaceParam(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey_Usual(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_InterfaceParam_results{ + r.Results = &MoqPartialGenericResults_Usual_results[S]{ Params: r.Params, Results: nil, Index: 0, @@ -10014,7 +14822,7 @@ func (r *MoqUsual_InterfaceParam_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_InterfaceParam_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_InterfaceParam_fnRecorder { +func (r *MoqPartialGenericResults_Usual_fnRecorder[S]) Repeat(repeaters ...moq.Repeater) *MoqPartialGenericResults_Usual_fnRecorder[S] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -10026,12 +14834,12 @@ func (r *MoqUsual_InterfaceParam_fnRecorder) Repeat(repeaters ...moq.Repeater) * if r.Sequence { last = struct { Values *struct { - SResult string - Err error + Result1 S + Result2 error } Sequence uint32 - DoFn MoqUsual_InterfaceParam_doFn - DoReturnFn MoqUsual_InterfaceParam_doReturnFn + DoFn MoqPartialGenericResults_Usual_doFn[S] + DoReturnFn MoqPartialGenericResults_Usual_doReturnFn[S] }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -10039,85 +14847,305 @@ func (r *MoqUsual_InterfaceParam_fnRecorder) Repeat(repeaters ...moq.Repeater) * } r.Results.Results = append(r.Results.Results, last) } - return r -} + return r +} + +func (m *MoqPartialGenericResults[S]) PrettyParams_Usual(params MoqPartialGenericResults_Usual_params[S]) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.Param1, params.Param2) +} + +func (m *MoqPartialGenericResults[S]) ParamsKey_Usual(params MoqPartialGenericResults_Usual_params[S], anyParams uint64) MoqPartialGenericResults_Usual_paramsKey[S] { + m.Scene.T.Helper() + var param1Used string + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.Runtime.ParameterIndexing.Usual.Param1 == moq.ParamIndexByValue { + param1Used = params.Param1 + } else { + param1UsedHash = hash.DeepHash(params.Param1) + } + } + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.Usual.Param2 == moq.ParamIndexByValue { + param2Used = params.Param2 + } else { + param2UsedHash = hash.DeepHash(params.Param2) + } + } + return MoqPartialGenericResults_Usual_paramsKey[S]{ + Params: struct { + Param1 string + Param2 bool + }{ + Param1: param1Used, + Param2: param2Used, + }, + Hashes: struct { + Param1 hash.Hash + Param2 hash.Hash + }{ + Param1: param1UsedHash, + Param2: param2UsedHash, + }, + } +} + +// Reset resets the state of the moq +func (m *MoqPartialGenericResults[S]) Reset() { m.ResultsByParams_Usual = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqPartialGenericResults[S]) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams_Usual { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Usual(results.Params)) + } + } + } +} + +// The following type assertion assures that testmoqs.GenericInterfaceParam is +// mocked completely +var _ testmoqs.GenericInterfaceParam[testmoqs.MyWriter] = (*MoqGenericInterfaceParam_mock[testmoqs.MyWriter])(nil) + +// MoqGenericInterfaceParam holds the state of a moq of the +// GenericInterfaceParam type +type MoqGenericInterfaceParam[W testmoqs.MyWriter] struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqGenericInterfaceParam_mock[W] + + ResultsByParams_Usual []MoqGenericInterfaceParam_Usual_resultsByParams[W] + + Runtime struct { + ParameterIndexing struct { + Usual struct { + W moq.ParamIndexing + } + } + } + // MoqGenericInterfaceParam_mock isolates the mock interface of the +} + +// GenericInterfaceParam type +type MoqGenericInterfaceParam_mock[W testmoqs.MyWriter] struct { + Moq *MoqGenericInterfaceParam[W] +} + +// MoqGenericInterfaceParam_recorder isolates the recorder interface of the +// GenericInterfaceParam type +type MoqGenericInterfaceParam_recorder[W testmoqs.MyWriter] struct { + Moq *MoqGenericInterfaceParam[W] +} + +// MoqGenericInterfaceParam_Usual_params holds the params of the +// GenericInterfaceParam type +type MoqGenericInterfaceParam_Usual_params[W testmoqs.MyWriter] struct{ W W } + +// MoqGenericInterfaceParam_Usual_paramsKey holds the map key params of the +// GenericInterfaceParam type +type MoqGenericInterfaceParam_Usual_paramsKey[W testmoqs.MyWriter] struct { + Params struct{} + Hashes struct{ W hash.Hash } +} + +// MoqGenericInterfaceParam_Usual_resultsByParams contains the results for a +// given set of parameters for the GenericInterfaceParam type +type MoqGenericInterfaceParam_Usual_resultsByParams[W testmoqs.MyWriter] struct { + AnyCount int + AnyParams uint64 + Results map[MoqGenericInterfaceParam_Usual_paramsKey[W]]*MoqGenericInterfaceParam_Usual_results[W] +} + +// MoqGenericInterfaceParam_Usual_doFn defines the type of function needed when +// calling AndDo for the GenericInterfaceParam type +type MoqGenericInterfaceParam_Usual_doFn[W testmoqs.MyWriter] func(w W) + +// MoqGenericInterfaceParam_Usual_doReturnFn defines the type of function +// needed when calling DoReturnResults for the GenericInterfaceParam type +type MoqGenericInterfaceParam_Usual_doReturnFn[W testmoqs.MyWriter] func(w W) (sResult string, err error) + +// MoqGenericInterfaceParam_Usual_results holds the results of the +// GenericInterfaceParam type +type MoqGenericInterfaceParam_Usual_results[W testmoqs.MyWriter] struct { + Params MoqGenericInterfaceParam_Usual_params[W] + Results []struct { + Values *struct { + SResult string + Err error + } + Sequence uint32 + DoFn MoqGenericInterfaceParam_Usual_doFn[W] + DoReturnFn MoqGenericInterfaceParam_Usual_doReturnFn[W] + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqGenericInterfaceParam_Usual_fnRecorder routes recorded function calls to +// the MoqGenericInterfaceParam moq +type MoqGenericInterfaceParam_Usual_fnRecorder[W testmoqs.MyWriter] struct { + Params MoqGenericInterfaceParam_Usual_params[W] + AnyParams uint64 + Sequence bool + Results *MoqGenericInterfaceParam_Usual_results[W] + Moq *MoqGenericInterfaceParam[W] +} + +// MoqGenericInterfaceParam_Usual_anyParams isolates the any params functions +// of the GenericInterfaceParam type +type MoqGenericInterfaceParam_Usual_anyParams[W testmoqs.MyWriter] struct { + Recorder *MoqGenericInterfaceParam_Usual_fnRecorder[W] +} + +// NewMoqGenericInterfaceParam creates a new moq of the GenericInterfaceParam +// type +func NewMoqGenericInterfaceParam[W testmoqs.MyWriter](scene *moq.Scene, config *moq.Config) *MoqGenericInterfaceParam[W] { + if config == nil { + config = &moq.Config{} + } + m := &MoqGenericInterfaceParam[W]{ + Scene: scene, + Config: *config, + Moq: &MoqGenericInterfaceParam_mock[W]{}, + + Runtime: struct { + ParameterIndexing struct { + Usual struct { + W moq.ParamIndexing + } + } + }{ParameterIndexing: struct { + Usual struct { + W moq.ParamIndexing + } + }{ + Usual: struct { + W moq.ParamIndexing + }{ + W: moq.ParamIndexByHash, + }, + }}, + } + m.Moq.Moq = m + + scene.AddMoq(m) + return m +} + +// Mock returns the mock implementation of the GenericInterfaceParam type +func (m *MoqGenericInterfaceParam[W]) Mock() *MoqGenericInterfaceParam_mock[W] { return m.Moq } + +func (m *MoqGenericInterfaceParam_mock[W]) Usual(w W) (sResult string, err error) { + m.Moq.Scene.T.Helper() + params := MoqGenericInterfaceParam_Usual_params[W]{ + W: w, + } + var results *MoqGenericInterfaceParam_Usual_results[W] + for _, resultsByParams := range m.Moq.ResultsByParams_Usual { + paramsKey := m.Moq.ParamsKey_Usual(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Usual(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Usual(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Usual(params)) + } + } + + if result.DoFn != nil { + result.DoFn(w) + } -func (m *MoqUsual) PrettyParams_InterfaceParam(params MoqUsual_InterfaceParam_params) string { - return fmt.Sprintf("InterfaceParam(%#v)", params.W) + if result.Values != nil { + sResult = result.Values.SResult + err = result.Values.Err + } + if result.DoReturnFn != nil { + sResult, err = result.DoReturnFn(w) + } + return } -func (m *MoqUsual) ParamsKey_InterfaceParam(params MoqUsual_InterfaceParam_params, anyParams uint64) MoqUsual_InterfaceParam_paramsKey { - m.Scene.T.Helper() - var wUsed io.Writer - var wUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.InterfaceParam.W == moq.ParamIndexByValue { - wUsed = params.W - } else { - wUsedHash = hash.DeepHash(params.W) - } - } - return MoqUsual_InterfaceParam_paramsKey{ - Params: struct{ W io.Writer }{ - W: wUsed, - }, - Hashes: struct{ W hash.Hash }{ - W: wUsedHash, - }, +// OnCall returns the recorder implementation of the GenericInterfaceParam type +func (m *MoqGenericInterfaceParam[W]) OnCall() *MoqGenericInterfaceParam_recorder[W] { + return &MoqGenericInterfaceParam_recorder[W]{ + Moq: m, } } -func (m *MoqUsual_recorder) InterfaceResult(sParam string, bParam bool) *MoqUsual_InterfaceResult_fnRecorder { - return &MoqUsual_InterfaceResult_fnRecorder{ - Params: MoqUsual_InterfaceResult_params{ - SParam: sParam, - BParam: bParam, +func (m *MoqGenericInterfaceParam_recorder[W]) Usual(w W) *MoqGenericInterfaceParam_Usual_fnRecorder[W] { + return &MoqGenericInterfaceParam_Usual_fnRecorder[W]{ + Params: MoqGenericInterfaceParam_Usual_params[W]{ + W: w, }, Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, Moq: m.Moq, } } -func (r *MoqUsual_InterfaceResult_fnRecorder) Any() *MoqUsual_InterfaceResult_anyParams { +func (r *MoqGenericInterfaceParam_Usual_fnRecorder[W]) Any() *MoqGenericInterfaceParam_Usual_anyParams[W] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceResult(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } - return &MoqUsual_InterfaceResult_anyParams{Recorder: r} + return &MoqGenericInterfaceParam_Usual_anyParams[W]{Recorder: r} } -func (a *MoqUsual_InterfaceResult_anyParams) SParam() *MoqUsual_InterfaceResult_fnRecorder { +func (a *MoqGenericInterfaceParam_Usual_anyParams[W]) W() *MoqGenericInterfaceParam_Usual_fnRecorder[W] { a.Recorder.AnyParams |= 1 << 0 return a.Recorder } -func (a *MoqUsual_InterfaceResult_anyParams) BParam() *MoqUsual_InterfaceResult_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 - return a.Recorder -} - -func (r *MoqUsual_InterfaceResult_fnRecorder) Seq() *MoqUsual_InterfaceResult_fnRecorder { +func (r *MoqGenericInterfaceParam_Usual_fnRecorder[W]) Seq() *MoqGenericInterfaceParam_Usual_fnRecorder[W] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceResult(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_InterfaceResult_fnRecorder) NoSeq() *MoqUsual_InterfaceResult_fnRecorder { +func (r *MoqGenericInterfaceParam_Usual_fnRecorder[W]) NoSeq() *MoqGenericInterfaceParam_Usual_fnRecorder[W] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_InterfaceResult(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_InterfaceResult_fnRecorder) ReturnResults(result1 io.Reader) *MoqUsual_InterfaceResult_fnRecorder { +func (r *MoqGenericInterfaceParam_Usual_fnRecorder[W]) ReturnResults(sResult string, err error) *MoqGenericInterfaceParam_Usual_fnRecorder[W] { r.Moq.Scene.T.Helper() r.FindResults() @@ -10127,20 +15155,27 @@ func (r *MoqUsual_InterfaceResult_fnRecorder) ReturnResults(result1 io.Reader) * } r.Results.Results = append(r.Results.Results, struct { - Values *struct{ Result1 io.Reader } + Values *struct { + SResult string + Err error + } Sequence uint32 - DoFn MoqUsual_InterfaceResult_doFn - DoReturnFn MoqUsual_InterfaceResult_doReturnFn + DoFn MoqGenericInterfaceParam_Usual_doFn[W] + DoReturnFn MoqGenericInterfaceParam_Usual_doReturnFn[W] }{ - Values: &struct{ Result1 io.Reader }{ - Result1: result1, + Values: &struct { + SResult string + Err error + }{ + SResult: sResult, + Err: err, }, Sequence: sequence, }) return r } -func (r *MoqUsual_InterfaceResult_fnRecorder) AndDo(fn MoqUsual_InterfaceResult_doFn) *MoqUsual_InterfaceResult_fnRecorder { +func (r *MoqGenericInterfaceParam_Usual_fnRecorder[W]) AndDo(fn MoqGenericInterfaceParam_Usual_doFn[W]) *MoqGenericInterfaceParam_Usual_fnRecorder[W] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -10151,7 +15186,7 @@ func (r *MoqUsual_InterfaceResult_fnRecorder) AndDo(fn MoqUsual_InterfaceResult_ return r } -func (r *MoqUsual_InterfaceResult_fnRecorder) DoReturnResults(fn MoqUsual_InterfaceResult_doReturnFn) *MoqUsual_InterfaceResult_fnRecorder { +func (r *MoqGenericInterfaceParam_Usual_fnRecorder[W]) DoReturnResults(fn MoqGenericInterfaceParam_Usual_doReturnFn[W]) *MoqGenericInterfaceParam_Usual_fnRecorder[W] { r.Moq.Scene.T.Helper() r.FindResults() @@ -10161,15 +15196,18 @@ func (r *MoqUsual_InterfaceResult_fnRecorder) DoReturnResults(fn MoqUsual_Interf } r.Results.Results = append(r.Results.Results, struct { - Values *struct{ Result1 io.Reader } + Values *struct { + SResult string + Err error + } Sequence uint32 - DoFn MoqUsual_InterfaceResult_doFn - DoReturnFn MoqUsual_InterfaceResult_doReturnFn + DoFn MoqGenericInterfaceParam_Usual_doFn[W] + DoReturnFn MoqGenericInterfaceParam_Usual_doReturnFn[W] }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_InterfaceResult_fnRecorder) FindResults() { +func (r *MoqGenericInterfaceParam_Usual_fnRecorder[W]) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -10178,8 +15216,8 @@ func (r *MoqUsual_InterfaceResult_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_InterfaceResult_resultsByParams - for n, res := range r.Moq.ResultsByParams_InterfaceResult { + var results *MoqGenericInterfaceParam_Usual_resultsByParams[W] + for n, res := range r.Moq.ResultsByParams_Usual { if res.AnyParams == r.AnyParams { results = &res break @@ -10189,24 +15227,24 @@ func (r *MoqUsual_InterfaceResult_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_InterfaceResult_resultsByParams{ + results = &MoqGenericInterfaceParam_Usual_resultsByParams[W]{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_InterfaceResult_paramsKey]*MoqUsual_InterfaceResult_results{}, + Results: map[MoqGenericInterfaceParam_Usual_paramsKey[W]]*MoqGenericInterfaceParam_Usual_results[W]{}, } - r.Moq.ResultsByParams_InterfaceResult = append(r.Moq.ResultsByParams_InterfaceResult, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_InterfaceResult) { - copy(r.Moq.ResultsByParams_InterfaceResult[insertAt+1:], r.Moq.ResultsByParams_InterfaceResult[insertAt:0]) - r.Moq.ResultsByParams_InterfaceResult[insertAt] = *results + r.Moq.ResultsByParams_Usual = append(r.Moq.ResultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Usual) { + copy(r.Moq.ResultsByParams_Usual[insertAt+1:], r.Moq.ResultsByParams_Usual[insertAt:0]) + r.Moq.ResultsByParams_Usual[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_InterfaceResult(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey_Usual(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_InterfaceResult_results{ + r.Results = &MoqGenericInterfaceParam_Usual_results[W]{ Params: r.Params, Results: nil, Index: 0, @@ -10218,7 +15256,7 @@ func (r *MoqUsual_InterfaceResult_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_InterfaceResult_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_InterfaceResult_fnRecorder { +func (r *MoqGenericInterfaceParam_Usual_fnRecorder[W]) Repeat(repeaters ...moq.Repeater) *MoqGenericInterfaceParam_Usual_fnRecorder[W] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -10229,10 +15267,13 @@ func (r *MoqUsual_InterfaceResult_fnRecorder) Repeat(repeaters ...moq.Repeater) for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { if r.Sequence { last = struct { - Values *struct{ Result1 io.Reader } + Values *struct { + SResult string + Err error + } Sequence uint32 - DoFn MoqUsual_InterfaceResult_doFn - DoReturnFn MoqUsual_InterfaceResult_doReturnFn + DoFn MoqGenericInterfaceParam_Usual_doFn[W] + DoReturnFn MoqGenericInterfaceParam_Usual_doReturnFn[W] }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -10243,93 +15284,299 @@ func (r *MoqUsual_InterfaceResult_fnRecorder) Repeat(repeaters ...moq.Repeater) return r } -func (m *MoqUsual) PrettyParams_InterfaceResult(params MoqUsual_InterfaceResult_params) string { - return fmt.Sprintf("InterfaceResult(%#v, %#v)", params.SParam, params.BParam) +func (m *MoqGenericInterfaceParam[W]) PrettyParams_Usual(params MoqGenericInterfaceParam_Usual_params[W]) string { + return fmt.Sprintf("Usual(%#v)", params.W) } -func (m *MoqUsual) ParamsKey_InterfaceResult(params MoqUsual_InterfaceResult_params, anyParams uint64) MoqUsual_InterfaceResult_paramsKey { +func (m *MoqGenericInterfaceParam[W]) ParamsKey_Usual(params MoqGenericInterfaceParam_Usual_params[W], anyParams uint64) MoqGenericInterfaceParam_Usual_paramsKey[W] { m.Scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash + var wUsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.InterfaceResult.SParam == moq.ParamIndexByValue { - sParamUsed = params.SParam - } else { - sParamUsedHash = hash.DeepHash(params.SParam) + if m.Runtime.ParameterIndexing.Usual.W == moq.ParamIndexByValue { + m.Scene.T.Fatalf("The w parameter of the Usual function can't be indexed by value") + } + wUsedHash = hash.DeepHash(params.W) + } + return MoqGenericInterfaceParam_Usual_paramsKey[W]{ + Params: struct{}{}, + Hashes: struct{ W hash.Hash }{ + W: wUsedHash, + }, + } +} + +// Reset resets the state of the moq +func (m *MoqGenericInterfaceParam[W]) Reset() { m.ResultsByParams_Usual = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqGenericInterfaceParam[W]) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams_Usual { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Usual(results.Params)) + } + } + } +} + +// The following type assertion assures that testmoqs.GenericInterfaceResult is +// mocked completely +var _ testmoqs.GenericInterfaceResult[testmoqs.MyReader] = (*MoqGenericInterfaceResult_mock[testmoqs.MyReader])(nil) + +// MoqGenericInterfaceResult holds the state of a moq of the +// GenericInterfaceResult type +type MoqGenericInterfaceResult[R testmoqs.MyReader] struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqGenericInterfaceResult_mock[R] + + ResultsByParams_Usual []MoqGenericInterfaceResult_Usual_resultsByParams[R] + + Runtime struct { + ParameterIndexing struct { + Usual struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + } + } + // MoqGenericInterfaceResult_mock isolates the mock interface of the +} + +// GenericInterfaceResult type +type MoqGenericInterfaceResult_mock[R testmoqs.MyReader] struct { + Moq *MoqGenericInterfaceResult[R] +} + +// MoqGenericInterfaceResult_recorder isolates the recorder interface of the +// GenericInterfaceResult type +type MoqGenericInterfaceResult_recorder[R testmoqs.MyReader] struct { + Moq *MoqGenericInterfaceResult[R] +} + +// MoqGenericInterfaceResult_Usual_params holds the params of the +// GenericInterfaceResult type +type MoqGenericInterfaceResult_Usual_params[R testmoqs.MyReader] struct { + SParam string + BParam bool +} + +// MoqGenericInterfaceResult_Usual_paramsKey holds the map key params of the +// GenericInterfaceResult type +type MoqGenericInterfaceResult_Usual_paramsKey[R testmoqs.MyReader] struct { + Params struct { + SParam string + BParam bool + } + Hashes struct { + SParam hash.Hash + BParam hash.Hash + } +} + +// MoqGenericInterfaceResult_Usual_resultsByParams contains the results for a +// given set of parameters for the GenericInterfaceResult type +type MoqGenericInterfaceResult_Usual_resultsByParams[R testmoqs.MyReader] struct { + AnyCount int + AnyParams uint64 + Results map[MoqGenericInterfaceResult_Usual_paramsKey[R]]*MoqGenericInterfaceResult_Usual_results[R] +} + +// MoqGenericInterfaceResult_Usual_doFn defines the type of function needed +// when calling AndDo for the GenericInterfaceResult type +type MoqGenericInterfaceResult_Usual_doFn[R testmoqs.MyReader] func(sParam string, bParam bool) + +// MoqGenericInterfaceResult_Usual_doReturnFn defines the type of function +// needed when calling DoReturnResults for the GenericInterfaceResult type +type MoqGenericInterfaceResult_Usual_doReturnFn[R testmoqs.MyReader] func(sParam string, bParam bool) (r R) + +// MoqGenericInterfaceResult_Usual_results holds the results of the +// GenericInterfaceResult type +type MoqGenericInterfaceResult_Usual_results[R testmoqs.MyReader] struct { + Params MoqGenericInterfaceResult_Usual_params[R] + Results []struct { + Values *struct{ Result1 R } + Sequence uint32 + DoFn MoqGenericInterfaceResult_Usual_doFn[R] + DoReturnFn MoqGenericInterfaceResult_Usual_doReturnFn[R] + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqGenericInterfaceResult_Usual_fnRecorder routes recorded function calls to +// the MoqGenericInterfaceResult moq +type MoqGenericInterfaceResult_Usual_fnRecorder[R testmoqs.MyReader] struct { + Params MoqGenericInterfaceResult_Usual_params[R] + AnyParams uint64 + Sequence bool + Results *MoqGenericInterfaceResult_Usual_results[R] + Moq *MoqGenericInterfaceResult[R] +} + +// MoqGenericInterfaceResult_Usual_anyParams isolates the any params functions +// of the GenericInterfaceResult type +type MoqGenericInterfaceResult_Usual_anyParams[R testmoqs.MyReader] struct { + Recorder *MoqGenericInterfaceResult_Usual_fnRecorder[R] +} + +// NewMoqGenericInterfaceResult creates a new moq of the GenericInterfaceResult +// type +func NewMoqGenericInterfaceResult[R testmoqs.MyReader](scene *moq.Scene, config *moq.Config) *MoqGenericInterfaceResult[R] { + if config == nil { + config = &moq.Config{} + } + m := &MoqGenericInterfaceResult[R]{ + Scene: scene, + Config: *config, + Moq: &MoqGenericInterfaceResult_mock[R]{}, + + Runtime: struct { + ParameterIndexing struct { + Usual struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + } + }{ParameterIndexing: struct { + Usual struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + } + }{ + Usual: struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing + }{ + SParam: moq.ParamIndexByValue, + BParam: moq.ParamIndexByValue, + }, + }}, + } + m.Moq.Moq = m + + scene.AddMoq(m) + return m +} + +// Mock returns the mock implementation of the GenericInterfaceResult type +func (m *MoqGenericInterfaceResult[R]) Mock() *MoqGenericInterfaceResult_mock[R] { return m.Moq } + +func (m *MoqGenericInterfaceResult_mock[R]) Usual(sParam string, bParam bool) (result1 R) { + m.Moq.Scene.T.Helper() + params := MoqGenericInterfaceResult_Usual_params[R]{ + SParam: sParam, + BParam: bParam, + } + var results *MoqGenericInterfaceResult_Usual_results[R] + for _, resultsByParams := range m.Moq.ResultsByParams_Usual { + paramsKey := m.Moq.ParamsKey_Usual(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_Usual(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_Usual(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_Usual(params)) } } - var bParamUsed bool - var bParamUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.Runtime.ParameterIndexing.InterfaceResult.BParam == moq.ParamIndexByValue { - bParamUsed = params.BParam - } else { - bParamUsedHash = hash.DeepHash(params.BParam) - } + + if result.DoFn != nil { + result.DoFn(sParam, bParam) } - return MoqUsual_InterfaceResult_paramsKey{ - Params: struct { - SParam string - BParam bool - }{ - SParam: sParamUsed, - BParam: bParamUsed, - }, - Hashes: struct { - SParam hash.Hash - BParam hash.Hash - }{ - SParam: sParamUsedHash, - BParam: bParamUsedHash, - }, + + if result.Values != nil { + result1 = result.Values.Result1 } + if result.DoReturnFn != nil { + result1 = result.DoReturnFn(sParam, bParam) + } + return } -func (m *MoqUsual_recorder) FnParam(fn func()) *MoqUsual_FnParam_fnRecorder { - return &MoqUsual_FnParam_fnRecorder{ - Params: MoqUsual_FnParam_params{ - Fn: fn, +// OnCall returns the recorder implementation of the GenericInterfaceResult +// type +func (m *MoqGenericInterfaceResult[R]) OnCall() *MoqGenericInterfaceResult_recorder[R] { + return &MoqGenericInterfaceResult_recorder[R]{ + Moq: m, + } +} + +func (m *MoqGenericInterfaceResult_recorder[R]) Usual(sParam string, bParam bool) *MoqGenericInterfaceResult_Usual_fnRecorder[R] { + return &MoqGenericInterfaceResult_Usual_fnRecorder[R]{ + Params: MoqGenericInterfaceResult_Usual_params[R]{ + SParam: sParam, + BParam: bParam, }, Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, Moq: m.Moq, } } -func (r *MoqUsual_FnParam_fnRecorder) Any() *MoqUsual_FnParam_anyParams { +func (r *MoqGenericInterfaceResult_Usual_fnRecorder[R]) Any() *MoqGenericInterfaceResult_Usual_anyParams[R] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_FnParam(r.Params)) + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } - return &MoqUsual_FnParam_anyParams{Recorder: r} + return &MoqGenericInterfaceResult_Usual_anyParams[R]{Recorder: r} } -func (a *MoqUsual_FnParam_anyParams) Fn() *MoqUsual_FnParam_fnRecorder { +func (a *MoqGenericInterfaceResult_Usual_anyParams[R]) SParam() *MoqGenericInterfaceResult_Usual_fnRecorder[R] { a.Recorder.AnyParams |= 1 << 0 return a.Recorder } -func (r *MoqUsual_FnParam_fnRecorder) Seq() *MoqUsual_FnParam_fnRecorder { +func (a *MoqGenericInterfaceResult_Usual_anyParams[R]) BParam() *MoqGenericInterfaceResult_Usual_fnRecorder[R] { + a.Recorder.AnyParams |= 1 << 1 + return a.Recorder +} + +func (r *MoqGenericInterfaceResult_Usual_fnRecorder[R]) Seq() *MoqGenericInterfaceResult_Usual_fnRecorder[R] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_FnParam(r.Params)) + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = true return r } -func (r *MoqUsual_FnParam_fnRecorder) NoSeq() *MoqUsual_FnParam_fnRecorder { +func (r *MoqGenericInterfaceResult_Usual_fnRecorder[R]) NoSeq() *MoqGenericInterfaceResult_Usual_fnRecorder[R] { r.Moq.Scene.T.Helper() if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_FnParam(r.Params)) + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_Usual(r.Params)) return nil } r.Sequence = false return r } -func (r *MoqUsual_FnParam_fnRecorder) ReturnResults() *MoqUsual_FnParam_fnRecorder { +func (r *MoqGenericInterfaceResult_Usual_fnRecorder[R]) ReturnResults(result1 R) *MoqGenericInterfaceResult_Usual_fnRecorder[R] { r.Moq.Scene.T.Helper() r.FindResults() @@ -10339,18 +15586,20 @@ func (r *MoqUsual_FnParam_fnRecorder) ReturnResults() *MoqUsual_FnParam_fnRecord } r.Results.Results = append(r.Results.Results, struct { - Values *struct{} + Values *struct{ Result1 R } Sequence uint32 - DoFn MoqUsual_FnParam_doFn - DoReturnFn MoqUsual_FnParam_doReturnFn + DoFn MoqGenericInterfaceResult_Usual_doFn[R] + DoReturnFn MoqGenericInterfaceResult_Usual_doReturnFn[R] }{ - Values: &struct{}{}, + Values: &struct{ Result1 R }{ + Result1: result1, + }, Sequence: sequence, }) return r } -func (r *MoqUsual_FnParam_fnRecorder) AndDo(fn MoqUsual_FnParam_doFn) *MoqUsual_FnParam_fnRecorder { +func (r *MoqGenericInterfaceResult_Usual_fnRecorder[R]) AndDo(fn MoqGenericInterfaceResult_Usual_doFn[R]) *MoqGenericInterfaceResult_Usual_fnRecorder[R] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") @@ -10361,7 +15610,7 @@ func (r *MoqUsual_FnParam_fnRecorder) AndDo(fn MoqUsual_FnParam_doFn) *MoqUsual_ return r } -func (r *MoqUsual_FnParam_fnRecorder) DoReturnResults(fn MoqUsual_FnParam_doReturnFn) *MoqUsual_FnParam_fnRecorder { +func (r *MoqGenericInterfaceResult_Usual_fnRecorder[R]) DoReturnResults(fn MoqGenericInterfaceResult_Usual_doReturnFn[R]) *MoqGenericInterfaceResult_Usual_fnRecorder[R] { r.Moq.Scene.T.Helper() r.FindResults() @@ -10371,15 +15620,15 @@ func (r *MoqUsual_FnParam_fnRecorder) DoReturnResults(fn MoqUsual_FnParam_doRetu } r.Results.Results = append(r.Results.Results, struct { - Values *struct{} + Values *struct{ Result1 R } Sequence uint32 - DoFn MoqUsual_FnParam_doFn - DoReturnFn MoqUsual_FnParam_doReturnFn + DoFn MoqGenericInterfaceResult_Usual_doFn[R] + DoReturnFn MoqGenericInterfaceResult_Usual_doReturnFn[R] }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_FnParam_fnRecorder) FindResults() { +func (r *MoqGenericInterfaceResult_Usual_fnRecorder[R]) FindResults() { r.Moq.Scene.T.Helper() if r.Results != nil { r.Results.Repeat.Increment(r.Moq.Scene.T) @@ -10388,8 +15637,8 @@ func (r *MoqUsual_FnParam_fnRecorder) FindResults() { anyCount := bits.OnesCount64(r.AnyParams) insertAt := -1 - var results *MoqUsual_FnParam_resultsByParams - for n, res := range r.Moq.ResultsByParams_FnParam { + var results *MoqGenericInterfaceResult_Usual_resultsByParams[R] + for n, res := range r.Moq.ResultsByParams_Usual { if res.AnyParams == r.AnyParams { results = &res break @@ -10399,24 +15648,24 @@ func (r *MoqUsual_FnParam_fnRecorder) FindResults() { } } if results == nil { - results = &MoqUsual_FnParam_resultsByParams{ + results = &MoqGenericInterfaceResult_Usual_resultsByParams[R]{ AnyCount: anyCount, AnyParams: r.AnyParams, - Results: map[MoqUsual_FnParam_paramsKey]*MoqUsual_FnParam_results{}, + Results: map[MoqGenericInterfaceResult_Usual_paramsKey[R]]*MoqGenericInterfaceResult_Usual_results[R]{}, } - r.Moq.ResultsByParams_FnParam = append(r.Moq.ResultsByParams_FnParam, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_FnParam) { - copy(r.Moq.ResultsByParams_FnParam[insertAt+1:], r.Moq.ResultsByParams_FnParam[insertAt:0]) - r.Moq.ResultsByParams_FnParam[insertAt] = *results + r.Moq.ResultsByParams_Usual = append(r.Moq.ResultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Usual) { + copy(r.Moq.ResultsByParams_Usual[insertAt+1:], r.Moq.ResultsByParams_Usual[insertAt:0]) + r.Moq.ResultsByParams_Usual[insertAt] = *results } } - paramsKey := r.Moq.ParamsKey_FnParam(r.Params, r.AnyParams) + paramsKey := r.Moq.ParamsKey_Usual(r.Params, r.AnyParams) var ok bool r.Results, ok = results.Results[paramsKey] if !ok { - r.Results = &MoqUsual_FnParam_results{ + r.Results = &MoqGenericInterfaceResult_Usual_results[R]{ Params: r.Params, Results: nil, Index: 0, @@ -10428,7 +15677,7 @@ func (r *MoqUsual_FnParam_fnRecorder) FindResults() { r.Results.Repeat.Increment(r.Moq.Scene.T) } -func (r *MoqUsual_FnParam_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_FnParam_fnRecorder { +func (r *MoqGenericInterfaceResult_Usual_fnRecorder[R]) Repeat(repeaters ...moq.Repeater) *MoqGenericInterfaceResult_Usual_fnRecorder[R] { r.Moq.Scene.T.Helper() if r.Results == nil { r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") @@ -10439,10 +15688,10 @@ func (r *MoqUsual_FnParam_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsua for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { if r.Sequence { last = struct { - Values *struct{} + Values *struct{ Result1 R } Sequence uint32 - DoFn MoqUsual_FnParam_doFn - DoReturnFn MoqUsual_FnParam_doReturnFn + DoFn MoqGenericInterfaceResult_Usual_doFn[R] + DoReturnFn MoqGenericInterfaceResult_Usual_doReturnFn[R] }{ Values: last.Values, Sequence: r.Moq.Scene.NextRecorderSequence(), @@ -10453,47 +15702,53 @@ func (r *MoqUsual_FnParam_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsua return r } -func (m *MoqUsual) PrettyParams_FnParam(params MoqUsual_FnParam_params) string { - return fmt.Sprintf("FnParam(%#v)", moq.FnString(params.Fn)) +func (m *MoqGenericInterfaceResult[R]) PrettyParams_Usual(params MoqGenericInterfaceResult_Usual_params[R]) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.SParam, params.BParam) } -func (m *MoqUsual) ParamsKey_FnParam(params MoqUsual_FnParam_params, anyParams uint64) MoqUsual_FnParam_paramsKey { +func (m *MoqGenericInterfaceResult[R]) ParamsKey_Usual(params MoqGenericInterfaceResult_Usual_params[R], anyParams uint64) MoqGenericInterfaceResult_Usual_paramsKey[R] { m.Scene.T.Helper() - var fnUsedHash hash.Hash + var sParamUsed string + var sParamUsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.FnParam.Fn == moq.ParamIndexByValue { - m.Scene.T.Fatalf("The fn parameter of the FnParam function can't be indexed by value") + if m.Runtime.ParameterIndexing.Usual.SParam == moq.ParamIndexByValue { + sParamUsed = params.SParam + } else { + sParamUsedHash = hash.DeepHash(params.SParam) } - fnUsedHash = hash.DeepHash(params.Fn) } - return MoqUsual_FnParam_paramsKey{ - Params: struct{}{}, - Hashes: struct{ Fn hash.Hash }{ - Fn: fnUsedHash, + var bParamUsed bool + var bParamUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.Runtime.ParameterIndexing.Usual.BParam == moq.ParamIndexByValue { + bParamUsed = params.BParam + } else { + bParamUsedHash = hash.DeepHash(params.BParam) + } + } + return MoqGenericInterfaceResult_Usual_paramsKey[R]{ + Params: struct { + SParam string + BParam bool + }{ + SParam: sParamUsed, + BParam: bParamUsed, + }, + Hashes: struct { + SParam hash.Hash + BParam hash.Hash + }{ + SParam: sParamUsedHash, + BParam: bParamUsedHash, }, } } // Reset resets the state of the moq -func (m *MoqUsual) Reset() { - m.ResultsByParams_Usual = nil - m.ResultsByParams_NoNames = nil - m.ResultsByParams_NoResults = nil - m.ResultsByParams_NoParams = nil - m.ResultsByParams_Nothing = nil - m.ResultsByParams_Variadic = nil - m.ResultsByParams_RepeatedIds = nil - m.ResultsByParams_Times = nil - m.ResultsByParams_DifficultParamNames = nil - m.ResultsByParams_DifficultResultNames = nil - m.ResultsByParams_PassByReference = nil - m.ResultsByParams_InterfaceParam = nil - m.ResultsByParams_InterfaceResult = nil - m.ResultsByParams_FnParam = nil -} +func (m *MoqGenericInterfaceResult[R]) Reset() { m.ResultsByParams_Usual = nil } // AssertExpectationsMet asserts that all expectations have been met -func (m *MoqUsual) AssertExpectationsMet() { +func (m *MoqGenericInterfaceResult[R]) AssertExpectationsMet() { m.Scene.T.Helper() for _, res := range m.ResultsByParams_Usual { for _, results := range res.Results { @@ -10503,108 +15758,4 @@ func (m *MoqUsual) AssertExpectationsMet() { } } } - for _, res := range m.ResultsByParams_NoNames { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_NoNames(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_NoResults { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_NoResults(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_NoParams { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_NoParams(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_Nothing { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Nothing(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_Variadic { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Variadic(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_RepeatedIds { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_RepeatedIds(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_Times { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_Times(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_DifficultParamNames { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_DifficultParamNames(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_DifficultResultNames { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_DifficultResultNames(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_PassByReference { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_PassByReference(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_InterfaceParam { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_InterfaceParam(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_InterfaceResult { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_InterfaceResult(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_FnParam { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_FnParam(results.Params)) - } - } - } } diff --git a/generator/testmoqs/fnadaptors_test.go b/generator/testmoqs/fnadaptors_test.go index d33562a..68dc40f 100644 --- a/generator/testmoqs/fnadaptors_test.go +++ b/generator/testmoqs/fnadaptors_test.go @@ -1189,7 +1189,9 @@ func (a *exportedRepeatedIdsFnAdaptor) newRecorder(sParams []string, bParam bool return &exportedRepeatedIdsFnRecorder{r: a.m.OnCall(sParams[0], sParams[1], bParam)} } -func (a *exportedRepeatedIdsFnAdaptor) invokeMockAndExpectResults(t moq.T, sParams []string, bParam bool, res results) { +func (a *exportedRepeatedIdsFnAdaptor) invokeMockAndExpectResults( + t moq.T, sParams []string, bParam bool, res results, +) { sResult1, sResult2, err := a.m.Mock()(sParams[0], sParams[1], bParam) if sResult1 != res.sResults[0] { t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult1) @@ -2523,3 +2525,843 @@ func (r *exportedInterfaceResultFnRecorder) repeat(repeaters ...moq.Repeater) { func (r *exportedInterfaceResultFnRecorder) isNil() bool { return r.r == nil } + +type genericParamsFnAdaptor[S, B any] struct { + //nolint:structcheck // definitely used + m *moqGenericParamsFn[S, B] +} + +func (a *genericParamsFnAdaptor[S, B]) config() adaptorConfig { return adaptorConfig{} } + +func (a *genericParamsFnAdaptor[S, B]) mock() interface{} { return a.m.mock() } + +func (a *genericParamsFnAdaptor[S, B]) newRecorder(sParams []S, bParam B) recorder { + return &genericParamsFnRecorder[S, B]{r: a.m.onCall(sParams[0], bParam)} +} + +func (a *genericParamsFnAdaptor[S, B]) invokeMockAndExpectResults(t moq.T, sParams []S, bParam B, res results) { + sResult, err := a.m.mock()(sParams[0], bParam) + if sResult != res.sResults[0] { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if err != res.err { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *genericParamsFnAdaptor[S, B]) prettyParams(sParams []S, bParam B) string { + return fmt.Sprintf("GenericParamsFn(%#v, %#v)", sParams[0], bParam) +} + +func (a *genericParamsFnAdaptor[S, B]) sceneMoq() moq.Moq { + return a.m +} + +type genericParamsFnRecorder[S, B any] struct { + //nolint:structcheck // definitely used + r *moqGenericParamsFn_fnRecorder[S, B] +} + +func (r *genericParamsFnRecorder[S, B]) anySParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param1() + } +} + +func (r *genericParamsFnRecorder[S, B]) anyBParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param2() + } +} + +func (r *genericParamsFnRecorder[S, B]) seq() { + r.r = r.r.seq() +} + +func (r *genericParamsFnRecorder[S, B]) noSeq() { + r.r = r.r.noSeq() +} + +func (r *genericParamsFnRecorder[S, B]) returnResults(sResults []string, err error) { + r.r = r.r.returnResults(sResults[0], err) +} + +func (r *genericParamsFnRecorder[S, B]) andDo(t moq.T, fn func(), expectedSParams []string, expectedBParam bool) { + r.r = r.r.andDo(func(sParam S, bParam B) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if !reflect.DeepEqual(bParam, expectedBParam) { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *genericParamsFnRecorder[S, B]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.doReturnResults(func(sParam S, bParam B) (string, error) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if !reflect.DeepEqual(bParam, expectedBParam) { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return sResults[0], err + }) +} + +func (r *genericParamsFnRecorder[S, B]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.repeat(repeaters...) +} + +func (r *genericParamsFnRecorder[S, B]) isNil() bool { + return r.r == nil +} + +type exportedGenericParamsFnAdaptor[S, B any] struct { + //nolint:structcheck // definitely used + m *exported.MoqGenericParamsFn[S, B] +} + +func (a *exportedGenericParamsFnAdaptor[S, B]) config() adaptorConfig { + return adaptorConfig{exported: true} +} + +func (a *exportedGenericParamsFnAdaptor[S, B]) mock() interface{} { return a.m.Mock() } + +func (a *exportedGenericParamsFnAdaptor[S, B]) newRecorder(sParams []S, bParam B) recorder { + return &exportedGenericParamsFnRecorder[S, B]{r: a.m.OnCall(sParams[0], bParam)} +} + +func (a *exportedGenericParamsFnAdaptor[S, B]) invokeMockAndExpectResults( + t moq.T, sParams []S, bParam B, res results, +) { + sResult, err := a.m.Mock()(sParams[0], bParam) + if sResult != res.sResults[0] { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if err != res.err { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *exportedGenericParamsFnAdaptor[S, B]) prettyParams(sParams []S, bParam B) string { + return fmt.Sprintf("GenericParamsFn(%#v, %#v)", sParams[0], bParam) +} + +func (a *exportedGenericParamsFnAdaptor[S, B]) sceneMoq() moq.Moq { + return a.m +} + +type exportedGenericParamsFnRecorder[S, B any] struct { + //nolint:structcheck // definitely used + r *exported.MoqGenericParamsFn_fnRecorder[S, B] +} + +func (r *exportedGenericParamsFnRecorder[S, B]) anySParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param1() + } +} + +func (r *exportedGenericParamsFnRecorder[S, B]) anyBParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param2() + } +} + +func (r *exportedGenericParamsFnRecorder[S, B]) seq() { + r.r = r.r.Seq() +} + +func (r *exportedGenericParamsFnRecorder[S, B]) noSeq() { + r.r = r.r.NoSeq() +} + +func (r *exportedGenericParamsFnRecorder[S, B]) returnResults(sResults []string, err error) { + r.r = r.r.ReturnResults(sResults[0], err) +} + +func (r *exportedGenericParamsFnRecorder[S, B]) andDo( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, +) { + r.r = r.r.AndDo(func(sParam S, bParam B) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if !reflect.DeepEqual(bParam, expectedBParam) { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *exportedGenericParamsFnRecorder[S, B]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.DoReturnResults(func(sParam S, bParam B) (string, error) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if !reflect.DeepEqual(bParam, expectedBParam) { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return sResults[0], err + }) +} + +func (r *exportedGenericParamsFnRecorder[S, B]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.Repeat(repeaters...) +} + +func (r *exportedGenericParamsFnRecorder[S, B]) isNil() bool { + return r.r == nil +} + +type partialGenericParamsFnAdaptor[S any] struct { + //nolint:structcheck // definitely used + m *moqPartialGenericParamsFn[S] +} + +func (a *partialGenericParamsFnAdaptor[S]) config() adaptorConfig { return adaptorConfig{} } + +func (a *partialGenericParamsFnAdaptor[S]) mock() interface{} { return a.m.mock() } + +func (a *partialGenericParamsFnAdaptor[S]) newRecorder(sParams []S, bParam bool) recorder { + return &partialGenericParamsFnRecorder[S]{r: a.m.onCall(sParams[0], bParam)} +} + +func (a *partialGenericParamsFnAdaptor[S]) invokeMockAndExpectResults( + t moq.T, sParams []S, bParam bool, res results, +) { + sResult, err := a.m.mock()(sParams[0], bParam) + if sResult != res.sResults[0] { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if err != res.err { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *partialGenericParamsFnAdaptor[S]) prettyParams(sParams []S, bParam bool) string { + return fmt.Sprintf("PartialGenericParamsFn(%#v, %#v)", sParams[0], bParam) +} + +func (a *partialGenericParamsFnAdaptor[S]) sceneMoq() moq.Moq { + return a.m +} + +type partialGenericParamsFnRecorder[S any] struct { + //nolint:structcheck // definitely used + r *moqPartialGenericParamsFn_fnRecorder[S] +} + +func (r *partialGenericParamsFnRecorder[S]) anySParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param1() + } +} + +func (r *partialGenericParamsFnRecorder[S]) anyBParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param2() + } +} + +func (r *partialGenericParamsFnRecorder[S]) seq() { + r.r = r.r.seq() +} + +func (r *partialGenericParamsFnRecorder[S]) noSeq() { + r.r = r.r.noSeq() +} + +func (r *partialGenericParamsFnRecorder[S]) returnResults(sResults []string, err error) { + r.r = r.r.returnResults(sResults[0], err) +} + +func (r *partialGenericParamsFnRecorder[S]) andDo(t moq.T, fn func(), expectedSParams []string, expectedBParam bool) { + r.r = r.r.andDo(func(sParam S, bParam bool) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *partialGenericParamsFnRecorder[S]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.doReturnResults(func(sParam S, bParam bool) (string, error) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return sResults[0], err + }) +} + +func (r *partialGenericParamsFnRecorder[S]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.repeat(repeaters...) +} + +func (r *partialGenericParamsFnRecorder[S]) isNil() bool { + return r.r == nil +} + +type exportedPartialGenericParamsFnAdaptor[S any] struct { + //nolint:structcheck // definitely used + m *exported.MoqPartialGenericParamsFn[S] +} + +func (a *exportedPartialGenericParamsFnAdaptor[S]) config() adaptorConfig { + return adaptorConfig{exported: true} +} + +func (a *exportedPartialGenericParamsFnAdaptor[S]) mock() interface{} { return a.m.Mock() } + +func (a *exportedPartialGenericParamsFnAdaptor[S]) newRecorder(sParams []S, bParam bool) recorder { + return &exportedPartialGenericParamsFnRecorder[S]{r: a.m.OnCall(sParams[0], bParam)} +} + +func (a *exportedPartialGenericParamsFnAdaptor[S]) invokeMockAndExpectResults( + t moq.T, sParams []S, bParam bool, res results, +) { + sResult, err := a.m.Mock()(sParams[0], bParam) + if sResult != res.sResults[0] { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if err != res.err { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *exportedPartialGenericParamsFnAdaptor[S]) prettyParams(sParams []S, bParam bool) string { + return fmt.Sprintf("PartialGenericParamsFn(%#v, %#v)", sParams[0], bParam) +} + +func (a *exportedPartialGenericParamsFnAdaptor[S]) sceneMoq() moq.Moq { + return a.m +} + +type exportedPartialGenericParamsFnRecorder[S any] struct { + //nolint:structcheck // definitely used + r *exported.MoqPartialGenericParamsFn_fnRecorder[S] +} + +func (r *exportedPartialGenericParamsFnRecorder[S]) anySParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param1() + } +} + +func (r *exportedPartialGenericParamsFnRecorder[S]) anyBParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param2() + } +} + +func (r *exportedPartialGenericParamsFnRecorder[S]) seq() { + r.r = r.r.Seq() +} + +func (r *exportedPartialGenericParamsFnRecorder[S]) noSeq() { + r.r = r.r.NoSeq() +} + +func (r *exportedPartialGenericParamsFnRecorder[S]) returnResults(sResults []string, err error) { + r.r = r.r.ReturnResults(sResults[0], err) +} + +func (r *exportedPartialGenericParamsFnRecorder[S]) andDo( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, +) { + r.r = r.r.AndDo(func(sParam S, bParam bool) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *exportedPartialGenericParamsFnRecorder[S]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.DoReturnResults(func(sParam S, bParam bool) (string, error) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return sResults[0], err + }) +} + +func (r *exportedPartialGenericParamsFnRecorder[S]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.Repeat(repeaters...) +} + +func (r *exportedPartialGenericParamsFnRecorder[S]) isNil() bool { + return r.r == nil +} + +type genericResultsFnAdaptor[S ~string, E error] struct { + //nolint:structcheck // definitely used + m *moqGenericResultsFn[S, E] +} + +func (a *genericResultsFnAdaptor[S, E]) config() adaptorConfig { return adaptorConfig{} } + +func (a *genericResultsFnAdaptor[S, E]) mock() interface{} { return a.m.mock() } + +func (a *genericResultsFnAdaptor[S, E]) newRecorder(sParams []string, bParam bool) recorder { + return &genericResultsFnRecorder[S, E]{r: a.m.onCall(sParams[0], bParam)} +} + +func (a *genericResultsFnAdaptor[S, E]) invokeMockAndExpectResults( + t moq.T, sParams []string, bParam bool, res results, +) { + sResult, err := a.m.mock()(sParams[0], bParam) + if !reflect.DeepEqual(sResult, res.sResults[0]) { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if !reflect.DeepEqual(err, res.err) { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *genericResultsFnAdaptor[S, E]) prettyParams(sParams []string, bParam bool) string { + return fmt.Sprintf("GenericResultsFn(%#v, %#v)", sParams[0], bParam) +} + +func (a *genericResultsFnAdaptor[S, E]) sceneMoq() moq.Moq { + return a.m +} + +type genericResultsFnRecorder[S ~string, E error] struct { + //nolint:structcheck // definitely used + r *moqGenericResultsFn_fnRecorder[S, E] +} + +func (r *genericResultsFnRecorder[S, E]) anySParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param1() + } +} + +func (r *genericResultsFnRecorder[S, E]) anyBParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param2() + } +} + +func (r *genericResultsFnRecorder[S, E]) seq() { + r.r = r.r.seq() +} + +func (r *genericResultsFnRecorder[S, E]) noSeq() { + r.r = r.r.noSeq() +} + +func (r *genericResultsFnRecorder[S, E]) returnResults(sResults []string, err error) { + var e E + if err != nil { + e = err.(E) + } + r.r = r.r.returnResults(S(sResults[0]), e) +} + +func (r *genericResultsFnRecorder[S, E]) andDo(t moq.T, fn func(), expectedSParams []string, expectedBParam bool) { + r.r = r.r.andDo(func(sParam string, bParam bool) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *genericResultsFnRecorder[S, E]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.doReturnResults(func(sParam string, bParam bool) (S, E) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + var e E + if err != nil { + e = err.(E) + } + return S(sResults[0]), e + }) +} + +func (r *genericResultsFnRecorder[S, E]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.repeat(repeaters...) +} + +func (r *genericResultsFnRecorder[S, E]) isNil() bool { + return r.r == nil +} + +type exportedGenericResultsFnAdaptor[S ~string, E error] struct { + //nolint:structcheck // definitely used + m *exported.MoqGenericResultsFn[S, E] +} + +func (a *exportedGenericResultsFnAdaptor[S, E]) config() adaptorConfig { + return adaptorConfig{exported: true} +} + +func (a *exportedGenericResultsFnAdaptor[S, E]) mock() interface{} { return a.m.Mock() } + +func (a *exportedGenericResultsFnAdaptor[S, E]) newRecorder(sParams []string, bParam bool) recorder { + return &exportedGenericResultsFnRecorder[S, E]{r: a.m.OnCall(sParams[0], bParam)} +} + +func (a *exportedGenericResultsFnAdaptor[S, E]) invokeMockAndExpectResults( + t moq.T, sParams []string, bParam bool, res results, +) { + sResult, err := a.m.Mock()(sParams[0], bParam) + if !reflect.DeepEqual(sResult, res.sResults[0]) { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if !reflect.DeepEqual(err, res.err) { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *exportedGenericResultsFnAdaptor[S, E]) prettyParams(sParams []string, bParam bool) string { + return fmt.Sprintf("GenericResultsFn(%#v, %#v)", sParams[0], bParam) +} + +func (a *exportedGenericResultsFnAdaptor[S, E]) sceneMoq() moq.Moq { + return a.m +} + +type exportedGenericResultsFnRecorder[S ~string, E error] struct { + //nolint:structcheck // definitely used + r *exported.MoqGenericResultsFn_fnRecorder[S, E] +} + +func (r *exportedGenericResultsFnRecorder[S, E]) anySParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param1() + } +} + +func (r *exportedGenericResultsFnRecorder[S, E]) anyBParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param2() + } +} + +func (r *exportedGenericResultsFnRecorder[S, E]) seq() { + r.r = r.r.Seq() +} + +func (r *exportedGenericResultsFnRecorder[S, E]) noSeq() { + r.r = r.r.NoSeq() +} + +func (r *exportedGenericResultsFnRecorder[S, E]) returnResults(sResults []string, err error) { + var e E + if err != nil { + e = err.(E) + } + r.r = r.r.ReturnResults(S(sResults[0]), e) +} + +func (r *exportedGenericResultsFnRecorder[S, E]) andDo( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, +) { + r.r = r.r.AndDo(func(sParam string, bParam bool) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *exportedGenericResultsFnRecorder[S, E]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.DoReturnResults(func(sParam string, bParam bool) (S, E) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + var e E + if err != nil { + e = err.(E) + } + return S(sResults[0]), e + }) +} + +func (r *exportedGenericResultsFnRecorder[S, E]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.Repeat(repeaters...) +} + +func (r *exportedGenericResultsFnRecorder[S, E]) isNil() bool { + return r.r == nil +} + +type partialGenericResultsFnAdaptor[S ~string] struct { + //nolint:structcheck // definitely used + m *moqPartialGenericResultsFn[S] +} + +func (a *partialGenericResultsFnAdaptor[S]) config() adaptorConfig { return adaptorConfig{} } + +func (a *partialGenericResultsFnAdaptor[S]) mock() interface{} { return a.m.mock() } + +func (a *partialGenericResultsFnAdaptor[S]) newRecorder(sParams []string, bParam bool) recorder { + return &partialGenericResultsFnRecorder[S]{r: a.m.onCall(sParams[0], bParam)} +} + +func (a *partialGenericResultsFnAdaptor[S]) invokeMockAndExpectResults( + t moq.T, sParams []string, bParam bool, res results, +) { + sResult, err := a.m.mock()(sParams[0], bParam) + if !reflect.DeepEqual(sResult, res.sResults[0]) { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if !reflect.DeepEqual(err, res.err) { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *partialGenericResultsFnAdaptor[S]) prettyParams(sParams []string, bParam bool) string { + return fmt.Sprintf("PartialGenericResultsFn(%#v, %#v)", sParams[0], bParam) +} + +func (a *partialGenericResultsFnAdaptor[S]) sceneMoq() moq.Moq { + return a.m +} + +type partialGenericResultsFnRecorder[S ~string] struct { + //nolint:structcheck // definitely used + r *moqPartialGenericResultsFn_fnRecorder[S] +} + +func (r *partialGenericResultsFnRecorder[S]) anySParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param1() + } +} + +func (r *partialGenericResultsFnRecorder[S]) anyBParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param2() + } +} + +func (r *partialGenericResultsFnRecorder[S]) seq() { + r.r = r.r.seq() +} + +func (r *partialGenericResultsFnRecorder[S]) noSeq() { + r.r = r.r.noSeq() +} + +func (r *partialGenericResultsFnRecorder[S]) returnResults(sResults []string, err error) { + r.r = r.r.returnResults(S(sResults[0]), err) +} + +func (r *partialGenericResultsFnRecorder[S]) andDo( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, +) { + r.r = r.r.andDo(func(sParam string, bParam bool) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *partialGenericResultsFnRecorder[S]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.doReturnResults(func(sParam string, bParam bool) (S, error) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return S(sResults[0]), err + }) +} + +func (r *partialGenericResultsFnRecorder[S]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.repeat(repeaters...) +} + +func (r *partialGenericResultsFnRecorder[S]) isNil() bool { + return r.r == nil +} + +type exportedPartialGenericResultsFnAdaptor[S ~string] struct { + //nolint:structcheck // definitely used + m *exported.MoqPartialGenericResultsFn[S] +} + +func (a *exportedPartialGenericResultsFnAdaptor[S]) config() adaptorConfig { + return adaptorConfig{exported: true} +} + +func (a *exportedPartialGenericResultsFnAdaptor[S]) mock() interface{} { return a.m.Mock() } + +func (a *exportedPartialGenericResultsFnAdaptor[S]) newRecorder(sParams []string, bParam bool) recorder { + return &exportedPartialGenericResultsFnRecorder[S]{r: a.m.OnCall(sParams[0], bParam)} +} + +func (a *exportedPartialGenericResultsFnAdaptor[S]) invokeMockAndExpectResults( + t moq.T, sParams []string, bParam bool, res results, +) { + sResult, err := a.m.Mock()(sParams[0], bParam) + if !reflect.DeepEqual(sResult, res.sResults[0]) { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if !reflect.DeepEqual(err, res.err) { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *exportedPartialGenericResultsFnAdaptor[S]) prettyParams(sParams []string, bParam bool) string { + return fmt.Sprintf("PartialGenericResultsFn(%#v, %#v)", sParams[0], bParam) +} + +func (a *exportedPartialGenericResultsFnAdaptor[S]) sceneMoq() moq.Moq { + return a.m +} + +type exportedPartialGenericResultsFnRecorder[S ~string] struct { + //nolint:structcheck // definitely used + r *exported.MoqPartialGenericResultsFn_fnRecorder[S] +} + +func (r *exportedPartialGenericResultsFnRecorder[S]) anySParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param1() + } +} + +func (r *exportedPartialGenericResultsFnRecorder[S]) anyBParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param2() + } +} + +func (r *exportedPartialGenericResultsFnRecorder[S]) seq() { + r.r = r.r.Seq() +} + +func (r *exportedPartialGenericResultsFnRecorder[S]) noSeq() { + r.r = r.r.NoSeq() +} + +func (r *exportedPartialGenericResultsFnRecorder[S]) returnResults(sResults []string, err error) { + r.r = r.r.ReturnResults(S(sResults[0]), err) +} + +func (r *exportedPartialGenericResultsFnRecorder[S]) andDo( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, +) { + r.r = r.r.AndDo(func(sParam string, bParam bool) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *exportedPartialGenericResultsFnRecorder[S]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.DoReturnResults(func(sParam string, bParam bool) (S, error) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return S(sResults[0]), err + }) +} + +func (r *exportedPartialGenericResultsFnRecorder[S]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.Repeat(repeaters...) +} + +func (r *exportedPartialGenericResultsFnRecorder[S]) isNil() bool { + return r.r == nil +} diff --git a/generator/testmoqs/moq_testmoqs_test.go b/generator/testmoqs/moq_testmoqs_test.go index 847f8cb..6692740 100644 --- a/generator/testmoqs/moq_testmoqs_test.go +++ b/generator/testmoqs/moq_testmoqs_test.go @@ -5422,1172 +5422,956 @@ func (m *moqInterfaceResultFn) AssertExpectationsMet() { } } -// The following type assertion assures that testmoqs.Usual is mocked -// completely -var _ testmoqs.Usual = (*moqUsual_mock)(nil) - -// moqUsual holds the state of a moq of the Usual type -type moqUsual struct { +// moqGenericParamsFn holds the state of a moq of the GenericParamsFn type +type moqGenericParamsFn[S, B any] struct { scene *moq.Scene config moq.Config - moq *moqUsual_mock + moq *moqGenericParamsFn_mock[S, B] - resultsByParams_Usual []moqUsual_Usual_resultsByParams - resultsByParams_NoNames []moqUsual_NoNames_resultsByParams - resultsByParams_NoResults []moqUsual_NoResults_resultsByParams - resultsByParams_NoParams []moqUsual_NoParams_resultsByParams - resultsByParams_Nothing []moqUsual_Nothing_resultsByParams - resultsByParams_Variadic []moqUsual_Variadic_resultsByParams - resultsByParams_RepeatedIds []moqUsual_RepeatedIds_resultsByParams - resultsByParams_Times []moqUsual_Times_resultsByParams - resultsByParams_DifficultParamNames []moqUsual_DifficultParamNames_resultsByParams - resultsByParams_DifficultResultNames []moqUsual_DifficultResultNames_resultsByParams - resultsByParams_PassByReference []moqUsual_PassByReference_resultsByParams - resultsByParams_InterfaceParam []moqUsual_InterfaceParam_resultsByParams - resultsByParams_InterfaceResult []moqUsual_InterfaceResult_resultsByParams - resultsByParams_FnParam []moqUsual_FnParam_resultsByParams + resultsByParams []moqGenericParamsFn_resultsByParams[S, B] runtime struct { parameterIndexing struct { - Usual struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - NoNames struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - NoResults struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - NoParams struct{} - Nothing struct{} - Variadic struct { - other moq.ParamIndexing - args moq.ParamIndexing - } - RepeatedIds struct { - sParam1 moq.ParamIndexing - sParam2 moq.ParamIndexing - bParam moq.ParamIndexing - } - Times struct { - sParam moq.ParamIndexing - times moq.ParamIndexing - } - DifficultParamNames struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - param3 moq.ParamIndexing - param moq.ParamIndexing - param5 moq.ParamIndexing - param6 moq.ParamIndexing - param7 moq.ParamIndexing - param8 moq.ParamIndexing - param9 moq.ParamIndexing - } - DifficultResultNames struct{} - PassByReference struct { - p moq.ParamIndexing - } - InterfaceParam struct { - w moq.ParamIndexing - } - InterfaceResult struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - FnParam struct { - fn moq.ParamIndexing - } + param1 moq.ParamIndexing + param2 moq.ParamIndexing } } - // moqUsual_mock isolates the mock interface of the Usual type -} - -type moqUsual_mock struct { - moq *moqUsual } -// moqUsual_recorder isolates the recorder interface of the Usual type -type moqUsual_recorder struct { - moq *moqUsual +// moqGenericParamsFn_mock isolates the mock interface of the GenericParamsFn +// type +type moqGenericParamsFn_mock[S, B any] struct { + moq *moqGenericParamsFn[S, B] } -// moqUsual_Usual_params holds the params of the Usual type -type moqUsual_Usual_params struct { - sParam string - bParam bool +// moqGenericParamsFn_params holds the params of the GenericParamsFn type +type moqGenericParamsFn_params[S, B any] struct { + param1 S + param2 B } -// moqUsual_Usual_paramsKey holds the map key params of the Usual type -type moqUsual_Usual_paramsKey struct { - params struct { - sParam string - bParam bool - } +// moqGenericParamsFn_paramsKey holds the map key params of the GenericParamsFn +// type +type moqGenericParamsFn_paramsKey[S, B any] struct { + params struct{} hashes struct { - sParam hash.Hash - bParam hash.Hash + param1 hash.Hash + param2 hash.Hash } } -// moqUsual_Usual_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_Usual_resultsByParams struct { +// moqGenericParamsFn_resultsByParams contains the results for a given set of +// parameters for the GenericParamsFn type +type moqGenericParamsFn_resultsByParams[S, B any] struct { anyCount int anyParams uint64 - results map[moqUsual_Usual_paramsKey]*moqUsual_Usual_results + results map[moqGenericParamsFn_paramsKey[S, B]]*moqGenericParamsFn_results[S, B] } -// moqUsual_Usual_doFn defines the type of function needed when calling andDo -// for the Usual type -type moqUsual_Usual_doFn func(sParam string, bParam bool) +// moqGenericParamsFn_doFn defines the type of function needed when calling +// andDo for the GenericParamsFn type +type moqGenericParamsFn_doFn[S, B any] func(S, B) -// moqUsual_Usual_doReturnFn defines the type of function needed when calling -// doReturnResults for the Usual type -type moqUsual_Usual_doReturnFn func(sParam string, bParam bool) (sResult string, err error) +// moqGenericParamsFn_doReturnFn defines the type of function needed when +// calling doReturnResults for the GenericParamsFn type +type moqGenericParamsFn_doReturnFn[S, B any] func(S, B) (string, error) -// moqUsual_Usual_results holds the results of the Usual type -type moqUsual_Usual_results struct { - params moqUsual_Usual_params +// moqGenericParamsFn_results holds the results of the GenericParamsFn type +type moqGenericParamsFn_results[S, B any] struct { + params moqGenericParamsFn_params[S, B] results []struct { values *struct { - sResult string - err error + result1 string + result2 error } sequence uint32 - doFn moqUsual_Usual_doFn - doReturnFn moqUsual_Usual_doReturnFn + doFn moqGenericParamsFn_doFn[S, B] + doReturnFn moqGenericParamsFn_doReturnFn[S, B] } index uint32 repeat *moq.RepeatVal } -// moqUsual_Usual_fnRecorder routes recorded function calls to the moqUsual moq -type moqUsual_Usual_fnRecorder struct { - params moqUsual_Usual_params +// moqGenericParamsFn_fnRecorder routes recorded function calls to the +// moqGenericParamsFn moq +type moqGenericParamsFn_fnRecorder[S, B any] struct { + params moqGenericParamsFn_params[S, B] anyParams uint64 sequence bool - results *moqUsual_Usual_results - moq *moqUsual -} - -// moqUsual_Usual_anyParams isolates the any params functions of the Usual type -type moqUsual_Usual_anyParams struct { - recorder *moqUsual_Usual_fnRecorder + results *moqGenericParamsFn_results[S, B] + moq *moqGenericParamsFn[S, B] } -// moqUsual_NoNames_params holds the params of the Usual type -type moqUsual_NoNames_params struct { - param1 string - param2 bool +// moqGenericParamsFn_anyParams isolates the any params functions of the +// GenericParamsFn type +type moqGenericParamsFn_anyParams[S, B any] struct { + recorder *moqGenericParamsFn_fnRecorder[S, B] } -// moqUsual_NoNames_paramsKey holds the map key params of the Usual type -type moqUsual_NoNames_paramsKey struct { - params struct { - param1 string - param2 bool +// newMoqGenericParamsFn creates a new moq of the GenericParamsFn type +func newMoqGenericParamsFn[S, B any](scene *moq.Scene, config *moq.Config) *moqGenericParamsFn[S, B] { + if config == nil { + config = &moq.Config{} } - hashes struct { - param1 hash.Hash - param2 hash.Hash + m := &moqGenericParamsFn[S, B]{ + scene: scene, + config: *config, + moq: &moqGenericParamsFn_mock[S, B]{}, + + runtime: struct { + parameterIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + }{parameterIndexing: struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + }{ + param1: moq.ParamIndexByHash, + param2: moq.ParamIndexByHash, + }}, } + m.moq.moq = m + + scene.AddMoq(m) + return m } -// moqUsual_NoNames_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_NoNames_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_NoNames_paramsKey]*moqUsual_NoNames_results +// mock returns the moq implementation of the GenericParamsFn type +func (m *moqGenericParamsFn[S, B]) mock() testmoqs.GenericParamsFn[S, B] { + return func(param1 S, param2 B) (string, error) { + m.scene.T.Helper() + moq := &moqGenericParamsFn_mock[S, B]{moq: m} + return moq.fn(param1, param2) + } } -// moqUsual_NoNames_doFn defines the type of function needed when calling andDo -// for the Usual type -type moqUsual_NoNames_doFn func(string, bool) +func (m *moqGenericParamsFn_mock[S, B]) fn(param1 S, param2 B) (result1 string, result2 error) { + m.moq.scene.T.Helper() + params := moqGenericParamsFn_params[S, B]{ + param1: param1, + param2: param2, + } + var results *moqGenericParamsFn_results[S, B] + for _, resultsByParams := range m.moq.resultsByParams { + paramsKey := m.moq.paramsKey(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams(params)) + } + return + } -// moqUsual_NoNames_doReturnFn defines the type of function needed when calling -// doReturnResults for the Usual type -type moqUsual_NoNames_doReturnFn func(string, bool) (string, error) + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } -// moqUsual_NoNames_results holds the results of the Usual type -type moqUsual_NoNames_results struct { - params moqUsual_NoNames_params - results []struct { - values *struct { - result1 string - result2 error + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams(params)) } - sequence uint32 - doFn moqUsual_NoNames_doFn - doReturnFn moqUsual_NoNames_doReturnFn } - index uint32 - repeat *moq.RepeatVal -} -// moqUsual_NoNames_fnRecorder routes recorded function calls to the moqUsual -// moq -type moqUsual_NoNames_fnRecorder struct { - params moqUsual_NoNames_params - anyParams uint64 - sequence bool - results *moqUsual_NoNames_results - moq *moqUsual -} + if result.doFn != nil { + result.doFn(param1, param2) + } -// moqUsual_NoNames_anyParams isolates the any params functions of the Usual -// type -type moqUsual_NoNames_anyParams struct { - recorder *moqUsual_NoNames_fnRecorder + if result.values != nil { + result1 = result.values.result1 + result2 = result.values.result2 + } + if result.doReturnFn != nil { + result1, result2 = result.doReturnFn(param1, param2) + } + return } -// moqUsual_NoResults_params holds the params of the Usual type -type moqUsual_NoResults_params struct { - sParam string - bParam bool +func (m *moqGenericParamsFn[S, B]) onCall(param1 S, param2 B) *moqGenericParamsFn_fnRecorder[S, B] { + return &moqGenericParamsFn_fnRecorder[S, B]{ + params: moqGenericParamsFn_params[S, B]{ + param1: param1, + param2: param2, + }, + sequence: m.config.Sequence == moq.SeqDefaultOn, + moq: m, + } } -// moqUsual_NoResults_paramsKey holds the map key params of the Usual type -type moqUsual_NoResults_paramsKey struct { - params struct { - sParam string - bParam bool - } - hashes struct { - sParam hash.Hash - bParam hash.Hash +func (r *moqGenericParamsFn_fnRecorder[S, B]) any() *moqGenericParamsFn_anyParams[S, B] { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) + return nil } + return &moqGenericParamsFn_anyParams[S, B]{recorder: r} } -// moqUsual_NoResults_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_NoResults_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_NoResults_paramsKey]*moqUsual_NoResults_results +func (a *moqGenericParamsFn_anyParams[S, B]) param1() *moqGenericParamsFn_fnRecorder[S, B] { + a.recorder.anyParams |= 1 << 0 + return a.recorder } -// moqUsual_NoResults_doFn defines the type of function needed when calling -// andDo for the Usual type -type moqUsual_NoResults_doFn func(sParam string, bParam bool) - -// moqUsual_NoResults_doReturnFn defines the type of function needed when -// calling doReturnResults for the Usual type -type moqUsual_NoResults_doReturnFn func(sParam string, bParam bool) +func (a *moqGenericParamsFn_anyParams[S, B]) param2() *moqGenericParamsFn_fnRecorder[S, B] { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} -// moqUsual_NoResults_results holds the results of the Usual type -type moqUsual_NoResults_results struct { - params moqUsual_NoResults_params - results []struct { - values *struct{} - sequence uint32 - doFn moqUsual_NoResults_doFn - doReturnFn moqUsual_NoResults_doReturnFn +func (r *moqGenericParamsFn_fnRecorder[S, B]) seq() *moqGenericParamsFn_fnRecorder[S, B] { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) + return nil } - index uint32 - repeat *moq.RepeatVal + r.sequence = true + return r } -// moqUsual_NoResults_fnRecorder routes recorded function calls to the moqUsual -// moq -type moqUsual_NoResults_fnRecorder struct { - params moqUsual_NoResults_params - anyParams uint64 - sequence bool - results *moqUsual_NoResults_results - moq *moqUsual +func (r *moqGenericParamsFn_fnRecorder[S, B]) noSeq() *moqGenericParamsFn_fnRecorder[S, B] { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) + return nil + } + r.sequence = false + return r } -// moqUsual_NoResults_anyParams isolates the any params functions of the Usual -// type -type moqUsual_NoResults_anyParams struct { - recorder *moqUsual_NoResults_fnRecorder -} +func (r *moqGenericParamsFn_fnRecorder[S, B]) returnResults(result1 string, result2 error) *moqGenericParamsFn_fnRecorder[S, B] { + r.moq.scene.T.Helper() + r.findResults() -// moqUsual_NoParams_params holds the params of the Usual type -type moqUsual_NoParams_params struct{} + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } -// moqUsual_NoParams_paramsKey holds the map key params of the Usual type -type moqUsual_NoParams_paramsKey struct { - params struct{} - hashes struct{} + r.results.results = append(r.results.results, struct { + values *struct { + result1 string + result2 error + } + sequence uint32 + doFn moqGenericParamsFn_doFn[S, B] + doReturnFn moqGenericParamsFn_doReturnFn[S, B] + }{ + values: &struct { + result1 string + result2 error + }{ + result1: result1, + result2: result2, + }, + sequence: sequence, + }) + return r } -// moqUsual_NoParams_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_NoParams_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_NoParams_paramsKey]*moqUsual_NoParams_results +func (r *moqGenericParamsFn_fnRecorder[S, B]) andDo(fn moqGenericParamsFn_doFn[S, B]) *moqGenericParamsFn_fnRecorder[S, B] { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r } -// moqUsual_NoParams_doFn defines the type of function needed when calling -// andDo for the Usual type -type moqUsual_NoParams_doFn func() +func (r *moqGenericParamsFn_fnRecorder[S, B]) doReturnResults(fn moqGenericParamsFn_doReturnFn[S, B]) *moqGenericParamsFn_fnRecorder[S, B] { + r.moq.scene.T.Helper() + r.findResults() -// moqUsual_NoParams_doReturnFn defines the type of function needed when -// calling doReturnResults for the Usual type -type moqUsual_NoParams_doReturnFn func() (sResult string, err error) + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } -// moqUsual_NoParams_results holds the results of the Usual type -type moqUsual_NoParams_results struct { - params moqUsual_NoParams_params - results []struct { + r.results.results = append(r.results.results, struct { values *struct { - sResult string - err error + result1 string + result2 error } sequence uint32 - doFn moqUsual_NoParams_doFn - doReturnFn moqUsual_NoParams_doReturnFn - } - index uint32 - repeat *moq.RepeatVal + doFn moqGenericParamsFn_doFn[S, B] + doReturnFn moqGenericParamsFn_doReturnFn[S, B] + }{sequence: sequence, doReturnFn: fn}) + return r } -// moqUsual_NoParams_fnRecorder routes recorded function calls to the moqUsual -// moq -type moqUsual_NoParams_fnRecorder struct { - params moqUsual_NoParams_params - anyParams uint64 - sequence bool - results *moqUsual_NoParams_results - moq *moqUsual -} +func (r *moqGenericParamsFn_fnRecorder[S, B]) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } -// moqUsual_NoParams_anyParams isolates the any params functions of the Usual -// type -type moqUsual_NoParams_anyParams struct { - recorder *moqUsual_NoParams_fnRecorder -} + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqGenericParamsFn_resultsByParams[S, B] + for n, res := range r.moq.resultsByParams { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqGenericParamsFn_resultsByParams[S, B]{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqGenericParamsFn_paramsKey[S, B]]*moqGenericParamsFn_results[S, B]{}, + } + r.moq.resultsByParams = append(r.moq.resultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams) { + copy(r.moq.resultsByParams[insertAt+1:], r.moq.resultsByParams[insertAt:0]) + r.moq.resultsByParams[insertAt] = *results + } + } -// moqUsual_Nothing_params holds the params of the Usual type -type moqUsual_Nothing_params struct{} + paramsKey := r.moq.paramsKey(r.params, r.anyParams) -// moqUsual_Nothing_paramsKey holds the map key params of the Usual type -type moqUsual_Nothing_paramsKey struct { - params struct{} - hashes struct{} -} + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqGenericParamsFn_results[S, B]{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } -// moqUsual_Nothing_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_Nothing_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_Nothing_paramsKey]*moqUsual_Nothing_results + r.results.repeat.Increment(r.moq.scene.T) } -// moqUsual_Nothing_doFn defines the type of function needed when calling andDo -// for the Usual type -type moqUsual_Nothing_doFn func() - -// moqUsual_Nothing_doReturnFn defines the type of function needed when calling -// doReturnResults for the Usual type -type moqUsual_Nothing_doReturnFn func() - -// moqUsual_Nothing_results holds the results of the Usual type -type moqUsual_Nothing_results struct { - params moqUsual_Nothing_params - results []struct { - values *struct{} - sequence uint32 - doFn moqUsual_Nothing_doFn - doReturnFn moqUsual_Nothing_doReturnFn +func (r *moqGenericParamsFn_fnRecorder[S, B]) repeat(repeaters ...moq.Repeater) *moqGenericParamsFn_fnRecorder[S, B] { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsual_Nothing_fnRecorder routes recorded function calls to the moqUsual -// moq -type moqUsual_Nothing_fnRecorder struct { - params moqUsual_Nothing_params - anyParams uint64 - sequence bool - results *moqUsual_Nothing_results - moq *moqUsual + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct { + result1 string + result2 error + } + sequence uint32 + doFn moqGenericParamsFn_doFn[S, B] + doReturnFn moqGenericParamsFn_doReturnFn[S, B] + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r } -// moqUsual_Nothing_anyParams isolates the any params functions of the Usual -// type -type moqUsual_Nothing_anyParams struct { - recorder *moqUsual_Nothing_fnRecorder +func (m *moqGenericParamsFn[S, B]) prettyParams(params moqGenericParamsFn_params[S, B]) string { + return fmt.Sprintf("GenericParamsFn(%#v, %#v)", params.param1, params.param2) } -// moqUsual_Variadic_params holds the params of the Usual type -type moqUsual_Variadic_params struct { - other bool - args []string -} - -// moqUsual_Variadic_paramsKey holds the map key params of the Usual type -type moqUsual_Variadic_paramsKey struct { - params struct{ other bool } - hashes struct { - other hash.Hash - args hash.Hash +func (m *moqGenericParamsFn[S, B]) paramsKey(params moqGenericParamsFn_params[S, B], anyParams uint64) moqGenericParamsFn_paramsKey[S, B] { + m.scene.T.Helper() + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.param1 == moq.ParamIndexByValue { + m.scene.T.Fatalf("The param1 parameter can't be indexed by value") + } + param1UsedHash = hash.DeepHash(params.param1) + } + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.param2 == moq.ParamIndexByValue { + m.scene.T.Fatalf("The param2 parameter can't be indexed by value") + } + param2UsedHash = hash.DeepHash(params.param2) + } + return moqGenericParamsFn_paramsKey[S, B]{ + params: struct{}{}, + hashes: struct { + param1 hash.Hash + param2 hash.Hash + }{ + param1: param1UsedHash, + param2: param2UsedHash, + }, } } -// moqUsual_Variadic_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_Variadic_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_Variadic_paramsKey]*moqUsual_Variadic_results +// Reset resets the state of the moq +func (m *moqGenericParamsFn[S, B]) Reset() { m.resultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqGenericParamsFn[S, B]) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams(results.params)) + } + } + } } -// moqUsual_Variadic_doFn defines the type of function needed when calling -// andDo for the Usual type -type moqUsual_Variadic_doFn func(other bool, args ...string) +// moqPartialGenericParamsFn holds the state of a moq of the +// PartialGenericParamsFn type +type moqPartialGenericParamsFn[S any] struct { + scene *moq.Scene + config moq.Config + moq *moqPartialGenericParamsFn_mock[S] -// moqUsual_Variadic_doReturnFn defines the type of function needed when -// calling doReturnResults for the Usual type -type moqUsual_Variadic_doReturnFn func(other bool, args ...string) (sResult string, err error) + resultsByParams []moqPartialGenericParamsFn_resultsByParams[S] -// moqUsual_Variadic_results holds the results of the Usual type -type moqUsual_Variadic_results struct { - params moqUsual_Variadic_params - results []struct { - values *struct { - sResult string - err error + runtime struct { + parameterIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } - sequence uint32 - doFn moqUsual_Variadic_doFn - doReturnFn moqUsual_Variadic_doReturnFn } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsual_Variadic_fnRecorder routes recorded function calls to the moqUsual -// moq -type moqUsual_Variadic_fnRecorder struct { - params moqUsual_Variadic_params - anyParams uint64 - sequence bool - results *moqUsual_Variadic_results - moq *moqUsual } -// moqUsual_Variadic_anyParams isolates the any params functions of the Usual -// type -type moqUsual_Variadic_anyParams struct { - recorder *moqUsual_Variadic_fnRecorder +// moqPartialGenericParamsFn_mock isolates the mock interface of the +// PartialGenericParamsFn type +type moqPartialGenericParamsFn_mock[S any] struct { + moq *moqPartialGenericParamsFn[S] } -// moqUsual_RepeatedIds_params holds the params of the Usual type -type moqUsual_RepeatedIds_params struct { - sParam1, sParam2 string - bParam bool +// moqPartialGenericParamsFn_params holds the params of the +// PartialGenericParamsFn type +type moqPartialGenericParamsFn_params[S any] struct { + param1 S + param2 bool } -// moqUsual_RepeatedIds_paramsKey holds the map key params of the Usual type -type moqUsual_RepeatedIds_paramsKey struct { - params struct { - sParam1, sParam2 string - bParam bool - } +// moqPartialGenericParamsFn_paramsKey holds the map key params of the +// PartialGenericParamsFn type +type moqPartialGenericParamsFn_paramsKey[S any] struct { + params struct{ param2 bool } hashes struct { - sParam1, sParam2 hash.Hash - bParam hash.Hash + param1 hash.Hash + param2 hash.Hash } } -// moqUsual_RepeatedIds_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_RepeatedIds_resultsByParams struct { +// moqPartialGenericParamsFn_resultsByParams contains the results for a given +// set of parameters for the PartialGenericParamsFn type +type moqPartialGenericParamsFn_resultsByParams[S any] struct { anyCount int anyParams uint64 - results map[moqUsual_RepeatedIds_paramsKey]*moqUsual_RepeatedIds_results + results map[moqPartialGenericParamsFn_paramsKey[S]]*moqPartialGenericParamsFn_results[S] } -// moqUsual_RepeatedIds_doFn defines the type of function needed when calling -// andDo for the Usual type -type moqUsual_RepeatedIds_doFn func(sParam1, sParam2 string, bParam bool) +// moqPartialGenericParamsFn_doFn defines the type of function needed when +// calling andDo for the PartialGenericParamsFn type +type moqPartialGenericParamsFn_doFn[S any] func(S, bool) -// moqUsual_RepeatedIds_doReturnFn defines the type of function needed when -// calling doReturnResults for the Usual type -type moqUsual_RepeatedIds_doReturnFn func(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) +// moqPartialGenericParamsFn_doReturnFn defines the type of function needed +// when calling doReturnResults for the PartialGenericParamsFn type +type moqPartialGenericParamsFn_doReturnFn[S any] func(S, bool) (string, error) -// moqUsual_RepeatedIds_results holds the results of the Usual type -type moqUsual_RepeatedIds_results struct { - params moqUsual_RepeatedIds_params +// moqPartialGenericParamsFn_results holds the results of the +// PartialGenericParamsFn type +type moqPartialGenericParamsFn_results[S any] struct { + params moqPartialGenericParamsFn_params[S] results []struct { values *struct { - sResult1, sResult2 string - err error + result1 string + result2 error } sequence uint32 - doFn moqUsual_RepeatedIds_doFn - doReturnFn moqUsual_RepeatedIds_doReturnFn + doFn moqPartialGenericParamsFn_doFn[S] + doReturnFn moqPartialGenericParamsFn_doReturnFn[S] } index uint32 repeat *moq.RepeatVal } -// moqUsual_RepeatedIds_fnRecorder routes recorded function calls to the -// moqUsual moq -type moqUsual_RepeatedIds_fnRecorder struct { - params moqUsual_RepeatedIds_params +// moqPartialGenericParamsFn_fnRecorder routes recorded function calls to the +// moqPartialGenericParamsFn moq +type moqPartialGenericParamsFn_fnRecorder[S any] struct { + params moqPartialGenericParamsFn_params[S] anyParams uint64 sequence bool - results *moqUsual_RepeatedIds_results - moq *moqUsual -} - -// moqUsual_RepeatedIds_anyParams isolates the any params functions of the -// Usual type -type moqUsual_RepeatedIds_anyParams struct { - recorder *moqUsual_RepeatedIds_fnRecorder + results *moqPartialGenericParamsFn_results[S] + moq *moqPartialGenericParamsFn[S] } -// moqUsual_Times_params holds the params of the Usual type -type moqUsual_Times_params struct { - sParam string - times bool +// moqPartialGenericParamsFn_anyParams isolates the any params functions of the +// PartialGenericParamsFn type +type moqPartialGenericParamsFn_anyParams[S any] struct { + recorder *moqPartialGenericParamsFn_fnRecorder[S] } -// moqUsual_Times_paramsKey holds the map key params of the Usual type -type moqUsual_Times_paramsKey struct { - params struct { - sParam string - times bool +// newMoqPartialGenericParamsFn creates a new moq of the PartialGenericParamsFn +// type +func newMoqPartialGenericParamsFn[S any](scene *moq.Scene, config *moq.Config) *moqPartialGenericParamsFn[S] { + if config == nil { + config = &moq.Config{} } - hashes struct { - sParam hash.Hash - times hash.Hash + m := &moqPartialGenericParamsFn[S]{ + scene: scene, + config: *config, + moq: &moqPartialGenericParamsFn_mock[S]{}, + + runtime: struct { + parameterIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + }{parameterIndexing: struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + }{ + param1: moq.ParamIndexByHash, + param2: moq.ParamIndexByValue, + }}, } + m.moq.moq = m + + scene.AddMoq(m) + return m } -// moqUsual_Times_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_Times_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_Times_paramsKey]*moqUsual_Times_results +// mock returns the moq implementation of the PartialGenericParamsFn type +func (m *moqPartialGenericParamsFn[S]) mock() testmoqs.PartialGenericParamsFn[S] { + return func(param1 S, param2 bool) (string, error) { + m.scene.T.Helper() + moq := &moqPartialGenericParamsFn_mock[S]{moq: m} + return moq.fn(param1, param2) + } } -// moqUsual_Times_doFn defines the type of function needed when calling andDo -// for the Usual type -type moqUsual_Times_doFn func(sParam string, times bool) +func (m *moqPartialGenericParamsFn_mock[S]) fn(param1 S, param2 bool) (result1 string, result2 error) { + m.moq.scene.T.Helper() + params := moqPartialGenericParamsFn_params[S]{ + param1: param1, + param2: param2, + } + var results *moqPartialGenericParamsFn_results[S] + for _, resultsByParams := range m.moq.resultsByParams { + paramsKey := m.moq.paramsKey(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams(params)) + } + return + } -// moqUsual_Times_doReturnFn defines the type of function needed when calling -// doReturnResults for the Usual type -type moqUsual_Times_doReturnFn func(sParam string, times bool) (sResult string, err error) + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } -// moqUsual_Times_results holds the results of the Usual type -type moqUsual_Times_results struct { - params moqUsual_Times_params - results []struct { - values *struct { - sResult string - err error + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams(params)) } - sequence uint32 - doFn moqUsual_Times_doFn - doReturnFn moqUsual_Times_doReturnFn } - index uint32 - repeat *moq.RepeatVal -} -// moqUsual_Times_fnRecorder routes recorded function calls to the moqUsual moq -type moqUsual_Times_fnRecorder struct { - params moqUsual_Times_params - anyParams uint64 - sequence bool - results *moqUsual_Times_results - moq *moqUsual + if result.doFn != nil { + result.doFn(param1, param2) + } + + if result.values != nil { + result1 = result.values.result1 + result2 = result.values.result2 + } + if result.doReturnFn != nil { + result1, result2 = result.doReturnFn(param1, param2) + } + return } -// moqUsual_Times_anyParams isolates the any params functions of the Usual type -type moqUsual_Times_anyParams struct { - recorder *moqUsual_Times_fnRecorder +func (m *moqPartialGenericParamsFn[S]) onCall(param1 S, param2 bool) *moqPartialGenericParamsFn_fnRecorder[S] { + return &moqPartialGenericParamsFn_fnRecorder[S]{ + params: moqPartialGenericParamsFn_params[S]{ + param1: param1, + param2: param2, + }, + sequence: m.config.Sequence == moq.SeqDefaultOn, + moq: m, + } } -// moqUsual_DifficultParamNames_params holds the params of the Usual type -type moqUsual_DifficultParamNames_params struct { - param1, param2 bool - param3 string - param, param5, param6 int - param7, param8, param9 float32 -} - -// moqUsual_DifficultParamNames_paramsKey holds the map key params of the Usual -// type -type moqUsual_DifficultParamNames_paramsKey struct { - params struct { - param1, param2 bool - param3 string - param, param5, param6 int - param7, param8, param9 float32 - } - hashes struct { - param1, param2 hash.Hash - param3 hash.Hash - param, param5, param6 hash.Hash - param7, param8, param9 hash.Hash +func (r *moqPartialGenericParamsFn_fnRecorder[S]) any() *moqPartialGenericParamsFn_anyParams[S] { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) + return nil } + return &moqPartialGenericParamsFn_anyParams[S]{recorder: r} } -// moqUsual_DifficultParamNames_resultsByParams contains the results for a -// given set of parameters for the Usual type -type moqUsual_DifficultParamNames_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_DifficultParamNames_paramsKey]*moqUsual_DifficultParamNames_results +func (a *moqPartialGenericParamsFn_anyParams[S]) param1() *moqPartialGenericParamsFn_fnRecorder[S] { + a.recorder.anyParams |= 1 << 0 + return a.recorder } -// moqUsual_DifficultParamNames_doFn defines the type of function needed when -// calling andDo for the Usual type -type moqUsual_DifficultParamNames_doFn func(m, r bool, sequence string, param, params, i int, result, results, _ float32) - -// moqUsual_DifficultParamNames_doReturnFn defines the type of function needed -// when calling doReturnResults for the Usual type -type moqUsual_DifficultParamNames_doReturnFn func(m, r bool, sequence string, param, params, i int, result, results, _ float32) +func (a *moqPartialGenericParamsFn_anyParams[S]) param2() *moqPartialGenericParamsFn_fnRecorder[S] { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} -// moqUsual_DifficultParamNames_results holds the results of the Usual type -type moqUsual_DifficultParamNames_results struct { - params moqUsual_DifficultParamNames_params - results []struct { - values *struct{} - sequence uint32 - doFn moqUsual_DifficultParamNames_doFn - doReturnFn moqUsual_DifficultParamNames_doReturnFn +func (r *moqPartialGenericParamsFn_fnRecorder[S]) seq() *moqPartialGenericParamsFn_fnRecorder[S] { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) + return nil } - index uint32 - repeat *moq.RepeatVal + r.sequence = true + return r } -// moqUsual_DifficultParamNames_fnRecorder routes recorded function calls to -// the moqUsual moq -type moqUsual_DifficultParamNames_fnRecorder struct { - params moqUsual_DifficultParamNames_params - anyParams uint64 - sequence bool - results *moqUsual_DifficultParamNames_results - moq *moqUsual +func (r *moqPartialGenericParamsFn_fnRecorder[S]) noSeq() *moqPartialGenericParamsFn_fnRecorder[S] { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) + return nil + } + r.sequence = false + return r } -// moqUsual_DifficultParamNames_anyParams isolates the any params functions of -// the Usual type -type moqUsual_DifficultParamNames_anyParams struct { - recorder *moqUsual_DifficultParamNames_fnRecorder -} +func (r *moqPartialGenericParamsFn_fnRecorder[S]) returnResults(result1 string, result2 error) *moqPartialGenericParamsFn_fnRecorder[S] { + r.moq.scene.T.Helper() + r.findResults() -// moqUsual_DifficultResultNames_params holds the params of the Usual type -type moqUsual_DifficultResultNames_params struct{} + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } -// moqUsual_DifficultResultNames_paramsKey holds the map key params of the -// Usual type -type moqUsual_DifficultResultNames_paramsKey struct { - params struct{} - hashes struct{} + r.results.results = append(r.results.results, struct { + values *struct { + result1 string + result2 error + } + sequence uint32 + doFn moqPartialGenericParamsFn_doFn[S] + doReturnFn moqPartialGenericParamsFn_doReturnFn[S] + }{ + values: &struct { + result1 string + result2 error + }{ + result1: result1, + result2: result2, + }, + sequence: sequence, + }) + return r } -// moqUsual_DifficultResultNames_resultsByParams contains the results for a -// given set of parameters for the Usual type -type moqUsual_DifficultResultNames_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_DifficultResultNames_paramsKey]*moqUsual_DifficultResultNames_results +func (r *moqPartialGenericParamsFn_fnRecorder[S]) andDo(fn moqPartialGenericParamsFn_doFn[S]) *moqPartialGenericParamsFn_fnRecorder[S] { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r } -// moqUsual_DifficultResultNames_doFn defines the type of function needed when -// calling andDo for the Usual type -type moqUsual_DifficultResultNames_doFn func() +func (r *moqPartialGenericParamsFn_fnRecorder[S]) doReturnResults(fn moqPartialGenericParamsFn_doReturnFn[S]) *moqPartialGenericParamsFn_fnRecorder[S] { + r.moq.scene.T.Helper() + r.findResults() -// moqUsual_DifficultResultNames_doReturnFn defines the type of function needed -// when calling doReturnResults for the Usual type -type moqUsual_DifficultResultNames_doReturnFn func() (m, r string, sequence error, param, params, i int, result, results, _ float32) + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } -// moqUsual_DifficultResultNames_results holds the results of the Usual type -type moqUsual_DifficultResultNames_results struct { - params moqUsual_DifficultResultNames_params - results []struct { + r.results.results = append(r.results.results, struct { values *struct { - result1, result2 string - result3 error - param, result5, result6 int - result7, result8, result9 float32 + result1 string + result2 error } sequence uint32 - doFn moqUsual_DifficultResultNames_doFn - doReturnFn moqUsual_DifficultResultNames_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsual_DifficultResultNames_fnRecorder routes recorded function calls to -// the moqUsual moq -type moqUsual_DifficultResultNames_fnRecorder struct { - params moqUsual_DifficultResultNames_params - anyParams uint64 - sequence bool - results *moqUsual_DifficultResultNames_results - moq *moqUsual -} - -// moqUsual_DifficultResultNames_anyParams isolates the any params functions of -// the Usual type -type moqUsual_DifficultResultNames_anyParams struct { - recorder *moqUsual_DifficultResultNames_fnRecorder -} - -// moqUsual_PassByReference_params holds the params of the Usual type -type moqUsual_PassByReference_params struct { - p *testmoqs.PassByReferenceParams + doFn moqPartialGenericParamsFn_doFn[S] + doReturnFn moqPartialGenericParamsFn_doReturnFn[S] + }{sequence: sequence, doReturnFn: fn}) + return r } -// moqUsual_PassByReference_paramsKey holds the map key params of the Usual -// type -type moqUsual_PassByReference_paramsKey struct { - params struct { - p *testmoqs.PassByReferenceParams +func (r *moqPartialGenericParamsFn_fnRecorder[S]) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return } - hashes struct{ p hash.Hash } -} - -// moqUsual_PassByReference_resultsByParams contains the results for a given -// set of parameters for the Usual type -type moqUsual_PassByReference_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_PassByReference_paramsKey]*moqUsual_PassByReference_results -} -// moqUsual_PassByReference_doFn defines the type of function needed when -// calling andDo for the Usual type -type moqUsual_PassByReference_doFn func(p *testmoqs.PassByReferenceParams) + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqPartialGenericParamsFn_resultsByParams[S] + for n, res := range r.moq.resultsByParams { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqPartialGenericParamsFn_resultsByParams[S]{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqPartialGenericParamsFn_paramsKey[S]]*moqPartialGenericParamsFn_results[S]{}, + } + r.moq.resultsByParams = append(r.moq.resultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams) { + copy(r.moq.resultsByParams[insertAt+1:], r.moq.resultsByParams[insertAt:0]) + r.moq.resultsByParams[insertAt] = *results + } + } -// moqUsual_PassByReference_doReturnFn defines the type of function needed when -// calling doReturnResults for the Usual type -type moqUsual_PassByReference_doReturnFn func(p *testmoqs.PassByReferenceParams) (sResult string, err error) + paramsKey := r.moq.paramsKey(r.params, r.anyParams) -// moqUsual_PassByReference_results holds the results of the Usual type -type moqUsual_PassByReference_results struct { - params moqUsual_PassByReference_params - results []struct { - values *struct { - sResult string - err error + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqPartialGenericParamsFn_results[S]{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, } - sequence uint32 - doFn moqUsual_PassByReference_doFn - doReturnFn moqUsual_PassByReference_doReturnFn + results.results[paramsKey] = r.results } - index uint32 - repeat *moq.RepeatVal -} -// moqUsual_PassByReference_fnRecorder routes recorded function calls to the -// moqUsual moq -type moqUsual_PassByReference_fnRecorder struct { - params moqUsual_PassByReference_params - anyParams uint64 - sequence bool - results *moqUsual_PassByReference_results - moq *moqUsual + r.results.repeat.Increment(r.moq.scene.T) } -// moqUsual_PassByReference_anyParams isolates the any params functions of the -// Usual type -type moqUsual_PassByReference_anyParams struct { - recorder *moqUsual_PassByReference_fnRecorder -} - -// moqUsual_InterfaceParam_params holds the params of the Usual type -type moqUsual_InterfaceParam_params struct{ w io.Writer } - -// moqUsual_InterfaceParam_paramsKey holds the map key params of the Usual type -type moqUsual_InterfaceParam_paramsKey struct { - params struct{ w io.Writer } - hashes struct{ w hash.Hash } -} - -// moqUsual_InterfaceParam_resultsByParams contains the results for a given set -// of parameters for the Usual type -type moqUsual_InterfaceParam_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_InterfaceParam_paramsKey]*moqUsual_InterfaceParam_results -} - -// moqUsual_InterfaceParam_doFn defines the type of function needed when -// calling andDo for the Usual type -type moqUsual_InterfaceParam_doFn func(w io.Writer) - -// moqUsual_InterfaceParam_doReturnFn defines the type of function needed when -// calling doReturnResults for the Usual type -type moqUsual_InterfaceParam_doReturnFn func(w io.Writer) (sResult string, err error) - -// moqUsual_InterfaceParam_results holds the results of the Usual type -type moqUsual_InterfaceParam_results struct { - params moqUsual_InterfaceParam_params - results []struct { - values *struct { - sResult string - err error +func (r *moqPartialGenericParamsFn_fnRecorder[S]) repeat(repeaters ...moq.Repeater) *moqPartialGenericParamsFn_fnRecorder[S] { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct { + result1 string + result2 error + } + sequence uint32 + doFn moqPartialGenericParamsFn_doFn[S] + doReturnFn moqPartialGenericParamsFn_doReturnFn[S] + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } } - sequence uint32 - doFn moqUsual_InterfaceParam_doFn - doReturnFn moqUsual_InterfaceParam_doReturnFn + r.results.results = append(r.results.results, last) } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsual_InterfaceParam_fnRecorder routes recorded function calls to the -// moqUsual moq -type moqUsual_InterfaceParam_fnRecorder struct { - params moqUsual_InterfaceParam_params - anyParams uint64 - sequence bool - results *moqUsual_InterfaceParam_results - moq *moqUsual -} - -// moqUsual_InterfaceParam_anyParams isolates the any params functions of the -// Usual type -type moqUsual_InterfaceParam_anyParams struct { - recorder *moqUsual_InterfaceParam_fnRecorder + return r } -// moqUsual_InterfaceResult_params holds the params of the Usual type -type moqUsual_InterfaceResult_params struct { - sParam string - bParam bool +func (m *moqPartialGenericParamsFn[S]) prettyParams(params moqPartialGenericParamsFn_params[S]) string { + return fmt.Sprintf("PartialGenericParamsFn(%#v, %#v)", params.param1, params.param2) } -// moqUsual_InterfaceResult_paramsKey holds the map key params of the Usual -// type -type moqUsual_InterfaceResult_paramsKey struct { - params struct { - sParam string - bParam bool +func (m *moqPartialGenericParamsFn[S]) paramsKey(params moqPartialGenericParamsFn_params[S], anyParams uint64) moqPartialGenericParamsFn_paramsKey[S] { + m.scene.T.Helper() + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.param1 == moq.ParamIndexByValue { + m.scene.T.Fatalf("The param1 parameter can't be indexed by value") + } + param1UsedHash = hash.DeepHash(params.param1) } - hashes struct { - sParam hash.Hash - bParam hash.Hash + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.param2 == moq.ParamIndexByValue { + param2Used = params.param2 + } else { + param2UsedHash = hash.DeepHash(params.param2) + } + } + return moqPartialGenericParamsFn_paramsKey[S]{ + params: struct{ param2 bool }{ + param2: param2Used, + }, + hashes: struct { + param1 hash.Hash + param2 hash.Hash + }{ + param1: param1UsedHash, + param2: param2UsedHash, + }, } } -// moqUsual_InterfaceResult_resultsByParams contains the results for a given -// set of parameters for the Usual type -type moqUsual_InterfaceResult_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_InterfaceResult_paramsKey]*moqUsual_InterfaceResult_results +// Reset resets the state of the moq +func (m *moqPartialGenericParamsFn[S]) Reset() { m.resultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqPartialGenericParamsFn[S]) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams(results.params)) + } + } + } } -// moqUsual_InterfaceResult_doFn defines the type of function needed when -// calling andDo for the Usual type -type moqUsual_InterfaceResult_doFn func(sParam string, bParam bool) +// moqGenericResultsFn holds the state of a moq of the GenericResultsFn type +type moqGenericResultsFn[S ~string, E error] struct { + scene *moq.Scene + config moq.Config + moq *moqGenericResultsFn_mock[S, E] -// moqUsual_InterfaceResult_doReturnFn defines the type of function needed when -// calling doReturnResults for the Usual type -type moqUsual_InterfaceResult_doReturnFn func(sParam string, bParam bool) (r io.Reader) + resultsByParams []moqGenericResultsFn_resultsByParams[S, E] -// moqUsual_InterfaceResult_results holds the results of the Usual type -type moqUsual_InterfaceResult_results struct { - params moqUsual_InterfaceResult_params - results []struct { - values *struct{ result1 io.Reader } - sequence uint32 - doFn moqUsual_InterfaceResult_doFn - doReturnFn moqUsual_InterfaceResult_doReturnFn + runtime struct { + parameterIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } } - index uint32 - repeat *moq.RepeatVal } -// moqUsual_InterfaceResult_fnRecorder routes recorded function calls to the -// moqUsual moq -type moqUsual_InterfaceResult_fnRecorder struct { - params moqUsual_InterfaceResult_params - anyParams uint64 - sequence bool - results *moqUsual_InterfaceResult_results - moq *moqUsual +// moqGenericResultsFn_mock isolates the mock interface of the GenericResultsFn +// type +type moqGenericResultsFn_mock[S ~string, E error] struct { + moq *moqGenericResultsFn[S, E] } -// moqUsual_InterfaceResult_anyParams isolates the any params functions of the -// Usual type -type moqUsual_InterfaceResult_anyParams struct { - recorder *moqUsual_InterfaceResult_fnRecorder +// moqGenericResultsFn_params holds the params of the GenericResultsFn type +type moqGenericResultsFn_params[S ~string, E error] struct { + param1 string + param2 bool } -// moqUsual_FnParam_params holds the params of the Usual type -type moqUsual_FnParam_params struct{ fn func() } - -// moqUsual_FnParam_paramsKey holds the map key params of the Usual type -type moqUsual_FnParam_paramsKey struct { - params struct{} - hashes struct{ fn hash.Hash } +// moqGenericResultsFn_paramsKey holds the map key params of the +// GenericResultsFn type +type moqGenericResultsFn_paramsKey[S ~string, E error] struct { + params struct { + param1 string + param2 bool + } + hashes struct { + param1 hash.Hash + param2 hash.Hash + } } -// moqUsual_FnParam_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_FnParam_resultsByParams struct { +// moqGenericResultsFn_resultsByParams contains the results for a given set of +// parameters for the GenericResultsFn type +type moqGenericResultsFn_resultsByParams[S ~string, E error] struct { anyCount int anyParams uint64 - results map[moqUsual_FnParam_paramsKey]*moqUsual_FnParam_results + results map[moqGenericResultsFn_paramsKey[S, E]]*moqGenericResultsFn_results[S, E] } -// moqUsual_FnParam_doFn defines the type of function needed when calling andDo -// for the Usual type -type moqUsual_FnParam_doFn func(fn func()) +// moqGenericResultsFn_doFn defines the type of function needed when calling +// andDo for the GenericResultsFn type +type moqGenericResultsFn_doFn[S ~string, E error] func(string, bool) -// moqUsual_FnParam_doReturnFn defines the type of function needed when calling -// doReturnResults for the Usual type -type moqUsual_FnParam_doReturnFn func(fn func()) +// moqGenericResultsFn_doReturnFn defines the type of function needed when +// calling doReturnResults for the GenericResultsFn type +type moqGenericResultsFn_doReturnFn[S ~string, E error] func(string, bool) (S, E) -// moqUsual_FnParam_results holds the results of the Usual type -type moqUsual_FnParam_results struct { - params moqUsual_FnParam_params +// moqGenericResultsFn_results holds the results of the GenericResultsFn type +type moqGenericResultsFn_results[S ~string, E error] struct { + params moqGenericResultsFn_params[S, E] results []struct { - values *struct{} + values *struct { + result1 S + result2 E + } sequence uint32 - doFn moqUsual_FnParam_doFn - doReturnFn moqUsual_FnParam_doReturnFn + doFn moqGenericResultsFn_doFn[S, E] + doReturnFn moqGenericResultsFn_doReturnFn[S, E] } index uint32 repeat *moq.RepeatVal } -// moqUsual_FnParam_fnRecorder routes recorded function calls to the moqUsual -// moq -type moqUsual_FnParam_fnRecorder struct { - params moqUsual_FnParam_params +// moqGenericResultsFn_fnRecorder routes recorded function calls to the +// moqGenericResultsFn moq +type moqGenericResultsFn_fnRecorder[S ~string, E error] struct { + params moqGenericResultsFn_params[S, E] anyParams uint64 sequence bool - results *moqUsual_FnParam_results - moq *moqUsual + results *moqGenericResultsFn_results[S, E] + moq *moqGenericResultsFn[S, E] } -// moqUsual_FnParam_anyParams isolates the any params functions of the Usual -// type -type moqUsual_FnParam_anyParams struct { - recorder *moqUsual_FnParam_fnRecorder +// moqGenericResultsFn_anyParams isolates the any params functions of the +// GenericResultsFn type +type moqGenericResultsFn_anyParams[S ~string, E error] struct { + recorder *moqGenericResultsFn_fnRecorder[S, E] } -// newMoqUsual creates a new moq of the Usual type -func newMoqUsual(scene *moq.Scene, config *moq.Config) *moqUsual { +// newMoqGenericResultsFn creates a new moq of the GenericResultsFn type +func newMoqGenericResultsFn[S ~string, E error](scene *moq.Scene, config *moq.Config) *moqGenericResultsFn[S, E] { if config == nil { config = &moq.Config{} } - m := &moqUsual{ + m := &moqGenericResultsFn[S, E]{ scene: scene, config: *config, - moq: &moqUsual_mock{}, + moq: &moqGenericResultsFn_mock[S, E]{}, runtime: struct { parameterIndexing struct { - Usual struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - NoNames struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - NoResults struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - NoParams struct{} - Nothing struct{} - Variadic struct { - other moq.ParamIndexing - args moq.ParamIndexing - } - RepeatedIds struct { - sParam1 moq.ParamIndexing - sParam2 moq.ParamIndexing - bParam moq.ParamIndexing - } - Times struct { - sParam moq.ParamIndexing - times moq.ParamIndexing - } - DifficultParamNames struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - param3 moq.ParamIndexing - param moq.ParamIndexing - param5 moq.ParamIndexing - param6 moq.ParamIndexing - param7 moq.ParamIndexing - param8 moq.ParamIndexing - param9 moq.ParamIndexing - } - DifficultResultNames struct{} - PassByReference struct { - p moq.ParamIndexing - } - InterfaceParam struct { - w moq.ParamIndexing - } - InterfaceResult struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - FnParam struct { - fn moq.ParamIndexing - } - } - }{parameterIndexing: struct { - Usual struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - NoNames struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - NoResults struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - NoParams struct{} - Nothing struct{} - Variadic struct { - other moq.ParamIndexing - args moq.ParamIndexing - } - RepeatedIds struct { - sParam1 moq.ParamIndexing - sParam2 moq.ParamIndexing - bParam moq.ParamIndexing - } - Times struct { - sParam moq.ParamIndexing - times moq.ParamIndexing - } - DifficultParamNames struct { param1 moq.ParamIndexing param2 moq.ParamIndexing - param3 moq.ParamIndexing - param moq.ParamIndexing - param5 moq.ParamIndexing - param6 moq.ParamIndexing - param7 moq.ParamIndexing - param8 moq.ParamIndexing - param9 moq.ParamIndexing - } - DifficultResultNames struct{} - PassByReference struct { - p moq.ParamIndexing - } - InterfaceParam struct { - w moq.ParamIndexing - } - InterfaceResult struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - FnParam struct { - fn moq.ParamIndexing } + }{parameterIndexing: struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing }{ - Usual: struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - }{ - sParam: moq.ParamIndexByValue, - bParam: moq.ParamIndexByValue, - }, - NoNames: struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - }{ - param1: moq.ParamIndexByValue, - param2: moq.ParamIndexByValue, - }, - NoResults: struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - }{ - sParam: moq.ParamIndexByValue, - bParam: moq.ParamIndexByValue, - }, - NoParams: struct{}{}, - Nothing: struct{}{}, - Variadic: struct { - other moq.ParamIndexing - args moq.ParamIndexing - }{ - other: moq.ParamIndexByValue, - args: moq.ParamIndexByHash, - }, - RepeatedIds: struct { - sParam1 moq.ParamIndexing - sParam2 moq.ParamIndexing - bParam moq.ParamIndexing - }{ - sParam1: moq.ParamIndexByValue, - sParam2: moq.ParamIndexByValue, - bParam: moq.ParamIndexByValue, - }, - Times: struct { - sParam moq.ParamIndexing - times moq.ParamIndexing - }{ - sParam: moq.ParamIndexByValue, - times: moq.ParamIndexByValue, - }, - DifficultParamNames: struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - param3 moq.ParamIndexing - param moq.ParamIndexing - param5 moq.ParamIndexing - param6 moq.ParamIndexing - param7 moq.ParamIndexing - param8 moq.ParamIndexing - param9 moq.ParamIndexing - }{ - param1: moq.ParamIndexByValue, - param2: moq.ParamIndexByValue, - param3: moq.ParamIndexByValue, - param: moq.ParamIndexByValue, - param5: moq.ParamIndexByValue, - param6: moq.ParamIndexByValue, - param7: moq.ParamIndexByValue, - param8: moq.ParamIndexByValue, - param9: moq.ParamIndexByValue, - }, - DifficultResultNames: struct{}{}, - PassByReference: struct { - p moq.ParamIndexing - }{ - p: moq.ParamIndexByHash, - }, - InterfaceParam: struct { - w moq.ParamIndexing - }{ - w: moq.ParamIndexByHash, - }, - InterfaceResult: struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - }{ - sParam: moq.ParamIndexByValue, - bParam: moq.ParamIndexByValue, - }, - FnParam: struct { - fn moq.ParamIndexing - }{ - fn: moq.ParamIndexByHash, - }, + param1: moq.ParamIndexByValue, + param2: moq.ParamIndexByValue, }}, } m.moq.moq = m @@ -6596,73 +6380,24 @@ func newMoqUsual(scene *moq.Scene, config *moq.Config) *moqUsual { return m } -// mock returns the mock implementation of the Usual type -func (m *moqUsual) mock() *moqUsual_mock { return m.moq } - -func (m *moqUsual_mock) Usual(sParam string, bParam bool) (sResult string, err error) { - m.moq.scene.T.Helper() - params := moqUsual_Usual_params{ - sParam: sParam, - bParam: bParam, - } - var results *moqUsual_Usual_results - for _, resultsByParams := range m.moq.resultsByParams_Usual { - paramsKey := m.moq.paramsKey_Usual(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Usual(params)) - } - return - } - - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Usual(params)) - } - return - } - i = results.repeat.ResultCount - 1 - } - - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Usual(params)) - } - } - - if result.doFn != nil { - result.doFn(sParam, bParam) - } - - if result.values != nil { - sResult = result.values.sResult - err = result.values.err - } - if result.doReturnFn != nil { - sResult, err = result.doReturnFn(sParam, bParam) +// mock returns the moq implementation of the GenericResultsFn type +func (m *moqGenericResultsFn[S, E]) mock() testmoqs.GenericResultsFn[S, E] { + return func(param1 string, param2 bool) (S, E) { + m.scene.T.Helper() + moq := &moqGenericResultsFn_mock[S, E]{moq: m} + return moq.fn(param1, param2) } - return } -func (m *moqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, result2 error) { +func (m *moqGenericResultsFn_mock[S, E]) fn(param1 string, param2 bool) (result1 S, result2 E) { m.moq.scene.T.Helper() - params := moqUsual_NoNames_params{ + params := moqGenericResultsFn_params[S, E]{ param1: param1, param2: param2, } - var results *moqUsual_NoNames_results - for _, resultsByParams := range m.moq.resultsByParams_NoNames { - paramsKey := m.moq.paramsKey_NoNames(params, resultsByParams.anyParams) + var results *moqGenericResultsFn_results[S, E] + for _, resultsByParams := range m.moq.resultsByParams { + paramsKey := m.moq.paramsKey(params, resultsByParams.anyParams) var ok bool results, ok = resultsByParams.results[paramsKey] if ok { @@ -6671,7 +6406,7 @@ func (m *moqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, res } if results == nil { if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_NoNames(params)) + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams(params)) } return } @@ -6680,7 +6415,7 @@ func (m *moqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, res if i >= results.repeat.ResultCount { if !results.repeat.AnyTimes { if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_NoNames(params)) + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams(params)) } return } @@ -6691,7 +6426,7 @@ func (m *moqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, res if result.sequence != 0 { sequence := m.moq.scene.NextMockSequence() if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_NoNames(params)) + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams(params)) } } @@ -6709,388 +6444,393 @@ func (m *moqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, res return } -func (m *moqUsual_mock) NoResults(sParam string, bParam bool) { - m.moq.scene.T.Helper() - params := moqUsual_NoResults_params{ - sParam: sParam, - bParam: bParam, - } - var results *moqUsual_NoResults_results - for _, resultsByParams := range m.moq.resultsByParams_NoResults { - paramsKey := m.moq.paramsKey_NoResults(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_NoResults(params)) - } - return +func (m *moqGenericResultsFn[S, E]) onCall(param1 string, param2 bool) *moqGenericResultsFn_fnRecorder[S, E] { + return &moqGenericResultsFn_fnRecorder[S, E]{ + params: moqGenericResultsFn_params[S, E]{ + param1: param1, + param2: param2, + }, + sequence: m.config.Sequence == moq.SeqDefaultOn, + moq: m, } +} - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_NoResults(params)) - } - return - } - i = results.repeat.ResultCount - 1 +func (r *moqGenericResultsFn_fnRecorder[S, E]) any() *moqGenericResultsFn_anyParams[S, E] { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) + return nil } + return &moqGenericResultsFn_anyParams[S, E]{recorder: r} +} - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_NoResults(params)) - } - } +func (a *moqGenericResultsFn_anyParams[S, E]) param1() *moqGenericResultsFn_fnRecorder[S, E] { + a.recorder.anyParams |= 1 << 0 + return a.recorder +} - if result.doFn != nil { - result.doFn(sParam, bParam) - } +func (a *moqGenericResultsFn_anyParams[S, E]) param2() *moqGenericResultsFn_fnRecorder[S, E] { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} - if result.doReturnFn != nil { - result.doReturnFn(sParam, bParam) +func (r *moqGenericResultsFn_fnRecorder[S, E]) seq() *moqGenericResultsFn_fnRecorder[S, E] { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) + return nil } - return + r.sequence = true + return r } -func (m *moqUsual_mock) NoParams() (sResult string, err error) { - m.moq.scene.T.Helper() - params := moqUsual_NoParams_params{} - var results *moqUsual_NoParams_results - for _, resultsByParams := range m.moq.resultsByParams_NoParams { - paramsKey := m.moq.paramsKey_NoParams(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_NoParams(params)) - } - return +func (r *moqGenericResultsFn_fnRecorder[S, E]) noSeq() *moqGenericResultsFn_fnRecorder[S, E] { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) + return nil } + r.sequence = false + return r +} - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_NoParams(params)) - } - return - } - i = results.repeat.ResultCount - 1 - } +func (r *moqGenericResultsFn_fnRecorder[S, E]) returnResults(result1 S, result2 E) *moqGenericResultsFn_fnRecorder[S, E] { + r.moq.scene.T.Helper() + r.findResults() - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_NoParams(params)) - } + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() } - if result.doFn != nil { - result.doFn() - } + r.results.results = append(r.results.results, struct { + values *struct { + result1 S + result2 E + } + sequence uint32 + doFn moqGenericResultsFn_doFn[S, E] + doReturnFn moqGenericResultsFn_doReturnFn[S, E] + }{ + values: &struct { + result1 S + result2 E + }{ + result1: result1, + result2: result2, + }, + sequence: sequence, + }) + return r +} - if result.values != nil { - sResult = result.values.sResult - err = result.values.err - } - if result.doReturnFn != nil { - sResult, err = result.doReturnFn() +func (r *moqGenericResultsFn_fnRecorder[S, E]) andDo(fn moqGenericResultsFn_doFn[S, E]) *moqGenericResultsFn_fnRecorder[S, E] { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil } - return + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r } -func (m *moqUsual_mock) Nothing() { - m.moq.scene.T.Helper() - params := moqUsual_Nothing_params{} - var results *moqUsual_Nothing_results - for _, resultsByParams := range m.moq.resultsByParams_Nothing { - paramsKey := m.moq.paramsKey_Nothing(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Nothing(params)) - } - return - } +func (r *moqGenericResultsFn_fnRecorder[S, E]) doReturnResults(fn moqGenericResultsFn_doReturnFn[S, E]) *moqGenericResultsFn_fnRecorder[S, E] { + r.moq.scene.T.Helper() + r.findResults() - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Nothing(params)) - } - return - } - i = results.repeat.ResultCount - 1 + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() } - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Nothing(params)) + r.results.results = append(r.results.results, struct { + values *struct { + result1 S + result2 E } - } - - if result.doFn != nil { - result.doFn() - } - - if result.doReturnFn != nil { - result.doReturnFn() - } - return + sequence uint32 + doFn moqGenericResultsFn_doFn[S, E] + doReturnFn moqGenericResultsFn_doReturnFn[S, E] + }{sequence: sequence, doReturnFn: fn}) + return r } -func (m *moqUsual_mock) Variadic(other bool, args ...string) (sResult string, err error) { - m.moq.scene.T.Helper() - params := moqUsual_Variadic_params{ - other: other, - args: args, +func (r *moqGenericResultsFn_fnRecorder[S, E]) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return } - var results *moqUsual_Variadic_results - for _, resultsByParams := range m.moq.resultsByParams_Variadic { - paramsKey := m.moq.paramsKey_Variadic(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqGenericResultsFn_resultsByParams[S, E] + for n, res := range r.moq.resultsByParams { + if res.anyParams == r.anyParams { + results = &res break } + if res.anyCount > anyCount { + insertAt = n + } } if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Variadic(params)) + results = &moqGenericResultsFn_resultsByParams[S, E]{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqGenericResultsFn_paramsKey[S, E]]*moqGenericResultsFn_results[S, E]{}, } - return - } - - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Variadic(params)) - } - return + r.moq.resultsByParams = append(r.moq.resultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams) { + copy(r.moq.resultsByParams[insertAt+1:], r.moq.resultsByParams[insertAt:0]) + r.moq.resultsByParams[insertAt] = *results } - i = results.repeat.ResultCount - 1 } - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Variadic(params)) + paramsKey := r.moq.paramsKey(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqGenericResultsFn_results[S, E]{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, } + results.results[paramsKey] = r.results } - if result.doFn != nil { - result.doFn(other, args...) - } + r.results.repeat.Increment(r.moq.scene.T) +} - if result.values != nil { - sResult = result.values.sResult - err = result.values.err +func (r *moqGenericResultsFn_fnRecorder[S, E]) repeat(repeaters ...moq.Repeater) *moqGenericResultsFn_fnRecorder[S, E] { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil } - if result.doReturnFn != nil { - sResult, err = result.doReturnFn(other, args...) + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct { + result1 S + result2 E + } + sequence uint32 + doFn moqGenericResultsFn_doFn[S, E] + doReturnFn moqGenericResultsFn_doReturnFn[S, E] + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) } - return + return r } -func (m *moqUsual_mock) RepeatedIds(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) { - m.moq.scene.T.Helper() - params := moqUsual_RepeatedIds_params{ - sParam1: sParam1, - sParam2: sParam2, - bParam: bParam, - } - var results *moqUsual_RepeatedIds_results - for _, resultsByParams := range m.moq.resultsByParams_RepeatedIds { - paramsKey := m.moq.paramsKey_RepeatedIds(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { - break +func (m *moqGenericResultsFn[S, E]) prettyParams(params moqGenericResultsFn_params[S, E]) string { + return fmt.Sprintf("GenericResultsFn(%#v, %#v)", params.param1, params.param2) +} + +func (m *moqGenericResultsFn[S, E]) paramsKey(params moqGenericResultsFn_params[S, E], anyParams uint64) moqGenericResultsFn_paramsKey[S, E] { + m.scene.T.Helper() + var param1Used string + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.param1 == moq.ParamIndexByValue { + param1Used = params.param1 + } else { + param1UsedHash = hash.DeepHash(params.param1) } } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_RepeatedIds(params)) + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.param2 == moq.ParamIndexByValue { + param2Used = params.param2 + } else { + param2UsedHash = hash.DeepHash(params.param2) } - return } + return moqGenericResultsFn_paramsKey[S, E]{ + params: struct { + param1 string + param2 bool + }{ + param1: param1Used, + param2: param2Used, + }, + hashes: struct { + param1 hash.Hash + param2 hash.Hash + }{ + param1: param1UsedHash, + param2: param2UsedHash, + }, + } +} - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_RepeatedIds(params)) +// Reset resets the state of the moq +func (m *moqGenericResultsFn[S, E]) Reset() { m.resultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqGenericResultsFn[S, E]) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams(results.params)) } - return } - i = results.repeat.ResultCount - 1 } +} - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_RepeatedIds(params)) +// moqPartialGenericResultsFn holds the state of a moq of the +// PartialGenericResultsFn type +type moqPartialGenericResultsFn[S ~string] struct { + scene *moq.Scene + config moq.Config + moq *moqPartialGenericResultsFn_mock[S] + + resultsByParams []moqPartialGenericResultsFn_resultsByParams[S] + + runtime struct { + parameterIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } } +} - if result.doFn != nil { - result.doFn(sParam1, sParam2, bParam) - } +// moqPartialGenericResultsFn_mock isolates the mock interface of the +// PartialGenericResultsFn type +type moqPartialGenericResultsFn_mock[S ~string] struct { + moq *moqPartialGenericResultsFn[S] +} - if result.values != nil { - sResult1 = result.values.sResult1 - sResult2 = result.values.sResult2 - err = result.values.err - } - if result.doReturnFn != nil { - sResult1, sResult2, err = result.doReturnFn(sParam1, sParam2, bParam) - } - return +// moqPartialGenericResultsFn_params holds the params of the +// PartialGenericResultsFn type +type moqPartialGenericResultsFn_params[S ~string] struct { + param1 string + param2 bool } -func (m *moqUsual_mock) Times(sParam string, times bool) (sResult string, err error) { - m.moq.scene.T.Helper() - params := moqUsual_Times_params{ - sParam: sParam, - times: times, - } - var results *moqUsual_Times_results - for _, resultsByParams := range m.moq.resultsByParams_Times { - paramsKey := m.moq.paramsKey_Times(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { - break - } +// moqPartialGenericResultsFn_paramsKey holds the map key params of the +// PartialGenericResultsFn type +type moqPartialGenericResultsFn_paramsKey[S ~string] struct { + params struct { + param1 string + param2 bool } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Times(params)) - } - return + hashes struct { + param1 hash.Hash + param2 hash.Hash } +} - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Times(params)) - } - return - } - i = results.repeat.ResultCount - 1 - } +// moqPartialGenericResultsFn_resultsByParams contains the results for a given +// set of parameters for the PartialGenericResultsFn type +type moqPartialGenericResultsFn_resultsByParams[S ~string] struct { + anyCount int + anyParams uint64 + results map[moqPartialGenericResultsFn_paramsKey[S]]*moqPartialGenericResultsFn_results[S] +} - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Times(params)) +// moqPartialGenericResultsFn_doFn defines the type of function needed when +// calling andDo for the PartialGenericResultsFn type +type moqPartialGenericResultsFn_doFn[S ~string] func(string, bool) + +// moqPartialGenericResultsFn_doReturnFn defines the type of function needed +// when calling doReturnResults for the PartialGenericResultsFn type +type moqPartialGenericResultsFn_doReturnFn[S ~string] func(string, bool) (S, error) + +// moqPartialGenericResultsFn_results holds the results of the +// PartialGenericResultsFn type +type moqPartialGenericResultsFn_results[S ~string] struct { + params moqPartialGenericResultsFn_params[S] + results []struct { + values *struct { + result1 S + result2 error } + sequence uint32 + doFn moqPartialGenericResultsFn_doFn[S] + doReturnFn moqPartialGenericResultsFn_doReturnFn[S] } + index uint32 + repeat *moq.RepeatVal +} - if result.doFn != nil { - result.doFn(sParam, times) - } +// moqPartialGenericResultsFn_fnRecorder routes recorded function calls to the +// moqPartialGenericResultsFn moq +type moqPartialGenericResultsFn_fnRecorder[S ~string] struct { + params moqPartialGenericResultsFn_params[S] + anyParams uint64 + sequence bool + results *moqPartialGenericResultsFn_results[S] + moq *moqPartialGenericResultsFn[S] +} - if result.values != nil { - sResult = result.values.sResult - err = result.values.err - } - if result.doReturnFn != nil { - sResult, err = result.doReturnFn(sParam, times) - } - return +// moqPartialGenericResultsFn_anyParams isolates the any params functions of +// the PartialGenericResultsFn type +type moqPartialGenericResultsFn_anyParams[S ~string] struct { + recorder *moqPartialGenericResultsFn_fnRecorder[S] } -func (m *moqUsual_mock) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) { - m.moq.scene.T.Helper() - params := moqUsual_DifficultParamNames_params{ - param1: param1, - param2: param2, - param3: param3, - param: param, - param5: param5, - param6: param6, - param7: param7, - param8: param8, - param9: param9, - } - var results *moqUsual_DifficultParamNames_results - for _, resultsByParams := range m.moq.resultsByParams_DifficultParamNames { - paramsKey := m.moq.paramsKey_DifficultParamNames(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_DifficultParamNames(params)) - } - return +// newMoqPartialGenericResultsFn creates a new moq of the +// PartialGenericResultsFn type +func newMoqPartialGenericResultsFn[S ~string](scene *moq.Scene, config *moq.Config) *moqPartialGenericResultsFn[S] { + if config == nil { + config = &moq.Config{} } + m := &moqPartialGenericResultsFn[S]{ + scene: scene, + config: *config, + moq: &moqPartialGenericResultsFn_mock[S]{}, - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_DifficultParamNames(params)) + runtime: struct { + parameterIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } - return - } - i = results.repeat.ResultCount - 1 - } - - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_DifficultParamNames(params)) - } + }{parameterIndexing: struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + }{ + param1: moq.ParamIndexByValue, + param2: moq.ParamIndexByValue, + }}, } + m.moq.moq = m - if result.doFn != nil { - result.doFn(param1, param2, param3, param, param5, param6, param7, param8, param9) - } + scene.AddMoq(m) + return m +} - if result.doReturnFn != nil { - result.doReturnFn(param1, param2, param3, param, param5, param6, param7, param8, param9) +// mock returns the moq implementation of the PartialGenericResultsFn type +func (m *moqPartialGenericResultsFn[S]) mock() testmoqs.PartialGenericResultsFn[S] { + return func(param1 string, param2 bool) (S, error) { + m.scene.T.Helper() + moq := &moqPartialGenericResultsFn_mock[S]{moq: m} + return moq.fn(param1, param2) } - return } -func (m *moqUsual_mock) DifficultResultNames() (result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) { +func (m *moqPartialGenericResultsFn_mock[S]) fn(param1 string, param2 bool) (result1 S, result2 error) { m.moq.scene.T.Helper() - params := moqUsual_DifficultResultNames_params{} - var results *moqUsual_DifficultResultNames_results - for _, resultsByParams := range m.moq.resultsByParams_DifficultResultNames { - paramsKey := m.moq.paramsKey_DifficultResultNames(params, resultsByParams.anyParams) + params := moqPartialGenericResultsFn_params[S]{ + param1: param1, + param2: param2, + } + var results *moqPartialGenericResultsFn_results[S] + for _, resultsByParams := range m.moq.resultsByParams { + paramsKey := m.moq.paramsKey(params, resultsByParams.anyParams) var ok bool results, ok = resultsByParams.results[paramsKey] if ok { @@ -7099,7 +6839,7 @@ func (m *moqUsual_mock) DifficultResultNames() (result1, result2 string, result3 } if results == nil { if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_DifficultResultNames(params)) + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams(params)) } return } @@ -7108,7 +6848,7 @@ func (m *moqUsual_mock) DifficultResultNames() (result1, result2 string, result3 if i >= results.repeat.ResultCount { if !results.repeat.AnyTimes { if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_DifficultResultNames(params)) + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams(params)) } return } @@ -7119,301 +6859,75 @@ func (m *moqUsual_mock) DifficultResultNames() (result1, result2 string, result3 if result.sequence != 0 { sequence := m.moq.scene.NextMockSequence() if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_DifficultResultNames(params)) + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams(params)) } } if result.doFn != nil { - result.doFn() + result.doFn(param1, param2) } if result.values != nil { result1 = result.values.result1 result2 = result.values.result2 - result3 = result.values.result3 - param = result.values.param - result5 = result.values.result5 - result6 = result.values.result6 - result7 = result.values.result7 - result8 = result.values.result8 - result9 = result.values.result9 } if result.doReturnFn != nil { - result1, result2, result3, param, result5, result6, result7, result8, result9 = result.doReturnFn() + result1, result2 = result.doReturnFn(param1, param2) } return } -func (m *moqUsual_mock) PassByReference(p *testmoqs.PassByReferenceParams) (sResult string, err error) { - m.moq.scene.T.Helper() - params := moqUsual_PassByReference_params{ - p: p, - } - var results *moqUsual_PassByReference_results - for _, resultsByParams := range m.moq.resultsByParams_PassByReference { - paramsKey := m.moq.paramsKey_PassByReference(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_PassByReference(params)) - } - return - } - - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_PassByReference(params)) - } - return - } - i = results.repeat.ResultCount - 1 - } - - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_PassByReference(params)) - } - } - - if result.doFn != nil { - result.doFn(p) - } - - if result.values != nil { - sResult = result.values.sResult - err = result.values.err - } - if result.doReturnFn != nil { - sResult, err = result.doReturnFn(p) - } - return -} - -func (m *moqUsual_mock) InterfaceParam(w io.Writer) (sResult string, err error) { - m.moq.scene.T.Helper() - params := moqUsual_InterfaceParam_params{ - w: w, - } - var results *moqUsual_InterfaceParam_results - for _, resultsByParams := range m.moq.resultsByParams_InterfaceParam { - paramsKey := m.moq.paramsKey_InterfaceParam(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_InterfaceParam(params)) - } - return - } - - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_InterfaceParam(params)) - } - return - } - i = results.repeat.ResultCount - 1 - } - - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_InterfaceParam(params)) - } - } - - if result.doFn != nil { - result.doFn(w) - } - - if result.values != nil { - sResult = result.values.sResult - err = result.values.err - } - if result.doReturnFn != nil { - sResult, err = result.doReturnFn(w) - } - return -} - -func (m *moqUsual_mock) InterfaceResult(sParam string, bParam bool) (result1 io.Reader) { - m.moq.scene.T.Helper() - params := moqUsual_InterfaceResult_params{ - sParam: sParam, - bParam: bParam, - } - var results *moqUsual_InterfaceResult_results - for _, resultsByParams := range m.moq.resultsByParams_InterfaceResult { - paramsKey := m.moq.paramsKey_InterfaceResult(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_InterfaceResult(params)) - } - return - } - - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_InterfaceResult(params)) - } - return - } - i = results.repeat.ResultCount - 1 - } - - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_InterfaceResult(params)) - } - } - - if result.doFn != nil { - result.doFn(sParam, bParam) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(sParam, bParam) - } - return -} - -func (m *moqUsual_mock) FnParam(fn func()) { - m.moq.scene.T.Helper() - params := moqUsual_FnParam_params{ - fn: fn, - } - var results *moqUsual_FnParam_results - for _, resultsByParams := range m.moq.resultsByParams_FnParam { - paramsKey := m.moq.paramsKey_FnParam(params, resultsByParams.anyParams) - var ok bool - results, ok = resultsByParams.results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_FnParam(params)) - } - return - } - - i := int(atomic.AddUint32(&results.index, 1)) - 1 - if i >= results.repeat.ResultCount { - if !results.repeat.AnyTimes { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_FnParam(params)) - } - return - } - i = results.repeat.ResultCount - 1 - } - - result := results.results[i] - if result.sequence != 0 { - sequence := m.moq.scene.NextMockSequence() - if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { - m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_FnParam(params)) - } - } - - if result.doFn != nil { - result.doFn(fn) - } - - if result.doReturnFn != nil { - result.doReturnFn(fn) - } - return -} - -// onCall returns the recorder implementation of the Usual type -func (m *moqUsual) onCall() *moqUsual_recorder { - return &moqUsual_recorder{ - moq: m, - } -} - -func (m *moqUsual_recorder) Usual(sParam string, bParam bool) *moqUsual_Usual_fnRecorder { - return &moqUsual_Usual_fnRecorder{ - params: moqUsual_Usual_params{ - sParam: sParam, - bParam: bParam, +func (m *moqPartialGenericResultsFn[S]) onCall(param1 string, param2 bool) *moqPartialGenericResultsFn_fnRecorder[S] { + return &moqPartialGenericResultsFn_fnRecorder[S]{ + params: moqPartialGenericResultsFn_params[S]{ + param1: param1, + param2: param2, }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + sequence: m.config.Sequence == moq.SeqDefaultOn, + moq: m, } } -func (r *moqUsual_Usual_fnRecorder) any() *moqUsual_Usual_anyParams { +func (r *moqPartialGenericResultsFn_fnRecorder[S]) any() *moqPartialGenericResultsFn_anyParams[S] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) return nil } - return &moqUsual_Usual_anyParams{recorder: r} + return &moqPartialGenericResultsFn_anyParams[S]{recorder: r} } -func (a *moqUsual_Usual_anyParams) sParam() *moqUsual_Usual_fnRecorder { +func (a *moqPartialGenericResultsFn_anyParams[S]) param1() *moqPartialGenericResultsFn_fnRecorder[S] { a.recorder.anyParams |= 1 << 0 return a.recorder } -func (a *moqUsual_Usual_anyParams) bParam() *moqUsual_Usual_fnRecorder { +func (a *moqPartialGenericResultsFn_anyParams[S]) param2() *moqPartialGenericResultsFn_fnRecorder[S] { a.recorder.anyParams |= 1 << 1 return a.recorder } -func (r *moqUsual_Usual_fnRecorder) seq() *moqUsual_Usual_fnRecorder { +func (r *moqPartialGenericResultsFn_fnRecorder[S]) seq() *moqPartialGenericResultsFn_fnRecorder[S] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_Usual_fnRecorder) noSeq() *moqUsual_Usual_fnRecorder { +func (r *moqPartialGenericResultsFn_fnRecorder[S]) noSeq() *moqPartialGenericResultsFn_fnRecorder[S] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_Usual_fnRecorder) returnResults(sResult string, err error) *moqUsual_Usual_fnRecorder { +func (r *moqPartialGenericResultsFn_fnRecorder[S]) returnResults(result1 S, result2 error) *moqPartialGenericResultsFn_fnRecorder[S] { r.moq.scene.T.Helper() r.findResults() @@ -7424,26 +6938,26 @@ func (r *moqUsual_Usual_fnRecorder) returnResults(sResult string, err error) *mo r.results.results = append(r.results.results, struct { values *struct { - sResult string - err error + result1 S + result2 error } sequence uint32 - doFn moqUsual_Usual_doFn - doReturnFn moqUsual_Usual_doReturnFn + doFn moqPartialGenericResultsFn_doFn[S] + doReturnFn moqPartialGenericResultsFn_doReturnFn[S] }{ values: &struct { - sResult string - err error + result1 S + result2 error }{ - sResult: sResult, - err: err, + result1: result1, + result2: result2, }, sequence: sequence, }) return r } -func (r *moqUsual_Usual_fnRecorder) andDo(fn moqUsual_Usual_doFn) *moqUsual_Usual_fnRecorder { +func (r *moqPartialGenericResultsFn_fnRecorder[S]) andDo(fn moqPartialGenericResultsFn_doFn[S]) *moqPartialGenericResultsFn_fnRecorder[S] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -7454,7 +6968,7 @@ func (r *moqUsual_Usual_fnRecorder) andDo(fn moqUsual_Usual_doFn) *moqUsual_Usua return r } -func (r *moqUsual_Usual_fnRecorder) doReturnResults(fn moqUsual_Usual_doReturnFn) *moqUsual_Usual_fnRecorder { +func (r *moqPartialGenericResultsFn_fnRecorder[S]) doReturnResults(fn moqPartialGenericResultsFn_doReturnFn[S]) *moqPartialGenericResultsFn_fnRecorder[S] { r.moq.scene.T.Helper() r.findResults() @@ -7465,17 +6979,17 @@ func (r *moqUsual_Usual_fnRecorder) doReturnResults(fn moqUsual_Usual_doReturnFn r.results.results = append(r.results.results, struct { values *struct { - sResult string - err error + result1 S + result2 error } sequence uint32 - doFn moqUsual_Usual_doFn - doReturnFn moqUsual_Usual_doReturnFn + doFn moqPartialGenericResultsFn_doFn[S] + doReturnFn moqPartialGenericResultsFn_doReturnFn[S] }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_Usual_fnRecorder) findResults() { +func (r *moqPartialGenericResultsFn_fnRecorder[S]) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -7484,8 +6998,8 @@ func (r *moqUsual_Usual_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_Usual_resultsByParams - for n, res := range r.moq.resultsByParams_Usual { + var results *moqPartialGenericResultsFn_resultsByParams[S] + for n, res := range r.moq.resultsByParams { if res.anyParams == r.anyParams { results = &res break @@ -7495,24 +7009,24 @@ func (r *moqUsual_Usual_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_Usual_resultsByParams{ + results = &moqPartialGenericResultsFn_resultsByParams[S]{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_Usual_paramsKey]*moqUsual_Usual_results{}, + results: map[moqPartialGenericResultsFn_paramsKey[S]]*moqPartialGenericResultsFn_results[S]{}, } - r.moq.resultsByParams_Usual = append(r.moq.resultsByParams_Usual, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Usual) { - copy(r.moq.resultsByParams_Usual[insertAt+1:], r.moq.resultsByParams_Usual[insertAt:0]) - r.moq.resultsByParams_Usual[insertAt] = *results + r.moq.resultsByParams = append(r.moq.resultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams) { + copy(r.moq.resultsByParams[insertAt+1:], r.moq.resultsByParams[insertAt:0]) + r.moq.resultsByParams[insertAt] = *results } } - paramsKey := r.moq.paramsKey_Usual(r.params, r.anyParams) + paramsKey := r.moq.paramsKey(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_Usual_results{ + r.results = &moqPartialGenericResultsFn_results[S]{ params: r.params, results: nil, index: 0, @@ -7524,7 +7038,7 @@ func (r *moqUsual_Usual_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_Usual_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_Usual_fnRecorder { +func (r *moqPartialGenericResultsFn_fnRecorder[S]) repeat(repeaters ...moq.Repeater) *moqPartialGenericResultsFn_fnRecorder[S] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -7536,12 +7050,12 @@ func (r *moqUsual_Usual_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_ if r.sequence { last = struct { values *struct { - sResult string - err error + result1 S + result2 error } sequence uint32 - doFn moqUsual_Usual_doFn - doReturnFn moqUsual_Usual_doReturnFn + doFn moqPartialGenericResultsFn_doFn[S] + doReturnFn moqPartialGenericResultsFn_doReturnFn[S] }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -7552,99 +7066,281 @@ func (r *moqUsual_Usual_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_ return r } -func (m *moqUsual) prettyParams_Usual(params moqUsual_Usual_params) string { - return fmt.Sprintf("Usual(%#v, %#v)", params.sParam, params.bParam) +func (m *moqPartialGenericResultsFn[S]) prettyParams(params moqPartialGenericResultsFn_params[S]) string { + return fmt.Sprintf("PartialGenericResultsFn(%#v, %#v)", params.param1, params.param2) } -func (m *moqUsual) paramsKey_Usual(params moqUsual_Usual_params, anyParams uint64) moqUsual_Usual_paramsKey { +func (m *moqPartialGenericResultsFn[S]) paramsKey(params moqPartialGenericResultsFn_params[S], anyParams uint64) moqPartialGenericResultsFn_paramsKey[S] { m.scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash + var param1Used string + var param1UsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Usual.sParam == moq.ParamIndexByValue { - sParamUsed = params.sParam + if m.runtime.parameterIndexing.param1 == moq.ParamIndexByValue { + param1Used = params.param1 } else { - sParamUsedHash = hash.DeepHash(params.sParam) + param1UsedHash = hash.DeepHash(params.param1) } } - var bParamUsed bool - var bParamUsedHash hash.Hash + var param2Used bool + var param2UsedHash hash.Hash if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.Usual.bParam == moq.ParamIndexByValue { - bParamUsed = params.bParam + if m.runtime.parameterIndexing.param2 == moq.ParamIndexByValue { + param2Used = params.param2 } else { - bParamUsedHash = hash.DeepHash(params.bParam) + param2UsedHash = hash.DeepHash(params.param2) } } - return moqUsual_Usual_paramsKey{ + return moqPartialGenericResultsFn_paramsKey[S]{ params: struct { - sParam string - bParam bool + param1 string + param2 bool }{ - sParam: sParamUsed, - bParam: bParamUsed, + param1: param1Used, + param2: param2Used, }, hashes: struct { - sParam hash.Hash - bParam hash.Hash + param1 hash.Hash + param2 hash.Hash }{ - sParam: sParamUsedHash, - bParam: bParamUsedHash, + param1: param1UsedHash, + param2: param2UsedHash, }, } } -func (m *moqUsual_recorder) NoNames(param1 string, param2 bool) *moqUsual_NoNames_fnRecorder { - return &moqUsual_NoNames_fnRecorder{ - params: moqUsual_NoNames_params{ - param1: param1, - param2: param2, +// Reset resets the state of the moq +func (m *moqPartialGenericResultsFn[S]) Reset() { m.resultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqPartialGenericResultsFn[S]) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams(results.params)) + } + } + } +} + +// moqGenericInterfaceParamFn holds the state of a moq of the +// GenericInterfaceParamFn type +type moqGenericInterfaceParamFn[W testmoqs.MyWriter] struct { + scene *moq.Scene + config moq.Config + moq *moqGenericInterfaceParamFn_mock[W] + + resultsByParams []moqGenericInterfaceParamFn_resultsByParams[W] + + runtime struct { + parameterIndexing struct { + w moq.ParamIndexing + } + } +} + +// moqGenericInterfaceParamFn_mock isolates the mock interface of the +// GenericInterfaceParamFn type +type moqGenericInterfaceParamFn_mock[W testmoqs.MyWriter] struct { + moq *moqGenericInterfaceParamFn[W] +} + +// moqGenericInterfaceParamFn_params holds the params of the +// GenericInterfaceParamFn type +type moqGenericInterfaceParamFn_params[W testmoqs.MyWriter] struct{ w W } + +// moqGenericInterfaceParamFn_paramsKey holds the map key params of the +// GenericInterfaceParamFn type +type moqGenericInterfaceParamFn_paramsKey[W testmoqs.MyWriter] struct { + params struct{} + hashes struct{ w hash.Hash } +} + +// moqGenericInterfaceParamFn_resultsByParams contains the results for a given +// set of parameters for the GenericInterfaceParamFn type +type moqGenericInterfaceParamFn_resultsByParams[W testmoqs.MyWriter] struct { + anyCount int + anyParams uint64 + results map[moqGenericInterfaceParamFn_paramsKey[W]]*moqGenericInterfaceParamFn_results[W] +} + +// moqGenericInterfaceParamFn_doFn defines the type of function needed when +// calling andDo for the GenericInterfaceParamFn type +type moqGenericInterfaceParamFn_doFn[W testmoqs.MyWriter] func(w W) + +// moqGenericInterfaceParamFn_doReturnFn defines the type of function needed +// when calling doReturnResults for the GenericInterfaceParamFn type +type moqGenericInterfaceParamFn_doReturnFn[W testmoqs.MyWriter] func(w W) (sResult string, err error) + +// moqGenericInterfaceParamFn_results holds the results of the +// GenericInterfaceParamFn type +type moqGenericInterfaceParamFn_results[W testmoqs.MyWriter] struct { + params moqGenericInterfaceParamFn_params[W] + results []struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqGenericInterfaceParamFn_doFn[W] + doReturnFn moqGenericInterfaceParamFn_doReturnFn[W] + } + index uint32 + repeat *moq.RepeatVal +} + +// moqGenericInterfaceParamFn_fnRecorder routes recorded function calls to the +// moqGenericInterfaceParamFn moq +type moqGenericInterfaceParamFn_fnRecorder[W testmoqs.MyWriter] struct { + params moqGenericInterfaceParamFn_params[W] + anyParams uint64 + sequence bool + results *moqGenericInterfaceParamFn_results[W] + moq *moqGenericInterfaceParamFn[W] +} + +// moqGenericInterfaceParamFn_anyParams isolates the any params functions of +// the GenericInterfaceParamFn type +type moqGenericInterfaceParamFn_anyParams[W testmoqs.MyWriter] struct { + recorder *moqGenericInterfaceParamFn_fnRecorder[W] +} + +// newMoqGenericInterfaceParamFn creates a new moq of the +// GenericInterfaceParamFn type +func newMoqGenericInterfaceParamFn[W testmoqs.MyWriter](scene *moq.Scene, config *moq.Config) *moqGenericInterfaceParamFn[W] { + if config == nil { + config = &moq.Config{} + } + m := &moqGenericInterfaceParamFn[W]{ + scene: scene, + config: *config, + moq: &moqGenericInterfaceParamFn_mock[W]{}, + + runtime: struct { + parameterIndexing struct { + w moq.ParamIndexing + } + }{parameterIndexing: struct { + w moq.ParamIndexing + }{ + w: moq.ParamIndexByHash, + }}, + } + m.moq.moq = m + + scene.AddMoq(m) + return m +} + +// mock returns the moq implementation of the GenericInterfaceParamFn type +func (m *moqGenericInterfaceParamFn[W]) mock() testmoqs.GenericInterfaceParamFn[W] { + return func(w W) (_ string, _ error) { + m.scene.T.Helper() + moq := &moqGenericInterfaceParamFn_mock[W]{moq: m} + return moq.fn(w) + } +} + +func (m *moqGenericInterfaceParamFn_mock[W]) fn(w W) (sResult string, err error) { + m.moq.scene.T.Helper() + params := moqGenericInterfaceParamFn_params[W]{ + w: w, + } + var results *moqGenericInterfaceParamFn_results[W] + for _, resultsByParams := range m.moq.resultsByParams { + paramsKey := m.moq.paramsKey(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams(params)) + } + } + + if result.doFn != nil { + result.doFn(w) + } + + if result.values != nil { + sResult = result.values.sResult + err = result.values.err + } + if result.doReturnFn != nil { + sResult, err = result.doReturnFn(w) + } + return +} + +func (m *moqGenericInterfaceParamFn[W]) onCall(w W) *moqGenericInterfaceParamFn_fnRecorder[W] { + return &moqGenericInterfaceParamFn_fnRecorder[W]{ + params: moqGenericInterfaceParamFn_params[W]{ + w: w, }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + sequence: m.config.Sequence == moq.SeqDefaultOn, + moq: m, } } -func (r *moqUsual_NoNames_fnRecorder) any() *moqUsual_NoNames_anyParams { +func (r *moqGenericInterfaceParamFn_fnRecorder[W]) any() *moqGenericInterfaceParamFn_anyParams[W] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoNames(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) return nil } - return &moqUsual_NoNames_anyParams{recorder: r} + return &moqGenericInterfaceParamFn_anyParams[W]{recorder: r} } -func (a *moqUsual_NoNames_anyParams) param1() *moqUsual_NoNames_fnRecorder { +func (a *moqGenericInterfaceParamFn_anyParams[W]) w() *moqGenericInterfaceParamFn_fnRecorder[W] { a.recorder.anyParams |= 1 << 0 return a.recorder } -func (a *moqUsual_NoNames_anyParams) param2() *moqUsual_NoNames_fnRecorder { - a.recorder.anyParams |= 1 << 1 - return a.recorder -} - -func (r *moqUsual_NoNames_fnRecorder) seq() *moqUsual_NoNames_fnRecorder { +func (r *moqGenericInterfaceParamFn_fnRecorder[W]) seq() *moqGenericInterfaceParamFn_fnRecorder[W] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoNames(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_NoNames_fnRecorder) noSeq() *moqUsual_NoNames_fnRecorder { +func (r *moqGenericInterfaceParamFn_fnRecorder[W]) noSeq() *moqGenericInterfaceParamFn_fnRecorder[W] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoNames(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_NoNames_fnRecorder) returnResults(result1 string, result2 error) *moqUsual_NoNames_fnRecorder { +func (r *moqGenericInterfaceParamFn_fnRecorder[W]) returnResults(sResult string, err error) *moqGenericInterfaceParamFn_fnRecorder[W] { r.moq.scene.T.Helper() r.findResults() @@ -7655,26 +7351,26 @@ func (r *moqUsual_NoNames_fnRecorder) returnResults(result1 string, result2 erro r.results.results = append(r.results.results, struct { values *struct { - result1 string - result2 error + sResult string + err error } sequence uint32 - doFn moqUsual_NoNames_doFn - doReturnFn moqUsual_NoNames_doReturnFn + doFn moqGenericInterfaceParamFn_doFn[W] + doReturnFn moqGenericInterfaceParamFn_doReturnFn[W] }{ values: &struct { - result1 string - result2 error + sResult string + err error }{ - result1: result1, - result2: result2, + sResult: sResult, + err: err, }, sequence: sequence, }) return r } -func (r *moqUsual_NoNames_fnRecorder) andDo(fn moqUsual_NoNames_doFn) *moqUsual_NoNames_fnRecorder { +func (r *moqGenericInterfaceParamFn_fnRecorder[W]) andDo(fn moqGenericInterfaceParamFn_doFn[W]) *moqGenericInterfaceParamFn_fnRecorder[W] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -7685,7 +7381,7 @@ func (r *moqUsual_NoNames_fnRecorder) andDo(fn moqUsual_NoNames_doFn) *moqUsual_ return r } -func (r *moqUsual_NoNames_fnRecorder) doReturnResults(fn moqUsual_NoNames_doReturnFn) *moqUsual_NoNames_fnRecorder { +func (r *moqGenericInterfaceParamFn_fnRecorder[W]) doReturnResults(fn moqGenericInterfaceParamFn_doReturnFn[W]) *moqGenericInterfaceParamFn_fnRecorder[W] { r.moq.scene.T.Helper() r.findResults() @@ -7696,17 +7392,17 @@ func (r *moqUsual_NoNames_fnRecorder) doReturnResults(fn moqUsual_NoNames_doRetu r.results.results = append(r.results.results, struct { values *struct { - result1 string - result2 error + sResult string + err error } sequence uint32 - doFn moqUsual_NoNames_doFn - doReturnFn moqUsual_NoNames_doReturnFn + doFn moqGenericInterfaceParamFn_doFn[W] + doReturnFn moqGenericInterfaceParamFn_doReturnFn[W] }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_NoNames_fnRecorder) findResults() { +func (r *moqGenericInterfaceParamFn_fnRecorder[W]) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -7715,8 +7411,8 @@ func (r *moqUsual_NoNames_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_NoNames_resultsByParams - for n, res := range r.moq.resultsByParams_NoNames { + var results *moqGenericInterfaceParamFn_resultsByParams[W] + for n, res := range r.moq.resultsByParams { if res.anyParams == r.anyParams { results = &res break @@ -7726,24 +7422,24 @@ func (r *moqUsual_NoNames_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_NoNames_resultsByParams{ + results = &moqGenericInterfaceParamFn_resultsByParams[W]{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_NoNames_paramsKey]*moqUsual_NoNames_results{}, + results: map[moqGenericInterfaceParamFn_paramsKey[W]]*moqGenericInterfaceParamFn_results[W]{}, } - r.moq.resultsByParams_NoNames = append(r.moq.resultsByParams_NoNames, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_NoNames) { - copy(r.moq.resultsByParams_NoNames[insertAt+1:], r.moq.resultsByParams_NoNames[insertAt:0]) - r.moq.resultsByParams_NoNames[insertAt] = *results + r.moq.resultsByParams = append(r.moq.resultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams) { + copy(r.moq.resultsByParams[insertAt+1:], r.moq.resultsByParams[insertAt:0]) + r.moq.resultsByParams[insertAt] = *results } } - paramsKey := r.moq.paramsKey_NoNames(r.params, r.anyParams) + paramsKey := r.moq.paramsKey(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_NoNames_results{ + r.results = &moqGenericInterfaceParamFn_results[W]{ params: r.params, results: nil, index: 0, @@ -7755,7 +7451,7 @@ func (r *moqUsual_NoNames_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_NoNames_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_NoNames_fnRecorder { +func (r *moqGenericInterfaceParamFn_fnRecorder[W]) repeat(repeaters ...moq.Repeater) *moqGenericInterfaceParamFn_fnRecorder[W] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -7767,12 +7463,12 @@ func (r *moqUsual_NoNames_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsua if r.sequence { last = struct { values *struct { - result1 string - result2 error + sResult string + err error } sequence uint32 - doFn moqUsual_NoNames_doFn - doReturnFn moqUsual_NoNames_doReturnFn + doFn moqGenericInterfaceParamFn_doFn[W] + doReturnFn moqGenericInterfaceParamFn_doReturnFn[W] }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -7783,99 +7479,276 @@ func (r *moqUsual_NoNames_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsua return r } -func (m *moqUsual) prettyParams_NoNames(params moqUsual_NoNames_params) string { - return fmt.Sprintf("NoNames(%#v, %#v)", params.param1, params.param2) +func (m *moqGenericInterfaceParamFn[W]) prettyParams(params moqGenericInterfaceParamFn_params[W]) string { + return fmt.Sprintf("GenericInterfaceParamFn(%#v)", params.w) } -func (m *moqUsual) paramsKey_NoNames(params moqUsual_NoNames_params, anyParams uint64) moqUsual_NoNames_paramsKey { +func (m *moqGenericInterfaceParamFn[W]) paramsKey(params moqGenericInterfaceParamFn_params[W], anyParams uint64) moqGenericInterfaceParamFn_paramsKey[W] { m.scene.T.Helper() - var param1Used string - var param1UsedHash hash.Hash + var wUsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.NoNames.param1 == moq.ParamIndexByValue { - param1Used = params.param1 - } else { - param1UsedHash = hash.DeepHash(params.param1) + if m.runtime.parameterIndexing.w == moq.ParamIndexByValue { + m.scene.T.Fatalf("The w parameter can't be indexed by value") } + wUsedHash = hash.DeepHash(params.w) } - var param2Used bool - var param2UsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.NoNames.param2 == moq.ParamIndexByValue { - param2Used = params.param2 - } else { - param2UsedHash = hash.DeepHash(params.param2) + return moqGenericInterfaceParamFn_paramsKey[W]{ + params: struct{}{}, + hashes: struct{ w hash.Hash }{ + w: wUsedHash, + }, + } +} + +// Reset resets the state of the moq +func (m *moqGenericInterfaceParamFn[W]) Reset() { m.resultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqGenericInterfaceParamFn[W]) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams(results.params)) + } } } - return moqUsual_NoNames_paramsKey{ - params: struct { - param1 string - param2 bool - }{ - param1: param1Used, - param2: param2Used, - }, - hashes: struct { - param1 hash.Hash - param2 hash.Hash +} + +// moqGenericInterfaceResultFn holds the state of a moq of the +// GenericInterfaceResultFn type +type moqGenericInterfaceResultFn[R testmoqs.MyReader] struct { + scene *moq.Scene + config moq.Config + moq *moqGenericInterfaceResultFn_mock[R] + + resultsByParams []moqGenericInterfaceResultFn_resultsByParams[R] + + runtime struct { + parameterIndexing struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + } +} + +// moqGenericInterfaceResultFn_mock isolates the mock interface of the +// GenericInterfaceResultFn type +type moqGenericInterfaceResultFn_mock[R testmoqs.MyReader] struct { + moq *moqGenericInterfaceResultFn[R] +} + +// moqGenericInterfaceResultFn_params holds the params of the +// GenericInterfaceResultFn type +type moqGenericInterfaceResultFn_params[R testmoqs.MyReader] struct { + sParam string + bParam bool +} + +// moqGenericInterfaceResultFn_paramsKey holds the map key params of the +// GenericInterfaceResultFn type +type moqGenericInterfaceResultFn_paramsKey[R testmoqs.MyReader] struct { + params struct { + sParam string + bParam bool + } + hashes struct { + sParam hash.Hash + bParam hash.Hash + } +} + +// moqGenericInterfaceResultFn_resultsByParams contains the results for a given +// set of parameters for the GenericInterfaceResultFn type +type moqGenericInterfaceResultFn_resultsByParams[R testmoqs.MyReader] struct { + anyCount int + anyParams uint64 + results map[moqGenericInterfaceResultFn_paramsKey[R]]*moqGenericInterfaceResultFn_results[R] +} + +// moqGenericInterfaceResultFn_doFn defines the type of function needed when +// calling andDo for the GenericInterfaceResultFn type +type moqGenericInterfaceResultFn_doFn[R testmoqs.MyReader] func(sParam string, bParam bool) + +// moqGenericInterfaceResultFn_doReturnFn defines the type of function needed +// when calling doReturnResults for the GenericInterfaceResultFn type +type moqGenericInterfaceResultFn_doReturnFn[R testmoqs.MyReader] func(sParam string, bParam bool) (r R) + +// moqGenericInterfaceResultFn_results holds the results of the +// GenericInterfaceResultFn type +type moqGenericInterfaceResultFn_results[R testmoqs.MyReader] struct { + params moqGenericInterfaceResultFn_params[R] + results []struct { + values *struct{ result1 R } + sequence uint32 + doFn moqGenericInterfaceResultFn_doFn[R] + doReturnFn moqGenericInterfaceResultFn_doReturnFn[R] + } + index uint32 + repeat *moq.RepeatVal +} + +// moqGenericInterfaceResultFn_fnRecorder routes recorded function calls to the +// moqGenericInterfaceResultFn moq +type moqGenericInterfaceResultFn_fnRecorder[R testmoqs.MyReader] struct { + params moqGenericInterfaceResultFn_params[R] + anyParams uint64 + sequence bool + results *moqGenericInterfaceResultFn_results[R] + moq *moqGenericInterfaceResultFn[R] +} + +// moqGenericInterfaceResultFn_anyParams isolates the any params functions of +// the GenericInterfaceResultFn type +type moqGenericInterfaceResultFn_anyParams[R testmoqs.MyReader] struct { + recorder *moqGenericInterfaceResultFn_fnRecorder[R] +} + +// newMoqGenericInterfaceResultFn creates a new moq of the +// GenericInterfaceResultFn type +func newMoqGenericInterfaceResultFn[R testmoqs.MyReader](scene *moq.Scene, config *moq.Config) *moqGenericInterfaceResultFn[R] { + if config == nil { + config = &moq.Config{} + } + m := &moqGenericInterfaceResultFn[R]{ + scene: scene, + config: *config, + moq: &moqGenericInterfaceResultFn_mock[R]{}, + + runtime: struct { + parameterIndexing struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + }{parameterIndexing: struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing }{ - param1: param1UsedHash, - param2: param2UsedHash, - }, + sParam: moq.ParamIndexByValue, + bParam: moq.ParamIndexByValue, + }}, } + m.moq.moq = m + + scene.AddMoq(m) + return m } -func (m *moqUsual_recorder) NoResults(sParam string, bParam bool) *moqUsual_NoResults_fnRecorder { - return &moqUsual_NoResults_fnRecorder{ - params: moqUsual_NoResults_params{ +// mock returns the moq implementation of the GenericInterfaceResultFn type +func (m *moqGenericInterfaceResultFn[R]) mock() testmoqs.GenericInterfaceResultFn[R] { + return func(sParam string, bParam bool) (_ R) { + m.scene.T.Helper() + moq := &moqGenericInterfaceResultFn_mock[R]{moq: m} + return moq.fn(sParam, bParam) + } +} + +func (m *moqGenericInterfaceResultFn_mock[R]) fn(sParam string, bParam bool) (result1 R) { + m.moq.scene.T.Helper() + params := moqGenericInterfaceResultFn_params[R]{ + sParam: sParam, + bParam: bParam, + } + var results *moqGenericInterfaceResultFn_results[R] + for _, resultsByParams := range m.moq.resultsByParams { + paramsKey := m.moq.paramsKey(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams(params)) + } + } + + if result.doFn != nil { + result.doFn(sParam, bParam) + } + + if result.values != nil { + result1 = result.values.result1 + } + if result.doReturnFn != nil { + result1 = result.doReturnFn(sParam, bParam) + } + return +} + +func (m *moqGenericInterfaceResultFn[R]) onCall(sParam string, bParam bool) *moqGenericInterfaceResultFn_fnRecorder[R] { + return &moqGenericInterfaceResultFn_fnRecorder[R]{ + params: moqGenericInterfaceResultFn_params[R]{ sParam: sParam, bParam: bParam, }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + sequence: m.config.Sequence == moq.SeqDefaultOn, + moq: m, } } -func (r *moqUsual_NoResults_fnRecorder) any() *moqUsual_NoResults_anyParams { +func (r *moqGenericInterfaceResultFn_fnRecorder[R]) any() *moqGenericInterfaceResultFn_anyParams[R] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoResults(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) return nil } - return &moqUsual_NoResults_anyParams{recorder: r} + return &moqGenericInterfaceResultFn_anyParams[R]{recorder: r} } -func (a *moqUsual_NoResults_anyParams) sParam() *moqUsual_NoResults_fnRecorder { +func (a *moqGenericInterfaceResultFn_anyParams[R]) sParam() *moqGenericInterfaceResultFn_fnRecorder[R] { a.recorder.anyParams |= 1 << 0 return a.recorder } -func (a *moqUsual_NoResults_anyParams) bParam() *moqUsual_NoResults_fnRecorder { +func (a *moqGenericInterfaceResultFn_anyParams[R]) bParam() *moqGenericInterfaceResultFn_fnRecorder[R] { a.recorder.anyParams |= 1 << 1 return a.recorder } -func (r *moqUsual_NoResults_fnRecorder) seq() *moqUsual_NoResults_fnRecorder { +func (r *moqGenericInterfaceResultFn_fnRecorder[R]) seq() *moqGenericInterfaceResultFn_fnRecorder[R] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoResults(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_NoResults_fnRecorder) noSeq() *moqUsual_NoResults_fnRecorder { +func (r *moqGenericInterfaceResultFn_fnRecorder[R]) noSeq() *moqGenericInterfaceResultFn_fnRecorder[R] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoResults(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_NoResults_fnRecorder) returnResults() *moqUsual_NoResults_fnRecorder { +func (r *moqGenericInterfaceResultFn_fnRecorder[R]) returnResults(result1 R) *moqGenericInterfaceResultFn_fnRecorder[R] { r.moq.scene.T.Helper() r.findResults() @@ -7885,18 +7758,20 @@ func (r *moqUsual_NoResults_fnRecorder) returnResults() *moqUsual_NoResults_fnRe } r.results.results = append(r.results.results, struct { - values *struct{} + values *struct{ result1 R } sequence uint32 - doFn moqUsual_NoResults_doFn - doReturnFn moqUsual_NoResults_doReturnFn + doFn moqGenericInterfaceResultFn_doFn[R] + doReturnFn moqGenericInterfaceResultFn_doReturnFn[R] }{ - values: &struct{}{}, + values: &struct{ result1 R }{ + result1: result1, + }, sequence: sequence, }) return r } -func (r *moqUsual_NoResults_fnRecorder) andDo(fn moqUsual_NoResults_doFn) *moqUsual_NoResults_fnRecorder { +func (r *moqGenericInterfaceResultFn_fnRecorder[R]) andDo(fn moqGenericInterfaceResultFn_doFn[R]) *moqGenericInterfaceResultFn_fnRecorder[R] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -7907,7 +7782,7 @@ func (r *moqUsual_NoResults_fnRecorder) andDo(fn moqUsual_NoResults_doFn) *moqUs return r } -func (r *moqUsual_NoResults_fnRecorder) doReturnResults(fn moqUsual_NoResults_doReturnFn) *moqUsual_NoResults_fnRecorder { +func (r *moqGenericInterfaceResultFn_fnRecorder[R]) doReturnResults(fn moqGenericInterfaceResultFn_doReturnFn[R]) *moqGenericInterfaceResultFn_fnRecorder[R] { r.moq.scene.T.Helper() r.findResults() @@ -7917,15 +7792,15 @@ func (r *moqUsual_NoResults_fnRecorder) doReturnResults(fn moqUsual_NoResults_do } r.results.results = append(r.results.results, struct { - values *struct{} + values *struct{ result1 R } sequence uint32 - doFn moqUsual_NoResults_doFn - doReturnFn moqUsual_NoResults_doReturnFn + doFn moqGenericInterfaceResultFn_doFn[R] + doReturnFn moqGenericInterfaceResultFn_doReturnFn[R] }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_NoResults_fnRecorder) findResults() { +func (r *moqGenericInterfaceResultFn_fnRecorder[R]) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -7934,8 +7809,8 @@ func (r *moqUsual_NoResults_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_NoResults_resultsByParams - for n, res := range r.moq.resultsByParams_NoResults { + var results *moqGenericInterfaceResultFn_resultsByParams[R] + for n, res := range r.moq.resultsByParams { if res.anyParams == r.anyParams { results = &res break @@ -7945,24 +7820,24 @@ func (r *moqUsual_NoResults_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_NoResults_resultsByParams{ + results = &moqGenericInterfaceResultFn_resultsByParams[R]{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_NoResults_paramsKey]*moqUsual_NoResults_results{}, + results: map[moqGenericInterfaceResultFn_paramsKey[R]]*moqGenericInterfaceResultFn_results[R]{}, } - r.moq.resultsByParams_NoResults = append(r.moq.resultsByParams_NoResults, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_NoResults) { - copy(r.moq.resultsByParams_NoResults[insertAt+1:], r.moq.resultsByParams_NoResults[insertAt:0]) - r.moq.resultsByParams_NoResults[insertAt] = *results + r.moq.resultsByParams = append(r.moq.resultsByParams, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams) { + copy(r.moq.resultsByParams[insertAt+1:], r.moq.resultsByParams[insertAt:0]) + r.moq.resultsByParams[insertAt] = *results } } - paramsKey := r.moq.paramsKey_NoResults(r.params, r.anyParams) + paramsKey := r.moq.paramsKey(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_NoResults_results{ + r.results = &moqGenericInterfaceResultFn_results[R]{ params: r.params, results: nil, index: 0, @@ -7974,7 +7849,7 @@ func (r *moqUsual_NoResults_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_NoResults_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_NoResults_fnRecorder { +func (r *moqGenericInterfaceResultFn_fnRecorder[R]) repeat(repeaters ...moq.Repeater) *moqGenericInterfaceResultFn_fnRecorder[R] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -7985,10 +7860,10 @@ func (r *moqUsual_NoResults_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUs for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{} + values *struct{ result1 R } sequence uint32 - doFn moqUsual_NoResults_doFn - doReturnFn moqUsual_NoResults_doReturnFn + doFn moqGenericInterfaceResultFn_doFn[R] + doReturnFn moqGenericInterfaceResultFn_doReturnFn[R] }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -7999,16 +7874,16 @@ func (r *moqUsual_NoResults_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUs return r } -func (m *moqUsual) prettyParams_NoResults(params moqUsual_NoResults_params) string { - return fmt.Sprintf("NoResults(%#v, %#v)", params.sParam, params.bParam) +func (m *moqGenericInterfaceResultFn[R]) prettyParams(params moqGenericInterfaceResultFn_params[R]) string { + return fmt.Sprintf("GenericInterfaceResultFn(%#v, %#v)", params.sParam, params.bParam) } -func (m *moqUsual) paramsKey_NoResults(params moqUsual_NoResults_params, anyParams uint64) moqUsual_NoResults_paramsKey { +func (m *moqGenericInterfaceResultFn[R]) paramsKey(params moqGenericInterfaceResultFn_params[R], anyParams uint64) moqGenericInterfaceResultFn_paramsKey[R] { m.scene.T.Helper() var sParamUsed string var sParamUsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.NoResults.sParam == moq.ParamIndexByValue { + if m.runtime.parameterIndexing.sParam == moq.ParamIndexByValue { sParamUsed = params.sParam } else { sParamUsedHash = hash.DeepHash(params.sParam) @@ -8017,13 +7892,13 @@ func (m *moqUsual) paramsKey_NoResults(params moqUsual_NoResults_params, anyPara var bParamUsed bool var bParamUsedHash hash.Hash if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.NoResults.bParam == moq.ParamIndexByValue { + if m.runtime.parameterIndexing.bParam == moq.ParamIndexByValue { bParamUsed = params.bParam } else { bParamUsedHash = hash.DeepHash(params.bParam) } } - return moqUsual_NoResults_paramsKey{ + return moqGenericInterfaceResultFn_paramsKey[R]{ params: struct { sParam string bParam bool @@ -8041,44 +7916,4504 @@ func (m *moqUsual) paramsKey_NoResults(params moqUsual_NoResults_params, anyPara } } -func (m *moqUsual_recorder) NoParams() *moqUsual_NoParams_fnRecorder { - return &moqUsual_NoParams_fnRecorder{ +// Reset resets the state of the moq +func (m *moqGenericInterfaceResultFn[R]) Reset() { m.resultsByParams = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqGenericInterfaceResultFn[R]) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams(results.params)) + } + } + } +} + +// The following type assertion assures that testmoqs.Usual is mocked +// completely +var _ testmoqs.Usual = (*moqUsual_mock)(nil) + +// moqUsual holds the state of a moq of the Usual type +type moqUsual struct { + scene *moq.Scene + config moq.Config + moq *moqUsual_mock + + resultsByParams_Usual []moqUsual_Usual_resultsByParams + resultsByParams_NoNames []moqUsual_NoNames_resultsByParams + resultsByParams_NoResults []moqUsual_NoResults_resultsByParams + resultsByParams_NoParams []moqUsual_NoParams_resultsByParams + resultsByParams_Nothing []moqUsual_Nothing_resultsByParams + resultsByParams_Variadic []moqUsual_Variadic_resultsByParams + resultsByParams_RepeatedIds []moqUsual_RepeatedIds_resultsByParams + resultsByParams_Times []moqUsual_Times_resultsByParams + resultsByParams_DifficultParamNames []moqUsual_DifficultParamNames_resultsByParams + resultsByParams_DifficultResultNames []moqUsual_DifficultResultNames_resultsByParams + resultsByParams_PassByReference []moqUsual_PassByReference_resultsByParams + resultsByParams_InterfaceParam []moqUsual_InterfaceParam_resultsByParams + resultsByParams_InterfaceResult []moqUsual_InterfaceResult_resultsByParams + resultsByParams_FnParam []moqUsual_FnParam_resultsByParams + + runtime struct { + parameterIndexing struct { + Usual struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + NoNames struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + NoResults struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + NoParams struct{} + Nothing struct{} + Variadic struct { + other moq.ParamIndexing + args moq.ParamIndexing + } + RepeatedIds struct { + sParam1 moq.ParamIndexing + sParam2 moq.ParamIndexing + bParam moq.ParamIndexing + } + Times struct { + sParam moq.ParamIndexing + times moq.ParamIndexing + } + DifficultParamNames struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + param3 moq.ParamIndexing + param moq.ParamIndexing + param5 moq.ParamIndexing + param6 moq.ParamIndexing + param7 moq.ParamIndexing + param8 moq.ParamIndexing + param9 moq.ParamIndexing + } + DifficultResultNames struct{} + PassByReference struct { + p moq.ParamIndexing + } + InterfaceParam struct { + w moq.ParamIndexing + } + InterfaceResult struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + FnParam struct { + fn moq.ParamIndexing + } + } + } + // moqUsual_mock isolates the mock interface of the Usual type +} + +type moqUsual_mock struct { + moq *moqUsual +} + +// moqUsual_recorder isolates the recorder interface of the Usual type +type moqUsual_recorder struct { + moq *moqUsual +} + +// moqUsual_Usual_params holds the params of the Usual type +type moqUsual_Usual_params struct { + sParam string + bParam bool +} + +// moqUsual_Usual_paramsKey holds the map key params of the Usual type +type moqUsual_Usual_paramsKey struct { + params struct { + sParam string + bParam bool + } + hashes struct { + sParam hash.Hash + bParam hash.Hash + } +} + +// moqUsual_Usual_resultsByParams contains the results for a given set of +// parameters for the Usual type +type moqUsual_Usual_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_Usual_paramsKey]*moqUsual_Usual_results +} + +// moqUsual_Usual_doFn defines the type of function needed when calling andDo +// for the Usual type +type moqUsual_Usual_doFn func(sParam string, bParam bool) + +// moqUsual_Usual_doReturnFn defines the type of function needed when calling +// doReturnResults for the Usual type +type moqUsual_Usual_doReturnFn func(sParam string, bParam bool) (sResult string, err error) + +// moqUsual_Usual_results holds the results of the Usual type +type moqUsual_Usual_results struct { + params moqUsual_Usual_params + results []struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Usual_doFn + doReturnFn moqUsual_Usual_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_Usual_fnRecorder routes recorded function calls to the moqUsual moq +type moqUsual_Usual_fnRecorder struct { + params moqUsual_Usual_params + anyParams uint64 + sequence bool + results *moqUsual_Usual_results + moq *moqUsual +} + +// moqUsual_Usual_anyParams isolates the any params functions of the Usual type +type moqUsual_Usual_anyParams struct { + recorder *moqUsual_Usual_fnRecorder +} + +// moqUsual_NoNames_params holds the params of the Usual type +type moqUsual_NoNames_params struct { + param1 string + param2 bool +} + +// moqUsual_NoNames_paramsKey holds the map key params of the Usual type +type moqUsual_NoNames_paramsKey struct { + params struct { + param1 string + param2 bool + } + hashes struct { + param1 hash.Hash + param2 hash.Hash + } +} + +// moqUsual_NoNames_resultsByParams contains the results for a given set of +// parameters for the Usual type +type moqUsual_NoNames_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_NoNames_paramsKey]*moqUsual_NoNames_results +} + +// moqUsual_NoNames_doFn defines the type of function needed when calling andDo +// for the Usual type +type moqUsual_NoNames_doFn func(string, bool) + +// moqUsual_NoNames_doReturnFn defines the type of function needed when calling +// doReturnResults for the Usual type +type moqUsual_NoNames_doReturnFn func(string, bool) (string, error) + +// moqUsual_NoNames_results holds the results of the Usual type +type moqUsual_NoNames_results struct { + params moqUsual_NoNames_params + results []struct { + values *struct { + result1 string + result2 error + } + sequence uint32 + doFn moqUsual_NoNames_doFn + doReturnFn moqUsual_NoNames_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_NoNames_fnRecorder routes recorded function calls to the moqUsual +// moq +type moqUsual_NoNames_fnRecorder struct { + params moqUsual_NoNames_params + anyParams uint64 + sequence bool + results *moqUsual_NoNames_results + moq *moqUsual +} + +// moqUsual_NoNames_anyParams isolates the any params functions of the Usual +// type +type moqUsual_NoNames_anyParams struct { + recorder *moqUsual_NoNames_fnRecorder +} + +// moqUsual_NoResults_params holds the params of the Usual type +type moqUsual_NoResults_params struct { + sParam string + bParam bool +} + +// moqUsual_NoResults_paramsKey holds the map key params of the Usual type +type moqUsual_NoResults_paramsKey struct { + params struct { + sParam string + bParam bool + } + hashes struct { + sParam hash.Hash + bParam hash.Hash + } +} + +// moqUsual_NoResults_resultsByParams contains the results for a given set of +// parameters for the Usual type +type moqUsual_NoResults_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_NoResults_paramsKey]*moqUsual_NoResults_results +} + +// moqUsual_NoResults_doFn defines the type of function needed when calling +// andDo for the Usual type +type moqUsual_NoResults_doFn func(sParam string, bParam bool) + +// moqUsual_NoResults_doReturnFn defines the type of function needed when +// calling doReturnResults for the Usual type +type moqUsual_NoResults_doReturnFn func(sParam string, bParam bool) + +// moqUsual_NoResults_results holds the results of the Usual type +type moqUsual_NoResults_results struct { + params moqUsual_NoResults_params + results []struct { + values *struct{} + sequence uint32 + doFn moqUsual_NoResults_doFn + doReturnFn moqUsual_NoResults_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_NoResults_fnRecorder routes recorded function calls to the moqUsual +// moq +type moqUsual_NoResults_fnRecorder struct { + params moqUsual_NoResults_params + anyParams uint64 + sequence bool + results *moqUsual_NoResults_results + moq *moqUsual +} + +// moqUsual_NoResults_anyParams isolates the any params functions of the Usual +// type +type moqUsual_NoResults_anyParams struct { + recorder *moqUsual_NoResults_fnRecorder +} + +// moqUsual_NoParams_params holds the params of the Usual type +type moqUsual_NoParams_params struct{} + +// moqUsual_NoParams_paramsKey holds the map key params of the Usual type +type moqUsual_NoParams_paramsKey struct { + params struct{} + hashes struct{} +} + +// moqUsual_NoParams_resultsByParams contains the results for a given set of +// parameters for the Usual type +type moqUsual_NoParams_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_NoParams_paramsKey]*moqUsual_NoParams_results +} + +// moqUsual_NoParams_doFn defines the type of function needed when calling +// andDo for the Usual type +type moqUsual_NoParams_doFn func() + +// moqUsual_NoParams_doReturnFn defines the type of function needed when +// calling doReturnResults for the Usual type +type moqUsual_NoParams_doReturnFn func() (sResult string, err error) + +// moqUsual_NoParams_results holds the results of the Usual type +type moqUsual_NoParams_results struct { + params moqUsual_NoParams_params + results []struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_NoParams_doFn + doReturnFn moqUsual_NoParams_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_NoParams_fnRecorder routes recorded function calls to the moqUsual +// moq +type moqUsual_NoParams_fnRecorder struct { + params moqUsual_NoParams_params + anyParams uint64 + sequence bool + results *moqUsual_NoParams_results + moq *moqUsual +} + +// moqUsual_NoParams_anyParams isolates the any params functions of the Usual +// type +type moqUsual_NoParams_anyParams struct { + recorder *moqUsual_NoParams_fnRecorder +} + +// moqUsual_Nothing_params holds the params of the Usual type +type moqUsual_Nothing_params struct{} + +// moqUsual_Nothing_paramsKey holds the map key params of the Usual type +type moqUsual_Nothing_paramsKey struct { + params struct{} + hashes struct{} +} + +// moqUsual_Nothing_resultsByParams contains the results for a given set of +// parameters for the Usual type +type moqUsual_Nothing_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_Nothing_paramsKey]*moqUsual_Nothing_results +} + +// moqUsual_Nothing_doFn defines the type of function needed when calling andDo +// for the Usual type +type moqUsual_Nothing_doFn func() + +// moqUsual_Nothing_doReturnFn defines the type of function needed when calling +// doReturnResults for the Usual type +type moqUsual_Nothing_doReturnFn func() + +// moqUsual_Nothing_results holds the results of the Usual type +type moqUsual_Nothing_results struct { + params moqUsual_Nothing_params + results []struct { + values *struct{} + sequence uint32 + doFn moqUsual_Nothing_doFn + doReturnFn moqUsual_Nothing_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_Nothing_fnRecorder routes recorded function calls to the moqUsual +// moq +type moqUsual_Nothing_fnRecorder struct { + params moqUsual_Nothing_params + anyParams uint64 + sequence bool + results *moqUsual_Nothing_results + moq *moqUsual +} + +// moqUsual_Nothing_anyParams isolates the any params functions of the Usual +// type +type moqUsual_Nothing_anyParams struct { + recorder *moqUsual_Nothing_fnRecorder +} + +// moqUsual_Variadic_params holds the params of the Usual type +type moqUsual_Variadic_params struct { + other bool + args []string +} + +// moqUsual_Variadic_paramsKey holds the map key params of the Usual type +type moqUsual_Variadic_paramsKey struct { + params struct{ other bool } + hashes struct { + other hash.Hash + args hash.Hash + } +} + +// moqUsual_Variadic_resultsByParams contains the results for a given set of +// parameters for the Usual type +type moqUsual_Variadic_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_Variadic_paramsKey]*moqUsual_Variadic_results +} + +// moqUsual_Variadic_doFn defines the type of function needed when calling +// andDo for the Usual type +type moqUsual_Variadic_doFn func(other bool, args ...string) + +// moqUsual_Variadic_doReturnFn defines the type of function needed when +// calling doReturnResults for the Usual type +type moqUsual_Variadic_doReturnFn func(other bool, args ...string) (sResult string, err error) + +// moqUsual_Variadic_results holds the results of the Usual type +type moqUsual_Variadic_results struct { + params moqUsual_Variadic_params + results []struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Variadic_doFn + doReturnFn moqUsual_Variadic_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_Variadic_fnRecorder routes recorded function calls to the moqUsual +// moq +type moqUsual_Variadic_fnRecorder struct { + params moqUsual_Variadic_params + anyParams uint64 + sequence bool + results *moqUsual_Variadic_results + moq *moqUsual +} + +// moqUsual_Variadic_anyParams isolates the any params functions of the Usual +// type +type moqUsual_Variadic_anyParams struct { + recorder *moqUsual_Variadic_fnRecorder +} + +// moqUsual_RepeatedIds_params holds the params of the Usual type +type moqUsual_RepeatedIds_params struct { + sParam1, sParam2 string + bParam bool +} + +// moqUsual_RepeatedIds_paramsKey holds the map key params of the Usual type +type moqUsual_RepeatedIds_paramsKey struct { + params struct { + sParam1, sParam2 string + bParam bool + } + hashes struct { + sParam1, sParam2 hash.Hash + bParam hash.Hash + } +} + +// moqUsual_RepeatedIds_resultsByParams contains the results for a given set of +// parameters for the Usual type +type moqUsual_RepeatedIds_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_RepeatedIds_paramsKey]*moqUsual_RepeatedIds_results +} + +// moqUsual_RepeatedIds_doFn defines the type of function needed when calling +// andDo for the Usual type +type moqUsual_RepeatedIds_doFn func(sParam1, sParam2 string, bParam bool) + +// moqUsual_RepeatedIds_doReturnFn defines the type of function needed when +// calling doReturnResults for the Usual type +type moqUsual_RepeatedIds_doReturnFn func(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) + +// moqUsual_RepeatedIds_results holds the results of the Usual type +type moqUsual_RepeatedIds_results struct { + params moqUsual_RepeatedIds_params + results []struct { + values *struct { + sResult1, sResult2 string + err error + } + sequence uint32 + doFn moqUsual_RepeatedIds_doFn + doReturnFn moqUsual_RepeatedIds_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_RepeatedIds_fnRecorder routes recorded function calls to the +// moqUsual moq +type moqUsual_RepeatedIds_fnRecorder struct { + params moqUsual_RepeatedIds_params + anyParams uint64 + sequence bool + results *moqUsual_RepeatedIds_results + moq *moqUsual +} + +// moqUsual_RepeatedIds_anyParams isolates the any params functions of the +// Usual type +type moqUsual_RepeatedIds_anyParams struct { + recorder *moqUsual_RepeatedIds_fnRecorder +} + +// moqUsual_Times_params holds the params of the Usual type +type moqUsual_Times_params struct { + sParam string + times bool +} + +// moqUsual_Times_paramsKey holds the map key params of the Usual type +type moqUsual_Times_paramsKey struct { + params struct { + sParam string + times bool + } + hashes struct { + sParam hash.Hash + times hash.Hash + } +} + +// moqUsual_Times_resultsByParams contains the results for a given set of +// parameters for the Usual type +type moqUsual_Times_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_Times_paramsKey]*moqUsual_Times_results +} + +// moqUsual_Times_doFn defines the type of function needed when calling andDo +// for the Usual type +type moqUsual_Times_doFn func(sParam string, times bool) + +// moqUsual_Times_doReturnFn defines the type of function needed when calling +// doReturnResults for the Usual type +type moqUsual_Times_doReturnFn func(sParam string, times bool) (sResult string, err error) + +// moqUsual_Times_results holds the results of the Usual type +type moqUsual_Times_results struct { + params moqUsual_Times_params + results []struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Times_doFn + doReturnFn moqUsual_Times_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_Times_fnRecorder routes recorded function calls to the moqUsual moq +type moqUsual_Times_fnRecorder struct { + params moqUsual_Times_params + anyParams uint64 + sequence bool + results *moqUsual_Times_results + moq *moqUsual +} + +// moqUsual_Times_anyParams isolates the any params functions of the Usual type +type moqUsual_Times_anyParams struct { + recorder *moqUsual_Times_fnRecorder +} + +// moqUsual_DifficultParamNames_params holds the params of the Usual type +type moqUsual_DifficultParamNames_params struct { + param1, param2 bool + param3 string + param, param5, param6 int + param7, param8, param9 float32 +} + +// moqUsual_DifficultParamNames_paramsKey holds the map key params of the Usual +// type +type moqUsual_DifficultParamNames_paramsKey struct { + params struct { + param1, param2 bool + param3 string + param, param5, param6 int + param7, param8, param9 float32 + } + hashes struct { + param1, param2 hash.Hash + param3 hash.Hash + param, param5, param6 hash.Hash + param7, param8, param9 hash.Hash + } +} + +// moqUsual_DifficultParamNames_resultsByParams contains the results for a +// given set of parameters for the Usual type +type moqUsual_DifficultParamNames_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_DifficultParamNames_paramsKey]*moqUsual_DifficultParamNames_results +} + +// moqUsual_DifficultParamNames_doFn defines the type of function needed when +// calling andDo for the Usual type +type moqUsual_DifficultParamNames_doFn func(m, r bool, sequence string, param, params, i int, result, results, _ float32) + +// moqUsual_DifficultParamNames_doReturnFn defines the type of function needed +// when calling doReturnResults for the Usual type +type moqUsual_DifficultParamNames_doReturnFn func(m, r bool, sequence string, param, params, i int, result, results, _ float32) + +// moqUsual_DifficultParamNames_results holds the results of the Usual type +type moqUsual_DifficultParamNames_results struct { + params moqUsual_DifficultParamNames_params + results []struct { + values *struct{} + sequence uint32 + doFn moqUsual_DifficultParamNames_doFn + doReturnFn moqUsual_DifficultParamNames_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_DifficultParamNames_fnRecorder routes recorded function calls to +// the moqUsual moq +type moqUsual_DifficultParamNames_fnRecorder struct { + params moqUsual_DifficultParamNames_params + anyParams uint64 + sequence bool + results *moqUsual_DifficultParamNames_results + moq *moqUsual +} + +// moqUsual_DifficultParamNames_anyParams isolates the any params functions of +// the Usual type +type moqUsual_DifficultParamNames_anyParams struct { + recorder *moqUsual_DifficultParamNames_fnRecorder +} + +// moqUsual_DifficultResultNames_params holds the params of the Usual type +type moqUsual_DifficultResultNames_params struct{} + +// moqUsual_DifficultResultNames_paramsKey holds the map key params of the +// Usual type +type moqUsual_DifficultResultNames_paramsKey struct { + params struct{} + hashes struct{} +} + +// moqUsual_DifficultResultNames_resultsByParams contains the results for a +// given set of parameters for the Usual type +type moqUsual_DifficultResultNames_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_DifficultResultNames_paramsKey]*moqUsual_DifficultResultNames_results +} + +// moqUsual_DifficultResultNames_doFn defines the type of function needed when +// calling andDo for the Usual type +type moqUsual_DifficultResultNames_doFn func() + +// moqUsual_DifficultResultNames_doReturnFn defines the type of function needed +// when calling doReturnResults for the Usual type +type moqUsual_DifficultResultNames_doReturnFn func() (m, r string, sequence error, param, params, i int, result, results, _ float32) + +// moqUsual_DifficultResultNames_results holds the results of the Usual type +type moqUsual_DifficultResultNames_results struct { + params moqUsual_DifficultResultNames_params + results []struct { + values *struct { + result1, result2 string + result3 error + param, result5, result6 int + result7, result8, result9 float32 + } + sequence uint32 + doFn moqUsual_DifficultResultNames_doFn + doReturnFn moqUsual_DifficultResultNames_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_DifficultResultNames_fnRecorder routes recorded function calls to +// the moqUsual moq +type moqUsual_DifficultResultNames_fnRecorder struct { + params moqUsual_DifficultResultNames_params + anyParams uint64 + sequence bool + results *moqUsual_DifficultResultNames_results + moq *moqUsual +} + +// moqUsual_DifficultResultNames_anyParams isolates the any params functions of +// the Usual type +type moqUsual_DifficultResultNames_anyParams struct { + recorder *moqUsual_DifficultResultNames_fnRecorder +} + +// moqUsual_PassByReference_params holds the params of the Usual type +type moqUsual_PassByReference_params struct { + p *testmoqs.PassByReferenceParams +} + +// moqUsual_PassByReference_paramsKey holds the map key params of the Usual +// type +type moqUsual_PassByReference_paramsKey struct { + params struct { + p *testmoqs.PassByReferenceParams + } + hashes struct{ p hash.Hash } +} + +// moqUsual_PassByReference_resultsByParams contains the results for a given +// set of parameters for the Usual type +type moqUsual_PassByReference_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_PassByReference_paramsKey]*moqUsual_PassByReference_results +} + +// moqUsual_PassByReference_doFn defines the type of function needed when +// calling andDo for the Usual type +type moqUsual_PassByReference_doFn func(p *testmoqs.PassByReferenceParams) + +// moqUsual_PassByReference_doReturnFn defines the type of function needed when +// calling doReturnResults for the Usual type +type moqUsual_PassByReference_doReturnFn func(p *testmoqs.PassByReferenceParams) (sResult string, err error) + +// moqUsual_PassByReference_results holds the results of the Usual type +type moqUsual_PassByReference_results struct { + params moqUsual_PassByReference_params + results []struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_PassByReference_doFn + doReturnFn moqUsual_PassByReference_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_PassByReference_fnRecorder routes recorded function calls to the +// moqUsual moq +type moqUsual_PassByReference_fnRecorder struct { + params moqUsual_PassByReference_params + anyParams uint64 + sequence bool + results *moqUsual_PassByReference_results + moq *moqUsual +} + +// moqUsual_PassByReference_anyParams isolates the any params functions of the +// Usual type +type moqUsual_PassByReference_anyParams struct { + recorder *moqUsual_PassByReference_fnRecorder +} + +// moqUsual_InterfaceParam_params holds the params of the Usual type +type moqUsual_InterfaceParam_params struct{ w io.Writer } + +// moqUsual_InterfaceParam_paramsKey holds the map key params of the Usual type +type moqUsual_InterfaceParam_paramsKey struct { + params struct{ w io.Writer } + hashes struct{ w hash.Hash } +} + +// moqUsual_InterfaceParam_resultsByParams contains the results for a given set +// of parameters for the Usual type +type moqUsual_InterfaceParam_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_InterfaceParam_paramsKey]*moqUsual_InterfaceParam_results +} + +// moqUsual_InterfaceParam_doFn defines the type of function needed when +// calling andDo for the Usual type +type moqUsual_InterfaceParam_doFn func(w io.Writer) + +// moqUsual_InterfaceParam_doReturnFn defines the type of function needed when +// calling doReturnResults for the Usual type +type moqUsual_InterfaceParam_doReturnFn func(w io.Writer) (sResult string, err error) + +// moqUsual_InterfaceParam_results holds the results of the Usual type +type moqUsual_InterfaceParam_results struct { + params moqUsual_InterfaceParam_params + results []struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_InterfaceParam_doFn + doReturnFn moqUsual_InterfaceParam_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_InterfaceParam_fnRecorder routes recorded function calls to the +// moqUsual moq +type moqUsual_InterfaceParam_fnRecorder struct { + params moqUsual_InterfaceParam_params + anyParams uint64 + sequence bool + results *moqUsual_InterfaceParam_results + moq *moqUsual +} + +// moqUsual_InterfaceParam_anyParams isolates the any params functions of the +// Usual type +type moqUsual_InterfaceParam_anyParams struct { + recorder *moqUsual_InterfaceParam_fnRecorder +} + +// moqUsual_InterfaceResult_params holds the params of the Usual type +type moqUsual_InterfaceResult_params struct { + sParam string + bParam bool +} + +// moqUsual_InterfaceResult_paramsKey holds the map key params of the Usual +// type +type moqUsual_InterfaceResult_paramsKey struct { + params struct { + sParam string + bParam bool + } + hashes struct { + sParam hash.Hash + bParam hash.Hash + } +} + +// moqUsual_InterfaceResult_resultsByParams contains the results for a given +// set of parameters for the Usual type +type moqUsual_InterfaceResult_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_InterfaceResult_paramsKey]*moqUsual_InterfaceResult_results +} + +// moqUsual_InterfaceResult_doFn defines the type of function needed when +// calling andDo for the Usual type +type moqUsual_InterfaceResult_doFn func(sParam string, bParam bool) + +// moqUsual_InterfaceResult_doReturnFn defines the type of function needed when +// calling doReturnResults for the Usual type +type moqUsual_InterfaceResult_doReturnFn func(sParam string, bParam bool) (r io.Reader) + +// moqUsual_InterfaceResult_results holds the results of the Usual type +type moqUsual_InterfaceResult_results struct { + params moqUsual_InterfaceResult_params + results []struct { + values *struct{ result1 io.Reader } + sequence uint32 + doFn moqUsual_InterfaceResult_doFn + doReturnFn moqUsual_InterfaceResult_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_InterfaceResult_fnRecorder routes recorded function calls to the +// moqUsual moq +type moqUsual_InterfaceResult_fnRecorder struct { + params moqUsual_InterfaceResult_params + anyParams uint64 + sequence bool + results *moqUsual_InterfaceResult_results + moq *moqUsual +} + +// moqUsual_InterfaceResult_anyParams isolates the any params functions of the +// Usual type +type moqUsual_InterfaceResult_anyParams struct { + recorder *moqUsual_InterfaceResult_fnRecorder +} + +// moqUsual_FnParam_params holds the params of the Usual type +type moqUsual_FnParam_params struct{ fn func() } + +// moqUsual_FnParam_paramsKey holds the map key params of the Usual type +type moqUsual_FnParam_paramsKey struct { + params struct{} + hashes struct{ fn hash.Hash } +} + +// moqUsual_FnParam_resultsByParams contains the results for a given set of +// parameters for the Usual type +type moqUsual_FnParam_resultsByParams struct { + anyCount int + anyParams uint64 + results map[moqUsual_FnParam_paramsKey]*moqUsual_FnParam_results +} + +// moqUsual_FnParam_doFn defines the type of function needed when calling andDo +// for the Usual type +type moqUsual_FnParam_doFn func(fn func()) + +// moqUsual_FnParam_doReturnFn defines the type of function needed when calling +// doReturnResults for the Usual type +type moqUsual_FnParam_doReturnFn func(fn func()) + +// moqUsual_FnParam_results holds the results of the Usual type +type moqUsual_FnParam_results struct { + params moqUsual_FnParam_params + results []struct { + values *struct{} + sequence uint32 + doFn moqUsual_FnParam_doFn + doReturnFn moqUsual_FnParam_doReturnFn + } + index uint32 + repeat *moq.RepeatVal +} + +// moqUsual_FnParam_fnRecorder routes recorded function calls to the moqUsual +// moq +type moqUsual_FnParam_fnRecorder struct { + params moqUsual_FnParam_params + anyParams uint64 + sequence bool + results *moqUsual_FnParam_results + moq *moqUsual +} + +// moqUsual_FnParam_anyParams isolates the any params functions of the Usual +// type +type moqUsual_FnParam_anyParams struct { + recorder *moqUsual_FnParam_fnRecorder +} + +// newMoqUsual creates a new moq of the Usual type +func newMoqUsual(scene *moq.Scene, config *moq.Config) *moqUsual { + if config == nil { + config = &moq.Config{} + } + m := &moqUsual{ + scene: scene, + config: *config, + moq: &moqUsual_mock{}, + + runtime: struct { + parameterIndexing struct { + Usual struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + NoNames struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + NoResults struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + NoParams struct{} + Nothing struct{} + Variadic struct { + other moq.ParamIndexing + args moq.ParamIndexing + } + RepeatedIds struct { + sParam1 moq.ParamIndexing + sParam2 moq.ParamIndexing + bParam moq.ParamIndexing + } + Times struct { + sParam moq.ParamIndexing + times moq.ParamIndexing + } + DifficultParamNames struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + param3 moq.ParamIndexing + param moq.ParamIndexing + param5 moq.ParamIndexing + param6 moq.ParamIndexing + param7 moq.ParamIndexing + param8 moq.ParamIndexing + param9 moq.ParamIndexing + } + DifficultResultNames struct{} + PassByReference struct { + p moq.ParamIndexing + } + InterfaceParam struct { + w moq.ParamIndexing + } + InterfaceResult struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + FnParam struct { + fn moq.ParamIndexing + } + } + }{parameterIndexing: struct { + Usual struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + NoNames struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + NoResults struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + NoParams struct{} + Nothing struct{} + Variadic struct { + other moq.ParamIndexing + args moq.ParamIndexing + } + RepeatedIds struct { + sParam1 moq.ParamIndexing + sParam2 moq.ParamIndexing + bParam moq.ParamIndexing + } + Times struct { + sParam moq.ParamIndexing + times moq.ParamIndexing + } + DifficultParamNames struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + param3 moq.ParamIndexing + param moq.ParamIndexing + param5 moq.ParamIndexing + param6 moq.ParamIndexing + param7 moq.ParamIndexing + param8 moq.ParamIndexing + param9 moq.ParamIndexing + } + DifficultResultNames struct{} + PassByReference struct { + p moq.ParamIndexing + } + InterfaceParam struct { + w moq.ParamIndexing + } + InterfaceResult struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + FnParam struct { + fn moq.ParamIndexing + } + }{ + Usual: struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + }{ + sParam: moq.ParamIndexByValue, + bParam: moq.ParamIndexByValue, + }, + NoNames: struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + }{ + param1: moq.ParamIndexByValue, + param2: moq.ParamIndexByValue, + }, + NoResults: struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + }{ + sParam: moq.ParamIndexByValue, + bParam: moq.ParamIndexByValue, + }, + NoParams: struct{}{}, + Nothing: struct{}{}, + Variadic: struct { + other moq.ParamIndexing + args moq.ParamIndexing + }{ + other: moq.ParamIndexByValue, + args: moq.ParamIndexByHash, + }, + RepeatedIds: struct { + sParam1 moq.ParamIndexing + sParam2 moq.ParamIndexing + bParam moq.ParamIndexing + }{ + sParam1: moq.ParamIndexByValue, + sParam2: moq.ParamIndexByValue, + bParam: moq.ParamIndexByValue, + }, + Times: struct { + sParam moq.ParamIndexing + times moq.ParamIndexing + }{ + sParam: moq.ParamIndexByValue, + times: moq.ParamIndexByValue, + }, + DifficultParamNames: struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + param3 moq.ParamIndexing + param moq.ParamIndexing + param5 moq.ParamIndexing + param6 moq.ParamIndexing + param7 moq.ParamIndexing + param8 moq.ParamIndexing + param9 moq.ParamIndexing + }{ + param1: moq.ParamIndexByValue, + param2: moq.ParamIndexByValue, + param3: moq.ParamIndexByValue, + param: moq.ParamIndexByValue, + param5: moq.ParamIndexByValue, + param6: moq.ParamIndexByValue, + param7: moq.ParamIndexByValue, + param8: moq.ParamIndexByValue, + param9: moq.ParamIndexByValue, + }, + DifficultResultNames: struct{}{}, + PassByReference: struct { + p moq.ParamIndexing + }{ + p: moq.ParamIndexByHash, + }, + InterfaceParam: struct { + w moq.ParamIndexing + }{ + w: moq.ParamIndexByHash, + }, + InterfaceResult: struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + }{ + sParam: moq.ParamIndexByValue, + bParam: moq.ParamIndexByValue, + }, + FnParam: struct { + fn moq.ParamIndexing + }{ + fn: moq.ParamIndexByHash, + }, + }}, + } + m.moq.moq = m + + scene.AddMoq(m) + return m +} + +// mock returns the mock implementation of the Usual type +func (m *moqUsual) mock() *moqUsual_mock { return m.moq } + +func (m *moqUsual_mock) Usual(sParam string, bParam bool) (sResult string, err error) { + m.moq.scene.T.Helper() + params := moqUsual_Usual_params{ + sParam: sParam, + bParam: bParam, + } + var results *moqUsual_Usual_results + for _, resultsByParams := range m.moq.resultsByParams_Usual { + paramsKey := m.moq.paramsKey_Usual(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Usual(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Usual(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Usual(params)) + } + } + + if result.doFn != nil { + result.doFn(sParam, bParam) + } + + if result.values != nil { + sResult = result.values.sResult + err = result.values.err + } + if result.doReturnFn != nil { + sResult, err = result.doReturnFn(sParam, bParam) + } + return +} + +func (m *moqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, result2 error) { + m.moq.scene.T.Helper() + params := moqUsual_NoNames_params{ + param1: param1, + param2: param2, + } + var results *moqUsual_NoNames_results + for _, resultsByParams := range m.moq.resultsByParams_NoNames { + paramsKey := m.moq.paramsKey_NoNames(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_NoNames(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_NoNames(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_NoNames(params)) + } + } + + if result.doFn != nil { + result.doFn(param1, param2) + } + + if result.values != nil { + result1 = result.values.result1 + result2 = result.values.result2 + } + if result.doReturnFn != nil { + result1, result2 = result.doReturnFn(param1, param2) + } + return +} + +func (m *moqUsual_mock) NoResults(sParam string, bParam bool) { + m.moq.scene.T.Helper() + params := moqUsual_NoResults_params{ + sParam: sParam, + bParam: bParam, + } + var results *moqUsual_NoResults_results + for _, resultsByParams := range m.moq.resultsByParams_NoResults { + paramsKey := m.moq.paramsKey_NoResults(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_NoResults(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_NoResults(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_NoResults(params)) + } + } + + if result.doFn != nil { + result.doFn(sParam, bParam) + } + + if result.doReturnFn != nil { + result.doReturnFn(sParam, bParam) + } + return +} + +func (m *moqUsual_mock) NoParams() (sResult string, err error) { + m.moq.scene.T.Helper() + params := moqUsual_NoParams_params{} + var results *moqUsual_NoParams_results + for _, resultsByParams := range m.moq.resultsByParams_NoParams { + paramsKey := m.moq.paramsKey_NoParams(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_NoParams(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_NoParams(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_NoParams(params)) + } + } + + if result.doFn != nil { + result.doFn() + } + + if result.values != nil { + sResult = result.values.sResult + err = result.values.err + } + if result.doReturnFn != nil { + sResult, err = result.doReturnFn() + } + return +} + +func (m *moqUsual_mock) Nothing() { + m.moq.scene.T.Helper() + params := moqUsual_Nothing_params{} + var results *moqUsual_Nothing_results + for _, resultsByParams := range m.moq.resultsByParams_Nothing { + paramsKey := m.moq.paramsKey_Nothing(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Nothing(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Nothing(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Nothing(params)) + } + } + + if result.doFn != nil { + result.doFn() + } + + if result.doReturnFn != nil { + result.doReturnFn() + } + return +} + +func (m *moqUsual_mock) Variadic(other bool, args ...string) (sResult string, err error) { + m.moq.scene.T.Helper() + params := moqUsual_Variadic_params{ + other: other, + args: args, + } + var results *moqUsual_Variadic_results + for _, resultsByParams := range m.moq.resultsByParams_Variadic { + paramsKey := m.moq.paramsKey_Variadic(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Variadic(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Variadic(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Variadic(params)) + } + } + + if result.doFn != nil { + result.doFn(other, args...) + } + + if result.values != nil { + sResult = result.values.sResult + err = result.values.err + } + if result.doReturnFn != nil { + sResult, err = result.doReturnFn(other, args...) + } + return +} + +func (m *moqUsual_mock) RepeatedIds(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) { + m.moq.scene.T.Helper() + params := moqUsual_RepeatedIds_params{ + sParam1: sParam1, + sParam2: sParam2, + bParam: bParam, + } + var results *moqUsual_RepeatedIds_results + for _, resultsByParams := range m.moq.resultsByParams_RepeatedIds { + paramsKey := m.moq.paramsKey_RepeatedIds(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_RepeatedIds(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_RepeatedIds(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_RepeatedIds(params)) + } + } + + if result.doFn != nil { + result.doFn(sParam1, sParam2, bParam) + } + + if result.values != nil { + sResult1 = result.values.sResult1 + sResult2 = result.values.sResult2 + err = result.values.err + } + if result.doReturnFn != nil { + sResult1, sResult2, err = result.doReturnFn(sParam1, sParam2, bParam) + } + return +} + +func (m *moqUsual_mock) Times(sParam string, times bool) (sResult string, err error) { + m.moq.scene.T.Helper() + params := moqUsual_Times_params{ + sParam: sParam, + times: times, + } + var results *moqUsual_Times_results + for _, resultsByParams := range m.moq.resultsByParams_Times { + paramsKey := m.moq.paramsKey_Times(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Times(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Times(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Times(params)) + } + } + + if result.doFn != nil { + result.doFn(sParam, times) + } + + if result.values != nil { + sResult = result.values.sResult + err = result.values.err + } + if result.doReturnFn != nil { + sResult, err = result.doReturnFn(sParam, times) + } + return +} + +func (m *moqUsual_mock) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) { + m.moq.scene.T.Helper() + params := moqUsual_DifficultParamNames_params{ + param1: param1, + param2: param2, + param3: param3, + param: param, + param5: param5, + param6: param6, + param7: param7, + param8: param8, + param9: param9, + } + var results *moqUsual_DifficultParamNames_results + for _, resultsByParams := range m.moq.resultsByParams_DifficultParamNames { + paramsKey := m.moq.paramsKey_DifficultParamNames(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_DifficultParamNames(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_DifficultParamNames(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_DifficultParamNames(params)) + } + } + + if result.doFn != nil { + result.doFn(param1, param2, param3, param, param5, param6, param7, param8, param9) + } + + if result.doReturnFn != nil { + result.doReturnFn(param1, param2, param3, param, param5, param6, param7, param8, param9) + } + return +} + +func (m *moqUsual_mock) DifficultResultNames() (result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) { + m.moq.scene.T.Helper() + params := moqUsual_DifficultResultNames_params{} + var results *moqUsual_DifficultResultNames_results + for _, resultsByParams := range m.moq.resultsByParams_DifficultResultNames { + paramsKey := m.moq.paramsKey_DifficultResultNames(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_DifficultResultNames(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_DifficultResultNames(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_DifficultResultNames(params)) + } + } + + if result.doFn != nil { + result.doFn() + } + + if result.values != nil { + result1 = result.values.result1 + result2 = result.values.result2 + result3 = result.values.result3 + param = result.values.param + result5 = result.values.result5 + result6 = result.values.result6 + result7 = result.values.result7 + result8 = result.values.result8 + result9 = result.values.result9 + } + if result.doReturnFn != nil { + result1, result2, result3, param, result5, result6, result7, result8, result9 = result.doReturnFn() + } + return +} + +func (m *moqUsual_mock) PassByReference(p *testmoqs.PassByReferenceParams) (sResult string, err error) { + m.moq.scene.T.Helper() + params := moqUsual_PassByReference_params{ + p: p, + } + var results *moqUsual_PassByReference_results + for _, resultsByParams := range m.moq.resultsByParams_PassByReference { + paramsKey := m.moq.paramsKey_PassByReference(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_PassByReference(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_PassByReference(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_PassByReference(params)) + } + } + + if result.doFn != nil { + result.doFn(p) + } + + if result.values != nil { + sResult = result.values.sResult + err = result.values.err + } + if result.doReturnFn != nil { + sResult, err = result.doReturnFn(p) + } + return +} + +func (m *moqUsual_mock) InterfaceParam(w io.Writer) (sResult string, err error) { + m.moq.scene.T.Helper() + params := moqUsual_InterfaceParam_params{ + w: w, + } + var results *moqUsual_InterfaceParam_results + for _, resultsByParams := range m.moq.resultsByParams_InterfaceParam { + paramsKey := m.moq.paramsKey_InterfaceParam(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_InterfaceParam(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_InterfaceParam(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_InterfaceParam(params)) + } + } + + if result.doFn != nil { + result.doFn(w) + } + + if result.values != nil { + sResult = result.values.sResult + err = result.values.err + } + if result.doReturnFn != nil { + sResult, err = result.doReturnFn(w) + } + return +} + +func (m *moqUsual_mock) InterfaceResult(sParam string, bParam bool) (result1 io.Reader) { + m.moq.scene.T.Helper() + params := moqUsual_InterfaceResult_params{ + sParam: sParam, + bParam: bParam, + } + var results *moqUsual_InterfaceResult_results + for _, resultsByParams := range m.moq.resultsByParams_InterfaceResult { + paramsKey := m.moq.paramsKey_InterfaceResult(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_InterfaceResult(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_InterfaceResult(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_InterfaceResult(params)) + } + } + + if result.doFn != nil { + result.doFn(sParam, bParam) + } + + if result.values != nil { + result1 = result.values.result1 + } + if result.doReturnFn != nil { + result1 = result.doReturnFn(sParam, bParam) + } + return +} + +func (m *moqUsual_mock) FnParam(fn func()) { + m.moq.scene.T.Helper() + params := moqUsual_FnParam_params{ + fn: fn, + } + var results *moqUsual_FnParam_results + for _, resultsByParams := range m.moq.resultsByParams_FnParam { + paramsKey := m.moq.paramsKey_FnParam(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_FnParam(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_FnParam(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_FnParam(params)) + } + } + + if result.doFn != nil { + result.doFn(fn) + } + + if result.doReturnFn != nil { + result.doReturnFn(fn) + } + return +} + +// onCall returns the recorder implementation of the Usual type +func (m *moqUsual) onCall() *moqUsual_recorder { + return &moqUsual_recorder{ + moq: m, + } +} + +func (m *moqUsual_recorder) Usual(sParam string, bParam bool) *moqUsual_Usual_fnRecorder { + return &moqUsual_Usual_fnRecorder{ + params: moqUsual_Usual_params{ + sParam: sParam, + bParam: bParam, + }, + sequence: m.moq.config.Sequence == moq.SeqDefaultOn, + moq: m.moq, + } +} + +func (r *moqUsual_Usual_fnRecorder) any() *moqUsual_Usual_anyParams { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) + return nil + } + return &moqUsual_Usual_anyParams{recorder: r} +} + +func (a *moqUsual_Usual_anyParams) sParam() *moqUsual_Usual_fnRecorder { + a.recorder.anyParams |= 1 << 0 + return a.recorder +} + +func (a *moqUsual_Usual_anyParams) bParam() *moqUsual_Usual_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (r *moqUsual_Usual_fnRecorder) seq() *moqUsual_Usual_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) + return nil + } + r.sequence = true + return r +} + +func (r *moqUsual_Usual_fnRecorder) noSeq() *moqUsual_Usual_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) + return nil + } + r.sequence = false + return r +} + +func (r *moqUsual_Usual_fnRecorder) returnResults(sResult string, err error) *moqUsual_Usual_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Usual_doFn + doReturnFn moqUsual_Usual_doReturnFn + }{ + values: &struct { + sResult string + err error + }{ + sResult: sResult, + err: err, + }, + sequence: sequence, + }) + return r +} + +func (r *moqUsual_Usual_fnRecorder) andDo(fn moqUsual_Usual_doFn) *moqUsual_Usual_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r +} + +func (r *moqUsual_Usual_fnRecorder) doReturnResults(fn moqUsual_Usual_doReturnFn) *moqUsual_Usual_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Usual_doFn + doReturnFn moqUsual_Usual_doReturnFn + }{sequence: sequence, doReturnFn: fn}) + return r +} + +func (r *moqUsual_Usual_fnRecorder) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqUsual_Usual_resultsByParams + for n, res := range r.moq.resultsByParams_Usual { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqUsual_Usual_resultsByParams{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqUsual_Usual_paramsKey]*moqUsual_Usual_results{}, + } + r.moq.resultsByParams_Usual = append(r.moq.resultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Usual) { + copy(r.moq.resultsByParams_Usual[insertAt+1:], r.moq.resultsByParams_Usual[insertAt:0]) + r.moq.resultsByParams_Usual[insertAt] = *results + } + } + + paramsKey := r.moq.paramsKey_Usual(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqUsual_Usual_results{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } + + r.results.repeat.Increment(r.moq.scene.T) +} + +func (r *moqUsual_Usual_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_Usual_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Usual_doFn + doReturnFn moqUsual_Usual_doReturnFn + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r +} + +func (m *moqUsual) prettyParams_Usual(params moqUsual_Usual_params) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.sParam, params.bParam) +} + +func (m *moqUsual) paramsKey_Usual(params moqUsual_Usual_params, anyParams uint64) moqUsual_Usual_paramsKey { + m.scene.T.Helper() + var sParamUsed string + var sParamUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.Usual.sParam == moq.ParamIndexByValue { + sParamUsed = params.sParam + } else { + sParamUsedHash = hash.DeepHash(params.sParam) + } + } + var bParamUsed bool + var bParamUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.Usual.bParam == moq.ParamIndexByValue { + bParamUsed = params.bParam + } else { + bParamUsedHash = hash.DeepHash(params.bParam) + } + } + return moqUsual_Usual_paramsKey{ + params: struct { + sParam string + bParam bool + }{ + sParam: sParamUsed, + bParam: bParamUsed, + }, + hashes: struct { + sParam hash.Hash + bParam hash.Hash + }{ + sParam: sParamUsedHash, + bParam: bParamUsedHash, + }, + } +} + +func (m *moqUsual_recorder) NoNames(param1 string, param2 bool) *moqUsual_NoNames_fnRecorder { + return &moqUsual_NoNames_fnRecorder{ + params: moqUsual_NoNames_params{ + param1: param1, + param2: param2, + }, + sequence: m.moq.config.Sequence == moq.SeqDefaultOn, + moq: m.moq, + } +} + +func (r *moqUsual_NoNames_fnRecorder) any() *moqUsual_NoNames_anyParams { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoNames(r.params)) + return nil + } + return &moqUsual_NoNames_anyParams{recorder: r} +} + +func (a *moqUsual_NoNames_anyParams) param1() *moqUsual_NoNames_fnRecorder { + a.recorder.anyParams |= 1 << 0 + return a.recorder +} + +func (a *moqUsual_NoNames_anyParams) param2() *moqUsual_NoNames_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (r *moqUsual_NoNames_fnRecorder) seq() *moqUsual_NoNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoNames(r.params)) + return nil + } + r.sequence = true + return r +} + +func (r *moqUsual_NoNames_fnRecorder) noSeq() *moqUsual_NoNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoNames(r.params)) + return nil + } + r.sequence = false + return r +} + +func (r *moqUsual_NoNames_fnRecorder) returnResults(result1 string, result2 error) *moqUsual_NoNames_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + result1 string + result2 error + } + sequence uint32 + doFn moqUsual_NoNames_doFn + doReturnFn moqUsual_NoNames_doReturnFn + }{ + values: &struct { + result1 string + result2 error + }{ + result1: result1, + result2: result2, + }, + sequence: sequence, + }) + return r +} + +func (r *moqUsual_NoNames_fnRecorder) andDo(fn moqUsual_NoNames_doFn) *moqUsual_NoNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r +} + +func (r *moqUsual_NoNames_fnRecorder) doReturnResults(fn moqUsual_NoNames_doReturnFn) *moqUsual_NoNames_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + result1 string + result2 error + } + sequence uint32 + doFn moqUsual_NoNames_doFn + doReturnFn moqUsual_NoNames_doReturnFn + }{sequence: sequence, doReturnFn: fn}) + return r +} + +func (r *moqUsual_NoNames_fnRecorder) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqUsual_NoNames_resultsByParams + for n, res := range r.moq.resultsByParams_NoNames { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqUsual_NoNames_resultsByParams{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqUsual_NoNames_paramsKey]*moqUsual_NoNames_results{}, + } + r.moq.resultsByParams_NoNames = append(r.moq.resultsByParams_NoNames, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_NoNames) { + copy(r.moq.resultsByParams_NoNames[insertAt+1:], r.moq.resultsByParams_NoNames[insertAt:0]) + r.moq.resultsByParams_NoNames[insertAt] = *results + } + } + + paramsKey := r.moq.paramsKey_NoNames(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqUsual_NoNames_results{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } + + r.results.repeat.Increment(r.moq.scene.T) +} + +func (r *moqUsual_NoNames_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_NoNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct { + result1 string + result2 error + } + sequence uint32 + doFn moqUsual_NoNames_doFn + doReturnFn moqUsual_NoNames_doReturnFn + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r +} + +func (m *moqUsual) prettyParams_NoNames(params moqUsual_NoNames_params) string { + return fmt.Sprintf("NoNames(%#v, %#v)", params.param1, params.param2) +} + +func (m *moqUsual) paramsKey_NoNames(params moqUsual_NoNames_params, anyParams uint64) moqUsual_NoNames_paramsKey { + m.scene.T.Helper() + var param1Used string + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.NoNames.param1 == moq.ParamIndexByValue { + param1Used = params.param1 + } else { + param1UsedHash = hash.DeepHash(params.param1) + } + } + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.NoNames.param2 == moq.ParamIndexByValue { + param2Used = params.param2 + } else { + param2UsedHash = hash.DeepHash(params.param2) + } + } + return moqUsual_NoNames_paramsKey{ + params: struct { + param1 string + param2 bool + }{ + param1: param1Used, + param2: param2Used, + }, + hashes: struct { + param1 hash.Hash + param2 hash.Hash + }{ + param1: param1UsedHash, + param2: param2UsedHash, + }, + } +} + +func (m *moqUsual_recorder) NoResults(sParam string, bParam bool) *moqUsual_NoResults_fnRecorder { + return &moqUsual_NoResults_fnRecorder{ + params: moqUsual_NoResults_params{ + sParam: sParam, + bParam: bParam, + }, + sequence: m.moq.config.Sequence == moq.SeqDefaultOn, + moq: m.moq, + } +} + +func (r *moqUsual_NoResults_fnRecorder) any() *moqUsual_NoResults_anyParams { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoResults(r.params)) + return nil + } + return &moqUsual_NoResults_anyParams{recorder: r} +} + +func (a *moqUsual_NoResults_anyParams) sParam() *moqUsual_NoResults_fnRecorder { + a.recorder.anyParams |= 1 << 0 + return a.recorder +} + +func (a *moqUsual_NoResults_anyParams) bParam() *moqUsual_NoResults_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (r *moqUsual_NoResults_fnRecorder) seq() *moqUsual_NoResults_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoResults(r.params)) + return nil + } + r.sequence = true + return r +} + +func (r *moqUsual_NoResults_fnRecorder) noSeq() *moqUsual_NoResults_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoResults(r.params)) + return nil + } + r.sequence = false + return r +} + +func (r *moqUsual_NoResults_fnRecorder) returnResults() *moqUsual_NoResults_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct{} + sequence uint32 + doFn moqUsual_NoResults_doFn + doReturnFn moqUsual_NoResults_doReturnFn + }{ + values: &struct{}{}, + sequence: sequence, + }) + return r +} + +func (r *moqUsual_NoResults_fnRecorder) andDo(fn moqUsual_NoResults_doFn) *moqUsual_NoResults_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r +} + +func (r *moqUsual_NoResults_fnRecorder) doReturnResults(fn moqUsual_NoResults_doReturnFn) *moqUsual_NoResults_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct{} + sequence uint32 + doFn moqUsual_NoResults_doFn + doReturnFn moqUsual_NoResults_doReturnFn + }{sequence: sequence, doReturnFn: fn}) + return r +} + +func (r *moqUsual_NoResults_fnRecorder) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqUsual_NoResults_resultsByParams + for n, res := range r.moq.resultsByParams_NoResults { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqUsual_NoResults_resultsByParams{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqUsual_NoResults_paramsKey]*moqUsual_NoResults_results{}, + } + r.moq.resultsByParams_NoResults = append(r.moq.resultsByParams_NoResults, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_NoResults) { + copy(r.moq.resultsByParams_NoResults[insertAt+1:], r.moq.resultsByParams_NoResults[insertAt:0]) + r.moq.resultsByParams_NoResults[insertAt] = *results + } + } + + paramsKey := r.moq.paramsKey_NoResults(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqUsual_NoResults_results{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } + + r.results.repeat.Increment(r.moq.scene.T) +} + +func (r *moqUsual_NoResults_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_NoResults_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct{} + sequence uint32 + doFn moqUsual_NoResults_doFn + doReturnFn moqUsual_NoResults_doReturnFn + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r +} + +func (m *moqUsual) prettyParams_NoResults(params moqUsual_NoResults_params) string { + return fmt.Sprintf("NoResults(%#v, %#v)", params.sParam, params.bParam) +} + +func (m *moqUsual) paramsKey_NoResults(params moqUsual_NoResults_params, anyParams uint64) moqUsual_NoResults_paramsKey { + m.scene.T.Helper() + var sParamUsed string + var sParamUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.NoResults.sParam == moq.ParamIndexByValue { + sParamUsed = params.sParam + } else { + sParamUsedHash = hash.DeepHash(params.sParam) + } + } + var bParamUsed bool + var bParamUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.NoResults.bParam == moq.ParamIndexByValue { + bParamUsed = params.bParam + } else { + bParamUsedHash = hash.DeepHash(params.bParam) + } + } + return moqUsual_NoResults_paramsKey{ + params: struct { + sParam string + bParam bool + }{ + sParam: sParamUsed, + bParam: bParamUsed, + }, + hashes: struct { + sParam hash.Hash + bParam hash.Hash + }{ + sParam: sParamUsedHash, + bParam: bParamUsedHash, + }, + } +} + +func (m *moqUsual_recorder) NoParams() *moqUsual_NoParams_fnRecorder { + return &moqUsual_NoParams_fnRecorder{ params: moqUsual_NoParams_params{}, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, } } -func (r *moqUsual_NoParams_fnRecorder) any() *moqUsual_NoParams_anyParams { +func (r *moqUsual_NoParams_fnRecorder) any() *moqUsual_NoParams_anyParams { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoParams(r.params)) + return nil + } + return &moqUsual_NoParams_anyParams{recorder: r} +} + +func (r *moqUsual_NoParams_fnRecorder) seq() *moqUsual_NoParams_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoParams(r.params)) + return nil + } + r.sequence = true + return r +} + +func (r *moqUsual_NoParams_fnRecorder) noSeq() *moqUsual_NoParams_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoParams(r.params)) + return nil + } + r.sequence = false + return r +} + +func (r *moqUsual_NoParams_fnRecorder) returnResults(sResult string, err error) *moqUsual_NoParams_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_NoParams_doFn + doReturnFn moqUsual_NoParams_doReturnFn + }{ + values: &struct { + sResult string + err error + }{ + sResult: sResult, + err: err, + }, + sequence: sequence, + }) + return r +} + +func (r *moqUsual_NoParams_fnRecorder) andDo(fn moqUsual_NoParams_doFn) *moqUsual_NoParams_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r +} + +func (r *moqUsual_NoParams_fnRecorder) doReturnResults(fn moqUsual_NoParams_doReturnFn) *moqUsual_NoParams_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_NoParams_doFn + doReturnFn moqUsual_NoParams_doReturnFn + }{sequence: sequence, doReturnFn: fn}) + return r +} + +func (r *moqUsual_NoParams_fnRecorder) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqUsual_NoParams_resultsByParams + for n, res := range r.moq.resultsByParams_NoParams { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqUsual_NoParams_resultsByParams{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqUsual_NoParams_paramsKey]*moqUsual_NoParams_results{}, + } + r.moq.resultsByParams_NoParams = append(r.moq.resultsByParams_NoParams, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_NoParams) { + copy(r.moq.resultsByParams_NoParams[insertAt+1:], r.moq.resultsByParams_NoParams[insertAt:0]) + r.moq.resultsByParams_NoParams[insertAt] = *results + } + } + + paramsKey := r.moq.paramsKey_NoParams(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqUsual_NoParams_results{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } + + r.results.repeat.Increment(r.moq.scene.T) +} + +func (r *moqUsual_NoParams_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_NoParams_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_NoParams_doFn + doReturnFn moqUsual_NoParams_doReturnFn + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r +} + +func (m *moqUsual) prettyParams_NoParams(params moqUsual_NoParams_params) string { + return fmt.Sprintf("NoParams()") +} + +func (m *moqUsual) paramsKey_NoParams(params moqUsual_NoParams_params, anyParams uint64) moqUsual_NoParams_paramsKey { + m.scene.T.Helper() + return moqUsual_NoParams_paramsKey{ + params: struct{}{}, + hashes: struct{}{}, + } +} + +func (m *moqUsual_recorder) Nothing() *moqUsual_Nothing_fnRecorder { + return &moqUsual_Nothing_fnRecorder{ + params: moqUsual_Nothing_params{}, + sequence: m.moq.config.Sequence == moq.SeqDefaultOn, + moq: m.moq, + } +} + +func (r *moqUsual_Nothing_fnRecorder) any() *moqUsual_Nothing_anyParams { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Nothing(r.params)) + return nil + } + return &moqUsual_Nothing_anyParams{recorder: r} +} + +func (r *moqUsual_Nothing_fnRecorder) seq() *moqUsual_Nothing_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Nothing(r.params)) + return nil + } + r.sequence = true + return r +} + +func (r *moqUsual_Nothing_fnRecorder) noSeq() *moqUsual_Nothing_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Nothing(r.params)) + return nil + } + r.sequence = false + return r +} + +func (r *moqUsual_Nothing_fnRecorder) returnResults() *moqUsual_Nothing_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct{} + sequence uint32 + doFn moqUsual_Nothing_doFn + doReturnFn moqUsual_Nothing_doReturnFn + }{ + values: &struct{}{}, + sequence: sequence, + }) + return r +} + +func (r *moqUsual_Nothing_fnRecorder) andDo(fn moqUsual_Nothing_doFn) *moqUsual_Nothing_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r +} + +func (r *moqUsual_Nothing_fnRecorder) doReturnResults(fn moqUsual_Nothing_doReturnFn) *moqUsual_Nothing_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct{} + sequence uint32 + doFn moqUsual_Nothing_doFn + doReturnFn moqUsual_Nothing_doReturnFn + }{sequence: sequence, doReturnFn: fn}) + return r +} + +func (r *moqUsual_Nothing_fnRecorder) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqUsual_Nothing_resultsByParams + for n, res := range r.moq.resultsByParams_Nothing { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqUsual_Nothing_resultsByParams{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqUsual_Nothing_paramsKey]*moqUsual_Nothing_results{}, + } + r.moq.resultsByParams_Nothing = append(r.moq.resultsByParams_Nothing, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Nothing) { + copy(r.moq.resultsByParams_Nothing[insertAt+1:], r.moq.resultsByParams_Nothing[insertAt:0]) + r.moq.resultsByParams_Nothing[insertAt] = *results + } + } + + paramsKey := r.moq.paramsKey_Nothing(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqUsual_Nothing_results{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } + + r.results.repeat.Increment(r.moq.scene.T) +} + +func (r *moqUsual_Nothing_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_Nothing_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct{} + sequence uint32 + doFn moqUsual_Nothing_doFn + doReturnFn moqUsual_Nothing_doReturnFn + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r +} + +func (m *moqUsual) prettyParams_Nothing(params moqUsual_Nothing_params) string { + return fmt.Sprintf("Nothing()") +} + +func (m *moqUsual) paramsKey_Nothing(params moqUsual_Nothing_params, anyParams uint64) moqUsual_Nothing_paramsKey { + m.scene.T.Helper() + return moqUsual_Nothing_paramsKey{ + params: struct{}{}, + hashes: struct{}{}, + } +} + +func (m *moqUsual_recorder) Variadic(other bool, args ...string) *moqUsual_Variadic_fnRecorder { + return &moqUsual_Variadic_fnRecorder{ + params: moqUsual_Variadic_params{ + other: other, + args: args, + }, + sequence: m.moq.config.Sequence == moq.SeqDefaultOn, + moq: m.moq, + } +} + +func (r *moqUsual_Variadic_fnRecorder) any() *moqUsual_Variadic_anyParams { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Variadic(r.params)) + return nil + } + return &moqUsual_Variadic_anyParams{recorder: r} +} + +func (a *moqUsual_Variadic_anyParams) other() *moqUsual_Variadic_fnRecorder { + a.recorder.anyParams |= 1 << 0 + return a.recorder +} + +func (a *moqUsual_Variadic_anyParams) args() *moqUsual_Variadic_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (r *moqUsual_Variadic_fnRecorder) seq() *moqUsual_Variadic_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Variadic(r.params)) + return nil + } + r.sequence = true + return r +} + +func (r *moqUsual_Variadic_fnRecorder) noSeq() *moqUsual_Variadic_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Variadic(r.params)) + return nil + } + r.sequence = false + return r +} + +func (r *moqUsual_Variadic_fnRecorder) returnResults(sResult string, err error) *moqUsual_Variadic_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Variadic_doFn + doReturnFn moqUsual_Variadic_doReturnFn + }{ + values: &struct { + sResult string + err error + }{ + sResult: sResult, + err: err, + }, + sequence: sequence, + }) + return r +} + +func (r *moqUsual_Variadic_fnRecorder) andDo(fn moqUsual_Variadic_doFn) *moqUsual_Variadic_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r +} + +func (r *moqUsual_Variadic_fnRecorder) doReturnResults(fn moqUsual_Variadic_doReturnFn) *moqUsual_Variadic_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Variadic_doFn + doReturnFn moqUsual_Variadic_doReturnFn + }{sequence: sequence, doReturnFn: fn}) + return r +} + +func (r *moqUsual_Variadic_fnRecorder) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqUsual_Variadic_resultsByParams + for n, res := range r.moq.resultsByParams_Variadic { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqUsual_Variadic_resultsByParams{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqUsual_Variadic_paramsKey]*moqUsual_Variadic_results{}, + } + r.moq.resultsByParams_Variadic = append(r.moq.resultsByParams_Variadic, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Variadic) { + copy(r.moq.resultsByParams_Variadic[insertAt+1:], r.moq.resultsByParams_Variadic[insertAt:0]) + r.moq.resultsByParams_Variadic[insertAt] = *results + } + } + + paramsKey := r.moq.paramsKey_Variadic(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqUsual_Variadic_results{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } + + r.results.repeat.Increment(r.moq.scene.T) +} + +func (r *moqUsual_Variadic_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_Variadic_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Variadic_doFn + doReturnFn moqUsual_Variadic_doReturnFn + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r +} + +func (m *moqUsual) prettyParams_Variadic(params moqUsual_Variadic_params) string { + return fmt.Sprintf("Variadic(%#v, %#v)", params.other, params.args) +} + +func (m *moqUsual) paramsKey_Variadic(params moqUsual_Variadic_params, anyParams uint64) moqUsual_Variadic_paramsKey { + m.scene.T.Helper() + var otherUsed bool + var otherUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.Variadic.other == moq.ParamIndexByValue { + otherUsed = params.other + } else { + otherUsedHash = hash.DeepHash(params.other) + } + } + var argsUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.Variadic.args == moq.ParamIndexByValue { + m.scene.T.Fatalf("The args parameter of the Variadic function can't be indexed by value") + } + argsUsedHash = hash.DeepHash(params.args) + } + return moqUsual_Variadic_paramsKey{ + params: struct{ other bool }{ + other: otherUsed, + }, + hashes: struct { + other hash.Hash + args hash.Hash + }{ + other: otherUsedHash, + args: argsUsedHash, + }, + } +} + +func (m *moqUsual_recorder) RepeatedIds(sParam1, sParam2 string, bParam bool) *moqUsual_RepeatedIds_fnRecorder { + return &moqUsual_RepeatedIds_fnRecorder{ + params: moqUsual_RepeatedIds_params{ + sParam1: sParam1, + sParam2: sParam2, + bParam: bParam, + }, + sequence: m.moq.config.Sequence == moq.SeqDefaultOn, + moq: m.moq, + } +} + +func (r *moqUsual_RepeatedIds_fnRecorder) any() *moqUsual_RepeatedIds_anyParams { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_RepeatedIds(r.params)) + return nil + } + return &moqUsual_RepeatedIds_anyParams{recorder: r} +} + +func (a *moqUsual_RepeatedIds_anyParams) sParam1() *moqUsual_RepeatedIds_fnRecorder { + a.recorder.anyParams |= 1 << 0 + return a.recorder +} + +func (a *moqUsual_RepeatedIds_anyParams) sParam2() *moqUsual_RepeatedIds_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (a *moqUsual_RepeatedIds_anyParams) bParam() *moqUsual_RepeatedIds_fnRecorder { + a.recorder.anyParams |= 1 << 2 + return a.recorder +} + +func (r *moqUsual_RepeatedIds_fnRecorder) seq() *moqUsual_RepeatedIds_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_RepeatedIds(r.params)) + return nil + } + r.sequence = true + return r +} + +func (r *moqUsual_RepeatedIds_fnRecorder) noSeq() *moqUsual_RepeatedIds_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_RepeatedIds(r.params)) + return nil + } + r.sequence = false + return r +} + +func (r *moqUsual_RepeatedIds_fnRecorder) returnResults(sResult1, sResult2 string, err error) *moqUsual_RepeatedIds_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult1, sResult2 string + err error + } + sequence uint32 + doFn moqUsual_RepeatedIds_doFn + doReturnFn moqUsual_RepeatedIds_doReturnFn + }{ + values: &struct { + sResult1, sResult2 string + err error + }{ + sResult1: sResult1, + sResult2: sResult2, + err: err, + }, + sequence: sequence, + }) + return r +} + +func (r *moqUsual_RepeatedIds_fnRecorder) andDo(fn moqUsual_RepeatedIds_doFn) *moqUsual_RepeatedIds_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r +} + +func (r *moqUsual_RepeatedIds_fnRecorder) doReturnResults(fn moqUsual_RepeatedIds_doReturnFn) *moqUsual_RepeatedIds_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult1, sResult2 string + err error + } + sequence uint32 + doFn moqUsual_RepeatedIds_doFn + doReturnFn moqUsual_RepeatedIds_doReturnFn + }{sequence: sequence, doReturnFn: fn}) + return r +} + +func (r *moqUsual_RepeatedIds_fnRecorder) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqUsual_RepeatedIds_resultsByParams + for n, res := range r.moq.resultsByParams_RepeatedIds { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqUsual_RepeatedIds_resultsByParams{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqUsual_RepeatedIds_paramsKey]*moqUsual_RepeatedIds_results{}, + } + r.moq.resultsByParams_RepeatedIds = append(r.moq.resultsByParams_RepeatedIds, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_RepeatedIds) { + copy(r.moq.resultsByParams_RepeatedIds[insertAt+1:], r.moq.resultsByParams_RepeatedIds[insertAt:0]) + r.moq.resultsByParams_RepeatedIds[insertAt] = *results + } + } + + paramsKey := r.moq.paramsKey_RepeatedIds(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqUsual_RepeatedIds_results{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } + + r.results.repeat.Increment(r.moq.scene.T) +} + +func (r *moqUsual_RepeatedIds_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_RepeatedIds_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct { + sResult1, sResult2 string + err error + } + sequence uint32 + doFn moqUsual_RepeatedIds_doFn + doReturnFn moqUsual_RepeatedIds_doReturnFn + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r +} + +func (m *moqUsual) prettyParams_RepeatedIds(params moqUsual_RepeatedIds_params) string { + return fmt.Sprintf("RepeatedIds(%#v, %#v, %#v)", params.sParam1, params.sParam2, params.bParam) +} + +func (m *moqUsual) paramsKey_RepeatedIds(params moqUsual_RepeatedIds_params, anyParams uint64) moqUsual_RepeatedIds_paramsKey { + m.scene.T.Helper() + var sParam1Used string + var sParam1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.RepeatedIds.sParam1 == moq.ParamIndexByValue { + sParam1Used = params.sParam1 + } else { + sParam1UsedHash = hash.DeepHash(params.sParam1) + } + } + var sParam2Used string + var sParam2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.RepeatedIds.sParam2 == moq.ParamIndexByValue { + sParam2Used = params.sParam2 + } else { + sParam2UsedHash = hash.DeepHash(params.sParam2) + } + } + var bParamUsed bool + var bParamUsedHash hash.Hash + if anyParams&(1<<2) == 0 { + if m.runtime.parameterIndexing.RepeatedIds.bParam == moq.ParamIndexByValue { + bParamUsed = params.bParam + } else { + bParamUsedHash = hash.DeepHash(params.bParam) + } + } + return moqUsual_RepeatedIds_paramsKey{ + params: struct { + sParam1, sParam2 string + bParam bool + }{ + sParam1: sParam1Used, + sParam2: sParam2Used, + bParam: bParamUsed, + }, + hashes: struct { + sParam1, sParam2 hash.Hash + bParam hash.Hash + }{ + sParam1: sParam1UsedHash, + sParam2: sParam2UsedHash, + bParam: bParamUsedHash, + }, + } +} + +func (m *moqUsual_recorder) Times(sParam string, times bool) *moqUsual_Times_fnRecorder { + return &moqUsual_Times_fnRecorder{ + params: moqUsual_Times_params{ + sParam: sParam, + times: times, + }, + sequence: m.moq.config.Sequence == moq.SeqDefaultOn, + moq: m.moq, + } +} + +func (r *moqUsual_Times_fnRecorder) any() *moqUsual_Times_anyParams { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Times(r.params)) + return nil + } + return &moqUsual_Times_anyParams{recorder: r} +} + +func (a *moqUsual_Times_anyParams) sParam() *moqUsual_Times_fnRecorder { + a.recorder.anyParams |= 1 << 0 + return a.recorder +} + +func (a *moqUsual_Times_anyParams) times() *moqUsual_Times_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (r *moqUsual_Times_fnRecorder) seq() *moqUsual_Times_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Times(r.params)) + return nil + } + r.sequence = true + return r +} + +func (r *moqUsual_Times_fnRecorder) noSeq() *moqUsual_Times_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Times(r.params)) + return nil + } + r.sequence = false + return r +} + +func (r *moqUsual_Times_fnRecorder) returnResults(sResult string, err error) *moqUsual_Times_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Times_doFn + doReturnFn moqUsual_Times_doReturnFn + }{ + values: &struct { + sResult string + err error + }{ + sResult: sResult, + err: err, + }, + sequence: sequence, + }) + return r +} + +func (r *moqUsual_Times_fnRecorder) andDo(fn moqUsual_Times_doFn) *moqUsual_Times_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r +} + +func (r *moqUsual_Times_fnRecorder) doReturnResults(fn moqUsual_Times_doReturnFn) *moqUsual_Times_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Times_doFn + doReturnFn moqUsual_Times_doReturnFn + }{sequence: sequence, doReturnFn: fn}) + return r +} + +func (r *moqUsual_Times_fnRecorder) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqUsual_Times_resultsByParams + for n, res := range r.moq.resultsByParams_Times { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqUsual_Times_resultsByParams{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqUsual_Times_paramsKey]*moqUsual_Times_results{}, + } + r.moq.resultsByParams_Times = append(r.moq.resultsByParams_Times, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Times) { + copy(r.moq.resultsByParams_Times[insertAt+1:], r.moq.resultsByParams_Times[insertAt:0]) + r.moq.resultsByParams_Times[insertAt] = *results + } + } + + paramsKey := r.moq.paramsKey_Times(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqUsual_Times_results{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } + + r.results.repeat.Increment(r.moq.scene.T) +} + +func (r *moqUsual_Times_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_Times_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_Times_doFn + doReturnFn moqUsual_Times_doReturnFn + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r +} + +func (m *moqUsual) prettyParams_Times(params moqUsual_Times_params) string { + return fmt.Sprintf("Times(%#v, %#v)", params.sParam, params.times) +} + +func (m *moqUsual) paramsKey_Times(params moqUsual_Times_params, anyParams uint64) moqUsual_Times_paramsKey { + m.scene.T.Helper() + var sParamUsed string + var sParamUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.Times.sParam == moq.ParamIndexByValue { + sParamUsed = params.sParam + } else { + sParamUsedHash = hash.DeepHash(params.sParam) + } + } + var timesUsed bool + var timesUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.Times.times == moq.ParamIndexByValue { + timesUsed = params.times + } else { + timesUsedHash = hash.DeepHash(params.times) + } + } + return moqUsual_Times_paramsKey{ + params: struct { + sParam string + times bool + }{ + sParam: sParamUsed, + times: timesUsed, + }, + hashes: struct { + sParam hash.Hash + times hash.Hash + }{ + sParam: sParamUsedHash, + times: timesUsedHash, + }, + } +} + +func (m *moqUsual_recorder) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) *moqUsual_DifficultParamNames_fnRecorder { + return &moqUsual_DifficultParamNames_fnRecorder{ + params: moqUsual_DifficultParamNames_params{ + param1: param1, + param2: param2, + param3: param3, + param: param, + param5: param5, + param6: param6, + param7: param7, + param8: param8, + param9: param9, + }, + sequence: m.moq.config.Sequence == moq.SeqDefaultOn, + moq: m.moq, + } +} + +func (r *moqUsual_DifficultParamNames_fnRecorder) any() *moqUsual_DifficultParamNames_anyParams { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultParamNames(r.params)) + return nil + } + return &moqUsual_DifficultParamNames_anyParams{recorder: r} +} + +func (a *moqUsual_DifficultParamNames_anyParams) param1() *moqUsual_DifficultParamNames_fnRecorder { + a.recorder.anyParams |= 1 << 0 + return a.recorder +} + +func (a *moqUsual_DifficultParamNames_anyParams) param2() *moqUsual_DifficultParamNames_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (a *moqUsual_DifficultParamNames_anyParams) param3() *moqUsual_DifficultParamNames_fnRecorder { + a.recorder.anyParams |= 1 << 2 + return a.recorder +} + +func (a *moqUsual_DifficultParamNames_anyParams) param() *moqUsual_DifficultParamNames_fnRecorder { + a.recorder.anyParams |= 1 << 3 + return a.recorder +} + +func (a *moqUsual_DifficultParamNames_anyParams) param5() *moqUsual_DifficultParamNames_fnRecorder { + a.recorder.anyParams |= 1 << 4 + return a.recorder +} + +func (a *moqUsual_DifficultParamNames_anyParams) param6() *moqUsual_DifficultParamNames_fnRecorder { + a.recorder.anyParams |= 1 << 5 + return a.recorder +} + +func (a *moqUsual_DifficultParamNames_anyParams) param7() *moqUsual_DifficultParamNames_fnRecorder { + a.recorder.anyParams |= 1 << 6 + return a.recorder +} + +func (a *moqUsual_DifficultParamNames_anyParams) param8() *moqUsual_DifficultParamNames_fnRecorder { + a.recorder.anyParams |= 1 << 7 + return a.recorder +} + +func (a *moqUsual_DifficultParamNames_anyParams) param9() *moqUsual_DifficultParamNames_fnRecorder { + a.recorder.anyParams |= 1 << 8 + return a.recorder +} + +func (r *moqUsual_DifficultParamNames_fnRecorder) seq() *moqUsual_DifficultParamNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultParamNames(r.params)) + return nil + } + r.sequence = true + return r +} + +func (r *moqUsual_DifficultParamNames_fnRecorder) noSeq() *moqUsual_DifficultParamNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultParamNames(r.params)) + return nil + } + r.sequence = false + return r +} + +func (r *moqUsual_DifficultParamNames_fnRecorder) returnResults() *moqUsual_DifficultParamNames_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct{} + sequence uint32 + doFn moqUsual_DifficultParamNames_doFn + doReturnFn moqUsual_DifficultParamNames_doReturnFn + }{ + values: &struct{}{}, + sequence: sequence, + }) + return r +} + +func (r *moqUsual_DifficultParamNames_fnRecorder) andDo(fn moqUsual_DifficultParamNames_doFn) *moqUsual_DifficultParamNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r +} + +func (r *moqUsual_DifficultParamNames_fnRecorder) doReturnResults(fn moqUsual_DifficultParamNames_doReturnFn) *moqUsual_DifficultParamNames_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct{} + sequence uint32 + doFn moqUsual_DifficultParamNames_doFn + doReturnFn moqUsual_DifficultParamNames_doReturnFn + }{sequence: sequence, doReturnFn: fn}) + return r +} + +func (r *moqUsual_DifficultParamNames_fnRecorder) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqUsual_DifficultParamNames_resultsByParams + for n, res := range r.moq.resultsByParams_DifficultParamNames { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqUsual_DifficultParamNames_resultsByParams{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqUsual_DifficultParamNames_paramsKey]*moqUsual_DifficultParamNames_results{}, + } + r.moq.resultsByParams_DifficultParamNames = append(r.moq.resultsByParams_DifficultParamNames, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_DifficultParamNames) { + copy(r.moq.resultsByParams_DifficultParamNames[insertAt+1:], r.moq.resultsByParams_DifficultParamNames[insertAt:0]) + r.moq.resultsByParams_DifficultParamNames[insertAt] = *results + } + } + + paramsKey := r.moq.paramsKey_DifficultParamNames(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqUsual_DifficultParamNames_results{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } + + r.results.repeat.Increment(r.moq.scene.T) +} + +func (r *moqUsual_DifficultParamNames_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_DifficultParamNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct{} + sequence uint32 + doFn moqUsual_DifficultParamNames_doFn + doReturnFn moqUsual_DifficultParamNames_doReturnFn + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r +} + +func (m *moqUsual) prettyParams_DifficultParamNames(params moqUsual_DifficultParamNames_params) string { + return fmt.Sprintf("DifficultParamNames(%#v, %#v, %#v, %#v, %#v, %#v, %#v, %#v, %#v)", params.param1, params.param2, params.param3, params.param, params.param5, params.param6, params.param7, params.param8, params.param9) +} + +func (m *moqUsual) paramsKey_DifficultParamNames(params moqUsual_DifficultParamNames_params, anyParams uint64) moqUsual_DifficultParamNames_paramsKey { + m.scene.T.Helper() + var param1Used bool + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.DifficultParamNames.param1 == moq.ParamIndexByValue { + param1Used = params.param1 + } else { + param1UsedHash = hash.DeepHash(params.param1) + } + } + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.DifficultParamNames.param2 == moq.ParamIndexByValue { + param2Used = params.param2 + } else { + param2UsedHash = hash.DeepHash(params.param2) + } + } + var param3Used string + var param3UsedHash hash.Hash + if anyParams&(1<<2) == 0 { + if m.runtime.parameterIndexing.DifficultParamNames.param3 == moq.ParamIndexByValue { + param3Used = params.param3 + } else { + param3UsedHash = hash.DeepHash(params.param3) + } + } + var paramUsed int + var paramUsedHash hash.Hash + if anyParams&(1<<3) == 0 { + if m.runtime.parameterIndexing.DifficultParamNames.param == moq.ParamIndexByValue { + paramUsed = params.param + } else { + paramUsedHash = hash.DeepHash(params.param) + } + } + var param5Used int + var param5UsedHash hash.Hash + if anyParams&(1<<4) == 0 { + if m.runtime.parameterIndexing.DifficultParamNames.param5 == moq.ParamIndexByValue { + param5Used = params.param5 + } else { + param5UsedHash = hash.DeepHash(params.param5) + } + } + var param6Used int + var param6UsedHash hash.Hash + if anyParams&(1<<5) == 0 { + if m.runtime.parameterIndexing.DifficultParamNames.param6 == moq.ParamIndexByValue { + param6Used = params.param6 + } else { + param6UsedHash = hash.DeepHash(params.param6) + } + } + var param7Used float32 + var param7UsedHash hash.Hash + if anyParams&(1<<6) == 0 { + if m.runtime.parameterIndexing.DifficultParamNames.param7 == moq.ParamIndexByValue { + param7Used = params.param7 + } else { + param7UsedHash = hash.DeepHash(params.param7) + } + } + var param8Used float32 + var param8UsedHash hash.Hash + if anyParams&(1<<7) == 0 { + if m.runtime.parameterIndexing.DifficultParamNames.param8 == moq.ParamIndexByValue { + param8Used = params.param8 + } else { + param8UsedHash = hash.DeepHash(params.param8) + } + } + var param9Used float32 + var param9UsedHash hash.Hash + if anyParams&(1<<8) == 0 { + if m.runtime.parameterIndexing.DifficultParamNames.param9 == moq.ParamIndexByValue { + param9Used = params.param9 + } else { + param9UsedHash = hash.DeepHash(params.param9) + } + } + return moqUsual_DifficultParamNames_paramsKey{ + params: struct { + param1, param2 bool + param3 string + param, param5, param6 int + param7, param8, param9 float32 + }{ + param1: param1Used, + param2: param2Used, + param3: param3Used, + param: paramUsed, + param5: param5Used, + param6: param6Used, + param7: param7Used, + param8: param8Used, + param9: param9Used, + }, + hashes: struct { + param1, param2 hash.Hash + param3 hash.Hash + param, param5, param6 hash.Hash + param7, param8, param9 hash.Hash + }{ + param1: param1UsedHash, + param2: param2UsedHash, + param3: param3UsedHash, + param: paramUsedHash, + param5: param5UsedHash, + param6: param6UsedHash, + param7: param7UsedHash, + param8: param8UsedHash, + param9: param9UsedHash, + }, + } +} + +func (m *moqUsual_recorder) DifficultResultNames() *moqUsual_DifficultResultNames_fnRecorder { + return &moqUsual_DifficultResultNames_fnRecorder{ + params: moqUsual_DifficultResultNames_params{}, + sequence: m.moq.config.Sequence == moq.SeqDefaultOn, + moq: m.moq, + } +} + +func (r *moqUsual_DifficultResultNames_fnRecorder) any() *moqUsual_DifficultResultNames_anyParams { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultResultNames(r.params)) + return nil + } + return &moqUsual_DifficultResultNames_anyParams{recorder: r} +} + +func (r *moqUsual_DifficultResultNames_fnRecorder) seq() *moqUsual_DifficultResultNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultResultNames(r.params)) + return nil + } + r.sequence = true + return r +} + +func (r *moqUsual_DifficultResultNames_fnRecorder) noSeq() *moqUsual_DifficultResultNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultResultNames(r.params)) + return nil + } + r.sequence = false + return r +} + +func (r *moqUsual_DifficultResultNames_fnRecorder) returnResults(result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) *moqUsual_DifficultResultNames_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + result1, result2 string + result3 error + param, result5, result6 int + result7, result8, result9 float32 + } + sequence uint32 + doFn moqUsual_DifficultResultNames_doFn + doReturnFn moqUsual_DifficultResultNames_doReturnFn + }{ + values: &struct { + result1, result2 string + result3 error + param, result5, result6 int + result7, result8, result9 float32 + }{ + result1: result1, + result2: result2, + result3: result3, + param: param, + result5: result5, + result6: result6, + result7: result7, + result8: result8, + result9: result9, + }, + sequence: sequence, + }) + return r +} + +func (r *moqUsual_DifficultResultNames_fnRecorder) andDo(fn moqUsual_DifficultResultNames_doFn) *moqUsual_DifficultResultNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r +} + +func (r *moqUsual_DifficultResultNames_fnRecorder) doReturnResults(fn moqUsual_DifficultResultNames_doReturnFn) *moqUsual_DifficultResultNames_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + result1, result2 string + result3 error + param, result5, result6 int + result7, result8, result9 float32 + } + sequence uint32 + doFn moqUsual_DifficultResultNames_doFn + doReturnFn moqUsual_DifficultResultNames_doReturnFn + }{sequence: sequence, doReturnFn: fn}) + return r +} + +func (r *moqUsual_DifficultResultNames_fnRecorder) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqUsual_DifficultResultNames_resultsByParams + for n, res := range r.moq.resultsByParams_DifficultResultNames { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqUsual_DifficultResultNames_resultsByParams{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqUsual_DifficultResultNames_paramsKey]*moqUsual_DifficultResultNames_results{}, + } + r.moq.resultsByParams_DifficultResultNames = append(r.moq.resultsByParams_DifficultResultNames, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_DifficultResultNames) { + copy(r.moq.resultsByParams_DifficultResultNames[insertAt+1:], r.moq.resultsByParams_DifficultResultNames[insertAt:0]) + r.moq.resultsByParams_DifficultResultNames[insertAt] = *results + } + } + + paramsKey := r.moq.paramsKey_DifficultResultNames(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqUsual_DifficultResultNames_results{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } + + r.results.repeat.Increment(r.moq.scene.T) +} + +func (r *moqUsual_DifficultResultNames_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_DifficultResultNames_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct { + result1, result2 string + result3 error + param, result5, result6 int + result7, result8, result9 float32 + } + sequence uint32 + doFn moqUsual_DifficultResultNames_doFn + doReturnFn moqUsual_DifficultResultNames_doReturnFn + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r +} + +func (m *moqUsual) prettyParams_DifficultResultNames(params moqUsual_DifficultResultNames_params) string { + return fmt.Sprintf("DifficultResultNames()") +} + +func (m *moqUsual) paramsKey_DifficultResultNames(params moqUsual_DifficultResultNames_params, anyParams uint64) moqUsual_DifficultResultNames_paramsKey { + m.scene.T.Helper() + return moqUsual_DifficultResultNames_paramsKey{ + params: struct{}{}, + hashes: struct{}{}, + } +} + +func (m *moqUsual_recorder) PassByReference(p *testmoqs.PassByReferenceParams) *moqUsual_PassByReference_fnRecorder { + return &moqUsual_PassByReference_fnRecorder{ + params: moqUsual_PassByReference_params{ + p: p, + }, + sequence: m.moq.config.Sequence == moq.SeqDefaultOn, + moq: m.moq, + } +} + +func (r *moqUsual_PassByReference_fnRecorder) any() *moqUsual_PassByReference_anyParams { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_PassByReference(r.params)) + return nil + } + return &moqUsual_PassByReference_anyParams{recorder: r} +} + +func (a *moqUsual_PassByReference_anyParams) p() *moqUsual_PassByReference_fnRecorder { + a.recorder.anyParams |= 1 << 0 + return a.recorder +} + +func (r *moqUsual_PassByReference_fnRecorder) seq() *moqUsual_PassByReference_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_PassByReference(r.params)) + return nil + } + r.sequence = true + return r +} + +func (r *moqUsual_PassByReference_fnRecorder) noSeq() *moqUsual_PassByReference_fnRecorder { + r.moq.scene.T.Helper() + if r.results != nil { + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_PassByReference(r.params)) + return nil + } + r.sequence = false + return r +} + +func (r *moqUsual_PassByReference_fnRecorder) returnResults(sResult string, err error) *moqUsual_PassByReference_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_PassByReference_doFn + doReturnFn moqUsual_PassByReference_doReturnFn + }{ + values: &struct { + sResult string + err error + }{ + sResult: sResult, + err: err, + }, + sequence: sequence, + }) + return r +} + +func (r *moqUsual_PassByReference_fnRecorder) andDo(fn moqUsual_PassByReference_doFn) *moqUsual_PassByReference_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") + return nil + } + last := &r.results.results[len(r.results.results)-1] + last.doFn = fn + return r +} + +func (r *moqUsual_PassByReference_fnRecorder) doReturnResults(fn moqUsual_PassByReference_doReturnFn) *moqUsual_PassByReference_fnRecorder { + r.moq.scene.T.Helper() + r.findResults() + + var sequence uint32 + if r.sequence { + sequence = r.moq.scene.NextRecorderSequence() + } + + r.results.results = append(r.results.results, struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_PassByReference_doFn + doReturnFn moqUsual_PassByReference_doReturnFn + }{sequence: sequence, doReturnFn: fn}) + return r +} + +func (r *moqUsual_PassByReference_fnRecorder) findResults() { + r.moq.scene.T.Helper() + if r.results != nil { + r.results.repeat.Increment(r.moq.scene.T) + return + } + + anyCount := bits.OnesCount64(r.anyParams) + insertAt := -1 + var results *moqUsual_PassByReference_resultsByParams + for n, res := range r.moq.resultsByParams_PassByReference { + if res.anyParams == r.anyParams { + results = &res + break + } + if res.anyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &moqUsual_PassByReference_resultsByParams{ + anyCount: anyCount, + anyParams: r.anyParams, + results: map[moqUsual_PassByReference_paramsKey]*moqUsual_PassByReference_results{}, + } + r.moq.resultsByParams_PassByReference = append(r.moq.resultsByParams_PassByReference, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_PassByReference) { + copy(r.moq.resultsByParams_PassByReference[insertAt+1:], r.moq.resultsByParams_PassByReference[insertAt:0]) + r.moq.resultsByParams_PassByReference[insertAt] = *results + } + } + + paramsKey := r.moq.paramsKey_PassByReference(r.params, r.anyParams) + + var ok bool + r.results, ok = results.results[paramsKey] + if !ok { + r.results = &moqUsual_PassByReference_results{ + params: r.params, + results: nil, + index: 0, + repeat: &moq.RepeatVal{}, + } + results.results[paramsKey] = r.results + } + + r.results.repeat.Increment(r.moq.scene.T) +} + +func (r *moqUsual_PassByReference_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByReference_fnRecorder { + r.moq.scene.T.Helper() + if r.results == nil { + r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") + return nil + } + r.results.repeat.Repeat(r.moq.scene.T, repeaters) + last := r.results.results[len(r.results.results)-1] + for n := 0; n < r.results.repeat.ResultCount-1; n++ { + if r.sequence { + last = struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqUsual_PassByReference_doFn + doReturnFn moqUsual_PassByReference_doReturnFn + }{ + values: last.values, + sequence: r.moq.scene.NextRecorderSequence(), + } + } + r.results.results = append(r.results.results, last) + } + return r +} + +func (m *moqUsual) prettyParams_PassByReference(params moqUsual_PassByReference_params) string { + return fmt.Sprintf("PassByReference(%#v)", params.p) +} + +func (m *moqUsual) paramsKey_PassByReference(params moqUsual_PassByReference_params, anyParams uint64) moqUsual_PassByReference_paramsKey { + m.scene.T.Helper() + var pUsed *testmoqs.PassByReferenceParams + var pUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.PassByReference.p == moq.ParamIndexByValue { + pUsed = params.p + } else { + pUsedHash = hash.DeepHash(params.p) + } + } + return moqUsual_PassByReference_paramsKey{ + params: struct { + p *testmoqs.PassByReferenceParams + }{ + p: pUsed, + }, + hashes: struct{ p hash.Hash }{ + p: pUsedHash, + }, + } +} + +func (m *moqUsual_recorder) InterfaceParam(w io.Writer) *moqUsual_InterfaceParam_fnRecorder { + return &moqUsual_InterfaceParam_fnRecorder{ + params: moqUsual_InterfaceParam_params{ + w: w, + }, + sequence: m.moq.config.Sequence == moq.SeqDefaultOn, + moq: m.moq, + } +} + +func (r *moqUsual_InterfaceParam_fnRecorder) any() *moqUsual_InterfaceParam_anyParams { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoParams(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceParam(r.params)) return nil } - return &moqUsual_NoParams_anyParams{recorder: r} + return &moqUsual_InterfaceParam_anyParams{recorder: r} } -func (r *moqUsual_NoParams_fnRecorder) seq() *moqUsual_NoParams_fnRecorder { +func (a *moqUsual_InterfaceParam_anyParams) w() *moqUsual_InterfaceParam_fnRecorder { + a.recorder.anyParams |= 1 << 0 + return a.recorder +} + +func (r *moqUsual_InterfaceParam_fnRecorder) seq() *moqUsual_InterfaceParam_fnRecorder { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoParams(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceParam(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_NoParams_fnRecorder) noSeq() *moqUsual_NoParams_fnRecorder { +func (r *moqUsual_InterfaceParam_fnRecorder) noSeq() *moqUsual_InterfaceParam_fnRecorder { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_NoParams(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceParam(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_NoParams_fnRecorder) returnResults(sResult string, err error) *moqUsual_NoParams_fnRecorder { +func (r *moqUsual_InterfaceParam_fnRecorder) returnResults(sResult string, err error) *moqUsual_InterfaceParam_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -8093,8 +12428,8 @@ func (r *moqUsual_NoParams_fnRecorder) returnResults(sResult string, err error) err error } sequence uint32 - doFn moqUsual_NoParams_doFn - doReturnFn moqUsual_NoParams_doReturnFn + doFn moqUsual_InterfaceParam_doFn + doReturnFn moqUsual_InterfaceParam_doReturnFn }{ values: &struct { sResult string @@ -8108,7 +12443,7 @@ func (r *moqUsual_NoParams_fnRecorder) returnResults(sResult string, err error) return r } -func (r *moqUsual_NoParams_fnRecorder) andDo(fn moqUsual_NoParams_doFn) *moqUsual_NoParams_fnRecorder { +func (r *moqUsual_InterfaceParam_fnRecorder) andDo(fn moqUsual_InterfaceParam_doFn) *moqUsual_InterfaceParam_fnRecorder { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -8119,7 +12454,7 @@ func (r *moqUsual_NoParams_fnRecorder) andDo(fn moqUsual_NoParams_doFn) *moqUsua return r } -func (r *moqUsual_NoParams_fnRecorder) doReturnResults(fn moqUsual_NoParams_doReturnFn) *moqUsual_NoParams_fnRecorder { +func (r *moqUsual_InterfaceParam_fnRecorder) doReturnResults(fn moqUsual_InterfaceParam_doReturnFn) *moqUsual_InterfaceParam_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -8134,13 +12469,13 @@ func (r *moqUsual_NoParams_fnRecorder) doReturnResults(fn moqUsual_NoParams_doRe err error } sequence uint32 - doFn moqUsual_NoParams_doFn - doReturnFn moqUsual_NoParams_doReturnFn + doFn moqUsual_InterfaceParam_doFn + doReturnFn moqUsual_InterfaceParam_doReturnFn }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_NoParams_fnRecorder) findResults() { +func (r *moqUsual_InterfaceParam_fnRecorder) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -8149,8 +12484,8 @@ func (r *moqUsual_NoParams_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_NoParams_resultsByParams - for n, res := range r.moq.resultsByParams_NoParams { + var results *moqUsual_InterfaceParam_resultsByParams + for n, res := range r.moq.resultsByParams_InterfaceParam { if res.anyParams == r.anyParams { results = &res break @@ -8160,24 +12495,24 @@ func (r *moqUsual_NoParams_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_NoParams_resultsByParams{ + results = &moqUsual_InterfaceParam_resultsByParams{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_NoParams_paramsKey]*moqUsual_NoParams_results{}, + results: map[moqUsual_InterfaceParam_paramsKey]*moqUsual_InterfaceParam_results{}, } - r.moq.resultsByParams_NoParams = append(r.moq.resultsByParams_NoParams, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_NoParams) { - copy(r.moq.resultsByParams_NoParams[insertAt+1:], r.moq.resultsByParams_NoParams[insertAt:0]) - r.moq.resultsByParams_NoParams[insertAt] = *results + r.moq.resultsByParams_InterfaceParam = append(r.moq.resultsByParams_InterfaceParam, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_InterfaceParam) { + copy(r.moq.resultsByParams_InterfaceParam[insertAt+1:], r.moq.resultsByParams_InterfaceParam[insertAt:0]) + r.moq.resultsByParams_InterfaceParam[insertAt] = *results } } - paramsKey := r.moq.paramsKey_NoParams(r.params, r.anyParams) + paramsKey := r.moq.paramsKey_InterfaceParam(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_NoParams_results{ + r.results = &moqUsual_InterfaceParam_results{ params: r.params, results: nil, index: 0, @@ -8189,7 +12524,7 @@ func (r *moqUsual_NoParams_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_NoParams_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_NoParams_fnRecorder { +func (r *moqUsual_InterfaceParam_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_InterfaceParam_fnRecorder { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -8205,8 +12540,8 @@ func (r *moqUsual_NoParams_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsu err error } sequence uint32 - doFn moqUsual_NoParams_doFn - doReturnFn moqUsual_NoParams_doReturnFn + doFn moqUsual_InterfaceParam_doFn + doReturnFn moqUsual_InterfaceParam_doReturnFn }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -8217,56 +12552,82 @@ func (r *moqUsual_NoParams_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsu return r } -func (m *moqUsual) prettyParams_NoParams(params moqUsual_NoParams_params) string { - return fmt.Sprintf("NoParams()") +func (m *moqUsual) prettyParams_InterfaceParam(params moqUsual_InterfaceParam_params) string { + return fmt.Sprintf("InterfaceParam(%#v)", params.w) } -func (m *moqUsual) paramsKey_NoParams(params moqUsual_NoParams_params, anyParams uint64) moqUsual_NoParams_paramsKey { +func (m *moqUsual) paramsKey_InterfaceParam(params moqUsual_InterfaceParam_params, anyParams uint64) moqUsual_InterfaceParam_paramsKey { m.scene.T.Helper() - return moqUsual_NoParams_paramsKey{ - params: struct{}{}, - hashes: struct{}{}, + var wUsed io.Writer + var wUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.InterfaceParam.w == moq.ParamIndexByValue { + wUsed = params.w + } else { + wUsedHash = hash.DeepHash(params.w) + } + } + return moqUsual_InterfaceParam_paramsKey{ + params: struct{ w io.Writer }{ + w: wUsed, + }, + hashes: struct{ w hash.Hash }{ + w: wUsedHash, + }, } } -func (m *moqUsual_recorder) Nothing() *moqUsual_Nothing_fnRecorder { - return &moqUsual_Nothing_fnRecorder{ - params: moqUsual_Nothing_params{}, +func (m *moqUsual_recorder) InterfaceResult(sParam string, bParam bool) *moqUsual_InterfaceResult_fnRecorder { + return &moqUsual_InterfaceResult_fnRecorder{ + params: moqUsual_InterfaceResult_params{ + sParam: sParam, + bParam: bParam, + }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, } } -func (r *moqUsual_Nothing_fnRecorder) any() *moqUsual_Nothing_anyParams { +func (r *moqUsual_InterfaceResult_fnRecorder) any() *moqUsual_InterfaceResult_anyParams { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Nothing(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceResult(r.params)) return nil } - return &moqUsual_Nothing_anyParams{recorder: r} + return &moqUsual_InterfaceResult_anyParams{recorder: r} } -func (r *moqUsual_Nothing_fnRecorder) seq() *moqUsual_Nothing_fnRecorder { +func (a *moqUsual_InterfaceResult_anyParams) sParam() *moqUsual_InterfaceResult_fnRecorder { + a.recorder.anyParams |= 1 << 0 + return a.recorder +} + +func (a *moqUsual_InterfaceResult_anyParams) bParam() *moqUsual_InterfaceResult_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (r *moqUsual_InterfaceResult_fnRecorder) seq() *moqUsual_InterfaceResult_fnRecorder { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Nothing(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceResult(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_Nothing_fnRecorder) noSeq() *moqUsual_Nothing_fnRecorder { +func (r *moqUsual_InterfaceResult_fnRecorder) noSeq() *moqUsual_InterfaceResult_fnRecorder { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Nothing(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceResult(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_Nothing_fnRecorder) returnResults() *moqUsual_Nothing_fnRecorder { +func (r *moqUsual_InterfaceResult_fnRecorder) returnResults(result1 io.Reader) *moqUsual_InterfaceResult_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -8276,18 +12637,20 @@ func (r *moqUsual_Nothing_fnRecorder) returnResults() *moqUsual_Nothing_fnRecord } r.results.results = append(r.results.results, struct { - values *struct{} + values *struct{ result1 io.Reader } sequence uint32 - doFn moqUsual_Nothing_doFn - doReturnFn moqUsual_Nothing_doReturnFn + doFn moqUsual_InterfaceResult_doFn + doReturnFn moqUsual_InterfaceResult_doReturnFn }{ - values: &struct{}{}, + values: &struct{ result1 io.Reader }{ + result1: result1, + }, sequence: sequence, }) return r } -func (r *moqUsual_Nothing_fnRecorder) andDo(fn moqUsual_Nothing_doFn) *moqUsual_Nothing_fnRecorder { +func (r *moqUsual_InterfaceResult_fnRecorder) andDo(fn moqUsual_InterfaceResult_doFn) *moqUsual_InterfaceResult_fnRecorder { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -8298,7 +12661,7 @@ func (r *moqUsual_Nothing_fnRecorder) andDo(fn moqUsual_Nothing_doFn) *moqUsual_ return r } -func (r *moqUsual_Nothing_fnRecorder) doReturnResults(fn moqUsual_Nothing_doReturnFn) *moqUsual_Nothing_fnRecorder { +func (r *moqUsual_InterfaceResult_fnRecorder) doReturnResults(fn moqUsual_InterfaceResult_doReturnFn) *moqUsual_InterfaceResult_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -8308,15 +12671,15 @@ func (r *moqUsual_Nothing_fnRecorder) doReturnResults(fn moqUsual_Nothing_doRetu } r.results.results = append(r.results.results, struct { - values *struct{} + values *struct{ result1 io.Reader } sequence uint32 - doFn moqUsual_Nothing_doFn - doReturnFn moqUsual_Nothing_doReturnFn + doFn moqUsual_InterfaceResult_doFn + doReturnFn moqUsual_InterfaceResult_doReturnFn }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_Nothing_fnRecorder) findResults() { +func (r *moqUsual_InterfaceResult_fnRecorder) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -8325,8 +12688,8 @@ func (r *moqUsual_Nothing_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_Nothing_resultsByParams - for n, res := range r.moq.resultsByParams_Nothing { + var results *moqUsual_InterfaceResult_resultsByParams + for n, res := range r.moq.resultsByParams_InterfaceResult { if res.anyParams == r.anyParams { results = &res break @@ -8336,24 +12699,24 @@ func (r *moqUsual_Nothing_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_Nothing_resultsByParams{ + results = &moqUsual_InterfaceResult_resultsByParams{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_Nothing_paramsKey]*moqUsual_Nothing_results{}, + results: map[moqUsual_InterfaceResult_paramsKey]*moqUsual_InterfaceResult_results{}, } - r.moq.resultsByParams_Nothing = append(r.moq.resultsByParams_Nothing, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Nothing) { - copy(r.moq.resultsByParams_Nothing[insertAt+1:], r.moq.resultsByParams_Nothing[insertAt:0]) - r.moq.resultsByParams_Nothing[insertAt] = *results + r.moq.resultsByParams_InterfaceResult = append(r.moq.resultsByParams_InterfaceResult, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_InterfaceResult) { + copy(r.moq.resultsByParams_InterfaceResult[insertAt+1:], r.moq.resultsByParams_InterfaceResult[insertAt:0]) + r.moq.resultsByParams_InterfaceResult[insertAt] = *results } } - paramsKey := r.moq.paramsKey_Nothing(r.params, r.anyParams) + paramsKey := r.moq.paramsKey_InterfaceResult(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_Nothing_results{ + r.results = &moqUsual_InterfaceResult_results{ params: r.params, results: nil, index: 0, @@ -8365,7 +12728,7 @@ func (r *moqUsual_Nothing_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_Nothing_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_Nothing_fnRecorder { +func (r *moqUsual_InterfaceResult_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_InterfaceResult_fnRecorder { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -8376,10 +12739,10 @@ func (r *moqUsual_Nothing_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsua for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{} + values *struct{ result1 io.Reader } sequence uint32 - doFn moqUsual_Nothing_doFn - doReturnFn moqUsual_Nothing_doReturnFn + doFn moqUsual_InterfaceResult_doFn + doReturnFn moqUsual_InterfaceResult_doReturnFn }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -8390,69 +12753,93 @@ func (r *moqUsual_Nothing_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsua return r } -func (m *moqUsual) prettyParams_Nothing(params moqUsual_Nothing_params) string { - return fmt.Sprintf("Nothing()") +func (m *moqUsual) prettyParams_InterfaceResult(params moqUsual_InterfaceResult_params) string { + return fmt.Sprintf("InterfaceResult(%#v, %#v)", params.sParam, params.bParam) } -func (m *moqUsual) paramsKey_Nothing(params moqUsual_Nothing_params, anyParams uint64) moqUsual_Nothing_paramsKey { +func (m *moqUsual) paramsKey_InterfaceResult(params moqUsual_InterfaceResult_params, anyParams uint64) moqUsual_InterfaceResult_paramsKey { m.scene.T.Helper() - return moqUsual_Nothing_paramsKey{ - params: struct{}{}, - hashes: struct{}{}, + var sParamUsed string + var sParamUsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.InterfaceResult.sParam == moq.ParamIndexByValue { + sParamUsed = params.sParam + } else { + sParamUsedHash = hash.DeepHash(params.sParam) + } + } + var bParamUsed bool + var bParamUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.InterfaceResult.bParam == moq.ParamIndexByValue { + bParamUsed = params.bParam + } else { + bParamUsedHash = hash.DeepHash(params.bParam) + } + } + return moqUsual_InterfaceResult_paramsKey{ + params: struct { + sParam string + bParam bool + }{ + sParam: sParamUsed, + bParam: bParamUsed, + }, + hashes: struct { + sParam hash.Hash + bParam hash.Hash + }{ + sParam: sParamUsedHash, + bParam: bParamUsedHash, + }, } } -func (m *moqUsual_recorder) Variadic(other bool, args ...string) *moqUsual_Variadic_fnRecorder { - return &moqUsual_Variadic_fnRecorder{ - params: moqUsual_Variadic_params{ - other: other, - args: args, +func (m *moqUsual_recorder) FnParam(fn func()) *moqUsual_FnParam_fnRecorder { + return &moqUsual_FnParam_fnRecorder{ + params: moqUsual_FnParam_params{ + fn: fn, }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, } } -func (r *moqUsual_Variadic_fnRecorder) any() *moqUsual_Variadic_anyParams { +func (r *moqUsual_FnParam_fnRecorder) any() *moqUsual_FnParam_anyParams { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Variadic(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_FnParam(r.params)) return nil } - return &moqUsual_Variadic_anyParams{recorder: r} + return &moqUsual_FnParam_anyParams{recorder: r} } -func (a *moqUsual_Variadic_anyParams) other() *moqUsual_Variadic_fnRecorder { +func (a *moqUsual_FnParam_anyParams) fn() *moqUsual_FnParam_fnRecorder { a.recorder.anyParams |= 1 << 0 return a.recorder } -func (a *moqUsual_Variadic_anyParams) args() *moqUsual_Variadic_fnRecorder { - a.recorder.anyParams |= 1 << 1 - return a.recorder -} - -func (r *moqUsual_Variadic_fnRecorder) seq() *moqUsual_Variadic_fnRecorder { +func (r *moqUsual_FnParam_fnRecorder) seq() *moqUsual_FnParam_fnRecorder { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Variadic(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_FnParam(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_Variadic_fnRecorder) noSeq() *moqUsual_Variadic_fnRecorder { +func (r *moqUsual_FnParam_fnRecorder) noSeq() *moqUsual_FnParam_fnRecorder { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Variadic(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_FnParam(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_Variadic_fnRecorder) returnResults(sResult string, err error) *moqUsual_Variadic_fnRecorder { +func (r *moqUsual_FnParam_fnRecorder) returnResults() *moqUsual_FnParam_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -8462,27 +12849,18 @@ func (r *moqUsual_Variadic_fnRecorder) returnResults(sResult string, err error) } r.results.results = append(r.results.results, struct { - values *struct { - sResult string - err error - } + values *struct{} sequence uint32 - doFn moqUsual_Variadic_doFn - doReturnFn moqUsual_Variadic_doReturnFn + doFn moqUsual_FnParam_doFn + doReturnFn moqUsual_FnParam_doReturnFn }{ - values: &struct { - sResult string - err error - }{ - sResult: sResult, - err: err, - }, + values: &struct{}{}, sequence: sequence, }) return r } -func (r *moqUsual_Variadic_fnRecorder) andDo(fn moqUsual_Variadic_doFn) *moqUsual_Variadic_fnRecorder { +func (r *moqUsual_FnParam_fnRecorder) andDo(fn moqUsual_FnParam_doFn) *moqUsual_FnParam_fnRecorder { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -8493,7 +12871,7 @@ func (r *moqUsual_Variadic_fnRecorder) andDo(fn moqUsual_Variadic_doFn) *moqUsua return r } -func (r *moqUsual_Variadic_fnRecorder) doReturnResults(fn moqUsual_Variadic_doReturnFn) *moqUsual_Variadic_fnRecorder { +func (r *moqUsual_FnParam_fnRecorder) doReturnResults(fn moqUsual_FnParam_doReturnFn) *moqUsual_FnParam_fnRecorder { r.moq.scene.T.Helper() r.findResults() @@ -8503,18 +12881,15 @@ func (r *moqUsual_Variadic_fnRecorder) doReturnResults(fn moqUsual_Variadic_doRe } r.results.results = append(r.results.results, struct { - values *struct { - sResult string - err error - } + values *struct{} sequence uint32 - doFn moqUsual_Variadic_doFn - doReturnFn moqUsual_Variadic_doReturnFn + doFn moqUsual_FnParam_doFn + doReturnFn moqUsual_FnParam_doReturnFn }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_Variadic_fnRecorder) findResults() { +func (r *moqUsual_FnParam_fnRecorder) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -8523,8 +12898,8 @@ func (r *moqUsual_Variadic_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_Variadic_resultsByParams - for n, res := range r.moq.resultsByParams_Variadic { + var results *moqUsual_FnParam_resultsByParams + for n, res := range r.moq.resultsByParams_FnParam { if res.anyParams == r.anyParams { results = &res break @@ -8534,24 +12909,24 @@ func (r *moqUsual_Variadic_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_Variadic_resultsByParams{ + results = &moqUsual_FnParam_resultsByParams{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_Variadic_paramsKey]*moqUsual_Variadic_results{}, + results: map[moqUsual_FnParam_paramsKey]*moqUsual_FnParam_results{}, } - r.moq.resultsByParams_Variadic = append(r.moq.resultsByParams_Variadic, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Variadic) { - copy(r.moq.resultsByParams_Variadic[insertAt+1:], r.moq.resultsByParams_Variadic[insertAt:0]) - r.moq.resultsByParams_Variadic[insertAt] = *results + r.moq.resultsByParams_FnParam = append(r.moq.resultsByParams_FnParam, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_FnParam) { + copy(r.moq.resultsByParams_FnParam[insertAt+1:], r.moq.resultsByParams_FnParam[insertAt:0]) + r.moq.resultsByParams_FnParam[insertAt] = *results } } - paramsKey := r.moq.paramsKey_Variadic(r.params, r.anyParams) + paramsKey := r.moq.paramsKey_FnParam(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_Variadic_results{ + r.results = &moqUsual_FnParam_results{ params: r.params, results: nil, index: 0, @@ -8563,7 +12938,7 @@ func (r *moqUsual_Variadic_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_Variadic_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_Variadic_fnRecorder { +func (r *moqUsual_FnParam_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_FnParam_fnRecorder { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -8572,15 +12947,12 @@ func (r *moqUsual_Variadic_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsu r.results.repeat.Repeat(r.moq.scene.T, repeaters) last := r.results.results[len(r.results.results)-1] for n := 0; n < r.results.repeat.ResultCount-1; n++ { - if r.sequence { - last = struct { - values *struct { - sResult string - err error - } + if r.sequence { + last = struct { + values *struct{} sequence uint32 - doFn moqUsual_Variadic_doFn - doReturnFn moqUsual_Variadic_doReturnFn + doFn moqUsual_FnParam_doFn + doReturnFn moqUsual_FnParam_doReturnFn }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -8591,342 +12963,413 @@ func (r *moqUsual_Variadic_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsu return r } -func (m *moqUsual) prettyParams_Variadic(params moqUsual_Variadic_params) string { - return fmt.Sprintf("Variadic(%#v, %#v)", params.other, params.args) +func (m *moqUsual) prettyParams_FnParam(params moqUsual_FnParam_params) string { + return fmt.Sprintf("FnParam(%#v)", moq.FnString(params.fn)) } -func (m *moqUsual) paramsKey_Variadic(params moqUsual_Variadic_params, anyParams uint64) moqUsual_Variadic_paramsKey { +func (m *moqUsual) paramsKey_FnParam(params moqUsual_FnParam_params, anyParams uint64) moqUsual_FnParam_paramsKey { m.scene.T.Helper() - var otherUsed bool - var otherUsedHash hash.Hash + var fnUsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Variadic.other == moq.ParamIndexByValue { - otherUsed = params.other - } else { - otherUsedHash = hash.DeepHash(params.other) - } - } - var argsUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.Variadic.args == moq.ParamIndexByValue { - m.scene.T.Fatalf("The args parameter of the Variadic function can't be indexed by value") + if m.runtime.parameterIndexing.FnParam.fn == moq.ParamIndexByValue { + m.scene.T.Fatalf("The fn parameter of the FnParam function can't be indexed by value") } - argsUsedHash = hash.DeepHash(params.args) + fnUsedHash = hash.DeepHash(params.fn) } - return moqUsual_Variadic_paramsKey{ - params: struct{ other bool }{ - other: otherUsed, - }, - hashes: struct { - other hash.Hash - args hash.Hash - }{ - other: otherUsedHash, - args: argsUsedHash, + return moqUsual_FnParam_paramsKey{ + params: struct{}{}, + hashes: struct{ fn hash.Hash }{ + fn: fnUsedHash, }, } } -func (m *moqUsual_recorder) RepeatedIds(sParam1, sParam2 string, bParam bool) *moqUsual_RepeatedIds_fnRecorder { - return &moqUsual_RepeatedIds_fnRecorder{ - params: moqUsual_RepeatedIds_params{ - sParam1: sParam1, - sParam2: sParam2, - bParam: bParam, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, - } +// Reset resets the state of the moq +func (m *moqUsual) Reset() { + m.resultsByParams_Usual = nil + m.resultsByParams_NoNames = nil + m.resultsByParams_NoResults = nil + m.resultsByParams_NoParams = nil + m.resultsByParams_Nothing = nil + m.resultsByParams_Variadic = nil + m.resultsByParams_RepeatedIds = nil + m.resultsByParams_Times = nil + m.resultsByParams_DifficultParamNames = nil + m.resultsByParams_DifficultResultNames = nil + m.resultsByParams_PassByReference = nil + m.resultsByParams_InterfaceParam = nil + m.resultsByParams_InterfaceResult = nil + m.resultsByParams_FnParam = nil } -func (r *moqUsual_RepeatedIds_fnRecorder) any() *moqUsual_RepeatedIds_anyParams { - r.moq.scene.T.Helper() - if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_RepeatedIds(r.params)) - return nil +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqUsual) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams_Usual { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Usual(results.params)) + } + } } - return &moqUsual_RepeatedIds_anyParams{recorder: r} -} - -func (a *moqUsual_RepeatedIds_anyParams) sParam1() *moqUsual_RepeatedIds_fnRecorder { - a.recorder.anyParams |= 1 << 0 - return a.recorder -} - -func (a *moqUsual_RepeatedIds_anyParams) sParam2() *moqUsual_RepeatedIds_fnRecorder { - a.recorder.anyParams |= 1 << 1 - return a.recorder -} - -func (a *moqUsual_RepeatedIds_anyParams) bParam() *moqUsual_RepeatedIds_fnRecorder { - a.recorder.anyParams |= 1 << 2 - return a.recorder -} - -func (r *moqUsual_RepeatedIds_fnRecorder) seq() *moqUsual_RepeatedIds_fnRecorder { - r.moq.scene.T.Helper() - if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_RepeatedIds(r.params)) - return nil + for _, res := range m.resultsByParams_NoNames { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_NoNames(results.params)) + } + } } - r.sequence = true - return r -} - -func (r *moqUsual_RepeatedIds_fnRecorder) noSeq() *moqUsual_RepeatedIds_fnRecorder { - r.moq.scene.T.Helper() - if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_RepeatedIds(r.params)) - return nil + for _, res := range m.resultsByParams_NoResults { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_NoResults(results.params)) + } + } + } + for _, res := range m.resultsByParams_NoParams { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_NoParams(results.params)) + } + } + } + for _, res := range m.resultsByParams_Nothing { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Nothing(results.params)) + } + } + } + for _, res := range m.resultsByParams_Variadic { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Variadic(results.params)) + } + } + } + for _, res := range m.resultsByParams_RepeatedIds { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_RepeatedIds(results.params)) + } + } + } + for _, res := range m.resultsByParams_Times { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Times(results.params)) + } + } + } + for _, res := range m.resultsByParams_DifficultParamNames { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_DifficultParamNames(results.params)) + } + } + } + for _, res := range m.resultsByParams_DifficultResultNames { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_DifficultResultNames(results.params)) + } + } + } + for _, res := range m.resultsByParams_PassByReference { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_PassByReference(results.params)) + } + } + } + for _, res := range m.resultsByParams_InterfaceParam { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_InterfaceParam(results.params)) + } + } + } + for _, res := range m.resultsByParams_InterfaceResult { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_InterfaceResult(results.params)) + } + } + } + for _, res := range m.resultsByParams_FnParam { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_FnParam(results.params)) + } + } } - r.sequence = false - return r } -func (r *moqUsual_RepeatedIds_fnRecorder) returnResults(sResult1, sResult2 string, err error) *moqUsual_RepeatedIds_fnRecorder { - r.moq.scene.T.Helper() - r.findResults() +// The following type assertion assures that testmoqs.GenericParams is mocked +// completely +var _ testmoqs.GenericParams[any, any] = (*moqGenericParams_mock[any, any])(nil) - var sequence uint32 - if r.sequence { - sequence = r.moq.scene.NextRecorderSequence() - } +// moqGenericParams holds the state of a moq of the GenericParams type +type moqGenericParams[S, B any] struct { + scene *moq.Scene + config moq.Config + moq *moqGenericParams_mock[S, B] - r.results.results = append(r.results.results, struct { - values *struct { - sResult1, sResult2 string - err error - } - sequence uint32 - doFn moqUsual_RepeatedIds_doFn - doReturnFn moqUsual_RepeatedIds_doReturnFn - }{ - values: &struct { - sResult1, sResult2 string - err error - }{ - sResult1: sResult1, - sResult2: sResult2, - err: err, - }, - sequence: sequence, - }) - return r + resultsByParams_Usual []moqGenericParams_Usual_resultsByParams[S, B] + + runtime struct { + parameterIndexing struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + } + } + // moqGenericParams_mock isolates the mock interface of the GenericParams type } -func (r *moqUsual_RepeatedIds_fnRecorder) andDo(fn moqUsual_RepeatedIds_doFn) *moqUsual_RepeatedIds_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") - return nil - } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn - return r +type moqGenericParams_mock[S, B any] struct { + moq *moqGenericParams[S, B] } -func (r *moqUsual_RepeatedIds_fnRecorder) doReturnResults(fn moqUsual_RepeatedIds_doReturnFn) *moqUsual_RepeatedIds_fnRecorder { - r.moq.scene.T.Helper() - r.findResults() +// moqGenericParams_recorder isolates the recorder interface of the +// GenericParams type +type moqGenericParams_recorder[S, B any] struct { + moq *moqGenericParams[S, B] +} - var sequence uint32 - if r.sequence { - sequence = r.moq.scene.NextRecorderSequence() +// moqGenericParams_Usual_params holds the params of the GenericParams type +type moqGenericParams_Usual_params[S, B any] struct { + param1 S + param2 B +} + +// moqGenericParams_Usual_paramsKey holds the map key params of the +// GenericParams type +type moqGenericParams_Usual_paramsKey[S, B any] struct { + params struct{} + hashes struct { + param1 hash.Hash + param2 hash.Hash } +} - r.results.results = append(r.results.results, struct { +// moqGenericParams_Usual_resultsByParams contains the results for a given set +// of parameters for the GenericParams type +type moqGenericParams_Usual_resultsByParams[S, B any] struct { + anyCount int + anyParams uint64 + results map[moqGenericParams_Usual_paramsKey[S, B]]*moqGenericParams_Usual_results[S, B] +} + +// moqGenericParams_Usual_doFn defines the type of function needed when calling +// andDo for the GenericParams type +type moqGenericParams_Usual_doFn[S, B any] func(S, B) + +// moqGenericParams_Usual_doReturnFn defines the type of function needed when +// calling doReturnResults for the GenericParams type +type moqGenericParams_Usual_doReturnFn[S, B any] func(S, B) (string, error) + +// moqGenericParams_Usual_results holds the results of the GenericParams type +type moqGenericParams_Usual_results[S, B any] struct { + params moqGenericParams_Usual_params[S, B] + results []struct { values *struct { - sResult1, sResult2 string - err error + result1 string + result2 error } sequence uint32 - doFn moqUsual_RepeatedIds_doFn - doReturnFn moqUsual_RepeatedIds_doReturnFn - }{sequence: sequence, doReturnFn: fn}) - return r + doFn moqGenericParams_Usual_doFn[S, B] + doReturnFn moqGenericParams_Usual_doReturnFn[S, B] + } + index uint32 + repeat *moq.RepeatVal } -func (r *moqUsual_RepeatedIds_fnRecorder) findResults() { - r.moq.scene.T.Helper() - if r.results != nil { - r.results.repeat.Increment(r.moq.scene.T) - return +// moqGenericParams_Usual_fnRecorder routes recorded function calls to the +// moqGenericParams moq +type moqGenericParams_Usual_fnRecorder[S, B any] struct { + params moqGenericParams_Usual_params[S, B] + anyParams uint64 + sequence bool + results *moqGenericParams_Usual_results[S, B] + moq *moqGenericParams[S, B] +} + +// moqGenericParams_Usual_anyParams isolates the any params functions of the +// GenericParams type +type moqGenericParams_Usual_anyParams[S, B any] struct { + recorder *moqGenericParams_Usual_fnRecorder[S, B] +} + +// newMoqGenericParams creates a new moq of the GenericParams type +func newMoqGenericParams[S, B any](scene *moq.Scene, config *moq.Config) *moqGenericParams[S, B] { + if config == nil { + config = &moq.Config{} } + m := &moqGenericParams[S, B]{ + scene: scene, + config: *config, + moq: &moqGenericParams_mock[S, B]{}, - anyCount := bits.OnesCount64(r.anyParams) - insertAt := -1 - var results *moqUsual_RepeatedIds_resultsByParams - for n, res := range r.moq.resultsByParams_RepeatedIds { - if res.anyParams == r.anyParams { - results = &res + runtime: struct { + parameterIndexing struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + } + }{parameterIndexing: struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + }{ + Usual: struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + }{ + param1: moq.ParamIndexByHash, + param2: moq.ParamIndexByHash, + }, + }}, + } + m.moq.moq = m + + scene.AddMoq(m) + return m +} + +// mock returns the mock implementation of the GenericParams type +func (m *moqGenericParams[S, B]) mock() *moqGenericParams_mock[S, B] { return m.moq } + +func (m *moqGenericParams_mock[S, B]) Usual(param1 S, param2 B) (result1 string, result2 error) { + m.moq.scene.T.Helper() + params := moqGenericParams_Usual_params[S, B]{ + param1: param1, + param2: param2, + } + var results *moqGenericParams_Usual_results[S, B] + for _, resultsByParams := range m.moq.resultsByParams_Usual { + paramsKey := m.moq.paramsKey_Usual(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { break } - if res.anyCount > anyCount { - insertAt = n - } } if results == nil { - results = &moqUsual_RepeatedIds_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_RepeatedIds_paramsKey]*moqUsual_RepeatedIds_results{}, - } - r.moq.resultsByParams_RepeatedIds = append(r.moq.resultsByParams_RepeatedIds, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_RepeatedIds) { - copy(r.moq.resultsByParams_RepeatedIds[insertAt+1:], r.moq.resultsByParams_RepeatedIds[insertAt:0]) - r.moq.resultsByParams_RepeatedIds[insertAt] = *results + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Usual(params)) } + return } - paramsKey := r.moq.paramsKey_RepeatedIds(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_RepeatedIds_results{ - params: r.params, - results: nil, - index: 0, - repeat: &moq.RepeatVal{}, + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Usual(params)) + } + return } - results.results[paramsKey] = r.results + i = results.repeat.ResultCount - 1 } - r.results.repeat.Increment(r.moq.scene.T) -} - -func (r *moqUsual_RepeatedIds_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_RepeatedIds_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") - return nil - } - r.results.repeat.Repeat(r.moq.scene.T, repeaters) - last := r.results.results[len(r.results.results)-1] - for n := 0; n < r.results.repeat.ResultCount-1; n++ { - if r.sequence { - last = struct { - values *struct { - sResult1, sResult2 string - err error - } - sequence uint32 - doFn moqUsual_RepeatedIds_doFn - doReturnFn moqUsual_RepeatedIds_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Usual(params)) } - r.results.results = append(r.results.results, last) } - return r -} - -func (m *moqUsual) prettyParams_RepeatedIds(params moqUsual_RepeatedIds_params) string { - return fmt.Sprintf("RepeatedIds(%#v, %#v, %#v)", params.sParam1, params.sParam2, params.bParam) -} -func (m *moqUsual) paramsKey_RepeatedIds(params moqUsual_RepeatedIds_params, anyParams uint64) moqUsual_RepeatedIds_paramsKey { - m.scene.T.Helper() - var sParam1Used string - var sParam1UsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.RepeatedIds.sParam1 == moq.ParamIndexByValue { - sParam1Used = params.sParam1 - } else { - sParam1UsedHash = hash.DeepHash(params.sParam1) - } + if result.doFn != nil { + result.doFn(param1, param2) } - var sParam2Used string - var sParam2UsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.RepeatedIds.sParam2 == moq.ParamIndexByValue { - sParam2Used = params.sParam2 - } else { - sParam2UsedHash = hash.DeepHash(params.sParam2) - } + + if result.values != nil { + result1 = result.values.result1 + result2 = result.values.result2 } - var bParamUsed bool - var bParamUsedHash hash.Hash - if anyParams&(1<<2) == 0 { - if m.runtime.parameterIndexing.RepeatedIds.bParam == moq.ParamIndexByValue { - bParamUsed = params.bParam - } else { - bParamUsedHash = hash.DeepHash(params.bParam) - } + if result.doReturnFn != nil { + result1, result2 = result.doReturnFn(param1, param2) } - return moqUsual_RepeatedIds_paramsKey{ - params: struct { - sParam1, sParam2 string - bParam bool - }{ - sParam1: sParam1Used, - sParam2: sParam2Used, - bParam: bParamUsed, - }, - hashes: struct { - sParam1, sParam2 hash.Hash - bParam hash.Hash - }{ - sParam1: sParam1UsedHash, - sParam2: sParam2UsedHash, - bParam: bParamUsedHash, - }, + return +} + +// onCall returns the recorder implementation of the GenericParams type +func (m *moqGenericParams[S, B]) onCall() *moqGenericParams_recorder[S, B] { + return &moqGenericParams_recorder[S, B]{ + moq: m, } } -func (m *moqUsual_recorder) Times(sParam string, times bool) *moqUsual_Times_fnRecorder { - return &moqUsual_Times_fnRecorder{ - params: moqUsual_Times_params{ - sParam: sParam, - times: times, +func (m *moqGenericParams_recorder[S, B]) Usual(param1 S, param2 B) *moqGenericParams_Usual_fnRecorder[S, B] { + return &moqGenericParams_Usual_fnRecorder[S, B]{ + params: moqGenericParams_Usual_params[S, B]{ + param1: param1, + param2: param2, }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, } } -func (r *moqUsual_Times_fnRecorder) any() *moqUsual_Times_anyParams { +func (r *moqGenericParams_Usual_fnRecorder[S, B]) any() *moqGenericParams_Usual_anyParams[S, B] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Times(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } - return &moqUsual_Times_anyParams{recorder: r} + return &moqGenericParams_Usual_anyParams[S, B]{recorder: r} } -func (a *moqUsual_Times_anyParams) sParam() *moqUsual_Times_fnRecorder { +func (a *moqGenericParams_Usual_anyParams[S, B]) param1() *moqGenericParams_Usual_fnRecorder[S, B] { a.recorder.anyParams |= 1 << 0 return a.recorder } -func (a *moqUsual_Times_anyParams) times() *moqUsual_Times_fnRecorder { +func (a *moqGenericParams_Usual_anyParams[S, B]) param2() *moqGenericParams_Usual_fnRecorder[S, B] { a.recorder.anyParams |= 1 << 1 return a.recorder } -func (r *moqUsual_Times_fnRecorder) seq() *moqUsual_Times_fnRecorder { +func (r *moqGenericParams_Usual_fnRecorder[S, B]) seq() *moqGenericParams_Usual_fnRecorder[S, B] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Times(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_Times_fnRecorder) noSeq() *moqUsual_Times_fnRecorder { +func (r *moqGenericParams_Usual_fnRecorder[S, B]) noSeq() *moqGenericParams_Usual_fnRecorder[S, B] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Times(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_Times_fnRecorder) returnResults(sResult string, err error) *moqUsual_Times_fnRecorder { +func (r *moqGenericParams_Usual_fnRecorder[S, B]) returnResults(result1 string, result2 error) *moqGenericParams_Usual_fnRecorder[S, B] { r.moq.scene.T.Helper() r.findResults() @@ -8937,26 +13380,26 @@ func (r *moqUsual_Times_fnRecorder) returnResults(sResult string, err error) *mo r.results.results = append(r.results.results, struct { values *struct { - sResult string - err error + result1 string + result2 error } - sequence uint32 - doFn moqUsual_Times_doFn - doReturnFn moqUsual_Times_doReturnFn + sequence uint32 + doFn moqGenericParams_Usual_doFn[S, B] + doReturnFn moqGenericParams_Usual_doReturnFn[S, B] }{ values: &struct { - sResult string - err error + result1 string + result2 error }{ - sResult: sResult, - err: err, + result1: result1, + result2: result2, }, sequence: sequence, }) return r } -func (r *moqUsual_Times_fnRecorder) andDo(fn moqUsual_Times_doFn) *moqUsual_Times_fnRecorder { +func (r *moqGenericParams_Usual_fnRecorder[S, B]) andDo(fn moqGenericParams_Usual_doFn[S, B]) *moqGenericParams_Usual_fnRecorder[S, B] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -8967,7 +13410,7 @@ func (r *moqUsual_Times_fnRecorder) andDo(fn moqUsual_Times_doFn) *moqUsual_Time return r } -func (r *moqUsual_Times_fnRecorder) doReturnResults(fn moqUsual_Times_doReturnFn) *moqUsual_Times_fnRecorder { +func (r *moqGenericParams_Usual_fnRecorder[S, B]) doReturnResults(fn moqGenericParams_Usual_doReturnFn[S, B]) *moqGenericParams_Usual_fnRecorder[S, B] { r.moq.scene.T.Helper() r.findResults() @@ -8978,17 +13421,17 @@ func (r *moqUsual_Times_fnRecorder) doReturnResults(fn moqUsual_Times_doReturnFn r.results.results = append(r.results.results, struct { values *struct { - sResult string - err error + result1 string + result2 error } sequence uint32 - doFn moqUsual_Times_doFn - doReturnFn moqUsual_Times_doReturnFn + doFn moqGenericParams_Usual_doFn[S, B] + doReturnFn moqGenericParams_Usual_doReturnFn[S, B] }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_Times_fnRecorder) findResults() { +func (r *moqGenericParams_Usual_fnRecorder[S, B]) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -8997,8 +13440,8 @@ func (r *moqUsual_Times_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_Times_resultsByParams - for n, res := range r.moq.resultsByParams_Times { + var results *moqGenericParams_Usual_resultsByParams[S, B] + for n, res := range r.moq.resultsByParams_Usual { if res.anyParams == r.anyParams { results = &res break @@ -9008,24 +13451,24 @@ func (r *moqUsual_Times_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_Times_resultsByParams{ + results = &moqGenericParams_Usual_resultsByParams[S, B]{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_Times_paramsKey]*moqUsual_Times_results{}, + results: map[moqGenericParams_Usual_paramsKey[S, B]]*moqGenericParams_Usual_results[S, B]{}, } - r.moq.resultsByParams_Times = append(r.moq.resultsByParams_Times, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Times) { - copy(r.moq.resultsByParams_Times[insertAt+1:], r.moq.resultsByParams_Times[insertAt:0]) - r.moq.resultsByParams_Times[insertAt] = *results + r.moq.resultsByParams_Usual = append(r.moq.resultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Usual) { + copy(r.moq.resultsByParams_Usual[insertAt+1:], r.moq.resultsByParams_Usual[insertAt:0]) + r.moq.resultsByParams_Usual[insertAt] = *results } } - paramsKey := r.moq.paramsKey_Times(r.params, r.anyParams) + paramsKey := r.moq.paramsKey_Usual(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_Times_results{ + r.results = &moqGenericParams_Usual_results[S, B]{ params: r.params, results: nil, index: 0, @@ -9037,7 +13480,7 @@ func (r *moqUsual_Times_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_Times_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_Times_fnRecorder { +func (r *moqGenericParams_Usual_fnRecorder[S, B]) repeat(repeaters ...moq.Repeater) *moqGenericParams_Usual_fnRecorder[S, B] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -9049,12 +13492,12 @@ func (r *moqUsual_Times_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_ if r.sequence { last = struct { values *struct { - sResult string - err error + result1 string + result2 error } sequence uint32 - doFn moqUsual_Times_doFn - doReturnFn moqUsual_Times_doReturnFn + doFn moqGenericParams_Usual_doFn[S, B] + doReturnFn moqGenericParams_Usual_doReturnFn[S, B] }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -9065,425 +13508,310 @@ func (r *moqUsual_Times_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_ return r } -func (m *moqUsual) prettyParams_Times(params moqUsual_Times_params) string { - return fmt.Sprintf("Times(%#v, %#v)", params.sParam, params.times) +func (m *moqGenericParams[S, B]) prettyParams_Usual(params moqGenericParams_Usual_params[S, B]) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.param1, params.param2) } -func (m *moqUsual) paramsKey_Times(params moqUsual_Times_params, anyParams uint64) moqUsual_Times_paramsKey { +func (m *moqGenericParams[S, B]) paramsKey_Usual(params moqGenericParams_Usual_params[S, B], anyParams uint64) moqGenericParams_Usual_paramsKey[S, B] { m.scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash + var param1UsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Times.sParam == moq.ParamIndexByValue { - sParamUsed = params.sParam - } else { - sParamUsedHash = hash.DeepHash(params.sParam) + if m.runtime.parameterIndexing.Usual.param1 == moq.ParamIndexByValue { + m.scene.T.Fatalf("The param1 parameter of the Usual function can't be indexed by value") } + param1UsedHash = hash.DeepHash(params.param1) } - var timesUsed bool - var timesUsedHash hash.Hash + var param2UsedHash hash.Hash if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.Times.times == moq.ParamIndexByValue { - timesUsed = params.times - } else { - timesUsedHash = hash.DeepHash(params.times) + if m.runtime.parameterIndexing.Usual.param2 == moq.ParamIndexByValue { + m.scene.T.Fatalf("The param2 parameter of the Usual function can't be indexed by value") } + param2UsedHash = hash.DeepHash(params.param2) } - return moqUsual_Times_paramsKey{ - params: struct { - sParam string - times bool - }{ - sParam: sParamUsed, - times: timesUsed, - }, + return moqGenericParams_Usual_paramsKey[S, B]{ + params: struct{}{}, hashes: struct { - sParam hash.Hash - times hash.Hash + param1 hash.Hash + param2 hash.Hash }{ - sParam: sParamUsedHash, - times: timesUsedHash, - }, - } -} - -func (m *moqUsual_recorder) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) *moqUsual_DifficultParamNames_fnRecorder { - return &moqUsual_DifficultParamNames_fnRecorder{ - params: moqUsual_DifficultParamNames_params{ - param1: param1, - param2: param2, - param3: param3, - param: param, - param5: param5, - param6: param6, - param7: param7, - param8: param8, - param9: param9, + param1: param1UsedHash, + param2: param2UsedHash, }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, - } -} - -func (r *moqUsual_DifficultParamNames_fnRecorder) any() *moqUsual_DifficultParamNames_anyParams { - r.moq.scene.T.Helper() - if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultParamNames(r.params)) - return nil - } - return &moqUsual_DifficultParamNames_anyParams{recorder: r} -} - -func (a *moqUsual_DifficultParamNames_anyParams) param1() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 0 - return a.recorder -} - -func (a *moqUsual_DifficultParamNames_anyParams) param2() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 1 - return a.recorder -} - -func (a *moqUsual_DifficultParamNames_anyParams) param3() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 2 - return a.recorder -} - -func (a *moqUsual_DifficultParamNames_anyParams) param() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 3 - return a.recorder -} - -func (a *moqUsual_DifficultParamNames_anyParams) param5() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 4 - return a.recorder -} - -func (a *moqUsual_DifficultParamNames_anyParams) param6() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 5 - return a.recorder -} - -func (a *moqUsual_DifficultParamNames_anyParams) param7() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 6 - return a.recorder -} - -func (a *moqUsual_DifficultParamNames_anyParams) param8() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 7 - return a.recorder -} - -func (a *moqUsual_DifficultParamNames_anyParams) param9() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 8 - return a.recorder -} - -func (r *moqUsual_DifficultParamNames_fnRecorder) seq() *moqUsual_DifficultParamNames_fnRecorder { - r.moq.scene.T.Helper() - if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultParamNames(r.params)) - return nil - } - r.sequence = true - return r -} - -func (r *moqUsual_DifficultParamNames_fnRecorder) noSeq() *moqUsual_DifficultParamNames_fnRecorder { - r.moq.scene.T.Helper() - if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultParamNames(r.params)) - return nil - } - r.sequence = false - return r -} - -func (r *moqUsual_DifficultParamNames_fnRecorder) returnResults() *moqUsual_DifficultParamNames_fnRecorder { - r.moq.scene.T.Helper() - r.findResults() - - var sequence uint32 - if r.sequence { - sequence = r.moq.scene.NextRecorderSequence() - } - - r.results.results = append(r.results.results, struct { - values *struct{} - sequence uint32 - doFn moqUsual_DifficultParamNames_doFn - doReturnFn moqUsual_DifficultParamNames_doReturnFn - }{ - values: &struct{}{}, - sequence: sequence, - }) - return r -} - -func (r *moqUsual_DifficultParamNames_fnRecorder) andDo(fn moqUsual_DifficultParamNames_doFn) *moqUsual_DifficultParamNames_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") - return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn - return r } -func (r *moqUsual_DifficultParamNames_fnRecorder) doReturnResults(fn moqUsual_DifficultParamNames_doReturnFn) *moqUsual_DifficultParamNames_fnRecorder { - r.moq.scene.T.Helper() - r.findResults() +// Reset resets the state of the moq +func (m *moqGenericParams[S, B]) Reset() { m.resultsByParams_Usual = nil } - var sequence uint32 - if r.sequence { - sequence = r.moq.scene.NextRecorderSequence() +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqGenericParams[S, B]) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams_Usual { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Usual(results.params)) + } + } } - - r.results.results = append(r.results.results, struct { - values *struct{} - sequence uint32 - doFn moqUsual_DifficultParamNames_doFn - doReturnFn moqUsual_DifficultParamNames_doReturnFn - }{sequence: sequence, doReturnFn: fn}) - return r } -func (r *moqUsual_DifficultParamNames_fnRecorder) findResults() { - r.moq.scene.T.Helper() - if r.results != nil { - r.results.repeat.Increment(r.moq.scene.T) - return - } +// The following type assertion assures that testmoqs.PartialGenericParams is +// mocked completely +var _ testmoqs.PartialGenericParams[any] = (*moqPartialGenericParams_mock[any])(nil) - anyCount := bits.OnesCount64(r.anyParams) - insertAt := -1 - var results *moqUsual_DifficultParamNames_resultsByParams - for n, res := range r.moq.resultsByParams_DifficultParamNames { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqUsual_DifficultParamNames_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_DifficultParamNames_paramsKey]*moqUsual_DifficultParamNames_results{}, - } - r.moq.resultsByParams_DifficultParamNames = append(r.moq.resultsByParams_DifficultParamNames, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_DifficultParamNames) { - copy(r.moq.resultsByParams_DifficultParamNames[insertAt+1:], r.moq.resultsByParams_DifficultParamNames[insertAt:0]) - r.moq.resultsByParams_DifficultParamNames[insertAt] = *results - } - } +// moqPartialGenericParams holds the state of a moq of the PartialGenericParams +// type +type moqPartialGenericParams[S any] struct { + scene *moq.Scene + config moq.Config + moq *moqPartialGenericParams_mock[S] - paramsKey := r.moq.paramsKey_DifficultParamNames(r.params, r.anyParams) + resultsByParams_Usual []moqPartialGenericParams_Usual_resultsByParams[S] - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_DifficultParamNames_results{ - params: r.params, - results: nil, - index: 0, - repeat: &moq.RepeatVal{}, + runtime struct { + parameterIndexing struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } } - results.results[paramsKey] = r.results } + // moqPartialGenericParams_mock isolates the mock interface of the +} - r.results.repeat.Increment(r.moq.scene.T) +// PartialGenericParams type +type moqPartialGenericParams_mock[S any] struct { + moq *moqPartialGenericParams[S] } -func (r *moqUsual_DifficultParamNames_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_DifficultParamNames_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") - return nil +// moqPartialGenericParams_recorder isolates the recorder interface of the +// PartialGenericParams type +type moqPartialGenericParams_recorder[S any] struct { + moq *moqPartialGenericParams[S] +} + +// moqPartialGenericParams_Usual_params holds the params of the +// PartialGenericParams type +type moqPartialGenericParams_Usual_params[S any] struct { + param1 S + param2 bool +} + +// moqPartialGenericParams_Usual_paramsKey holds the map key params of the +// PartialGenericParams type +type moqPartialGenericParams_Usual_paramsKey[S any] struct { + params struct{ param2 bool } + hashes struct { + param1 hash.Hash + param2 hash.Hash } - r.results.repeat.Repeat(r.moq.scene.T, repeaters) - last := r.results.results[len(r.results.results)-1] - for n := 0; n < r.results.repeat.ResultCount-1; n++ { - if r.sequence { - last = struct { - values *struct{} - sequence uint32 - doFn moqUsual_DifficultParamNames_doFn - doReturnFn moqUsual_DifficultParamNames_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } +} + +// moqPartialGenericParams_Usual_resultsByParams contains the results for a +// given set of parameters for the PartialGenericParams type +type moqPartialGenericParams_Usual_resultsByParams[S any] struct { + anyCount int + anyParams uint64 + results map[moqPartialGenericParams_Usual_paramsKey[S]]*moqPartialGenericParams_Usual_results[S] +} + +// moqPartialGenericParams_Usual_doFn defines the type of function needed when +// calling andDo for the PartialGenericParams type +type moqPartialGenericParams_Usual_doFn[S any] func(S, bool) + +// moqPartialGenericParams_Usual_doReturnFn defines the type of function needed +// when calling doReturnResults for the PartialGenericParams type +type moqPartialGenericParams_Usual_doReturnFn[S any] func(S, bool) (string, error) + +// moqPartialGenericParams_Usual_results holds the results of the +// PartialGenericParams type +type moqPartialGenericParams_Usual_results[S any] struct { + params moqPartialGenericParams_Usual_params[S] + results []struct { + values *struct { + result1 string + result2 error } - r.results.results = append(r.results.results, last) + sequence uint32 + doFn moqPartialGenericParams_Usual_doFn[S] + doReturnFn moqPartialGenericParams_Usual_doReturnFn[S] } - return r + index uint32 + repeat *moq.RepeatVal } -func (m *moqUsual) prettyParams_DifficultParamNames(params moqUsual_DifficultParamNames_params) string { - return fmt.Sprintf("DifficultParamNames(%#v, %#v, %#v, %#v, %#v, %#v, %#v, %#v, %#v)", params.param1, params.param2, params.param3, params.param, params.param5, params.param6, params.param7, params.param8, params.param9) +// moqPartialGenericParams_Usual_fnRecorder routes recorded function calls to +// the moqPartialGenericParams moq +type moqPartialGenericParams_Usual_fnRecorder[S any] struct { + params moqPartialGenericParams_Usual_params[S] + anyParams uint64 + sequence bool + results *moqPartialGenericParams_Usual_results[S] + moq *moqPartialGenericParams[S] } -func (m *moqUsual) paramsKey_DifficultParamNames(params moqUsual_DifficultParamNames_params, anyParams uint64) moqUsual_DifficultParamNames_paramsKey { - m.scene.T.Helper() - var param1Used bool - var param1UsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.DifficultParamNames.param1 == moq.ParamIndexByValue { - param1Used = params.param1 - } else { - param1UsedHash = hash.DeepHash(params.param1) - } +// moqPartialGenericParams_Usual_anyParams isolates the any params functions of +// the PartialGenericParams type +type moqPartialGenericParams_Usual_anyParams[S any] struct { + recorder *moqPartialGenericParams_Usual_fnRecorder[S] +} + +// newMoqPartialGenericParams creates a new moq of the PartialGenericParams +// type +func newMoqPartialGenericParams[S any](scene *moq.Scene, config *moq.Config) *moqPartialGenericParams[S] { + if config == nil { + config = &moq.Config{} } - var param2Used bool - var param2UsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.DifficultParamNames.param2 == moq.ParamIndexByValue { - param2Used = params.param2 - } else { - param2UsedHash = hash.DeepHash(params.param2) - } + m := &moqPartialGenericParams[S]{ + scene: scene, + config: *config, + moq: &moqPartialGenericParams_mock[S]{}, + + runtime: struct { + parameterIndexing struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + } + }{parameterIndexing: struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + }{ + Usual: struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + }{ + param1: moq.ParamIndexByHash, + param2: moq.ParamIndexByValue, + }, + }}, } - var param3Used string - var param3UsedHash hash.Hash - if anyParams&(1<<2) == 0 { - if m.runtime.parameterIndexing.DifficultParamNames.param3 == moq.ParamIndexByValue { - param3Used = params.param3 - } else { - param3UsedHash = hash.DeepHash(params.param3) - } + m.moq.moq = m + + scene.AddMoq(m) + return m +} + +// mock returns the mock implementation of the PartialGenericParams type +func (m *moqPartialGenericParams[S]) mock() *moqPartialGenericParams_mock[S] { return m.moq } + +func (m *moqPartialGenericParams_mock[S]) Usual(param1 S, param2 bool) (result1 string, result2 error) { + m.moq.scene.T.Helper() + params := moqPartialGenericParams_Usual_params[S]{ + param1: param1, + param2: param2, } - var paramUsed int - var paramUsedHash hash.Hash - if anyParams&(1<<3) == 0 { - if m.runtime.parameterIndexing.DifficultParamNames.param == moq.ParamIndexByValue { - paramUsed = params.param - } else { - paramUsedHash = hash.DeepHash(params.param) + var results *moqPartialGenericParams_Usual_results[S] + for _, resultsByParams := range m.moq.resultsByParams_Usual { + paramsKey := m.moq.paramsKey_Usual(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break } } - var param5Used int - var param5UsedHash hash.Hash - if anyParams&(1<<4) == 0 { - if m.runtime.parameterIndexing.DifficultParamNames.param5 == moq.ParamIndexByValue { - param5Used = params.param5 - } else { - param5UsedHash = hash.DeepHash(params.param5) + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Usual(params)) } + return } - var param6Used int - var param6UsedHash hash.Hash - if anyParams&(1<<5) == 0 { - if m.runtime.parameterIndexing.DifficultParamNames.param6 == moq.ParamIndexByValue { - param6Used = params.param6 - } else { - param6UsedHash = hash.DeepHash(params.param6) + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Usual(params)) + } + return } + i = results.repeat.ResultCount - 1 } - var param7Used float32 - var param7UsedHash hash.Hash - if anyParams&(1<<6) == 0 { - if m.runtime.parameterIndexing.DifficultParamNames.param7 == moq.ParamIndexByValue { - param7Used = params.param7 - } else { - param7UsedHash = hash.DeepHash(params.param7) + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Usual(params)) } } - var param8Used float32 - var param8UsedHash hash.Hash - if anyParams&(1<<7) == 0 { - if m.runtime.parameterIndexing.DifficultParamNames.param8 == moq.ParamIndexByValue { - param8Used = params.param8 - } else { - param8UsedHash = hash.DeepHash(params.param8) - } + + if result.doFn != nil { + result.doFn(param1, param2) } - var param9Used float32 - var param9UsedHash hash.Hash - if anyParams&(1<<8) == 0 { - if m.runtime.parameterIndexing.DifficultParamNames.param9 == moq.ParamIndexByValue { - param9Used = params.param9 - } else { - param9UsedHash = hash.DeepHash(params.param9) - } + + if result.values != nil { + result1 = result.values.result1 + result2 = result.values.result2 } - return moqUsual_DifficultParamNames_paramsKey{ - params: struct { - param1, param2 bool - param3 string - param, param5, param6 int - param7, param8, param9 float32 - }{ - param1: param1Used, - param2: param2Used, - param3: param3Used, - param: paramUsed, - param5: param5Used, - param6: param6Used, - param7: param7Used, - param8: param8Used, - param9: param9Used, - }, - hashes: struct { - param1, param2 hash.Hash - param3 hash.Hash - param, param5, param6 hash.Hash - param7, param8, param9 hash.Hash - }{ - param1: param1UsedHash, - param2: param2UsedHash, - param3: param3UsedHash, - param: paramUsedHash, - param5: param5UsedHash, - param6: param6UsedHash, - param7: param7UsedHash, - param8: param8UsedHash, - param9: param9UsedHash, - }, + if result.doReturnFn != nil { + result1, result2 = result.doReturnFn(param1, param2) } + return } -func (m *moqUsual_recorder) DifficultResultNames() *moqUsual_DifficultResultNames_fnRecorder { - return &moqUsual_DifficultResultNames_fnRecorder{ - params: moqUsual_DifficultResultNames_params{}, +// onCall returns the recorder implementation of the PartialGenericParams type +func (m *moqPartialGenericParams[S]) onCall() *moqPartialGenericParams_recorder[S] { + return &moqPartialGenericParams_recorder[S]{ + moq: m, + } +} + +func (m *moqPartialGenericParams_recorder[S]) Usual(param1 S, param2 bool) *moqPartialGenericParams_Usual_fnRecorder[S] { + return &moqPartialGenericParams_Usual_fnRecorder[S]{ + params: moqPartialGenericParams_Usual_params[S]{ + param1: param1, + param2: param2, + }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, } } -func (r *moqUsual_DifficultResultNames_fnRecorder) any() *moqUsual_DifficultResultNames_anyParams { +func (r *moqPartialGenericParams_Usual_fnRecorder[S]) any() *moqPartialGenericParams_Usual_anyParams[S] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultResultNames(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } - return &moqUsual_DifficultResultNames_anyParams{recorder: r} + return &moqPartialGenericParams_Usual_anyParams[S]{recorder: r} +} + +func (a *moqPartialGenericParams_Usual_anyParams[S]) param1() *moqPartialGenericParams_Usual_fnRecorder[S] { + a.recorder.anyParams |= 1 << 0 + return a.recorder } -func (r *moqUsual_DifficultResultNames_fnRecorder) seq() *moqUsual_DifficultResultNames_fnRecorder { +func (a *moqPartialGenericParams_Usual_anyParams[S]) param2() *moqPartialGenericParams_Usual_fnRecorder[S] { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (r *moqPartialGenericParams_Usual_fnRecorder[S]) seq() *moqPartialGenericParams_Usual_fnRecorder[S] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultResultNames(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_DifficultResultNames_fnRecorder) noSeq() *moqUsual_DifficultResultNames_fnRecorder { +func (r *moqPartialGenericParams_Usual_fnRecorder[S]) noSeq() *moqPartialGenericParams_Usual_fnRecorder[S] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_DifficultResultNames(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_DifficultResultNames_fnRecorder) returnResults(result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) *moqUsual_DifficultResultNames_fnRecorder { +func (r *moqPartialGenericParams_Usual_fnRecorder[S]) returnResults(result1 string, result2 error) *moqPartialGenericParams_Usual_fnRecorder[S] { r.moq.scene.T.Helper() r.findResults() @@ -9494,37 +13822,26 @@ func (r *moqUsual_DifficultResultNames_fnRecorder) returnResults(result1, result r.results.results = append(r.results.results, struct { values *struct { - result1, result2 string - result3 error - param, result5, result6 int - result7, result8, result9 float32 + result1 string + result2 error } sequence uint32 - doFn moqUsual_DifficultResultNames_doFn - doReturnFn moqUsual_DifficultResultNames_doReturnFn + doFn moqPartialGenericParams_Usual_doFn[S] + doReturnFn moqPartialGenericParams_Usual_doReturnFn[S] }{ values: &struct { - result1, result2 string - result3 error - param, result5, result6 int - result7, result8, result9 float32 + result1 string + result2 error }{ result1: result1, result2: result2, - result3: result3, - param: param, - result5: result5, - result6: result6, - result7: result7, - result8: result8, - result9: result9, }, sequence: sequence, }) return r } -func (r *moqUsual_DifficultResultNames_fnRecorder) andDo(fn moqUsual_DifficultResultNames_doFn) *moqUsual_DifficultResultNames_fnRecorder { +func (r *moqPartialGenericParams_Usual_fnRecorder[S]) andDo(fn moqPartialGenericParams_Usual_doFn[S]) *moqPartialGenericParams_Usual_fnRecorder[S] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -9535,7 +13852,7 @@ func (r *moqUsual_DifficultResultNames_fnRecorder) andDo(fn moqUsual_DifficultRe return r } -func (r *moqUsual_DifficultResultNames_fnRecorder) doReturnResults(fn moqUsual_DifficultResultNames_doReturnFn) *moqUsual_DifficultResultNames_fnRecorder { +func (r *moqPartialGenericParams_Usual_fnRecorder[S]) doReturnResults(fn moqPartialGenericParams_Usual_doReturnFn[S]) *moqPartialGenericParams_Usual_fnRecorder[S] { r.moq.scene.T.Helper() r.findResults() @@ -9546,19 +13863,17 @@ func (r *moqUsual_DifficultResultNames_fnRecorder) doReturnResults(fn moqUsual_D r.results.results = append(r.results.results, struct { values *struct { - result1, result2 string - result3 error - param, result5, result6 int - result7, result8, result9 float32 + result1 string + result2 error } sequence uint32 - doFn moqUsual_DifficultResultNames_doFn - doReturnFn moqUsual_DifficultResultNames_doReturnFn + doFn moqPartialGenericParams_Usual_doFn[S] + doReturnFn moqPartialGenericParams_Usual_doReturnFn[S] }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_DifficultResultNames_fnRecorder) findResults() { +func (r *moqPartialGenericParams_Usual_fnRecorder[S]) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -9567,8 +13882,8 @@ func (r *moqUsual_DifficultResultNames_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_DifficultResultNames_resultsByParams - for n, res := range r.moq.resultsByParams_DifficultResultNames { + var results *moqPartialGenericParams_Usual_resultsByParams[S] + for n, res := range r.moq.resultsByParams_Usual { if res.anyParams == r.anyParams { results = &res break @@ -9578,24 +13893,24 @@ func (r *moqUsual_DifficultResultNames_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_DifficultResultNames_resultsByParams{ + results = &moqPartialGenericParams_Usual_resultsByParams[S]{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_DifficultResultNames_paramsKey]*moqUsual_DifficultResultNames_results{}, + results: map[moqPartialGenericParams_Usual_paramsKey[S]]*moqPartialGenericParams_Usual_results[S]{}, } - r.moq.resultsByParams_DifficultResultNames = append(r.moq.resultsByParams_DifficultResultNames, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_DifficultResultNames) { - copy(r.moq.resultsByParams_DifficultResultNames[insertAt+1:], r.moq.resultsByParams_DifficultResultNames[insertAt:0]) - r.moq.resultsByParams_DifficultResultNames[insertAt] = *results + r.moq.resultsByParams_Usual = append(r.moq.resultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Usual) { + copy(r.moq.resultsByParams_Usual[insertAt+1:], r.moq.resultsByParams_Usual[insertAt:0]) + r.moq.resultsByParams_Usual[insertAt] = *results } } - paramsKey := r.moq.paramsKey_DifficultResultNames(r.params, r.anyParams) + paramsKey := r.moq.paramsKey_Usual(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_DifficultResultNames_results{ + r.results = &moqPartialGenericParams_Usual_results[S]{ params: r.params, results: nil, index: 0, @@ -9607,7 +13922,7 @@ func (r *moqUsual_DifficultResultNames_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_DifficultResultNames_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_DifficultResultNames_fnRecorder { +func (r *moqPartialGenericParams_Usual_fnRecorder[S]) repeat(repeaters ...moq.Repeater) *moqPartialGenericParams_Usual_fnRecorder[S] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -9619,14 +13934,12 @@ func (r *moqUsual_DifficultResultNames_fnRecorder) repeat(repeaters ...moq.Repea if r.sequence { last = struct { values *struct { - result1, result2 string - result3 error - param, result5, result6 int - result7, result8, result9 float32 + result1 string + result2 error } sequence uint32 - doFn moqUsual_DifficultResultNames_doFn - doReturnFn moqUsual_DifficultResultNames_doReturnFn + doFn moqPartialGenericParams_Usual_doFn[S] + doReturnFn moqPartialGenericParams_Usual_doReturnFn[S] }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -9637,63 +13950,313 @@ func (r *moqUsual_DifficultResultNames_fnRecorder) repeat(repeaters ...moq.Repea return r } -func (m *moqUsual) prettyParams_DifficultResultNames(params moqUsual_DifficultResultNames_params) string { - return fmt.Sprintf("DifficultResultNames()") +func (m *moqPartialGenericParams[S]) prettyParams_Usual(params moqPartialGenericParams_Usual_params[S]) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.param1, params.param2) } -func (m *moqUsual) paramsKey_DifficultResultNames(params moqUsual_DifficultResultNames_params, anyParams uint64) moqUsual_DifficultResultNames_paramsKey { +func (m *moqPartialGenericParams[S]) paramsKey_Usual(params moqPartialGenericParams_Usual_params[S], anyParams uint64) moqPartialGenericParams_Usual_paramsKey[S] { m.scene.T.Helper() - return moqUsual_DifficultResultNames_paramsKey{ - params: struct{}{}, - hashes: struct{}{}, + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.Usual.param1 == moq.ParamIndexByValue { + m.scene.T.Fatalf("The param1 parameter of the Usual function can't be indexed by value") + } + param1UsedHash = hash.DeepHash(params.param1) + } + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.Usual.param2 == moq.ParamIndexByValue { + param2Used = params.param2 + } else { + param2UsedHash = hash.DeepHash(params.param2) + } + } + return moqPartialGenericParams_Usual_paramsKey[S]{ + params: struct{ param2 bool }{ + param2: param2Used, + }, + hashes: struct { + param1 hash.Hash + param2 hash.Hash + }{ + param1: param1UsedHash, + param2: param2UsedHash, + }, + } +} + +// Reset resets the state of the moq +func (m *moqPartialGenericParams[S]) Reset() { m.resultsByParams_Usual = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqPartialGenericParams[S]) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams_Usual { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Usual(results.params)) + } + } + } +} + +// The following type assertion assures that testmoqs.GenericResults is mocked +// completely +var _ testmoqs.GenericResults[string, error] = (*moqGenericResults_mock[string, error])(nil) + +// moqGenericResults holds the state of a moq of the GenericResults type +type moqGenericResults[S ~string, E error] struct { + scene *moq.Scene + config moq.Config + moq *moqGenericResults_mock[S, E] + + resultsByParams_Usual []moqGenericResults_Usual_resultsByParams[S, E] + + runtime struct { + parameterIndexing struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + } + } + // moqGenericResults_mock isolates the mock interface of the GenericResults +} + +// type +type moqGenericResults_mock[S ~string, E error] struct { + moq *moqGenericResults[S, E] +} + +// moqGenericResults_recorder isolates the recorder interface of the +// GenericResults type +type moqGenericResults_recorder[S ~string, E error] struct { + moq *moqGenericResults[S, E] +} + +// moqGenericResults_Usual_params holds the params of the GenericResults type +type moqGenericResults_Usual_params[S ~string, E error] struct { + param1 string + param2 bool +} + +// moqGenericResults_Usual_paramsKey holds the map key params of the +// GenericResults type +type moqGenericResults_Usual_paramsKey[S ~string, E error] struct { + params struct { + param1 string + param2 bool + } + hashes struct { + param1 hash.Hash + param2 hash.Hash + } +} + +// moqGenericResults_Usual_resultsByParams contains the results for a given set +// of parameters for the GenericResults type +type moqGenericResults_Usual_resultsByParams[S ~string, E error] struct { + anyCount int + anyParams uint64 + results map[moqGenericResults_Usual_paramsKey[S, E]]*moqGenericResults_Usual_results[S, E] +} + +// moqGenericResults_Usual_doFn defines the type of function needed when +// calling andDo for the GenericResults type +type moqGenericResults_Usual_doFn[S ~string, E error] func(string, bool) + +// moqGenericResults_Usual_doReturnFn defines the type of function needed when +// calling doReturnResults for the GenericResults type +type moqGenericResults_Usual_doReturnFn[S ~string, E error] func(string, bool) (S, E) + +// moqGenericResults_Usual_results holds the results of the GenericResults type +type moqGenericResults_Usual_results[S ~string, E error] struct { + params moqGenericResults_Usual_params[S, E] + results []struct { + values *struct { + result1 S + result2 E + } + sequence uint32 + doFn moqGenericResults_Usual_doFn[S, E] + doReturnFn moqGenericResults_Usual_doReturnFn[S, E] + } + index uint32 + repeat *moq.RepeatVal +} + +// moqGenericResults_Usual_fnRecorder routes recorded function calls to the +// moqGenericResults moq +type moqGenericResults_Usual_fnRecorder[S ~string, E error] struct { + params moqGenericResults_Usual_params[S, E] + anyParams uint64 + sequence bool + results *moqGenericResults_Usual_results[S, E] + moq *moqGenericResults[S, E] +} + +// moqGenericResults_Usual_anyParams isolates the any params functions of the +// GenericResults type +type moqGenericResults_Usual_anyParams[S ~string, E error] struct { + recorder *moqGenericResults_Usual_fnRecorder[S, E] +} + +// newMoqGenericResults creates a new moq of the GenericResults type +func newMoqGenericResults[S ~string, E error](scene *moq.Scene, config *moq.Config) *moqGenericResults[S, E] { + if config == nil { + config = &moq.Config{} + } + m := &moqGenericResults[S, E]{ + scene: scene, + config: *config, + moq: &moqGenericResults_mock[S, E]{}, + + runtime: struct { + parameterIndexing struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + } + }{parameterIndexing: struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + }{ + Usual: struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + }{ + param1: moq.ParamIndexByValue, + param2: moq.ParamIndexByValue, + }, + }}, + } + m.moq.moq = m + + scene.AddMoq(m) + return m +} + +// mock returns the mock implementation of the GenericResults type +func (m *moqGenericResults[S, E]) mock() *moqGenericResults_mock[S, E] { return m.moq } + +func (m *moqGenericResults_mock[S, E]) Usual(param1 string, param2 bool) (result1 S, result2 E) { + m.moq.scene.T.Helper() + params := moqGenericResults_Usual_params[S, E]{ + param1: param1, + param2: param2, + } + var results *moqGenericResults_Usual_results[S, E] + for _, resultsByParams := range m.moq.resultsByParams_Usual { + paramsKey := m.moq.paramsKey_Usual(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Usual(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Usual(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Usual(params)) + } + } + + if result.doFn != nil { + result.doFn(param1, param2) + } + + if result.values != nil { + result1 = result.values.result1 + result2 = result.values.result2 + } + if result.doReturnFn != nil { + result1, result2 = result.doReturnFn(param1, param2) + } + return +} + +// onCall returns the recorder implementation of the GenericResults type +func (m *moqGenericResults[S, E]) onCall() *moqGenericResults_recorder[S, E] { + return &moqGenericResults_recorder[S, E]{ + moq: m, } } -func (m *moqUsual_recorder) PassByReference(p *testmoqs.PassByReferenceParams) *moqUsual_PassByReference_fnRecorder { - return &moqUsual_PassByReference_fnRecorder{ - params: moqUsual_PassByReference_params{ - p: p, +func (m *moqGenericResults_recorder[S, E]) Usual(param1 string, param2 bool) *moqGenericResults_Usual_fnRecorder[S, E] { + return &moqGenericResults_Usual_fnRecorder[S, E]{ + params: moqGenericResults_Usual_params[S, E]{ + param1: param1, + param2: param2, }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, } } -func (r *moqUsual_PassByReference_fnRecorder) any() *moqUsual_PassByReference_anyParams { +func (r *moqGenericResults_Usual_fnRecorder[S, E]) any() *moqGenericResults_Usual_anyParams[S, E] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_PassByReference(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } - return &moqUsual_PassByReference_anyParams{recorder: r} + return &moqGenericResults_Usual_anyParams[S, E]{recorder: r} } -func (a *moqUsual_PassByReference_anyParams) p() *moqUsual_PassByReference_fnRecorder { +func (a *moqGenericResults_Usual_anyParams[S, E]) param1() *moqGenericResults_Usual_fnRecorder[S, E] { a.recorder.anyParams |= 1 << 0 return a.recorder } -func (r *moqUsual_PassByReference_fnRecorder) seq() *moqUsual_PassByReference_fnRecorder { +func (a *moqGenericResults_Usual_anyParams[S, E]) param2() *moqGenericResults_Usual_fnRecorder[S, E] { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (r *moqGenericResults_Usual_fnRecorder[S, E]) seq() *moqGenericResults_Usual_fnRecorder[S, E] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_PassByReference(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_PassByReference_fnRecorder) noSeq() *moqUsual_PassByReference_fnRecorder { +func (r *moqGenericResults_Usual_fnRecorder[S, E]) noSeq() *moqGenericResults_Usual_fnRecorder[S, E] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_PassByReference(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_PassByReference_fnRecorder) returnResults(sResult string, err error) *moqUsual_PassByReference_fnRecorder { +func (r *moqGenericResults_Usual_fnRecorder[S, E]) returnResults(result1 S, result2 E) *moqGenericResults_Usual_fnRecorder[S, E] { r.moq.scene.T.Helper() r.findResults() @@ -9704,26 +14267,26 @@ func (r *moqUsual_PassByReference_fnRecorder) returnResults(sResult string, err r.results.results = append(r.results.results, struct { values *struct { - sResult string - err error + result1 S + result2 E } sequence uint32 - doFn moqUsual_PassByReference_doFn - doReturnFn moqUsual_PassByReference_doReturnFn + doFn moqGenericResults_Usual_doFn[S, E] + doReturnFn moqGenericResults_Usual_doReturnFn[S, E] }{ values: &struct { - sResult string - err error + result1 S + result2 E }{ - sResult: sResult, - err: err, + result1: result1, + result2: result2, }, sequence: sequence, }) return r } -func (r *moqUsual_PassByReference_fnRecorder) andDo(fn moqUsual_PassByReference_doFn) *moqUsual_PassByReference_fnRecorder { +func (r *moqGenericResults_Usual_fnRecorder[S, E]) andDo(fn moqGenericResults_Usual_doFn[S, E]) *moqGenericResults_Usual_fnRecorder[S, E] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -9734,7 +14297,7 @@ func (r *moqUsual_PassByReference_fnRecorder) andDo(fn moqUsual_PassByReference_ return r } -func (r *moqUsual_PassByReference_fnRecorder) doReturnResults(fn moqUsual_PassByReference_doReturnFn) *moqUsual_PassByReference_fnRecorder { +func (r *moqGenericResults_Usual_fnRecorder[S, E]) doReturnResults(fn moqGenericResults_Usual_doReturnFn[S, E]) *moqGenericResults_Usual_fnRecorder[S, E] { r.moq.scene.T.Helper() r.findResults() @@ -9745,17 +14308,17 @@ func (r *moqUsual_PassByReference_fnRecorder) doReturnResults(fn moqUsual_PassBy r.results.results = append(r.results.results, struct { values *struct { - sResult string - err error + result1 S + result2 E } sequence uint32 - doFn moqUsual_PassByReference_doFn - doReturnFn moqUsual_PassByReference_doReturnFn + doFn moqGenericResults_Usual_doFn[S, E] + doReturnFn moqGenericResults_Usual_doReturnFn[S, E] }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_PassByReference_fnRecorder) findResults() { +func (r *moqGenericResults_Usual_fnRecorder[S, E]) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -9764,8 +14327,8 @@ func (r *moqUsual_PassByReference_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_PassByReference_resultsByParams - for n, res := range r.moq.resultsByParams_PassByReference { + var results *moqGenericResults_Usual_resultsByParams[S, E] + for n, res := range r.moq.resultsByParams_Usual { if res.anyParams == r.anyParams { results = &res break @@ -9775,24 +14338,24 @@ func (r *moqUsual_PassByReference_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_PassByReference_resultsByParams{ + results = &moqGenericResults_Usual_resultsByParams[S, E]{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_PassByReference_paramsKey]*moqUsual_PassByReference_results{}, + results: map[moqGenericResults_Usual_paramsKey[S, E]]*moqGenericResults_Usual_results[S, E]{}, } - r.moq.resultsByParams_PassByReference = append(r.moq.resultsByParams_PassByReference, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_PassByReference) { - copy(r.moq.resultsByParams_PassByReference[insertAt+1:], r.moq.resultsByParams_PassByReference[insertAt:0]) - r.moq.resultsByParams_PassByReference[insertAt] = *results + r.moq.resultsByParams_Usual = append(r.moq.resultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Usual) { + copy(r.moq.resultsByParams_Usual[insertAt+1:], r.moq.resultsByParams_Usual[insertAt:0]) + r.moq.resultsByParams_Usual[insertAt] = *results } } - paramsKey := r.moq.paramsKey_PassByReference(r.params, r.anyParams) + paramsKey := r.moq.paramsKey_Usual(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_PassByReference_results{ + r.results = &moqGenericResults_Usual_results[S, E]{ params: r.params, results: nil, index: 0, @@ -9804,7 +14367,7 @@ func (r *moqUsual_PassByReference_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_PassByReference_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByReference_fnRecorder { +func (r *moqGenericResults_Usual_fnRecorder[S, E]) repeat(repeaters ...moq.Repeater) *moqGenericResults_Usual_fnRecorder[S, E] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -9816,12 +14379,12 @@ func (r *moqUsual_PassByReference_fnRecorder) repeat(repeaters ...moq.Repeater) if r.sequence { last = struct { values *struct { - sResult string - err error + result1 S + result2 E } sequence uint32 - doFn moqUsual_PassByReference_doFn - doReturnFn moqUsual_PassByReference_doReturnFn + doFn moqGenericResults_Usual_doFn[S, E] + doReturnFn moqGenericResults_Usual_doReturnFn[S, E] }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -9832,78 +14395,323 @@ func (r *moqUsual_PassByReference_fnRecorder) repeat(repeaters ...moq.Repeater) return r } -func (m *moqUsual) prettyParams_PassByReference(params moqUsual_PassByReference_params) string { - return fmt.Sprintf("PassByReference(%#v)", params.p) +func (m *moqGenericResults[S, E]) prettyParams_Usual(params moqGenericResults_Usual_params[S, E]) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.param1, params.param2) +} + +func (m *moqGenericResults[S, E]) paramsKey_Usual(params moqGenericResults_Usual_params[S, E], anyParams uint64) moqGenericResults_Usual_paramsKey[S, E] { + m.scene.T.Helper() + var param1Used string + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.Usual.param1 == moq.ParamIndexByValue { + param1Used = params.param1 + } else { + param1UsedHash = hash.DeepHash(params.param1) + } + } + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.Usual.param2 == moq.ParamIndexByValue { + param2Used = params.param2 + } else { + param2UsedHash = hash.DeepHash(params.param2) + } + } + return moqGenericResults_Usual_paramsKey[S, E]{ + params: struct { + param1 string + param2 bool + }{ + param1: param1Used, + param2: param2Used, + }, + hashes: struct { + param1 hash.Hash + param2 hash.Hash + }{ + param1: param1UsedHash, + param2: param2UsedHash, + }, + } +} + +// Reset resets the state of the moq +func (m *moqGenericResults[S, E]) Reset() { m.resultsByParams_Usual = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqGenericResults[S, E]) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams_Usual { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Usual(results.params)) + } + } + } +} + +// The following type assertion assures that testmoqs.PartialGenericResults is +// mocked completely +var _ testmoqs.PartialGenericResults[string] = (*moqPartialGenericResults_mock[string])(nil) + +// moqPartialGenericResults holds the state of a moq of the +// PartialGenericResults type +type moqPartialGenericResults[S ~string] struct { + scene *moq.Scene + config moq.Config + moq *moqPartialGenericResults_mock[S] + + resultsByParams_Usual []moqPartialGenericResults_Usual_resultsByParams[S] + + runtime struct { + parameterIndexing struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + } + } + // moqPartialGenericResults_mock isolates the mock interface of the +} + +// PartialGenericResults type +type moqPartialGenericResults_mock[S ~string] struct { + moq *moqPartialGenericResults[S] +} + +// moqPartialGenericResults_recorder isolates the recorder interface of the +// PartialGenericResults type +type moqPartialGenericResults_recorder[S ~string] struct { + moq *moqPartialGenericResults[S] +} + +// moqPartialGenericResults_Usual_params holds the params of the +// PartialGenericResults type +type moqPartialGenericResults_Usual_params[S ~string] struct { + param1 string + param2 bool +} + +// moqPartialGenericResults_Usual_paramsKey holds the map key params of the +// PartialGenericResults type +type moqPartialGenericResults_Usual_paramsKey[S ~string] struct { + params struct { + param1 string + param2 bool + } + hashes struct { + param1 hash.Hash + param2 hash.Hash + } +} + +// moqPartialGenericResults_Usual_resultsByParams contains the results for a +// given set of parameters for the PartialGenericResults type +type moqPartialGenericResults_Usual_resultsByParams[S ~string] struct { + anyCount int + anyParams uint64 + results map[moqPartialGenericResults_Usual_paramsKey[S]]*moqPartialGenericResults_Usual_results[S] +} + +// moqPartialGenericResults_Usual_doFn defines the type of function needed when +// calling andDo for the PartialGenericResults type +type moqPartialGenericResults_Usual_doFn[S ~string] func(string, bool) + +// moqPartialGenericResults_Usual_doReturnFn defines the type of function +// needed when calling doReturnResults for the PartialGenericResults type +type moqPartialGenericResults_Usual_doReturnFn[S ~string] func(string, bool) (S, error) + +// moqPartialGenericResults_Usual_results holds the results of the +// PartialGenericResults type +type moqPartialGenericResults_Usual_results[S ~string] struct { + params moqPartialGenericResults_Usual_params[S] + results []struct { + values *struct { + result1 S + result2 error + } + sequence uint32 + doFn moqPartialGenericResults_Usual_doFn[S] + doReturnFn moqPartialGenericResults_Usual_doReturnFn[S] + } + index uint32 + repeat *moq.RepeatVal +} + +// moqPartialGenericResults_Usual_fnRecorder routes recorded function calls to +// the moqPartialGenericResults moq +type moqPartialGenericResults_Usual_fnRecorder[S ~string] struct { + params moqPartialGenericResults_Usual_params[S] + anyParams uint64 + sequence bool + results *moqPartialGenericResults_Usual_results[S] + moq *moqPartialGenericResults[S] +} + +// moqPartialGenericResults_Usual_anyParams isolates the any params functions +// of the PartialGenericResults type +type moqPartialGenericResults_Usual_anyParams[S ~string] struct { + recorder *moqPartialGenericResults_Usual_fnRecorder[S] +} + +// newMoqPartialGenericResults creates a new moq of the PartialGenericResults +// type +func newMoqPartialGenericResults[S ~string](scene *moq.Scene, config *moq.Config) *moqPartialGenericResults[S] { + if config == nil { + config = &moq.Config{} + } + m := &moqPartialGenericResults[S]{ + scene: scene, + config: *config, + moq: &moqPartialGenericResults_mock[S]{}, + + runtime: struct { + parameterIndexing struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + } + }{parameterIndexing: struct { + Usual struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + } + }{ + Usual: struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing + }{ + param1: moq.ParamIndexByValue, + param2: moq.ParamIndexByValue, + }, + }}, + } + m.moq.moq = m + + scene.AddMoq(m) + return m +} + +// mock returns the mock implementation of the PartialGenericResults type +func (m *moqPartialGenericResults[S]) mock() *moqPartialGenericResults_mock[S] { return m.moq } + +func (m *moqPartialGenericResults_mock[S]) Usual(param1 string, param2 bool) (result1 S, result2 error) { + m.moq.scene.T.Helper() + params := moqPartialGenericResults_Usual_params[S]{ + param1: param1, + param2: param2, + } + var results *moqPartialGenericResults_Usual_results[S] + for _, resultsByParams := range m.moq.resultsByParams_Usual { + paramsKey := m.moq.paramsKey_Usual(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Usual(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Usual(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Usual(params)) + } + } + + if result.doFn != nil { + result.doFn(param1, param2) + } + + if result.values != nil { + result1 = result.values.result1 + result2 = result.values.result2 + } + if result.doReturnFn != nil { + result1, result2 = result.doReturnFn(param1, param2) + } + return } -func (m *moqUsual) paramsKey_PassByReference(params moqUsual_PassByReference_params, anyParams uint64) moqUsual_PassByReference_paramsKey { - m.scene.T.Helper() - var pUsed *testmoqs.PassByReferenceParams - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.PassByReference.p == moq.ParamIndexByValue { - pUsed = params.p - } else { - pUsedHash = hash.DeepHash(params.p) - } - } - return moqUsual_PassByReference_paramsKey{ - params: struct { - p *testmoqs.PassByReferenceParams - }{ - p: pUsed, - }, - hashes: struct{ p hash.Hash }{ - p: pUsedHash, - }, +// onCall returns the recorder implementation of the PartialGenericResults type +func (m *moqPartialGenericResults[S]) onCall() *moqPartialGenericResults_recorder[S] { + return &moqPartialGenericResults_recorder[S]{ + moq: m, } } -func (m *moqUsual_recorder) InterfaceParam(w io.Writer) *moqUsual_InterfaceParam_fnRecorder { - return &moqUsual_InterfaceParam_fnRecorder{ - params: moqUsual_InterfaceParam_params{ - w: w, +func (m *moqPartialGenericResults_recorder[S]) Usual(param1 string, param2 bool) *moqPartialGenericResults_Usual_fnRecorder[S] { + return &moqPartialGenericResults_Usual_fnRecorder[S]{ + params: moqPartialGenericResults_Usual_params[S]{ + param1: param1, + param2: param2, }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, } } -func (r *moqUsual_InterfaceParam_fnRecorder) any() *moqUsual_InterfaceParam_anyParams { +func (r *moqPartialGenericResults_Usual_fnRecorder[S]) any() *moqPartialGenericResults_Usual_anyParams[S] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceParam(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } - return &moqUsual_InterfaceParam_anyParams{recorder: r} + return &moqPartialGenericResults_Usual_anyParams[S]{recorder: r} } -func (a *moqUsual_InterfaceParam_anyParams) w() *moqUsual_InterfaceParam_fnRecorder { +func (a *moqPartialGenericResults_Usual_anyParams[S]) param1() *moqPartialGenericResults_Usual_fnRecorder[S] { a.recorder.anyParams |= 1 << 0 return a.recorder } -func (r *moqUsual_InterfaceParam_fnRecorder) seq() *moqUsual_InterfaceParam_fnRecorder { +func (a *moqPartialGenericResults_Usual_anyParams[S]) param2() *moqPartialGenericResults_Usual_fnRecorder[S] { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (r *moqPartialGenericResults_Usual_fnRecorder[S]) seq() *moqPartialGenericResults_Usual_fnRecorder[S] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceParam(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_InterfaceParam_fnRecorder) noSeq() *moqUsual_InterfaceParam_fnRecorder { +func (r *moqPartialGenericResults_Usual_fnRecorder[S]) noSeq() *moqPartialGenericResults_Usual_fnRecorder[S] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceParam(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_InterfaceParam_fnRecorder) returnResults(sResult string, err error) *moqUsual_InterfaceParam_fnRecorder { +func (r *moqPartialGenericResults_Usual_fnRecorder[S]) returnResults(result1 S, result2 error) *moqPartialGenericResults_Usual_fnRecorder[S] { r.moq.scene.T.Helper() r.findResults() @@ -9914,26 +14722,26 @@ func (r *moqUsual_InterfaceParam_fnRecorder) returnResults(sResult string, err e r.results.results = append(r.results.results, struct { values *struct { - sResult string - err error + result1 S + result2 error } sequence uint32 - doFn moqUsual_InterfaceParam_doFn - doReturnFn moqUsual_InterfaceParam_doReturnFn + doFn moqPartialGenericResults_Usual_doFn[S] + doReturnFn moqPartialGenericResults_Usual_doReturnFn[S] }{ values: &struct { - sResult string - err error + result1 S + result2 error }{ - sResult: sResult, - err: err, + result1: result1, + result2: result2, }, sequence: sequence, }) return r } -func (r *moqUsual_InterfaceParam_fnRecorder) andDo(fn moqUsual_InterfaceParam_doFn) *moqUsual_InterfaceParam_fnRecorder { +func (r *moqPartialGenericResults_Usual_fnRecorder[S]) andDo(fn moqPartialGenericResults_Usual_doFn[S]) *moqPartialGenericResults_Usual_fnRecorder[S] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -9944,7 +14752,7 @@ func (r *moqUsual_InterfaceParam_fnRecorder) andDo(fn moqUsual_InterfaceParam_do return r } -func (r *moqUsual_InterfaceParam_fnRecorder) doReturnResults(fn moqUsual_InterfaceParam_doReturnFn) *moqUsual_InterfaceParam_fnRecorder { +func (r *moqPartialGenericResults_Usual_fnRecorder[S]) doReturnResults(fn moqPartialGenericResults_Usual_doReturnFn[S]) *moqPartialGenericResults_Usual_fnRecorder[S] { r.moq.scene.T.Helper() r.findResults() @@ -9955,17 +14763,17 @@ func (r *moqUsual_InterfaceParam_fnRecorder) doReturnResults(fn moqUsual_Interfa r.results.results = append(r.results.results, struct { values *struct { - sResult string - err error + result1 S + result2 error } sequence uint32 - doFn moqUsual_InterfaceParam_doFn - doReturnFn moqUsual_InterfaceParam_doReturnFn + doFn moqPartialGenericResults_Usual_doFn[S] + doReturnFn moqPartialGenericResults_Usual_doReturnFn[S] }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_InterfaceParam_fnRecorder) findResults() { +func (r *moqPartialGenericResults_Usual_fnRecorder[S]) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -9974,8 +14782,8 @@ func (r *moqUsual_InterfaceParam_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_InterfaceParam_resultsByParams - for n, res := range r.moq.resultsByParams_InterfaceParam { + var results *moqPartialGenericResults_Usual_resultsByParams[S] + for n, res := range r.moq.resultsByParams_Usual { if res.anyParams == r.anyParams { results = &res break @@ -9985,24 +14793,24 @@ func (r *moqUsual_InterfaceParam_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_InterfaceParam_resultsByParams{ + results = &moqPartialGenericResults_Usual_resultsByParams[S]{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_InterfaceParam_paramsKey]*moqUsual_InterfaceParam_results{}, + results: map[moqPartialGenericResults_Usual_paramsKey[S]]*moqPartialGenericResults_Usual_results[S]{}, } - r.moq.resultsByParams_InterfaceParam = append(r.moq.resultsByParams_InterfaceParam, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_InterfaceParam) { - copy(r.moq.resultsByParams_InterfaceParam[insertAt+1:], r.moq.resultsByParams_InterfaceParam[insertAt:0]) - r.moq.resultsByParams_InterfaceParam[insertAt] = *results + r.moq.resultsByParams_Usual = append(r.moq.resultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Usual) { + copy(r.moq.resultsByParams_Usual[insertAt+1:], r.moq.resultsByParams_Usual[insertAt:0]) + r.moq.resultsByParams_Usual[insertAt] = *results } } - paramsKey := r.moq.paramsKey_InterfaceParam(r.params, r.anyParams) + paramsKey := r.moq.paramsKey_Usual(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_InterfaceParam_results{ + r.results = &moqPartialGenericResults_Usual_results[S]{ params: r.params, results: nil, index: 0, @@ -10014,7 +14822,7 @@ func (r *moqUsual_InterfaceParam_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_InterfaceParam_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_InterfaceParam_fnRecorder { +func (r *moqPartialGenericResults_Usual_fnRecorder[S]) repeat(repeaters ...moq.Repeater) *moqPartialGenericResults_Usual_fnRecorder[S] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -10026,12 +14834,12 @@ func (r *moqUsual_InterfaceParam_fnRecorder) repeat(repeaters ...moq.Repeater) * if r.sequence { last = struct { values *struct { - sResult string - err error + result1 S + result2 error } sequence uint32 - doFn moqUsual_InterfaceParam_doFn - doReturnFn moqUsual_InterfaceParam_doReturnFn + doFn moqPartialGenericResults_Usual_doFn[S] + doReturnFn moqPartialGenericResults_Usual_doReturnFn[S] }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -10039,85 +14847,305 @@ func (r *moqUsual_InterfaceParam_fnRecorder) repeat(repeaters ...moq.Repeater) * } r.results.results = append(r.results.results, last) } - return r -} + return r +} + +func (m *moqPartialGenericResults[S]) prettyParams_Usual(params moqPartialGenericResults_Usual_params[S]) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.param1, params.param2) +} + +func (m *moqPartialGenericResults[S]) paramsKey_Usual(params moqPartialGenericResults_Usual_params[S], anyParams uint64) moqPartialGenericResults_Usual_paramsKey[S] { + m.scene.T.Helper() + var param1Used string + var param1UsedHash hash.Hash + if anyParams&(1<<0) == 0 { + if m.runtime.parameterIndexing.Usual.param1 == moq.ParamIndexByValue { + param1Used = params.param1 + } else { + param1UsedHash = hash.DeepHash(params.param1) + } + } + var param2Used bool + var param2UsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.Usual.param2 == moq.ParamIndexByValue { + param2Used = params.param2 + } else { + param2UsedHash = hash.DeepHash(params.param2) + } + } + return moqPartialGenericResults_Usual_paramsKey[S]{ + params: struct { + param1 string + param2 bool + }{ + param1: param1Used, + param2: param2Used, + }, + hashes: struct { + param1 hash.Hash + param2 hash.Hash + }{ + param1: param1UsedHash, + param2: param2UsedHash, + }, + } +} + +// Reset resets the state of the moq +func (m *moqPartialGenericResults[S]) Reset() { m.resultsByParams_Usual = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqPartialGenericResults[S]) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams_Usual { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Usual(results.params)) + } + } + } +} + +// The following type assertion assures that testmoqs.GenericInterfaceParam is +// mocked completely +var _ testmoqs.GenericInterfaceParam[testmoqs.MyWriter] = (*moqGenericInterfaceParam_mock[testmoqs.MyWriter])(nil) + +// moqGenericInterfaceParam holds the state of a moq of the +// GenericInterfaceParam type +type moqGenericInterfaceParam[W testmoqs.MyWriter] struct { + scene *moq.Scene + config moq.Config + moq *moqGenericInterfaceParam_mock[W] + + resultsByParams_Usual []moqGenericInterfaceParam_Usual_resultsByParams[W] + + runtime struct { + parameterIndexing struct { + Usual struct { + w moq.ParamIndexing + } + } + } + // moqGenericInterfaceParam_mock isolates the mock interface of the +} + +// GenericInterfaceParam type +type moqGenericInterfaceParam_mock[W testmoqs.MyWriter] struct { + moq *moqGenericInterfaceParam[W] +} + +// moqGenericInterfaceParam_recorder isolates the recorder interface of the +// GenericInterfaceParam type +type moqGenericInterfaceParam_recorder[W testmoqs.MyWriter] struct { + moq *moqGenericInterfaceParam[W] +} + +// moqGenericInterfaceParam_Usual_params holds the params of the +// GenericInterfaceParam type +type moqGenericInterfaceParam_Usual_params[W testmoqs.MyWriter] struct{ w W } + +// moqGenericInterfaceParam_Usual_paramsKey holds the map key params of the +// GenericInterfaceParam type +type moqGenericInterfaceParam_Usual_paramsKey[W testmoqs.MyWriter] struct { + params struct{} + hashes struct{ w hash.Hash } +} + +// moqGenericInterfaceParam_Usual_resultsByParams contains the results for a +// given set of parameters for the GenericInterfaceParam type +type moqGenericInterfaceParam_Usual_resultsByParams[W testmoqs.MyWriter] struct { + anyCount int + anyParams uint64 + results map[moqGenericInterfaceParam_Usual_paramsKey[W]]*moqGenericInterfaceParam_Usual_results[W] +} + +// moqGenericInterfaceParam_Usual_doFn defines the type of function needed when +// calling andDo for the GenericInterfaceParam type +type moqGenericInterfaceParam_Usual_doFn[W testmoqs.MyWriter] func(w W) + +// moqGenericInterfaceParam_Usual_doReturnFn defines the type of function +// needed when calling doReturnResults for the GenericInterfaceParam type +type moqGenericInterfaceParam_Usual_doReturnFn[W testmoqs.MyWriter] func(w W) (sResult string, err error) + +// moqGenericInterfaceParam_Usual_results holds the results of the +// GenericInterfaceParam type +type moqGenericInterfaceParam_Usual_results[W testmoqs.MyWriter] struct { + params moqGenericInterfaceParam_Usual_params[W] + results []struct { + values *struct { + sResult string + err error + } + sequence uint32 + doFn moqGenericInterfaceParam_Usual_doFn[W] + doReturnFn moqGenericInterfaceParam_Usual_doReturnFn[W] + } + index uint32 + repeat *moq.RepeatVal +} + +// moqGenericInterfaceParam_Usual_fnRecorder routes recorded function calls to +// the moqGenericInterfaceParam moq +type moqGenericInterfaceParam_Usual_fnRecorder[W testmoqs.MyWriter] struct { + params moqGenericInterfaceParam_Usual_params[W] + anyParams uint64 + sequence bool + results *moqGenericInterfaceParam_Usual_results[W] + moq *moqGenericInterfaceParam[W] +} + +// moqGenericInterfaceParam_Usual_anyParams isolates the any params functions +// of the GenericInterfaceParam type +type moqGenericInterfaceParam_Usual_anyParams[W testmoqs.MyWriter] struct { + recorder *moqGenericInterfaceParam_Usual_fnRecorder[W] +} + +// newMoqGenericInterfaceParam creates a new moq of the GenericInterfaceParam +// type +func newMoqGenericInterfaceParam[W testmoqs.MyWriter](scene *moq.Scene, config *moq.Config) *moqGenericInterfaceParam[W] { + if config == nil { + config = &moq.Config{} + } + m := &moqGenericInterfaceParam[W]{ + scene: scene, + config: *config, + moq: &moqGenericInterfaceParam_mock[W]{}, + + runtime: struct { + parameterIndexing struct { + Usual struct { + w moq.ParamIndexing + } + } + }{parameterIndexing: struct { + Usual struct { + w moq.ParamIndexing + } + }{ + Usual: struct { + w moq.ParamIndexing + }{ + w: moq.ParamIndexByHash, + }, + }}, + } + m.moq.moq = m + + scene.AddMoq(m) + return m +} + +// mock returns the mock implementation of the GenericInterfaceParam type +func (m *moqGenericInterfaceParam[W]) mock() *moqGenericInterfaceParam_mock[W] { return m.moq } + +func (m *moqGenericInterfaceParam_mock[W]) Usual(w W) (sResult string, err error) { + m.moq.scene.T.Helper() + params := moqGenericInterfaceParam_Usual_params[W]{ + w: w, + } + var results *moqGenericInterfaceParam_Usual_results[W] + for _, resultsByParams := range m.moq.resultsByParams_Usual { + paramsKey := m.moq.paramsKey_Usual(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Usual(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Usual(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Usual(params)) + } + } + + if result.doFn != nil { + result.doFn(w) + } -func (m *moqUsual) prettyParams_InterfaceParam(params moqUsual_InterfaceParam_params) string { - return fmt.Sprintf("InterfaceParam(%#v)", params.w) + if result.values != nil { + sResult = result.values.sResult + err = result.values.err + } + if result.doReturnFn != nil { + sResult, err = result.doReturnFn(w) + } + return } -func (m *moqUsual) paramsKey_InterfaceParam(params moqUsual_InterfaceParam_params, anyParams uint64) moqUsual_InterfaceParam_paramsKey { - m.scene.T.Helper() - var wUsed io.Writer - var wUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.InterfaceParam.w == moq.ParamIndexByValue { - wUsed = params.w - } else { - wUsedHash = hash.DeepHash(params.w) - } - } - return moqUsual_InterfaceParam_paramsKey{ - params: struct{ w io.Writer }{ - w: wUsed, - }, - hashes: struct{ w hash.Hash }{ - w: wUsedHash, - }, +// onCall returns the recorder implementation of the GenericInterfaceParam type +func (m *moqGenericInterfaceParam[W]) onCall() *moqGenericInterfaceParam_recorder[W] { + return &moqGenericInterfaceParam_recorder[W]{ + moq: m, } } -func (m *moqUsual_recorder) InterfaceResult(sParam string, bParam bool) *moqUsual_InterfaceResult_fnRecorder { - return &moqUsual_InterfaceResult_fnRecorder{ - params: moqUsual_InterfaceResult_params{ - sParam: sParam, - bParam: bParam, +func (m *moqGenericInterfaceParam_recorder[W]) Usual(w W) *moqGenericInterfaceParam_Usual_fnRecorder[W] { + return &moqGenericInterfaceParam_Usual_fnRecorder[W]{ + params: moqGenericInterfaceParam_Usual_params[W]{ + w: w, }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, } } -func (r *moqUsual_InterfaceResult_fnRecorder) any() *moqUsual_InterfaceResult_anyParams { +func (r *moqGenericInterfaceParam_Usual_fnRecorder[W]) any() *moqGenericInterfaceParam_Usual_anyParams[W] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceResult(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } - return &moqUsual_InterfaceResult_anyParams{recorder: r} + return &moqGenericInterfaceParam_Usual_anyParams[W]{recorder: r} } -func (a *moqUsual_InterfaceResult_anyParams) sParam() *moqUsual_InterfaceResult_fnRecorder { +func (a *moqGenericInterfaceParam_Usual_anyParams[W]) w() *moqGenericInterfaceParam_Usual_fnRecorder[W] { a.recorder.anyParams |= 1 << 0 return a.recorder } -func (a *moqUsual_InterfaceResult_anyParams) bParam() *moqUsual_InterfaceResult_fnRecorder { - a.recorder.anyParams |= 1 << 1 - return a.recorder -} - -func (r *moqUsual_InterfaceResult_fnRecorder) seq() *moqUsual_InterfaceResult_fnRecorder { +func (r *moqGenericInterfaceParam_Usual_fnRecorder[W]) seq() *moqGenericInterfaceParam_Usual_fnRecorder[W] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceResult(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_InterfaceResult_fnRecorder) noSeq() *moqUsual_InterfaceResult_fnRecorder { +func (r *moqGenericInterfaceParam_Usual_fnRecorder[W]) noSeq() *moqGenericInterfaceParam_Usual_fnRecorder[W] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_InterfaceResult(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_InterfaceResult_fnRecorder) returnResults(result1 io.Reader) *moqUsual_InterfaceResult_fnRecorder { +func (r *moqGenericInterfaceParam_Usual_fnRecorder[W]) returnResults(sResult string, err error) *moqGenericInterfaceParam_Usual_fnRecorder[W] { r.moq.scene.T.Helper() r.findResults() @@ -10127,20 +15155,27 @@ func (r *moqUsual_InterfaceResult_fnRecorder) returnResults(result1 io.Reader) * } r.results.results = append(r.results.results, struct { - values *struct{ result1 io.Reader } + values *struct { + sResult string + err error + } sequence uint32 - doFn moqUsual_InterfaceResult_doFn - doReturnFn moqUsual_InterfaceResult_doReturnFn + doFn moqGenericInterfaceParam_Usual_doFn[W] + doReturnFn moqGenericInterfaceParam_Usual_doReturnFn[W] }{ - values: &struct{ result1 io.Reader }{ - result1: result1, + values: &struct { + sResult string + err error + }{ + sResult: sResult, + err: err, }, sequence: sequence, }) return r } -func (r *moqUsual_InterfaceResult_fnRecorder) andDo(fn moqUsual_InterfaceResult_doFn) *moqUsual_InterfaceResult_fnRecorder { +func (r *moqGenericInterfaceParam_Usual_fnRecorder[W]) andDo(fn moqGenericInterfaceParam_Usual_doFn[W]) *moqGenericInterfaceParam_Usual_fnRecorder[W] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -10151,7 +15186,7 @@ func (r *moqUsual_InterfaceResult_fnRecorder) andDo(fn moqUsual_InterfaceResult_ return r } -func (r *moqUsual_InterfaceResult_fnRecorder) doReturnResults(fn moqUsual_InterfaceResult_doReturnFn) *moqUsual_InterfaceResult_fnRecorder { +func (r *moqGenericInterfaceParam_Usual_fnRecorder[W]) doReturnResults(fn moqGenericInterfaceParam_Usual_doReturnFn[W]) *moqGenericInterfaceParam_Usual_fnRecorder[W] { r.moq.scene.T.Helper() r.findResults() @@ -10161,15 +15196,18 @@ func (r *moqUsual_InterfaceResult_fnRecorder) doReturnResults(fn moqUsual_Interf } r.results.results = append(r.results.results, struct { - values *struct{ result1 io.Reader } + values *struct { + sResult string + err error + } sequence uint32 - doFn moqUsual_InterfaceResult_doFn - doReturnFn moqUsual_InterfaceResult_doReturnFn + doFn moqGenericInterfaceParam_Usual_doFn[W] + doReturnFn moqGenericInterfaceParam_Usual_doReturnFn[W] }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_InterfaceResult_fnRecorder) findResults() { +func (r *moqGenericInterfaceParam_Usual_fnRecorder[W]) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -10178,8 +15216,8 @@ func (r *moqUsual_InterfaceResult_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_InterfaceResult_resultsByParams - for n, res := range r.moq.resultsByParams_InterfaceResult { + var results *moqGenericInterfaceParam_Usual_resultsByParams[W] + for n, res := range r.moq.resultsByParams_Usual { if res.anyParams == r.anyParams { results = &res break @@ -10189,24 +15227,24 @@ func (r *moqUsual_InterfaceResult_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_InterfaceResult_resultsByParams{ + results = &moqGenericInterfaceParam_Usual_resultsByParams[W]{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_InterfaceResult_paramsKey]*moqUsual_InterfaceResult_results{}, + results: map[moqGenericInterfaceParam_Usual_paramsKey[W]]*moqGenericInterfaceParam_Usual_results[W]{}, } - r.moq.resultsByParams_InterfaceResult = append(r.moq.resultsByParams_InterfaceResult, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_InterfaceResult) { - copy(r.moq.resultsByParams_InterfaceResult[insertAt+1:], r.moq.resultsByParams_InterfaceResult[insertAt:0]) - r.moq.resultsByParams_InterfaceResult[insertAt] = *results + r.moq.resultsByParams_Usual = append(r.moq.resultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Usual) { + copy(r.moq.resultsByParams_Usual[insertAt+1:], r.moq.resultsByParams_Usual[insertAt:0]) + r.moq.resultsByParams_Usual[insertAt] = *results } } - paramsKey := r.moq.paramsKey_InterfaceResult(r.params, r.anyParams) + paramsKey := r.moq.paramsKey_Usual(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_InterfaceResult_results{ + r.results = &moqGenericInterfaceParam_Usual_results[W]{ params: r.params, results: nil, index: 0, @@ -10218,7 +15256,7 @@ func (r *moqUsual_InterfaceResult_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_InterfaceResult_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_InterfaceResult_fnRecorder { +func (r *moqGenericInterfaceParam_Usual_fnRecorder[W]) repeat(repeaters ...moq.Repeater) *moqGenericInterfaceParam_Usual_fnRecorder[W] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -10229,10 +15267,13 @@ func (r *moqUsual_InterfaceResult_fnRecorder) repeat(repeaters ...moq.Repeater) for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{ result1 io.Reader } + values *struct { + sResult string + err error + } sequence uint32 - doFn moqUsual_InterfaceResult_doFn - doReturnFn moqUsual_InterfaceResult_doReturnFn + doFn moqGenericInterfaceParam_Usual_doFn[W] + doReturnFn moqGenericInterfaceParam_Usual_doReturnFn[W] }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -10243,93 +15284,299 @@ func (r *moqUsual_InterfaceResult_fnRecorder) repeat(repeaters ...moq.Repeater) return r } -func (m *moqUsual) prettyParams_InterfaceResult(params moqUsual_InterfaceResult_params) string { - return fmt.Sprintf("InterfaceResult(%#v, %#v)", params.sParam, params.bParam) +func (m *moqGenericInterfaceParam[W]) prettyParams_Usual(params moqGenericInterfaceParam_Usual_params[W]) string { + return fmt.Sprintf("Usual(%#v)", params.w) } -func (m *moqUsual) paramsKey_InterfaceResult(params moqUsual_InterfaceResult_params, anyParams uint64) moqUsual_InterfaceResult_paramsKey { +func (m *moqGenericInterfaceParam[W]) paramsKey_Usual(params moqGenericInterfaceParam_Usual_params[W], anyParams uint64) moqGenericInterfaceParam_Usual_paramsKey[W] { m.scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash + var wUsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.InterfaceResult.sParam == moq.ParamIndexByValue { - sParamUsed = params.sParam - } else { - sParamUsedHash = hash.DeepHash(params.sParam) + if m.runtime.parameterIndexing.Usual.w == moq.ParamIndexByValue { + m.scene.T.Fatalf("The w parameter of the Usual function can't be indexed by value") + } + wUsedHash = hash.DeepHash(params.w) + } + return moqGenericInterfaceParam_Usual_paramsKey[W]{ + params: struct{}{}, + hashes: struct{ w hash.Hash }{ + w: wUsedHash, + }, + } +} + +// Reset resets the state of the moq +func (m *moqGenericInterfaceParam[W]) Reset() { m.resultsByParams_Usual = nil } + +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqGenericInterfaceParam[W]) AssertExpectationsMet() { + m.scene.T.Helper() + for _, res := range m.resultsByParams_Usual { + for _, results := range res.results { + missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) + if missing > 0 { + m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Usual(results.params)) + } + } + } +} + +// The following type assertion assures that testmoqs.GenericInterfaceResult is +// mocked completely +var _ testmoqs.GenericInterfaceResult[testmoqs.MyReader] = (*moqGenericInterfaceResult_mock[testmoqs.MyReader])(nil) + +// moqGenericInterfaceResult holds the state of a moq of the +// GenericInterfaceResult type +type moqGenericInterfaceResult[R testmoqs.MyReader] struct { + scene *moq.Scene + config moq.Config + moq *moqGenericInterfaceResult_mock[R] + + resultsByParams_Usual []moqGenericInterfaceResult_Usual_resultsByParams[R] + + runtime struct { + parameterIndexing struct { + Usual struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + } + } + // moqGenericInterfaceResult_mock isolates the mock interface of the +} + +// GenericInterfaceResult type +type moqGenericInterfaceResult_mock[R testmoqs.MyReader] struct { + moq *moqGenericInterfaceResult[R] +} + +// moqGenericInterfaceResult_recorder isolates the recorder interface of the +// GenericInterfaceResult type +type moqGenericInterfaceResult_recorder[R testmoqs.MyReader] struct { + moq *moqGenericInterfaceResult[R] +} + +// moqGenericInterfaceResult_Usual_params holds the params of the +// GenericInterfaceResult type +type moqGenericInterfaceResult_Usual_params[R testmoqs.MyReader] struct { + sParam string + bParam bool +} + +// moqGenericInterfaceResult_Usual_paramsKey holds the map key params of the +// GenericInterfaceResult type +type moqGenericInterfaceResult_Usual_paramsKey[R testmoqs.MyReader] struct { + params struct { + sParam string + bParam bool + } + hashes struct { + sParam hash.Hash + bParam hash.Hash + } +} + +// moqGenericInterfaceResult_Usual_resultsByParams contains the results for a +// given set of parameters for the GenericInterfaceResult type +type moqGenericInterfaceResult_Usual_resultsByParams[R testmoqs.MyReader] struct { + anyCount int + anyParams uint64 + results map[moqGenericInterfaceResult_Usual_paramsKey[R]]*moqGenericInterfaceResult_Usual_results[R] +} + +// moqGenericInterfaceResult_Usual_doFn defines the type of function needed +// when calling andDo for the GenericInterfaceResult type +type moqGenericInterfaceResult_Usual_doFn[R testmoqs.MyReader] func(sParam string, bParam bool) + +// moqGenericInterfaceResult_Usual_doReturnFn defines the type of function +// needed when calling doReturnResults for the GenericInterfaceResult type +type moqGenericInterfaceResult_Usual_doReturnFn[R testmoqs.MyReader] func(sParam string, bParam bool) (r R) + +// moqGenericInterfaceResult_Usual_results holds the results of the +// GenericInterfaceResult type +type moqGenericInterfaceResult_Usual_results[R testmoqs.MyReader] struct { + params moqGenericInterfaceResult_Usual_params[R] + results []struct { + values *struct{ result1 R } + sequence uint32 + doFn moqGenericInterfaceResult_Usual_doFn[R] + doReturnFn moqGenericInterfaceResult_Usual_doReturnFn[R] + } + index uint32 + repeat *moq.RepeatVal +} + +// moqGenericInterfaceResult_Usual_fnRecorder routes recorded function calls to +// the moqGenericInterfaceResult moq +type moqGenericInterfaceResult_Usual_fnRecorder[R testmoqs.MyReader] struct { + params moqGenericInterfaceResult_Usual_params[R] + anyParams uint64 + sequence bool + results *moqGenericInterfaceResult_Usual_results[R] + moq *moqGenericInterfaceResult[R] +} + +// moqGenericInterfaceResult_Usual_anyParams isolates the any params functions +// of the GenericInterfaceResult type +type moqGenericInterfaceResult_Usual_anyParams[R testmoqs.MyReader] struct { + recorder *moqGenericInterfaceResult_Usual_fnRecorder[R] +} + +// newMoqGenericInterfaceResult creates a new moq of the GenericInterfaceResult +// type +func newMoqGenericInterfaceResult[R testmoqs.MyReader](scene *moq.Scene, config *moq.Config) *moqGenericInterfaceResult[R] { + if config == nil { + config = &moq.Config{} + } + m := &moqGenericInterfaceResult[R]{ + scene: scene, + config: *config, + moq: &moqGenericInterfaceResult_mock[R]{}, + + runtime: struct { + parameterIndexing struct { + Usual struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + } + }{parameterIndexing: struct { + Usual struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + } + }{ + Usual: struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing + }{ + sParam: moq.ParamIndexByValue, + bParam: moq.ParamIndexByValue, + }, + }}, + } + m.moq.moq = m + + scene.AddMoq(m) + return m +} + +// mock returns the mock implementation of the GenericInterfaceResult type +func (m *moqGenericInterfaceResult[R]) mock() *moqGenericInterfaceResult_mock[R] { return m.moq } + +func (m *moqGenericInterfaceResult_mock[R]) Usual(sParam string, bParam bool) (result1 R) { + m.moq.scene.T.Helper() + params := moqGenericInterfaceResult_Usual_params[R]{ + sParam: sParam, + bParam: bParam, + } + var results *moqGenericInterfaceResult_Usual_results[R] + for _, resultsByParams := range m.moq.resultsByParams_Usual { + paramsKey := m.moq.paramsKey_Usual(params, resultsByParams.anyParams) + var ok bool + results, ok = resultsByParams.results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams_Usual(params)) + } + return + } + + i := int(atomic.AddUint32(&results.index, 1)) - 1 + if i >= results.repeat.ResultCount { + if !results.repeat.AnyTimes { + if m.moq.config.Expectation == moq.Strict { + m.moq.scene.T.Fatalf("Too many calls to %s", m.moq.prettyParams_Usual(params)) + } + return + } + i = results.repeat.ResultCount - 1 + } + + result := results.results[i] + if result.sequence != 0 { + sequence := m.moq.scene.NextMockSequence() + if (!results.repeat.AnyTimes && result.sequence != sequence) || result.sequence > sequence { + m.moq.scene.T.Fatalf("Call sequence does not match call to %s", m.moq.prettyParams_Usual(params)) } } - var bParamUsed bool - var bParamUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.InterfaceResult.bParam == moq.ParamIndexByValue { - bParamUsed = params.bParam - } else { - bParamUsedHash = hash.DeepHash(params.bParam) - } + + if result.doFn != nil { + result.doFn(sParam, bParam) } - return moqUsual_InterfaceResult_paramsKey{ - params: struct { - sParam string - bParam bool - }{ - sParam: sParamUsed, - bParam: bParamUsed, - }, - hashes: struct { - sParam hash.Hash - bParam hash.Hash - }{ - sParam: sParamUsedHash, - bParam: bParamUsedHash, - }, + + if result.values != nil { + result1 = result.values.result1 } + if result.doReturnFn != nil { + result1 = result.doReturnFn(sParam, bParam) + } + return } -func (m *moqUsual_recorder) FnParam(fn func()) *moqUsual_FnParam_fnRecorder { - return &moqUsual_FnParam_fnRecorder{ - params: moqUsual_FnParam_params{ - fn: fn, +// onCall returns the recorder implementation of the GenericInterfaceResult +// type +func (m *moqGenericInterfaceResult[R]) onCall() *moqGenericInterfaceResult_recorder[R] { + return &moqGenericInterfaceResult_recorder[R]{ + moq: m, + } +} + +func (m *moqGenericInterfaceResult_recorder[R]) Usual(sParam string, bParam bool) *moqGenericInterfaceResult_Usual_fnRecorder[R] { + return &moqGenericInterfaceResult_Usual_fnRecorder[R]{ + params: moqGenericInterfaceResult_Usual_params[R]{ + sParam: sParam, + bParam: bParam, }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, } } -func (r *moqUsual_FnParam_fnRecorder) any() *moqUsual_FnParam_anyParams { +func (r *moqGenericInterfaceResult_Usual_fnRecorder[R]) any() *moqGenericInterfaceResult_Usual_anyParams[R] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_FnParam(r.params)) + r.moq.scene.T.Fatalf("Any functions must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } - return &moqUsual_FnParam_anyParams{recorder: r} + return &moqGenericInterfaceResult_Usual_anyParams[R]{recorder: r} } -func (a *moqUsual_FnParam_anyParams) fn() *moqUsual_FnParam_fnRecorder { +func (a *moqGenericInterfaceResult_Usual_anyParams[R]) sParam() *moqGenericInterfaceResult_Usual_fnRecorder[R] { a.recorder.anyParams |= 1 << 0 return a.recorder } -func (r *moqUsual_FnParam_fnRecorder) seq() *moqUsual_FnParam_fnRecorder { +func (a *moqGenericInterfaceResult_Usual_anyParams[R]) bParam() *moqGenericInterfaceResult_Usual_fnRecorder[R] { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + +func (r *moqGenericInterfaceResult_Usual_fnRecorder[R]) seq() *moqGenericInterfaceResult_Usual_fnRecorder[R] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_FnParam(r.params)) + r.moq.scene.T.Fatalf("seq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = true return r } -func (r *moqUsual_FnParam_fnRecorder) noSeq() *moqUsual_FnParam_fnRecorder { +func (r *moqGenericInterfaceResult_Usual_fnRecorder[R]) noSeq() *moqGenericInterfaceResult_Usual_fnRecorder[R] { r.moq.scene.T.Helper() if r.results != nil { - r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_FnParam(r.params)) + r.moq.scene.T.Fatalf("noSeq must be called before returnResults or doReturnResults calls, recording %s", r.moq.prettyParams_Usual(r.params)) return nil } r.sequence = false return r } -func (r *moqUsual_FnParam_fnRecorder) returnResults() *moqUsual_FnParam_fnRecorder { +func (r *moqGenericInterfaceResult_Usual_fnRecorder[R]) returnResults(result1 R) *moqGenericInterfaceResult_Usual_fnRecorder[R] { r.moq.scene.T.Helper() r.findResults() @@ -10339,18 +15586,20 @@ func (r *moqUsual_FnParam_fnRecorder) returnResults() *moqUsual_FnParam_fnRecord } r.results.results = append(r.results.results, struct { - values *struct{} + values *struct{ result1 R } sequence uint32 - doFn moqUsual_FnParam_doFn - doReturnFn moqUsual_FnParam_doReturnFn + doFn moqGenericInterfaceResult_Usual_doFn[R] + doReturnFn moqGenericInterfaceResult_Usual_doReturnFn[R] }{ - values: &struct{}{}, + values: &struct{ result1 R }{ + result1: result1, + }, sequence: sequence, }) return r } -func (r *moqUsual_FnParam_fnRecorder) andDo(fn moqUsual_FnParam_doFn) *moqUsual_FnParam_fnRecorder { +func (r *moqGenericInterfaceResult_Usual_fnRecorder[R]) andDo(fn moqGenericInterfaceResult_Usual_doFn[R]) *moqGenericInterfaceResult_Usual_fnRecorder[R] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") @@ -10361,7 +15610,7 @@ func (r *moqUsual_FnParam_fnRecorder) andDo(fn moqUsual_FnParam_doFn) *moqUsual_ return r } -func (r *moqUsual_FnParam_fnRecorder) doReturnResults(fn moqUsual_FnParam_doReturnFn) *moqUsual_FnParam_fnRecorder { +func (r *moqGenericInterfaceResult_Usual_fnRecorder[R]) doReturnResults(fn moqGenericInterfaceResult_Usual_doReturnFn[R]) *moqGenericInterfaceResult_Usual_fnRecorder[R] { r.moq.scene.T.Helper() r.findResults() @@ -10371,15 +15620,15 @@ func (r *moqUsual_FnParam_fnRecorder) doReturnResults(fn moqUsual_FnParam_doRetu } r.results.results = append(r.results.results, struct { - values *struct{} + values *struct{ result1 R } sequence uint32 - doFn moqUsual_FnParam_doFn - doReturnFn moqUsual_FnParam_doReturnFn + doFn moqGenericInterfaceResult_Usual_doFn[R] + doReturnFn moqGenericInterfaceResult_Usual_doReturnFn[R] }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_FnParam_fnRecorder) findResults() { +func (r *moqGenericInterfaceResult_Usual_fnRecorder[R]) findResults() { r.moq.scene.T.Helper() if r.results != nil { r.results.repeat.Increment(r.moq.scene.T) @@ -10388,8 +15637,8 @@ func (r *moqUsual_FnParam_fnRecorder) findResults() { anyCount := bits.OnesCount64(r.anyParams) insertAt := -1 - var results *moqUsual_FnParam_resultsByParams - for n, res := range r.moq.resultsByParams_FnParam { + var results *moqGenericInterfaceResult_Usual_resultsByParams[R] + for n, res := range r.moq.resultsByParams_Usual { if res.anyParams == r.anyParams { results = &res break @@ -10399,24 +15648,24 @@ func (r *moqUsual_FnParam_fnRecorder) findResults() { } } if results == nil { - results = &moqUsual_FnParam_resultsByParams{ + results = &moqGenericInterfaceResult_Usual_resultsByParams[R]{ anyCount: anyCount, anyParams: r.anyParams, - results: map[moqUsual_FnParam_paramsKey]*moqUsual_FnParam_results{}, + results: map[moqGenericInterfaceResult_Usual_paramsKey[R]]*moqGenericInterfaceResult_Usual_results[R]{}, } - r.moq.resultsByParams_FnParam = append(r.moq.resultsByParams_FnParam, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_FnParam) { - copy(r.moq.resultsByParams_FnParam[insertAt+1:], r.moq.resultsByParams_FnParam[insertAt:0]) - r.moq.resultsByParams_FnParam[insertAt] = *results + r.moq.resultsByParams_Usual = append(r.moq.resultsByParams_Usual, *results) + if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Usual) { + copy(r.moq.resultsByParams_Usual[insertAt+1:], r.moq.resultsByParams_Usual[insertAt:0]) + r.moq.resultsByParams_Usual[insertAt] = *results } } - paramsKey := r.moq.paramsKey_FnParam(r.params, r.anyParams) + paramsKey := r.moq.paramsKey_Usual(r.params, r.anyParams) var ok bool r.results, ok = results.results[paramsKey] if !ok { - r.results = &moqUsual_FnParam_results{ + r.results = &moqGenericInterfaceResult_Usual_results[R]{ params: r.params, results: nil, index: 0, @@ -10428,7 +15677,7 @@ func (r *moqUsual_FnParam_fnRecorder) findResults() { r.results.repeat.Increment(r.moq.scene.T) } -func (r *moqUsual_FnParam_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_FnParam_fnRecorder { +func (r *moqGenericInterfaceResult_Usual_fnRecorder[R]) repeat(repeaters ...moq.Repeater) *moqGenericInterfaceResult_Usual_fnRecorder[R] { r.moq.scene.T.Helper() if r.results == nil { r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") @@ -10439,10 +15688,10 @@ func (r *moqUsual_FnParam_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsua for n := 0; n < r.results.repeat.ResultCount-1; n++ { if r.sequence { last = struct { - values *struct{} + values *struct{ result1 R } sequence uint32 - doFn moqUsual_FnParam_doFn - doReturnFn moqUsual_FnParam_doReturnFn + doFn moqGenericInterfaceResult_Usual_doFn[R] + doReturnFn moqGenericInterfaceResult_Usual_doReturnFn[R] }{ values: last.values, sequence: r.moq.scene.NextRecorderSequence(), @@ -10453,47 +15702,53 @@ func (r *moqUsual_FnParam_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsua return r } -func (m *moqUsual) prettyParams_FnParam(params moqUsual_FnParam_params) string { - return fmt.Sprintf("FnParam(%#v)", moq.FnString(params.fn)) +func (m *moqGenericInterfaceResult[R]) prettyParams_Usual(params moqGenericInterfaceResult_Usual_params[R]) string { + return fmt.Sprintf("Usual(%#v, %#v)", params.sParam, params.bParam) } -func (m *moqUsual) paramsKey_FnParam(params moqUsual_FnParam_params, anyParams uint64) moqUsual_FnParam_paramsKey { +func (m *moqGenericInterfaceResult[R]) paramsKey_Usual(params moqGenericInterfaceResult_Usual_params[R], anyParams uint64) moqGenericInterfaceResult_Usual_paramsKey[R] { m.scene.T.Helper() - var fnUsedHash hash.Hash + var sParamUsed string + var sParamUsedHash hash.Hash if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.FnParam.fn == moq.ParamIndexByValue { - m.scene.T.Fatalf("The fn parameter of the FnParam function can't be indexed by value") + if m.runtime.parameterIndexing.Usual.sParam == moq.ParamIndexByValue { + sParamUsed = params.sParam + } else { + sParamUsedHash = hash.DeepHash(params.sParam) } - fnUsedHash = hash.DeepHash(params.fn) } - return moqUsual_FnParam_paramsKey{ - params: struct{}{}, - hashes: struct{ fn hash.Hash }{ - fn: fnUsedHash, + var bParamUsed bool + var bParamUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.Usual.bParam == moq.ParamIndexByValue { + bParamUsed = params.bParam + } else { + bParamUsedHash = hash.DeepHash(params.bParam) + } + } + return moqGenericInterfaceResult_Usual_paramsKey[R]{ + params: struct { + sParam string + bParam bool + }{ + sParam: sParamUsed, + bParam: bParamUsed, + }, + hashes: struct { + sParam hash.Hash + bParam hash.Hash + }{ + sParam: sParamUsedHash, + bParam: bParamUsedHash, }, } } // Reset resets the state of the moq -func (m *moqUsual) Reset() { - m.resultsByParams_Usual = nil - m.resultsByParams_NoNames = nil - m.resultsByParams_NoResults = nil - m.resultsByParams_NoParams = nil - m.resultsByParams_Nothing = nil - m.resultsByParams_Variadic = nil - m.resultsByParams_RepeatedIds = nil - m.resultsByParams_Times = nil - m.resultsByParams_DifficultParamNames = nil - m.resultsByParams_DifficultResultNames = nil - m.resultsByParams_PassByReference = nil - m.resultsByParams_InterfaceParam = nil - m.resultsByParams_InterfaceResult = nil - m.resultsByParams_FnParam = nil -} +func (m *moqGenericInterfaceResult[R]) Reset() { m.resultsByParams_Usual = nil } // AssertExpectationsMet asserts that all expectations have been met -func (m *moqUsual) AssertExpectationsMet() { +func (m *moqGenericInterfaceResult[R]) AssertExpectationsMet() { m.scene.T.Helper() for _, res := range m.resultsByParams_Usual { for _, results := range res.results { @@ -10503,108 +15758,4 @@ func (m *moqUsual) AssertExpectationsMet() { } } } - for _, res := range m.resultsByParams_NoNames { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_NoNames(results.params)) - } - } - } - for _, res := range m.resultsByParams_NoResults { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_NoResults(results.params)) - } - } - } - for _, res := range m.resultsByParams_NoParams { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_NoParams(results.params)) - } - } - } - for _, res := range m.resultsByParams_Nothing { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Nothing(results.params)) - } - } - } - for _, res := range m.resultsByParams_Variadic { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Variadic(results.params)) - } - } - } - for _, res := range m.resultsByParams_RepeatedIds { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_RepeatedIds(results.params)) - } - } - } - for _, res := range m.resultsByParams_Times { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_Times(results.params)) - } - } - } - for _, res := range m.resultsByParams_DifficultParamNames { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_DifficultParamNames(results.params)) - } - } - } - for _, res := range m.resultsByParams_DifficultResultNames { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_DifficultResultNames(results.params)) - } - } - } - for _, res := range m.resultsByParams_PassByReference { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_PassByReference(results.params)) - } - } - } - for _, res := range m.resultsByParams_InterfaceParam { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_InterfaceParam(results.params)) - } - } - } - for _, res := range m.resultsByParams_InterfaceResult { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_InterfaceResult(results.params)) - } - } - } - for _, res := range m.resultsByParams_FnParam { - for _, results := range res.results { - missing := results.repeat.MinTimes - int(atomic.LoadUint32(&results.index)) - if missing > 0 { - m.scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.prettyParams_FnParam(results.params)) - } - } - } } diff --git a/generator/testmoqs/testmoqs_test.go b/generator/testmoqs/testmoqs_test.go index fdaeb5f..00a79ed 100644 --- a/generator/testmoqs/testmoqs_test.go +++ b/generator/testmoqs/testmoqs_test.go @@ -76,6 +76,14 @@ func testCases(t *testing.T, c moq.Config) map[string]adaptor { usualMoq := newMoqUsual(moqScene, &c) exportUsualMoq := exported.NewMoqUsual(moqScene, &c) + genericParamsMoq := newMoqGenericParams[string, bool](moqScene, &c) + exportedGenericParamsMoq := exported.NewMoqGenericParams[string, bool](moqScene, &c) + partialGenericParamsMoq := newMoqPartialGenericParams[string](moqScene, &c) + exportedPartialGenericParamsMoq := exported.NewMoqPartialGenericParams[string](moqScene, &c) + genericResultsMoq := newMoqGenericResults[string, error](moqScene, &c) + exportedGenericResultsMoq := exported.NewMoqGenericResults[string, error](moqScene, &c) + partialGenericResultsMoq := newMoqPartialGenericResults[string](moqScene, &c) + exportedPartialGenericResultsMoq := exported.NewMoqPartialGenericResults[string](moqScene, &c) //nolint:lll // chopped down entries are reverted by gofumpt entries := map[string]adaptor{ "usual fn": &usualFnAdaptor{m: newMoqUsualFn(moqScene, &c)}, @@ -104,6 +112,30 @@ func testCases(t *testing.T, c moq.Config) map[string]adaptor { "exported interface param fn": &exportedInterfaceParamFnAdaptor{m: exported.NewMoqInterfaceParamFn(moqScene, &c)}, "interface result fn": &interfaceResultFnAdaptor{m: newMoqInterfaceResultFn(moqScene, &c)}, "exported interface result param fn": &exportedInterfaceResultFnAdaptor{m: exported.NewMoqInterfaceResultFn(moqScene, &c)}, + "generic params fn": &genericParamsFnAdaptor[string, bool]{ + m: newMoqGenericParamsFn[string, bool](moqScene, &c), + }, + "exported generic params fn": &exportedGenericParamsFnAdaptor[string, bool]{ + m: exported.NewMoqGenericParamsFn[string, bool](moqScene, &c), + }, + "partial generic params fn": &partialGenericParamsFnAdaptor[string]{ + m: newMoqPartialGenericParamsFn[string](moqScene, &c), + }, + "exported partial generic params fn": &exportedPartialGenericParamsFnAdaptor[string]{ + m: exported.NewMoqPartialGenericParamsFn[string](moqScene, &c), + }, + "generic results fn": &genericResultsFnAdaptor[string, error]{ + m: newMoqGenericResultsFn[string, error](moqScene, &c), + }, + "exported generic results fn": &exportedGenericResultsFnAdaptor[string, error]{ + m: exported.NewMoqGenericResultsFn[string, error](moqScene, &c), + }, + "partial generic results fn": &partialGenericResultsFnAdaptor[string]{ + m: newMoqPartialGenericResultsFn[string](moqScene, &c), + }, + "partial exported generic results fn": &exportedPartialGenericResultsFnAdaptor[string]{ + m: exported.NewMoqPartialGenericResultsFn[string](moqScene, &c), + }, "usual": &usualAdaptor{m: usualMoq}, "exported usual": &exportedUsualAdaptor{m: exportUsualMoq}, @@ -131,6 +163,20 @@ func testCases(t *testing.T, c moq.Config) map[string]adaptor { "exported interface param": &exportedInterfaceParamAdaptor{m: exportUsualMoq}, "interface result": &interfaceResultAdaptor{m: usualMoq}, "exported interface result param": &exportedInterfaceResultAdaptor{m: exportUsualMoq}, + "generic params": &genericParamsAdaptor[string, bool]{m: genericParamsMoq}, + "exported generic params": &exportedGenericParamsAdaptor[string, bool]{m: exportedGenericParamsMoq}, + "partial generic params": &partialGenericParamsAdaptor[string]{m: partialGenericParamsMoq}, + "partial exported generic params": &exportedPartialGenericParamsAdaptor[string]{ + m: exportedPartialGenericParamsMoq, + }, + "generic results": &genericResultsAdaptor[string, error]{m: genericResultsMoq}, + "exported generic results": &exportedGenericResultsAdaptor[string, error]{ + m: exportedGenericResultsMoq, + }, + "partial generic results": &partialGenericResultsAdaptor[string]{m: partialGenericResultsMoq}, + "exported partial generic results": &exportedPartialGenericResultsAdaptor[string]{ + m: exportedPartialGenericResultsMoq, + }, } return entries diff --git a/generator/testmoqs/types.go b/generator/testmoqs/types.go index e51f44e..2f5ecae 100644 --- a/generator/testmoqs/types.go +++ b/generator/testmoqs/types.go @@ -4,10 +4,12 @@ package testmoqs import "io" +// TODO: Need to have a full copy of this file in a test package? + // NB: Keep in sync with ../generator_test.go TestGenerating -//go:generate moqueries --destination moq_testmoqs_test.go UsualFn NoNamesFn NoResultsFn NoParamsFn NothingFn VariadicFn RepeatedIdsFn TimesFn DifficultParamNamesFn DifficultResultNamesFn PassByReferenceFn InterfaceParamFn InterfaceResultFn Usual -//go:generate moqueries --destination exported/moq_exported_testmoqs.go --export UsualFn NoNamesFn NoResultsFn NoParamsFn NothingFn VariadicFn RepeatedIdsFn TimesFn DifficultParamNamesFn DifficultResultNamesFn PassByReferenceFn InterfaceParamFn InterfaceResultFn Usual +//go:generate moqueries --destination moq_testmoqs_test.go UsualFn NoNamesFn NoResultsFn NoParamsFn NothingFn VariadicFn RepeatedIdsFn TimesFn DifficultParamNamesFn DifficultResultNamesFn PassByReferenceFn InterfaceParamFn InterfaceResultFn GenericParamsFn PartialGenericParamsFn GenericResultsFn PartialGenericResultsFn GenericInterfaceParamFn GenericInterfaceResultFn Usual GenericParams PartialGenericParams GenericResults PartialGenericResults GenericInterfaceParam GenericInterfaceResult +//go:generate moqueries --destination exported/moq_exported_testmoqs.go --export UsualFn NoNamesFn NoResultsFn NoParamsFn NothingFn VariadicFn RepeatedIdsFn TimesFn DifficultParamNamesFn DifficultResultNamesFn PassByReferenceFn InterfaceParamFn InterfaceResultFn GenericParamsFn PartialGenericParamsFn GenericResultsFn PartialGenericResultsFn GenericInterfaceParamFn GenericInterfaceResultFn Usual GenericParams PartialGenericParams GenericResults PartialGenericResults GenericInterfaceParam GenericInterfaceResult // UsualFn is a typical function type type UsualFn func(sParam string, bParam bool) (sResult string, err error) @@ -69,13 +71,35 @@ type InterfaceResultReader struct { Err error } -func (r *InterfaceResultReader) Read(p []byte) (int, error) { +func (r *InterfaceResultReader) Read([]byte) (int, error) { return 0, nil } // InterfaceResultFn tests returning interface results type InterfaceResultFn func(sParam string, bParam bool) (r io.Reader) +// GenericParamsFn has all generic parameters +type GenericParamsFn[S, B any] func(S, B) (string, error) + +// PartialGenericParamsFn has some generic parameters +type PartialGenericParamsFn[S any] func(S, bool) (string, error) + +// GenericResultsFn has all generic results +type GenericResultsFn[S ~string, E error] func(string, bool) (S, E) + +// PartialGenericResultsFn has some generic results +type PartialGenericResultsFn[S ~string] func(string, bool) (S, error) + +type MyWriter io.Writer + +// GenericInterfaceParamFn tests passing generic interface parameters +type GenericInterfaceParamFn[W MyWriter] func(w W) (sResult string, err error) + +type MyReader io.Reader + +// GenericInterfaceResultFn tests returning generic interface results +type GenericInterfaceResultFn[R MyReader] func(sParam string, bParam bool) (r R) + // Usual combines all the above function types into an interface // //nolint:interfacebloat // Test interface with one of every method type @@ -95,3 +119,27 @@ type Usual interface { InterfaceResult(sParam string, bParam bool) (r io.Reader) FnParam(fn func()) } + +type GenericParams[S, B any] interface { + Usual(S, B) (string, error) +} + +type PartialGenericParams[S any] interface { + Usual(S, bool) (string, error) +} + +type GenericResults[S ~string, E error] interface { + Usual(string, bool) (S, E) +} + +type PartialGenericResults[S ~string] interface { + Usual(string, bool) (S, error) +} + +type GenericInterfaceParam[W MyWriter] interface { + Usual(w W) (sResult string, err error) +} + +type GenericInterfaceResult[R MyReader] interface { + Usual(sParam string, bParam bool) (r R) +} diff --git a/generator/testmoqs/usualadaptors_test.go b/generator/testmoqs/usualadaptors_test.go index 67306ab..2451d80 100644 --- a/generator/testmoqs/usualadaptors_test.go +++ b/generator/testmoqs/usualadaptors_test.go @@ -2524,3 +2524,837 @@ func (r *exportedInterfaceResultRecorder) repeat(repeaters ...moq.Repeater) { func (r *exportedInterfaceResultRecorder) isNil() bool { return r.r == nil } + +type genericParamsAdaptor[S, B any] struct { + //nolint:structcheck // definitely used + m *moqGenericParams[S, B] +} + +func (a *genericParamsAdaptor[S, B]) config() adaptorConfig { return adaptorConfig{} } + +func (a *genericParamsAdaptor[S, B]) mock() interface{} { return a.m.mock() } + +func (a *genericParamsAdaptor[S, B]) newRecorder(sParams []S, bParam B) recorder { + return &genericParamsRecorder[S, B]{r: a.m.onCall().Usual(sParams[0], bParam)} +} + +func (a *genericParamsAdaptor[S, B]) invokeMockAndExpectResults(t moq.T, sParams []S, bParam B, res results) { + sResult, err := a.m.mock().Usual(sParams[0], bParam) + if sResult != res.sResults[0] { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if err != res.err { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *genericParamsAdaptor[S, B]) prettyParams(sParams []S, bParam B) string { + return fmt.Sprintf("Usual(%#v, %#v)", sParams[0], bParam) +} + +func (a *genericParamsAdaptor[S, B]) sceneMoq() moq.Moq { + return a.m +} + +type genericParamsRecorder[S, B any] struct { + //nolint:structcheck // definitely used + r *moqGenericParams_Usual_fnRecorder[S, B] +} + +func (r *genericParamsRecorder[S, B]) anySParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param1() + } +} + +func (r *genericParamsRecorder[S, B]) anyBParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param2() + } +} + +func (r *genericParamsRecorder[S, B]) seq() { + r.r = r.r.seq() +} + +func (r *genericParamsRecorder[S, B]) noSeq() { + r.r = r.r.noSeq() +} + +func (r *genericParamsRecorder[S, B]) returnResults(sResults []string, err error) { + r.r = r.r.returnResults(sResults[0], err) +} + +func (r *genericParamsRecorder[S, B]) andDo(t moq.T, fn func(), expectedSParams []string, expectedBParam bool) { + r.r = r.r.andDo(func(sParam S, bParam B) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if !reflect.DeepEqual(bParam, expectedBParam) { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *genericParamsRecorder[S, B]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.doReturnResults(func(sParam S, bParam B) (string, error) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if !reflect.DeepEqual(bParam, expectedBParam) { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return sResults[0], err + }) +} + +func (r *genericParamsRecorder[S, B]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.repeat(repeaters...) +} + +func (r *genericParamsRecorder[S, B]) isNil() bool { + return r.r == nil +} + +type exportedGenericParamsAdaptor[S, B any] struct { + //nolint:structcheck // definitely used + m *exported.MoqGenericParams[S, B] +} + +func (a *exportedGenericParamsAdaptor[S, B]) config() adaptorConfig { + return adaptorConfig{exported: true} +} + +func (a *exportedGenericParamsAdaptor[S, B]) mock() interface{} { return a.m.Mock() } + +func (a *exportedGenericParamsAdaptor[S, B]) newRecorder(sParams []S, bParam B) recorder { + return &exportedGenericParamsRecorder[S, B]{r: a.m.OnCall().Usual(sParams[0], bParam)} +} + +func (a *exportedGenericParamsAdaptor[S, B]) invokeMockAndExpectResults(t moq.T, sParams []S, bParam B, res results) { + sResult, err := a.m.Mock().Usual(sParams[0], bParam) + if sResult != res.sResults[0] { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if err != res.err { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *exportedGenericParamsAdaptor[S, B]) prettyParams(sParams []S, bParam B) string { + return fmt.Sprintf("Usual(%#v, %#v)", sParams[0], bParam) +} + +func (a *exportedGenericParamsAdaptor[S, B]) sceneMoq() moq.Moq { + return a.m +} + +type exportedGenericParamsRecorder[S, B any] struct { + //nolint:structcheck // definitely used + r *exported.MoqGenericParams_Usual_fnRecorder[S, B] +} + +func (r *exportedGenericParamsRecorder[S, B]) anySParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param1() + } +} + +func (r *exportedGenericParamsRecorder[S, B]) anyBParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param2() + } +} + +func (r *exportedGenericParamsRecorder[S, B]) seq() { + r.r = r.r.Seq() +} + +func (r *exportedGenericParamsRecorder[S, B]) noSeq() { + r.r = r.r.NoSeq() +} + +func (r *exportedGenericParamsRecorder[S, B]) returnResults(sResults []string, err error) { + r.r = r.r.ReturnResults(sResults[0], err) +} + +func (r *exportedGenericParamsRecorder[S, B]) andDo( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, +) { + r.r = r.r.AndDo(func(sParam S, bParam B) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if !reflect.DeepEqual(bParam, expectedBParam) { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *exportedGenericParamsRecorder[S, B]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.DoReturnResults(func(sParam S, bParam B) (string, error) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if !reflect.DeepEqual(bParam, expectedBParam) { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return sResults[0], err + }) +} + +func (r *exportedGenericParamsRecorder[S, B]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.Repeat(repeaters...) +} + +func (r *exportedGenericParamsRecorder[S, B]) isNil() bool { + return r.r == nil +} + +type partialGenericParamsAdaptor[S any] struct { + //nolint:structcheck // definitely used + m *moqPartialGenericParams[S] +} + +func (a *partialGenericParamsAdaptor[S]) config() adaptorConfig { return adaptorConfig{} } + +func (a *partialGenericParamsAdaptor[S]) mock() interface{} { return a.m.mock() } + +func (a *partialGenericParamsAdaptor[S]) newRecorder(sParams []S, bParam bool) recorder { + return &partialGenericParamsRecorder[S]{r: a.m.onCall().Usual(sParams[0], bParam)} +} + +func (a *partialGenericParamsAdaptor[S]) invokeMockAndExpectResults(t moq.T, sParams []S, bParam bool, res results) { + sResult, err := a.m.mock().Usual(sParams[0], bParam) + if sResult != res.sResults[0] { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if err != res.err { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *partialGenericParamsAdaptor[S]) prettyParams(sParams []S, bParam bool) string { + return fmt.Sprintf("Usual(%#v, %#v)", sParams[0], bParam) +} + +func (a *partialGenericParamsAdaptor[S]) sceneMoq() moq.Moq { + return a.m +} + +type partialGenericParamsRecorder[S any] struct { + //nolint:structcheck // definitely used + r *moqPartialGenericParams_Usual_fnRecorder[S] +} + +func (r *partialGenericParamsRecorder[S]) anySParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param1() + } +} + +func (r *partialGenericParamsRecorder[S]) anyBParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param2() + } +} + +func (r *partialGenericParamsRecorder[S]) seq() { + r.r = r.r.seq() +} + +func (r *partialGenericParamsRecorder[S]) noSeq() { + r.r = r.r.noSeq() +} + +func (r *partialGenericParamsRecorder[S]) returnResults(sResults []string, err error) { + r.r = r.r.returnResults(sResults[0], err) +} + +func (r *partialGenericParamsRecorder[S]) andDo(t moq.T, fn func(), expectedSParams []string, expectedBParam bool) { + r.r = r.r.andDo(func(sParam S, bParam bool) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *partialGenericParamsRecorder[S]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.doReturnResults(func(sParam S, bParam bool) (string, error) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return sResults[0], err + }) +} + +func (r *partialGenericParamsRecorder[S]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.repeat(repeaters...) +} + +func (r *partialGenericParamsRecorder[S]) isNil() bool { + return r.r == nil +} + +type exportedPartialGenericParamsAdaptor[S any] struct { + //nolint:structcheck // definitely used + m *exported.MoqPartialGenericParams[S] +} + +func (a *exportedPartialGenericParamsAdaptor[S]) config() adaptorConfig { + return adaptorConfig{exported: true} +} + +func (a *exportedPartialGenericParamsAdaptor[S]) mock() interface{} { return a.m.Mock() } + +func (a *exportedPartialGenericParamsAdaptor[S]) newRecorder(sParams []S, bParam bool) recorder { + return &exportedPartialGenericParamsRecorder[S]{r: a.m.OnCall().Usual(sParams[0], bParam)} +} + +func (a *exportedPartialGenericParamsAdaptor[S]) invokeMockAndExpectResults( + t moq.T, sParams []S, bParam bool, res results, +) { + sResult, err := a.m.Mock().Usual(sParams[0], bParam) + if sResult != res.sResults[0] { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if err != res.err { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *exportedPartialGenericParamsAdaptor[S]) prettyParams(sParams []S, bParam bool) string { + return fmt.Sprintf("Usual(%#v, %#v)", sParams[0], bParam) +} + +func (a *exportedPartialGenericParamsAdaptor[S]) sceneMoq() moq.Moq { + return a.m +} + +type exportedPartialGenericParamsRecorder[S any] struct { + //nolint:structcheck // definitely used + r *exported.MoqPartialGenericParams_Usual_fnRecorder[S] +} + +func (r *exportedPartialGenericParamsRecorder[S]) anySParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param1() + } +} + +func (r *exportedPartialGenericParamsRecorder[S]) anyBParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param2() + } +} + +func (r *exportedPartialGenericParamsRecorder[S]) seq() { + r.r = r.r.Seq() +} + +func (r *exportedPartialGenericParamsRecorder[S]) noSeq() { + r.r = r.r.NoSeq() +} + +func (r *exportedPartialGenericParamsRecorder[S]) returnResults(sResults []string, err error) { + r.r = r.r.ReturnResults(sResults[0], err) +} + +func (r *exportedPartialGenericParamsRecorder[S]) andDo( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, +) { + r.r = r.r.AndDo(func(sParam S, bParam bool) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *exportedPartialGenericParamsRecorder[S]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.DoReturnResults(func(sParam S, bParam bool) (string, error) { + fn() + if !reflect.DeepEqual(sParam, expectedSParams[0]) { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if !reflect.DeepEqual(bParam, expectedBParam) { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return sResults[0], err + }) +} + +func (r *exportedPartialGenericParamsRecorder[S]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.Repeat(repeaters...) +} + +func (r *exportedPartialGenericParamsRecorder[S]) isNil() bool { + return r.r == nil +} + +type genericResultsAdaptor[S ~string, E error] struct { + //nolint:structcheck // definitely used + m *moqGenericResults[S, E] +} + +func (a *genericResultsAdaptor[S, E]) config() adaptorConfig { return adaptorConfig{} } + +func (a *genericResultsAdaptor[S, E]) mock() interface{} { return a.m.mock() } + +func (a *genericResultsAdaptor[S, E]) newRecorder(sParams []string, bParam bool) recorder { + return &genericResultsRecorder[S, E]{r: a.m.onCall().Usual(sParams[0], bParam)} +} + +func (a *genericResultsAdaptor[S, E]) invokeMockAndExpectResults( + t moq.T, sParams []string, bParam bool, res results, +) { + sResult, err := a.m.mock().Usual(sParams[0], bParam) + if !reflect.DeepEqual(sResult, res.sResults[0]) { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if !reflect.DeepEqual(err, res.err) { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *genericResultsAdaptor[S, E]) prettyParams(sParams []string, bParam bool) string { + return fmt.Sprintf("Usual(%#v, %#v)", sParams[0], bParam) +} + +func (a *genericResultsAdaptor[S, E]) sceneMoq() moq.Moq { + return a.m +} + +type genericResultsRecorder[S ~string, E error] struct { + //nolint:structcheck // definitely used + r *moqGenericResults_Usual_fnRecorder[S, E] +} + +func (r *genericResultsRecorder[S, E]) anySParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param1() + } +} + +func (r *genericResultsRecorder[S, E]) anyBParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param2() + } +} + +func (r *genericResultsRecorder[S, E]) seq() { + r.r = r.r.seq() +} + +func (r *genericResultsRecorder[S, E]) noSeq() { + r.r = r.r.noSeq() +} + +func (r *genericResultsRecorder[S, E]) returnResults(sResults []string, err error) { + var e E + if err != nil { + e = err.(E) + } + r.r = r.r.returnResults(S(sResults[0]), e) +} + +func (r *genericResultsRecorder[S, E]) andDo(t moq.T, fn func(), expectedSParams []string, expectedBParam bool) { + r.r = r.r.andDo(func(sParam string, bParam bool) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *genericResultsRecorder[S, E]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.doReturnResults(func(sParam string, bParam bool) (S, E) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + var e E + if err != nil { + e = err.(E) + } + return S(sResults[0]), e + }) +} + +func (r *genericResultsRecorder[S, E]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.repeat(repeaters...) +} + +func (r *genericResultsRecorder[S, E]) isNil() bool { + return r.r == nil +} + +type exportedGenericResultsAdaptor[S ~string, E error] struct { + //nolint:structcheck // definitely used + m *exported.MoqGenericResults[S, E] +} + +func (a *exportedGenericResultsAdaptor[S, E]) config() adaptorConfig { + return adaptorConfig{exported: true} +} + +func (a *exportedGenericResultsAdaptor[S, E]) mock() interface{} { return a.m.Mock() } + +func (a *exportedGenericResultsAdaptor[S, E]) newRecorder(sParams []string, bParam bool) recorder { + return &exportedGenericResultsRecorder[S, E]{r: a.m.OnCall().Usual(sParams[0], bParam)} +} + +func (a *exportedGenericResultsAdaptor[S, E]) invokeMockAndExpectResults( + t moq.T, sParams []string, bParam bool, res results, +) { + sResult, err := a.m.Mock().Usual(sParams[0], bParam) + if !reflect.DeepEqual(sResult, res.sResults[0]) { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if !reflect.DeepEqual(err, res.err) { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *exportedGenericResultsAdaptor[S, E]) prettyParams(sParams []string, bParam bool) string { + return fmt.Sprintf("Usual(%#v, %#v)", sParams[0], bParam) +} + +func (a *exportedGenericResultsAdaptor[S, E]) sceneMoq() moq.Moq { + return a.m +} + +type exportedGenericResultsRecorder[S ~string, E error] struct { + //nolint:structcheck // definitely used + r *exported.MoqGenericResults_Usual_fnRecorder[S, E] +} + +func (r *exportedGenericResultsRecorder[S, E]) anySParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param1() + } +} + +func (r *exportedGenericResultsRecorder[S, E]) anyBParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param2() + } +} + +func (r *exportedGenericResultsRecorder[S, E]) seq() { + r.r = r.r.Seq() +} + +func (r *exportedGenericResultsRecorder[S, E]) noSeq() { + r.r = r.r.NoSeq() +} + +func (r *exportedGenericResultsRecorder[S, E]) returnResults(sResults []string, err error) { + var e E + if err != nil { + e = err.(E) + } + r.r = r.r.ReturnResults(S(sResults[0]), e) +} + +func (r *exportedGenericResultsRecorder[S, E]) andDo( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, +) { + r.r = r.r.AndDo(func(sParam string, bParam bool) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *exportedGenericResultsRecorder[S, E]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.DoReturnResults(func(sParam string, bParam bool) (S, E) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + var e E + if err != nil { + e = err.(E) + } + return S(sResults[0]), e + }) +} + +func (r *exportedGenericResultsRecorder[S, E]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.Repeat(repeaters...) +} + +func (r *exportedGenericResultsRecorder[S, E]) isNil() bool { + return r.r == nil +} + +type partialGenericResultsAdaptor[S ~string] struct { + //nolint:structcheck // definitely used + m *moqPartialGenericResults[S] +} + +func (a *partialGenericResultsAdaptor[S]) config() adaptorConfig { return adaptorConfig{} } + +func (a *partialGenericResultsAdaptor[S]) mock() interface{} { return a.m.mock() } + +func (a *partialGenericResultsAdaptor[S]) newRecorder(sParams []string, bParam bool) recorder { + return &partialGenericResultsRecorder[S]{r: a.m.onCall().Usual(sParams[0], bParam)} +} + +func (a *partialGenericResultsAdaptor[S]) invokeMockAndExpectResults( + t moq.T, sParams []string, bParam bool, res results, +) { + sResult, err := a.m.mock().Usual(sParams[0], bParam) + if !reflect.DeepEqual(sResult, res.sResults[0]) { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if !reflect.DeepEqual(err, res.err) { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *partialGenericResultsAdaptor[S]) prettyParams(sParams []string, bParam bool) string { + return fmt.Sprintf("Usual(%#v, %#v)", sParams[0], bParam) +} + +func (a *partialGenericResultsAdaptor[S]) sceneMoq() moq.Moq { + return a.m +} + +type partialGenericResultsRecorder[S ~string] struct { + //nolint:structcheck // definitely used + r *moqPartialGenericResults_Usual_fnRecorder[S] +} + +func (r *partialGenericResultsRecorder[S]) anySParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param1() + } +} + +func (r *partialGenericResultsRecorder[S]) anyBParam() { + if a := r.r.any(); a == nil { + r.r = nil + } else { + r.r = a.param2() + } +} + +func (r *partialGenericResultsRecorder[S]) seq() { + r.r = r.r.seq() +} + +func (r *partialGenericResultsRecorder[S]) noSeq() { + r.r = r.r.noSeq() +} + +func (r *partialGenericResultsRecorder[S]) returnResults(sResults []string, err error) { + r.r = r.r.returnResults(S(sResults[0]), err) +} + +func (r *partialGenericResultsRecorder[S]) andDo(t moq.T, fn func(), expectedSParams []string, expectedBParam bool) { + r.r = r.r.andDo(func(sParam string, bParam bool) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *partialGenericResultsRecorder[S]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.doReturnResults(func(sParam string, bParam bool) (S, error) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return S(sResults[0]), err + }) +} + +func (r *partialGenericResultsRecorder[S]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.repeat(repeaters...) +} + +func (r *partialGenericResultsRecorder[S]) isNil() bool { + return r.r == nil +} + +type exportedPartialGenericResultsAdaptor[S ~string] struct { + //nolint:structcheck // definitely used + m *exported.MoqPartialGenericResults[S] +} + +func (a *exportedPartialGenericResultsAdaptor[S]) config() adaptorConfig { + return adaptorConfig{exported: true} +} + +func (a *exportedPartialGenericResultsAdaptor[S]) mock() interface{} { return a.m.Mock() } + +func (a *exportedPartialGenericResultsAdaptor[S]) newRecorder(sParams []string, bParam bool) recorder { + return &exportedPartialGenericResultsRecorder[S]{r: a.m.OnCall().Usual(sParams[0], bParam)} +} + +func (a *exportedPartialGenericResultsAdaptor[S]) invokeMockAndExpectResults( + t moq.T, sParams []string, bParam bool, res results, +) { + sResult, err := a.m.Mock().Usual(sParams[0], bParam) + if !reflect.DeepEqual(sResult, res.sResults[0]) { + t.Errorf("wanted %#v, got %#v", res.sResults[0], sResult) + } + if !reflect.DeepEqual(err, res.err) { + t.Errorf("wanted %#v, got %#v", res.err, err) + } +} + +func (a *exportedPartialGenericResultsAdaptor[S]) prettyParams(sParams []string, bParam bool) string { + return fmt.Sprintf("Usual(%#v, %#v)", sParams[0], bParam) +} + +func (a *exportedPartialGenericResultsAdaptor[S]) sceneMoq() moq.Moq { + return a.m +} + +type exportedPartialGenericResultsRecorder[S ~string] struct { + //nolint:structcheck // definitely used + r *exported.MoqPartialGenericResults_Usual_fnRecorder[S] +} + +func (r *exportedPartialGenericResultsRecorder[S]) anySParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param1() + } +} + +func (r *exportedPartialGenericResultsRecorder[S]) anyBParam() { + if a := r.r.Any(); a == nil { + r.r = nil + } else { + r.r = a.Param2() + } +} + +func (r *exportedPartialGenericResultsRecorder[S]) seq() { + r.r = r.r.Seq() +} + +func (r *exportedPartialGenericResultsRecorder[S]) noSeq() { + r.r = r.r.NoSeq() +} + +func (r *exportedPartialGenericResultsRecorder[S]) returnResults(sResults []string, err error) { + r.r = r.r.ReturnResults(S(sResults[0]), err) +} + +func (r *exportedPartialGenericResultsRecorder[S]) andDo( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, +) { + r.r = r.r.AndDo(func(sParam string, bParam bool) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + }) +} + +func (r *exportedPartialGenericResultsRecorder[S]) doReturnResults( + t moq.T, fn func(), expectedSParams []string, expectedBParam bool, sResults []string, err error, +) { + r.r = r.r.DoReturnResults(func(sParam string, bParam bool) (S, error) { + fn() + if sParam != expectedSParams[0] { + t.Errorf("wanted %#v, got %#v", expectedSParams[0], sParam) + } + if bParam != expectedBParam { + t.Errorf("wanted %t, got %#v", expectedBParam, bParam) + } + return S(sResults[0]), err + }) +} + +func (r *exportedPartialGenericResultsRecorder[S]) repeat(repeaters ...moq.Repeater) { + r.r = r.r.Repeat(repeaters...) +} + +func (r *exportedPartialGenericResultsRecorder[S]) isNil() bool { + return r.r == nil +} diff --git a/go.mod b/go.mod index a9d5aba..0f53f7c 100644 --- a/go.mod +++ b/go.mod @@ -1,16 +1,19 @@ module moqueries.org/cli -go 1.15 +go 1.19 require ( - github.com/dave/dst v0.26.2 + github.com/dave/dst v0.27.2 github.com/spf13/cobra v1.6.1 + golang.org/x/mod v0.8.0 golang.org/x/text v0.7.0 golang.org/x/tools v0.6.0 + moqueries.org/runtime v0.2.1-0.20230514231133-79eabd1bc852 ) require ( - github.com/stretchr/testify v1.8.0 // indirect - golang.org/x/mod v0.8.0 - moqueries.org/runtime v0.2.0 + github.com/inconshreveable/mousetrap v1.0.1 // indirect + github.com/spf13/pflag v1.0.5 // indirect + golang.org/x/sys v0.5.0 // indirect + moqueries.org/deephash v0.26.0 // indirect ) diff --git a/go.sum b/go.sum index 5858ae6..57c2454 100644 --- a/go.sum +++ b/go.sum @@ -1,92 +1,36 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/dave/dst v0.26.2 h1:lnxLAKI3tx7MgLNVDirFCsDTlTG9nKTk7GcptKcWSwY= -github.com/dave/dst v0.26.2/go.mod h1:UMDJuIRPfyUCC78eFuB+SV/WI8oDeyFDvM/JR6NI3IU= -github.com/dave/gopackages v0.0.0-20170318123100-46e7023ec56e/go.mod h1:i00+b/gKdIDIxuLDFob7ustLAVqhsZRk2qVZrArELGQ= -github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= -github.com/dave/kerr v0.0.0-20170318121727-bc25dd6abe8e/go.mod h1:qZqlPyPvfsDJt+3wHJ1EvSXDuVjFTK0j2p/ca+gtsb8= -github.com/dave/rebecca v0.9.1/go.mod h1:N6XYdMD/OKw3lkF3ywh8Z6wPGuwNFDNtWYEMFWEmXBA= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davegardnerisme/deephash v0.0.0-20210406090112-6d072427d830 h1:gn7TsPBQ3HoEUaa8oBLbMalIBPf3eeQb7W/8kK3gERk= +github.com/dave/dst v0.27.2 h1:4Y5VFTkhGLC1oddtNwuxxe36pnyLxMFXT51FOzH8Ekc= +github.com/dave/dst v0.27.2/go.mod h1:jHh6EOibnHgcUW3WjKHisiooEkYwqpHLBSX1iOBhEyc= +github.com/dave/jennifer v1.5.0 h1:HmgPN93bVDpkQyYbqhCHj5QlgvUkvEOzMyEvKLgCRrg= github.com/davegardnerisme/deephash v0.0.0-20210406090112-6d072427d830/go.mod h1:ToGe2SdaElKXzEmYLttAgFHy0exxh0wyq9zG7ZjjjYM= -github.com/google/pprof v0.0.0-20181127221834-b4f47329b966/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/arch v0.0.0-20180920145803-b19384d3c130/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/src-d/go-billy.v4 v4.3.0 h1:KtlZ4c1OWbIs4jCv5ZXrTqG8EQocr0g/d4DjNg70aek= -gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +moqueries.org/deephash v0.0.1 h1:wjyDOUebdr6b3waxMcrQT70Zym+yGhyyWU3+bcDz3iE= +moqueries.org/deephash v0.0.1/go.mod h1:brwHe2Ks78ZEA1xIgUTEy0gtZfO7tJTqXT9haTdIRNE= +moqueries.org/deephash v0.26.0 h1:KvMnNvb/N9lId0OOO1X6Yp2BifVuDuJJQH3epAeF178= +moqueries.org/deephash v0.26.0/go.mod h1:brwHe2Ks78ZEA1xIgUTEy0gtZfO7tJTqXT9haTdIRNE= moqueries.org/runtime v0.2.0 h1:0/J/LQaXtXoLEQq3ylOJf/ZJ0XAfOk1oFyxULuSik5Q= moqueries.org/runtime v0.2.0/go.mod h1:sVzS1LDG0bCn3vvtZrahBbutdrq68ZXka2q1Xzn3bz4= +moqueries.org/runtime v0.2.1-0.20230509151527-1b9c0d948fcf h1:FJVQ+0lb80IfYZv8ryS+xPtAWLbNEJ+SZQphHvPgk/Y= +moqueries.org/runtime v0.2.1-0.20230509151527-1b9c0d948fcf/go.mod h1:6TYQARbafolpsKM+zSxgJDMY7UcCOtm7xJtckEbKb0c= +moqueries.org/runtime v0.2.1-0.20230511165754-0d97cc5a02da h1:CmY5dRD9VpPPoVT9oTCwyUL6dL0TJXeJnkh8Lq9748k= +moqueries.org/runtime v0.2.1-0.20230511165754-0d97cc5a02da/go.mod h1:6TYQARbafolpsKM+zSxgJDMY7UcCOtm7xJtckEbKb0c= +moqueries.org/runtime v0.2.1-0.20230514231133-79eabd1bc852 h1:PdI8B/YreKpU3iNOASeYK3+4cgtvgD9OqIekMRew1VE= +moqueries.org/runtime v0.2.1-0.20230514231133-79eabd1bc852/go.mod h1:IXFe0wh6tJnD+dfHM6BCCpBuwjQQ5JIxdhRR3Be+IbQ= diff --git a/metrics/metrics.go b/metrics/metrics.go index 8365854..5b9a526 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -20,8 +20,6 @@ const ( type Metrics interface { ASTPkgCacheHitsInc() ASTPkgCacheMissesInc() - ASTTypeCacheHitsInc() - ASTTypeCacheMissesInc() ASTTotalLoadTimeInc(d time.Duration) ASTTotalDecorationTimeInc(d time.Duration) @@ -103,16 +101,6 @@ func (m *Processor) ASTPkgCacheMissesInc() { m.state.ASTPkgCacheMisses++ } -// ASTTypeCacheHitsInc increments the ASTTypeCacheHits metric -func (m *Processor) ASTTypeCacheHitsInc() { - m.state.ASTTypeCacheHits++ -} - -// ASTTypeCacheMissesInc increments the ASTTypeCacheMisses metric -func (m *Processor) ASTTypeCacheMissesInc() { - m.state.ASTTypeCacheMisses++ -} - // ASTTotalLoadTimeInc increments the ASTTotalLoadTime duration metric by the // d duration specified func (m *Processor) ASTTotalLoadTimeInc(d time.Duration) { diff --git a/metrics/metrics_test.go b/metrics/metrics_test.go index 07677d6..64f3ba5 100644 --- a/metrics/metrics_test.go +++ b/metrics/metrics_test.go @@ -44,8 +44,6 @@ func TestMetrics(t *testing.T) { m.ASTPkgCacheHitsInc() m.ASTPkgCacheMissesInc() - m.ASTTypeCacheHitsInc() - m.ASTTypeCacheMissesInc() m.ASTTotalLoadTimeInc(1234 * time.Millisecond) m.ASTTotalDecorationTimeInc(9999 * time.Millisecond) m.TotalProcessingTimeInc(4321 * time.Millisecond) @@ -60,10 +58,8 @@ func TestMetrics(t *testing.T) { t.Run("single int increment", func(t *testing.T) { incFuncs := map[string]func(m *metrics.Processor){ - "ast-pkg-cache-hits": func(m *metrics.Processor) { m.ASTPkgCacheHitsInc() }, - "ast-pkg-cache-misses": func(m *metrics.Processor) { m.ASTPkgCacheMissesInc() }, - "ast-type-cache-hits": func(m *metrics.Processor) { m.ASTTypeCacheHitsInc() }, - "ast-type-cache-misses": func(m *metrics.Processor) { m.ASTTypeCacheMissesInc() }, + "ast-pkg-cache-hits": func(m *metrics.Processor) { m.ASTPkgCacheHitsInc() }, + "ast-pkg-cache-misses": func(m *metrics.Processor) { m.ASTPkgCacheMissesInc() }, } for name, incFunc := range incFuncs { diff --git a/metrics/moq_metrics.go b/metrics/moq_metrics.go index ab8e478..0912a87 100644 --- a/metrics/moq_metrics.go +++ b/metrics/moq_metrics.go @@ -24,8 +24,6 @@ type MoqMetrics struct { ResultsByParams_ASTPkgCacheHitsInc []MoqMetrics_ASTPkgCacheHitsInc_resultsByParams ResultsByParams_ASTPkgCacheMissesInc []MoqMetrics_ASTPkgCacheMissesInc_resultsByParams - ResultsByParams_ASTTypeCacheHitsInc []MoqMetrics_ASTTypeCacheHitsInc_resultsByParams - ResultsByParams_ASTTypeCacheMissesInc []MoqMetrics_ASTTypeCacheMissesInc_resultsByParams ResultsByParams_ASTTotalLoadTimeInc []MoqMetrics_ASTTotalLoadTimeInc_resultsByParams ResultsByParams_ASTTotalDecorationTimeInc []MoqMetrics_ASTTotalDecorationTimeInc_resultsByParams ResultsByParams_TotalProcessingTimeInc []MoqMetrics_TotalProcessingTimeInc_resultsByParams @@ -33,11 +31,9 @@ type MoqMetrics struct { Runtime struct { ParameterIndexing struct { - ASTPkgCacheHitsInc struct{} - ASTPkgCacheMissesInc struct{} - ASTTypeCacheHitsInc struct{} - ASTTypeCacheMissesInc struct{} - ASTTotalLoadTimeInc struct { + ASTPkgCacheHitsInc struct{} + ASTPkgCacheMissesInc struct{} + ASTTotalLoadTimeInc struct { D moq.ParamIndexing } ASTTotalDecorationTimeInc struct { @@ -172,117 +168,6 @@ type MoqMetrics_ASTPkgCacheMissesInc_anyParams struct { Recorder *MoqMetrics_ASTPkgCacheMissesInc_fnRecorder } -// MoqMetrics_ASTTypeCacheHitsInc_params holds the params of the Metrics type -type MoqMetrics_ASTTypeCacheHitsInc_params struct{} - -// MoqMetrics_ASTTypeCacheHitsInc_paramsKey holds the map key params of the -// Metrics type -type MoqMetrics_ASTTypeCacheHitsInc_paramsKey struct { - Params struct{} - Hashes struct{} -} - -// MoqMetrics_ASTTypeCacheHitsInc_resultsByParams contains the results for a -// given set of parameters for the Metrics type -type MoqMetrics_ASTTypeCacheHitsInc_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqMetrics_ASTTypeCacheHitsInc_paramsKey]*MoqMetrics_ASTTypeCacheHitsInc_results -} - -// MoqMetrics_ASTTypeCacheHitsInc_doFn defines the type of function needed when -// calling AndDo for the Metrics type -type MoqMetrics_ASTTypeCacheHitsInc_doFn func() - -// MoqMetrics_ASTTypeCacheHitsInc_doReturnFn defines the type of function -// needed when calling DoReturnResults for the Metrics type -type MoqMetrics_ASTTypeCacheHitsInc_doReturnFn func() - -// MoqMetrics_ASTTypeCacheHitsInc_results holds the results of the Metrics type -type MoqMetrics_ASTTypeCacheHitsInc_results struct { - Params MoqMetrics_ASTTypeCacheHitsInc_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTTypeCacheHitsInc_doFn - DoReturnFn MoqMetrics_ASTTypeCacheHitsInc_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqMetrics_ASTTypeCacheHitsInc_fnRecorder routes recorded function calls to -// the MoqMetrics moq -type MoqMetrics_ASTTypeCacheHitsInc_fnRecorder struct { - Params MoqMetrics_ASTTypeCacheHitsInc_params - AnyParams uint64 - Sequence bool - Results *MoqMetrics_ASTTypeCacheHitsInc_results - Moq *MoqMetrics -} - -// MoqMetrics_ASTTypeCacheHitsInc_anyParams isolates the any params functions -// of the Metrics type -type MoqMetrics_ASTTypeCacheHitsInc_anyParams struct { - Recorder *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder -} - -// MoqMetrics_ASTTypeCacheMissesInc_params holds the params of the Metrics type -type MoqMetrics_ASTTypeCacheMissesInc_params struct{} - -// MoqMetrics_ASTTypeCacheMissesInc_paramsKey holds the map key params of the -// Metrics type -type MoqMetrics_ASTTypeCacheMissesInc_paramsKey struct { - Params struct{} - Hashes struct{} -} - -// MoqMetrics_ASTTypeCacheMissesInc_resultsByParams contains the results for a -// given set of parameters for the Metrics type -type MoqMetrics_ASTTypeCacheMissesInc_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqMetrics_ASTTypeCacheMissesInc_paramsKey]*MoqMetrics_ASTTypeCacheMissesInc_results -} - -// MoqMetrics_ASTTypeCacheMissesInc_doFn defines the type of function needed -// when calling AndDo for the Metrics type -type MoqMetrics_ASTTypeCacheMissesInc_doFn func() - -// MoqMetrics_ASTTypeCacheMissesInc_doReturnFn defines the type of function -// needed when calling DoReturnResults for the Metrics type -type MoqMetrics_ASTTypeCacheMissesInc_doReturnFn func() - -// MoqMetrics_ASTTypeCacheMissesInc_results holds the results of the Metrics -// type -type MoqMetrics_ASTTypeCacheMissesInc_results struct { - Params MoqMetrics_ASTTypeCacheMissesInc_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTTypeCacheMissesInc_doFn - DoReturnFn MoqMetrics_ASTTypeCacheMissesInc_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqMetrics_ASTTypeCacheMissesInc_fnRecorder routes recorded function calls -// to the MoqMetrics moq -type MoqMetrics_ASTTypeCacheMissesInc_fnRecorder struct { - Params MoqMetrics_ASTTypeCacheMissesInc_params - AnyParams uint64 - Sequence bool - Results *MoqMetrics_ASTTypeCacheMissesInc_results - Moq *MoqMetrics -} - -// MoqMetrics_ASTTypeCacheMissesInc_anyParams isolates the any params functions -// of the Metrics type -type MoqMetrics_ASTTypeCacheMissesInc_anyParams struct { - Recorder *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder -} - // MoqMetrics_ASTTotalLoadTimeInc_params holds the params of the Metrics type type MoqMetrics_ASTTotalLoadTimeInc_params struct{ D time.Duration } @@ -518,11 +403,9 @@ func NewMoqMetrics(scene *moq.Scene, config *moq.Config) *MoqMetrics { Runtime: struct { ParameterIndexing struct { - ASTPkgCacheHitsInc struct{} - ASTPkgCacheMissesInc struct{} - ASTTypeCacheHitsInc struct{} - ASTTypeCacheMissesInc struct{} - ASTTotalLoadTimeInc struct { + ASTPkgCacheHitsInc struct{} + ASTPkgCacheMissesInc struct{} + ASTTotalLoadTimeInc struct { D moq.ParamIndexing } ASTTotalDecorationTimeInc struct { @@ -534,11 +417,9 @@ func NewMoqMetrics(scene *moq.Scene, config *moq.Config) *MoqMetrics { Finalize struct{} } }{ParameterIndexing: struct { - ASTPkgCacheHitsInc struct{} - ASTPkgCacheMissesInc struct{} - ASTTypeCacheHitsInc struct{} - ASTTypeCacheMissesInc struct{} - ASTTotalLoadTimeInc struct { + ASTPkgCacheHitsInc struct{} + ASTPkgCacheMissesInc struct{} + ASTTotalLoadTimeInc struct { D moq.ParamIndexing } ASTTotalDecorationTimeInc struct { @@ -549,10 +430,8 @@ func NewMoqMetrics(scene *moq.Scene, config *moq.Config) *MoqMetrics { } Finalize struct{} }{ - ASTPkgCacheHitsInc: struct{}{}, - ASTPkgCacheMissesInc: struct{}{}, - ASTTypeCacheHitsInc: struct{}{}, - ASTTypeCacheMissesInc: struct{}{}, + ASTPkgCacheHitsInc: struct{}{}, + ASTPkgCacheMissesInc: struct{}{}, ASTTotalLoadTimeInc: struct { D moq.ParamIndexing }{ @@ -676,102 +555,6 @@ func (m *MoqMetrics_mock) ASTPkgCacheMissesInc() { return } -func (m *MoqMetrics_mock) ASTTypeCacheHitsInc() { - m.Moq.Scene.T.Helper() - params := MoqMetrics_ASTTypeCacheHitsInc_params{} - var results *MoqMetrics_ASTTypeCacheHitsInc_results - for _, resultsByParams := range m.Moq.ResultsByParams_ASTTypeCacheHitsInc { - paramsKey := m.Moq.ParamsKey_ASTTypeCacheHitsInc(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_ASTTypeCacheHitsInc(params)) - } - return - } - - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_ASTTypeCacheHitsInc(params)) - } - return - } - i = results.Repeat.ResultCount - 1 - } - - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_ASTTypeCacheHitsInc(params)) - } - } - - if result.DoFn != nil { - result.DoFn() - } - - if result.DoReturnFn != nil { - result.DoReturnFn() - } - return -} - -func (m *MoqMetrics_mock) ASTTypeCacheMissesInc() { - m.Moq.Scene.T.Helper() - params := MoqMetrics_ASTTypeCacheMissesInc_params{} - var results *MoqMetrics_ASTTypeCacheMissesInc_results - for _, resultsByParams := range m.Moq.ResultsByParams_ASTTypeCacheMissesInc { - paramsKey := m.Moq.ParamsKey_ASTTypeCacheMissesInc(params, resultsByParams.AnyParams) - var ok bool - results, ok = resultsByParams.Results[paramsKey] - if ok { - break - } - } - if results == nil { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_ASTTypeCacheMissesInc(params)) - } - return - } - - i := int(atomic.AddUint32(&results.Index, 1)) - 1 - if i >= results.Repeat.ResultCount { - if !results.Repeat.AnyTimes { - if m.Moq.Config.Expectation == moq.Strict { - m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_ASTTypeCacheMissesInc(params)) - } - return - } - i = results.Repeat.ResultCount - 1 - } - - result := results.Results[i] - if result.Sequence != 0 { - sequence := m.Moq.Scene.NextMockSequence() - if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { - m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_ASTTypeCacheMissesInc(params)) - } - } - - if result.DoFn != nil { - result.DoFn() - } - - if result.DoReturnFn != nil { - result.DoReturnFn() - } - return -} - func (m *MoqMetrics_mock) ASTTotalLoadTimeInc(d time.Duration) { m.Moq.Scene.T.Helper() params := MoqMetrics_ASTTotalLoadTimeInc_params{ @@ -1323,352 +1106,6 @@ func (m *MoqMetrics) ParamsKey_ASTPkgCacheMissesInc(params MoqMetrics_ASTPkgCach } } -func (m *MoqMetrics_recorder) ASTTypeCacheHitsInc() *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder { - return &MoqMetrics_ASTTypeCacheHitsInc_fnRecorder{ - Params: MoqMetrics_ASTTypeCacheHitsInc_params{}, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, - } -} - -func (r *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder) Any() *MoqMetrics_ASTTypeCacheHitsInc_anyParams { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_ASTTypeCacheHitsInc(r.Params)) - return nil - } - return &MoqMetrics_ASTTypeCacheHitsInc_anyParams{Recorder: r} -} - -func (r *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder) Seq() *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_ASTTypeCacheHitsInc(r.Params)) - return nil - } - r.Sequence = true - return r -} - -func (r *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder) NoSeq() *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_ASTTypeCacheHitsInc(r.Params)) - return nil - } - r.Sequence = false - return r -} - -func (r *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder) ReturnResults() *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder { - r.Moq.Scene.T.Helper() - r.FindResults() - - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() - } - - r.Results.Results = append(r.Results.Results, struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTTypeCacheHitsInc_doFn - DoReturnFn MoqMetrics_ASTTypeCacheHitsInc_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) - return r -} - -func (r *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder) AndDo(fn MoqMetrics_ASTTypeCacheHitsInc_doFn) *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") - return nil - } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn - return r -} - -func (r *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder) DoReturnResults(fn MoqMetrics_ASTTypeCacheHitsInc_doReturnFn) *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder { - r.Moq.Scene.T.Helper() - r.FindResults() - - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() - } - - r.Results.Results = append(r.Results.Results, struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTTypeCacheHitsInc_doFn - DoReturnFn MoqMetrics_ASTTypeCacheHitsInc_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) - return r -} - -func (r *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder) FindResults() { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Results.Repeat.Increment(r.Moq.Scene.T) - return - } - - anyCount := bits.OnesCount64(r.AnyParams) - insertAt := -1 - var results *MoqMetrics_ASTTypeCacheHitsInc_resultsByParams - for n, res := range r.Moq.ResultsByParams_ASTTypeCacheHitsInc { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqMetrics_ASTTypeCacheHitsInc_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqMetrics_ASTTypeCacheHitsInc_paramsKey]*MoqMetrics_ASTTypeCacheHitsInc_results{}, - } - r.Moq.ResultsByParams_ASTTypeCacheHitsInc = append(r.Moq.ResultsByParams_ASTTypeCacheHitsInc, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_ASTTypeCacheHitsInc) { - copy(r.Moq.ResultsByParams_ASTTypeCacheHitsInc[insertAt+1:], r.Moq.ResultsByParams_ASTTypeCacheHitsInc[insertAt:0]) - r.Moq.ResultsByParams_ASTTypeCacheHitsInc[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_ASTTypeCacheHitsInc(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqMetrics_ASTTypeCacheHitsInc_results{ - Params: r.Params, - Results: nil, - Index: 0, - Repeat: &moq.RepeatVal{}, - } - results.Results[paramsKey] = r.Results - } - - r.Results.Repeat.Increment(r.Moq.Scene.T) -} - -func (r *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_ASTTypeCacheHitsInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") - return nil - } - r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) - last := r.Results.Results[len(r.Results.Results)-1] - for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { - if r.Sequence { - last = struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTTypeCacheHitsInc_doFn - DoReturnFn MoqMetrics_ASTTypeCacheHitsInc_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } - return r -} - -func (m *MoqMetrics) PrettyParams_ASTTypeCacheHitsInc(params MoqMetrics_ASTTypeCacheHitsInc_params) string { - return fmt.Sprintf("ASTTypeCacheHitsInc()") -} - -func (m *MoqMetrics) ParamsKey_ASTTypeCacheHitsInc(params MoqMetrics_ASTTypeCacheHitsInc_params, anyParams uint64) MoqMetrics_ASTTypeCacheHitsInc_paramsKey { - m.Scene.T.Helper() - return MoqMetrics_ASTTypeCacheHitsInc_paramsKey{ - Params: struct{}{}, - Hashes: struct{}{}, - } -} - -func (m *MoqMetrics_recorder) ASTTypeCacheMissesInc() *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder { - return &MoqMetrics_ASTTypeCacheMissesInc_fnRecorder{ - Params: MoqMetrics_ASTTypeCacheMissesInc_params{}, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, - } -} - -func (r *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder) Any() *MoqMetrics_ASTTypeCacheMissesInc_anyParams { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_ASTTypeCacheMissesInc(r.Params)) - return nil - } - return &MoqMetrics_ASTTypeCacheMissesInc_anyParams{Recorder: r} -} - -func (r *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder) Seq() *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_ASTTypeCacheMissesInc(r.Params)) - return nil - } - r.Sequence = true - return r -} - -func (r *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder) NoSeq() *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_ASTTypeCacheMissesInc(r.Params)) - return nil - } - r.Sequence = false - return r -} - -func (r *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder) ReturnResults() *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder { - r.Moq.Scene.T.Helper() - r.FindResults() - - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() - } - - r.Results.Results = append(r.Results.Results, struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTTypeCacheMissesInc_doFn - DoReturnFn MoqMetrics_ASTTypeCacheMissesInc_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) - return r -} - -func (r *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder) AndDo(fn MoqMetrics_ASTTypeCacheMissesInc_doFn) *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") - return nil - } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn - return r -} - -func (r *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder) DoReturnResults(fn MoqMetrics_ASTTypeCacheMissesInc_doReturnFn) *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder { - r.Moq.Scene.T.Helper() - r.FindResults() - - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() - } - - r.Results.Results = append(r.Results.Results, struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTTypeCacheMissesInc_doFn - DoReturnFn MoqMetrics_ASTTypeCacheMissesInc_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) - return r -} - -func (r *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder) FindResults() { - r.Moq.Scene.T.Helper() - if r.Results != nil { - r.Results.Repeat.Increment(r.Moq.Scene.T) - return - } - - anyCount := bits.OnesCount64(r.AnyParams) - insertAt := -1 - var results *MoqMetrics_ASTTypeCacheMissesInc_resultsByParams - for n, res := range r.Moq.ResultsByParams_ASTTypeCacheMissesInc { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqMetrics_ASTTypeCacheMissesInc_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqMetrics_ASTTypeCacheMissesInc_paramsKey]*MoqMetrics_ASTTypeCacheMissesInc_results{}, - } - r.Moq.ResultsByParams_ASTTypeCacheMissesInc = append(r.Moq.ResultsByParams_ASTTypeCacheMissesInc, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_ASTTypeCacheMissesInc) { - copy(r.Moq.ResultsByParams_ASTTypeCacheMissesInc[insertAt+1:], r.Moq.ResultsByParams_ASTTypeCacheMissesInc[insertAt:0]) - r.Moq.ResultsByParams_ASTTypeCacheMissesInc[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_ASTTypeCacheMissesInc(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqMetrics_ASTTypeCacheMissesInc_results{ - Params: r.Params, - Results: nil, - Index: 0, - Repeat: &moq.RepeatVal{}, - } - results.Results[paramsKey] = r.Results - } - - r.Results.Repeat.Increment(r.Moq.Scene.T) -} - -func (r *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_ASTTypeCacheMissesInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") - return nil - } - r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) - last := r.Results.Results[len(r.Results.Results)-1] - for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { - if r.Sequence { - last = struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTTypeCacheMissesInc_doFn - DoReturnFn MoqMetrics_ASTTypeCacheMissesInc_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } - return r -} - -func (m *MoqMetrics) PrettyParams_ASTTypeCacheMissesInc(params MoqMetrics_ASTTypeCacheMissesInc_params) string { - return fmt.Sprintf("ASTTypeCacheMissesInc()") -} - -func (m *MoqMetrics) ParamsKey_ASTTypeCacheMissesInc(params MoqMetrics_ASTTypeCacheMissesInc_params, anyParams uint64) MoqMetrics_ASTTypeCacheMissesInc_paramsKey { - m.Scene.T.Helper() - return MoqMetrics_ASTTypeCacheMissesInc_paramsKey{ - Params: struct{}{}, - Hashes: struct{}{}, - } -} - func (m *MoqMetrics_recorder) ASTTotalLoadTimeInc(d time.Duration) *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder { return &MoqMetrics_ASTTotalLoadTimeInc_fnRecorder{ Params: MoqMetrics_ASTTotalLoadTimeInc_params{ @@ -2425,8 +1862,6 @@ func (m *MoqMetrics) ParamsKey_Finalize(params MoqMetrics_Finalize_params, anyPa func (m *MoqMetrics) Reset() { m.ResultsByParams_ASTPkgCacheHitsInc = nil m.ResultsByParams_ASTPkgCacheMissesInc = nil - m.ResultsByParams_ASTTypeCacheHitsInc = nil - m.ResultsByParams_ASTTypeCacheMissesInc = nil m.ResultsByParams_ASTTotalLoadTimeInc = nil m.ResultsByParams_ASTTotalDecorationTimeInc = nil m.ResultsByParams_TotalProcessingTimeInc = nil @@ -2452,22 +1887,6 @@ func (m *MoqMetrics) AssertExpectationsMet() { } } } - for _, res := range m.ResultsByParams_ASTTypeCacheHitsInc { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_ASTTypeCacheHitsInc(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_ASTTypeCacheMissesInc { - for _, results := range res.Results { - missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) - if missing > 0 { - m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_ASTTypeCacheMissesInc(results.Params)) - } - } - } for _, res := range m.ResultsByParams_ASTTotalLoadTimeInc { for _, results := range res.Results { missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) diff --git a/pkg/internal/moq_typecache_test.go b/pkg/internal/moq_typecache_test.go index 610a544..5eb79fd 100644 --- a/pkg/internal/moq_typecache_test.go +++ b/pkg/internal/moq_typecache_test.go @@ -45,10 +45,12 @@ type moqTypeCache struct { testImport moq.ParamIndexing } IsComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } IsDefaultComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } FindPackage struct { dir moq.ParamIndexing @@ -250,13 +252,22 @@ type moqTypeCache_Type_anyParams struct { } // moqTypeCache_IsComparable_params holds the params of the TypeCache type -type moqTypeCache_IsComparable_params struct{ expr dst.Expr } +type moqTypeCache_IsComparable_params struct { + expr dst.Expr + parentType ast.TypeInfo +} // moqTypeCache_IsComparable_paramsKey holds the map key params of the // TypeCache type type moqTypeCache_IsComparable_paramsKey struct { - params struct{ expr dst.Expr } - hashes struct{ expr hash.Hash } + params struct { + expr dst.Expr + parentType ast.TypeInfo + } + hashes struct { + expr hash.Hash + parentType hash.Hash + } } // moqTypeCache_IsComparable_resultsByParams contains the results for a given @@ -269,11 +280,11 @@ type moqTypeCache_IsComparable_resultsByParams struct { // moqTypeCache_IsComparable_doFn defines the type of function needed when // calling andDo for the TypeCache type -type moqTypeCache_IsComparable_doFn func(expr dst.Expr) +type moqTypeCache_IsComparable_doFn func(expr dst.Expr, parentType ast.TypeInfo) // moqTypeCache_IsComparable_doReturnFn defines the type of function needed // when calling doReturnResults for the TypeCache type -type moqTypeCache_IsComparable_doReturnFn func(expr dst.Expr) (bool, error) +type moqTypeCache_IsComparable_doReturnFn func(expr dst.Expr, parentType ast.TypeInfo) (bool, error) // moqTypeCache_IsComparable_results holds the results of the TypeCache type type moqTypeCache_IsComparable_results struct { @@ -309,13 +320,22 @@ type moqTypeCache_IsComparable_anyParams struct { // moqTypeCache_IsDefaultComparable_params holds the params of the TypeCache // type -type moqTypeCache_IsDefaultComparable_params struct{ expr dst.Expr } +type moqTypeCache_IsDefaultComparable_params struct { + expr dst.Expr + parentType ast.TypeInfo +} // moqTypeCache_IsDefaultComparable_paramsKey holds the map key params of the // TypeCache type type moqTypeCache_IsDefaultComparable_paramsKey struct { - params struct{ expr dst.Expr } - hashes struct{ expr hash.Hash } + params struct { + expr dst.Expr + parentType ast.TypeInfo + } + hashes struct { + expr hash.Hash + parentType hash.Hash + } } // moqTypeCache_IsDefaultComparable_resultsByParams contains the results for a @@ -328,11 +348,11 @@ type moqTypeCache_IsDefaultComparable_resultsByParams struct { // moqTypeCache_IsDefaultComparable_doFn defines the type of function needed // when calling andDo for the TypeCache type -type moqTypeCache_IsDefaultComparable_doFn func(expr dst.Expr) +type moqTypeCache_IsDefaultComparable_doFn func(expr dst.Expr, parentType ast.TypeInfo) // moqTypeCache_IsDefaultComparable_doReturnFn defines the type of function // needed when calling doReturnResults for the TypeCache type -type moqTypeCache_IsDefaultComparable_doReturnFn func(expr dst.Expr) (bool, error) +type moqTypeCache_IsDefaultComparable_doReturnFn func(expr dst.Expr, parentType ast.TypeInfo) (bool, error) // moqTypeCache_IsDefaultComparable_results holds the results of the TypeCache // type @@ -449,10 +469,12 @@ func newMoqTypeCache(scene *moq.Scene, config *moq.Config) *moqTypeCache { testImport moq.ParamIndexing } IsComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } IsDefaultComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } FindPackage struct { dir moq.ParamIndexing @@ -471,10 +493,12 @@ func newMoqTypeCache(scene *moq.Scene, config *moq.Config) *moqTypeCache { testImport moq.ParamIndexing } IsComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } IsDefaultComparable struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing } FindPackage struct { dir moq.ParamIndexing @@ -500,14 +524,18 @@ func newMoqTypeCache(scene *moq.Scene, config *moq.Config) *moqTypeCache { testImport: moq.ParamIndexByValue, }, IsComparable: struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing }{ - expr: moq.ParamIndexByHash, + expr: moq.ParamIndexByHash, + parentType: moq.ParamIndexByHash, }, IsDefaultComparable: struct { - expr moq.ParamIndexing + expr moq.ParamIndexing + parentType moq.ParamIndexing }{ - expr: moq.ParamIndexByHash, + expr: moq.ParamIndexByHash, + parentType: moq.ParamIndexByHash, }, FindPackage: struct { dir moq.ParamIndexing @@ -687,10 +715,11 @@ func (m *moqTypeCache_mock) Type(id dst.Ident, contextPkg string, testImport boo return } -func (m *moqTypeCache_mock) IsComparable(expr dst.Expr) (result1 bool, result2 error) { +func (m *moqTypeCache_mock) IsComparable(expr dst.Expr, parentType ast.TypeInfo) (result1 bool, result2 error) { m.moq.scene.T.Helper() params := moqTypeCache_IsComparable_params{ - expr: expr, + expr: expr, + parentType: parentType, } var results *moqTypeCache_IsComparable_results for _, resultsByParams := range m.moq.resultsByParams_IsComparable { @@ -728,7 +757,7 @@ func (m *moqTypeCache_mock) IsComparable(expr dst.Expr) (result1 bool, result2 e } if result.doFn != nil { - result.doFn(expr) + result.doFn(expr, parentType) } if result.values != nil { @@ -736,15 +765,16 @@ func (m *moqTypeCache_mock) IsComparable(expr dst.Expr) (result1 bool, result2 e result2 = result.values.result2 } if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(expr) + result1, result2 = result.doReturnFn(expr, parentType) } return } -func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr) (result1 bool, result2 error) { +func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) (result1 bool, result2 error) { m.moq.scene.T.Helper() params := moqTypeCache_IsDefaultComparable_params{ - expr: expr, + expr: expr, + parentType: parentType, } var results *moqTypeCache_IsDefaultComparable_results for _, resultsByParams := range m.moq.resultsByParams_IsDefaultComparable { @@ -782,7 +812,7 @@ func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr) (result1 bool, re } if result.doFn != nil { - result.doFn(expr) + result.doFn(expr, parentType) } if result.values != nil { @@ -790,7 +820,7 @@ func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr) (result1 bool, re result2 = result.values.result2 } if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(expr) + result1, result2 = result.doReturnFn(expr, parentType) } return } @@ -1508,10 +1538,11 @@ func (m *moqTypeCache) paramsKey_Type(params moqTypeCache_Type_params, anyParams } } -func (m *moqTypeCache_recorder) IsComparable(expr dst.Expr) *moqTypeCache_IsComparable_fnRecorder { +func (m *moqTypeCache_recorder) IsComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsComparable_fnRecorder { return &moqTypeCache_IsComparable_fnRecorder{ params: moqTypeCache_IsComparable_params{ - expr: expr, + expr: expr, + parentType: parentType, }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, @@ -1532,6 +1563,11 @@ func (a *moqTypeCache_IsComparable_anyParams) expr() *moqTypeCache_IsComparable_ return a.recorder } +func (a *moqTypeCache_IsComparable_anyParams) parentType() *moqTypeCache_IsComparable_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + func (r *moqTypeCache_IsComparable_fnRecorder) seq() *moqTypeCache_IsComparable_fnRecorder { r.moq.scene.T.Helper() if r.results != nil { @@ -1692,7 +1728,7 @@ func (r *moqTypeCache_IsComparable_fnRecorder) repeat(repeaters ...moq.Repeater) } func (m *moqTypeCache) prettyParams_IsComparable(params moqTypeCache_IsComparable_params) string { - return fmt.Sprintf("IsComparable(%#v)", params.expr) + return fmt.Sprintf("IsComparable(%#v, %#v)", params.expr, params.parentType) } func (m *moqTypeCache) paramsKey_IsComparable(params moqTypeCache_IsComparable_params, anyParams uint64) moqTypeCache_IsComparable_paramsKey { @@ -1706,20 +1742,38 @@ func (m *moqTypeCache) paramsKey_IsComparable(params moqTypeCache_IsComparable_p exprUsedHash = hash.DeepHash(params.expr) } } + var parentTypeUsed ast.TypeInfo + var parentTypeUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.IsComparable.parentType == moq.ParamIndexByValue { + parentTypeUsed = params.parentType + } else { + parentTypeUsedHash = hash.DeepHash(params.parentType) + } + } return moqTypeCache_IsComparable_paramsKey{ - params: struct{ expr dst.Expr }{ - expr: exprUsed, + params: struct { + expr dst.Expr + parentType ast.TypeInfo + }{ + expr: exprUsed, + parentType: parentTypeUsed, }, - hashes: struct{ expr hash.Hash }{ - expr: exprUsedHash, + hashes: struct { + expr hash.Hash + parentType hash.Hash + }{ + expr: exprUsedHash, + parentType: parentTypeUsedHash, }, } } -func (m *moqTypeCache_recorder) IsDefaultComparable(expr dst.Expr) *moqTypeCache_IsDefaultComparable_fnRecorder { +func (m *moqTypeCache_recorder) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsDefaultComparable_fnRecorder { return &moqTypeCache_IsDefaultComparable_fnRecorder{ params: moqTypeCache_IsDefaultComparable_params{ - expr: expr, + expr: expr, + parentType: parentType, }, sequence: m.moq.config.Sequence == moq.SeqDefaultOn, moq: m.moq, @@ -1740,6 +1794,11 @@ func (a *moqTypeCache_IsDefaultComparable_anyParams) expr() *moqTypeCache_IsDefa return a.recorder } +func (a *moqTypeCache_IsDefaultComparable_anyParams) parentType() *moqTypeCache_IsDefaultComparable_fnRecorder { + a.recorder.anyParams |= 1 << 1 + return a.recorder +} + func (r *moqTypeCache_IsDefaultComparable_fnRecorder) seq() *moqTypeCache_IsDefaultComparable_fnRecorder { r.moq.scene.T.Helper() if r.results != nil { @@ -1900,7 +1959,7 @@ func (r *moqTypeCache_IsDefaultComparable_fnRecorder) repeat(repeaters ...moq.Re } func (m *moqTypeCache) prettyParams_IsDefaultComparable(params moqTypeCache_IsDefaultComparable_params) string { - return fmt.Sprintf("IsDefaultComparable(%#v)", params.expr) + return fmt.Sprintf("IsDefaultComparable(%#v, %#v)", params.expr, params.parentType) } func (m *moqTypeCache) paramsKey_IsDefaultComparable(params moqTypeCache_IsDefaultComparable_params, anyParams uint64) moqTypeCache_IsDefaultComparable_paramsKey { @@ -1914,12 +1973,29 @@ func (m *moqTypeCache) paramsKey_IsDefaultComparable(params moqTypeCache_IsDefau exprUsedHash = hash.DeepHash(params.expr) } } + var parentTypeUsed ast.TypeInfo + var parentTypeUsedHash hash.Hash + if anyParams&(1<<1) == 0 { + if m.runtime.parameterIndexing.IsDefaultComparable.parentType == moq.ParamIndexByValue { + parentTypeUsed = params.parentType + } else { + parentTypeUsedHash = hash.DeepHash(params.parentType) + } + } return moqTypeCache_IsDefaultComparable_paramsKey{ - params: struct{ expr dst.Expr }{ - expr: exprUsed, + params: struct { + expr dst.Expr + parentType ast.TypeInfo + }{ + expr: exprUsed, + parentType: parentTypeUsed, }, - hashes: struct{ expr hash.Hash }{ - expr: exprUsedHash, + hashes: struct { + expr hash.Hash + parentType hash.Hash + }{ + expr: exprUsedHash, + parentType: parentTypeUsedHash, }, } } diff --git a/pkg/testmoqs/moq_generic_indexlistgentype.go b/pkg/testmoqs/moq_generic_indexlistgentype.go new file mode 100644 index 0000000..c55f4d8 --- /dev/null +++ b/pkg/testmoqs/moq_generic_indexlistgentype.go @@ -0,0 +1,1267 @@ +// Code generated by Moqueries - https://moqueries.org - DO NOT EDIT! + +package testmoqs + +import ( + "fmt" + "math/bits" + "sync/atomic" + + "moqueries.org/runtime/moq" +) + +// The following type assertion assures that testmoqs.Generic_indexListGenType +// is mocked completely +var _ Generic_indexListGenType = (*MoqGeneric_indexListGenType_mock)(nil) + +// Generic_indexListGenType is the fabricated implementation type of this mock +// (emitted when mocking a collections of methods directly and not from an +// interface type) +type Generic_indexListGenType interface { + DoSomethingPtr() + DoSomethingElsePtr() + DoSomething() + DoSomethingElse() +} + +// MoqGeneric_indexListGenType holds the state of a moq of the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType struct { + Scene *moq.Scene + Config moq.Config + Moq *MoqGeneric_indexListGenType_mock + + ResultsByParams_DoSomethingPtr []MoqGeneric_indexListGenType_DoSomethingPtr_resultsByParams + ResultsByParams_DoSomethingElsePtr []MoqGeneric_indexListGenType_DoSomethingElsePtr_resultsByParams + ResultsByParams_DoSomething []MoqGeneric_indexListGenType_DoSomething_resultsByParams + ResultsByParams_DoSomethingElse []MoqGeneric_indexListGenType_DoSomethingElse_resultsByParams + + Runtime struct { + ParameterIndexing struct { + DoSomethingPtr struct{} + DoSomethingElsePtr struct{} + DoSomething struct{} + DoSomethingElse struct{} + } + } +} + +// MoqGeneric_indexListGenType_mock isolates the mock interface of the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_mock struct { + Moq *MoqGeneric_indexListGenType +} + +// MoqGeneric_indexListGenType_recorder isolates the recorder interface of the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_recorder struct { + Moq *MoqGeneric_indexListGenType +} + +// MoqGeneric_indexListGenType_DoSomethingPtr_params holds the params of the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingPtr_params struct{} + +// MoqGeneric_indexListGenType_DoSomethingPtr_paramsKey holds the map key +// params of the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingPtr_paramsKey struct { + Params struct{} + Hashes struct{} +} + +// MoqGeneric_indexListGenType_DoSomethingPtr_resultsByParams contains the +// results for a given set of parameters for the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingPtr_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqGeneric_indexListGenType_DoSomethingPtr_paramsKey]*MoqGeneric_indexListGenType_DoSomethingPtr_results +} + +// MoqGeneric_indexListGenType_DoSomethingPtr_doFn defines the type of function +// needed when calling AndDo for the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingPtr_doFn func() + +// MoqGeneric_indexListGenType_DoSomethingPtr_doReturnFn defines the type of +// function needed when calling DoReturnResults for the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingPtr_doReturnFn func() + +// MoqGeneric_indexListGenType_DoSomethingPtr_results holds the results of the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingPtr_results struct { + Params MoqGeneric_indexListGenType_DoSomethingPtr_params + Results []struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingPtr_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingPtr_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder routes recorded +// function calls to the MoqGeneric_indexListGenType moq +type MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder struct { + Params MoqGeneric_indexListGenType_DoSomethingPtr_params + AnyParams uint64 + Sequence bool + Results *MoqGeneric_indexListGenType_DoSomethingPtr_results + Moq *MoqGeneric_indexListGenType +} + +// MoqGeneric_indexListGenType_DoSomethingPtr_anyParams isolates the any params +// functions of the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingPtr_anyParams struct { + Recorder *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder +} + +// MoqGeneric_indexListGenType_DoSomethingElsePtr_params holds the params of +// the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElsePtr_params struct{} + +// MoqGeneric_indexListGenType_DoSomethingElsePtr_paramsKey holds the map key +// params of the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElsePtr_paramsKey struct { + Params struct{} + Hashes struct{} +} + +// MoqGeneric_indexListGenType_DoSomethingElsePtr_resultsByParams contains the +// results for a given set of parameters for the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElsePtr_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqGeneric_indexListGenType_DoSomethingElsePtr_paramsKey]*MoqGeneric_indexListGenType_DoSomethingElsePtr_results +} + +// MoqGeneric_indexListGenType_DoSomethingElsePtr_doFn defines the type of +// function needed when calling AndDo for the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElsePtr_doFn func() + +// MoqGeneric_indexListGenType_DoSomethingElsePtr_doReturnFn defines the type +// of function needed when calling DoReturnResults for the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElsePtr_doReturnFn func() + +// MoqGeneric_indexListGenType_DoSomethingElsePtr_results holds the results of +// the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElsePtr_results struct { + Params MoqGeneric_indexListGenType_DoSomethingElsePtr_params + Results []struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingElsePtr_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingElsePtr_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder routes recorded +// function calls to the MoqGeneric_indexListGenType moq +type MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder struct { + Params MoqGeneric_indexListGenType_DoSomethingElsePtr_params + AnyParams uint64 + Sequence bool + Results *MoqGeneric_indexListGenType_DoSomethingElsePtr_results + Moq *MoqGeneric_indexListGenType +} + +// MoqGeneric_indexListGenType_DoSomethingElsePtr_anyParams isolates the any +// params functions of the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElsePtr_anyParams struct { + Recorder *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder +} + +// MoqGeneric_indexListGenType_DoSomething_params holds the params of the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomething_params struct{} + +// MoqGeneric_indexListGenType_DoSomething_paramsKey holds the map key params +// of the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomething_paramsKey struct { + Params struct{} + Hashes struct{} +} + +// MoqGeneric_indexListGenType_DoSomething_resultsByParams contains the results +// for a given set of parameters for the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomething_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqGeneric_indexListGenType_DoSomething_paramsKey]*MoqGeneric_indexListGenType_DoSomething_results +} + +// MoqGeneric_indexListGenType_DoSomething_doFn defines the type of function +// needed when calling AndDo for the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomething_doFn func() + +// MoqGeneric_indexListGenType_DoSomething_doReturnFn defines the type of +// function needed when calling DoReturnResults for the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomething_doReturnFn func() + +// MoqGeneric_indexListGenType_DoSomething_results holds the results of the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomething_results struct { + Params MoqGeneric_indexListGenType_DoSomething_params + Results []struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomething_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomething_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqGeneric_indexListGenType_DoSomething_fnRecorder routes recorded function +// calls to the MoqGeneric_indexListGenType moq +type MoqGeneric_indexListGenType_DoSomething_fnRecorder struct { + Params MoqGeneric_indexListGenType_DoSomething_params + AnyParams uint64 + Sequence bool + Results *MoqGeneric_indexListGenType_DoSomething_results + Moq *MoqGeneric_indexListGenType +} + +// MoqGeneric_indexListGenType_DoSomething_anyParams isolates the any params +// functions of the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomething_anyParams struct { + Recorder *MoqGeneric_indexListGenType_DoSomething_fnRecorder +} + +// MoqGeneric_indexListGenType_DoSomethingElse_params holds the params of the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElse_params struct{} + +// MoqGeneric_indexListGenType_DoSomethingElse_paramsKey holds the map key +// params of the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElse_paramsKey struct { + Params struct{} + Hashes struct{} +} + +// MoqGeneric_indexListGenType_DoSomethingElse_resultsByParams contains the +// results for a given set of parameters for the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElse_resultsByParams struct { + AnyCount int + AnyParams uint64 + Results map[MoqGeneric_indexListGenType_DoSomethingElse_paramsKey]*MoqGeneric_indexListGenType_DoSomethingElse_results +} + +// MoqGeneric_indexListGenType_DoSomethingElse_doFn defines the type of +// function needed when calling AndDo for the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElse_doFn func() + +// MoqGeneric_indexListGenType_DoSomethingElse_doReturnFn defines the type of +// function needed when calling DoReturnResults for the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElse_doReturnFn func() + +// MoqGeneric_indexListGenType_DoSomethingElse_results holds the results of the +// Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElse_results struct { + Params MoqGeneric_indexListGenType_DoSomethingElse_params + Results []struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingElse_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingElse_doReturnFn + } + Index uint32 + Repeat *moq.RepeatVal +} + +// MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder routes recorded +// function calls to the MoqGeneric_indexListGenType moq +type MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder struct { + Params MoqGeneric_indexListGenType_DoSomethingElse_params + AnyParams uint64 + Sequence bool + Results *MoqGeneric_indexListGenType_DoSomethingElse_results + Moq *MoqGeneric_indexListGenType +} + +// MoqGeneric_indexListGenType_DoSomethingElse_anyParams isolates the any +// params functions of the Generic_indexListGenType type +type MoqGeneric_indexListGenType_DoSomethingElse_anyParams struct { + Recorder *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder +} + +// NewMoqGeneric_indexListGenType creates a new moq of the +// Generic_indexListGenType type +func NewMoqGeneric_indexListGenType(scene *moq.Scene, config *moq.Config) *MoqGeneric_indexListGenType { + if config == nil { + config = &moq.Config{} + } + m := &MoqGeneric_indexListGenType{ + Scene: scene, + Config: *config, + Moq: &MoqGeneric_indexListGenType_mock{}, + + Runtime: struct { + ParameterIndexing struct { + DoSomethingPtr struct{} + DoSomethingElsePtr struct{} + DoSomething struct{} + DoSomethingElse struct{} + } + }{ParameterIndexing: struct { + DoSomethingPtr struct{} + DoSomethingElsePtr struct{} + DoSomething struct{} + DoSomethingElse struct{} + }{ + DoSomethingPtr: struct{}{}, + DoSomethingElsePtr: struct{}{}, + DoSomething: struct{}{}, + DoSomethingElse: struct{}{}, + }}, + } + m.Moq.Moq = m + + scene.AddMoq(m) + return m +} + +// Mock returns the mock implementation of the Generic_indexListGenType type +func (m *MoqGeneric_indexListGenType) Mock() *MoqGeneric_indexListGenType_mock { return m.Moq } + +func (m *MoqGeneric_indexListGenType_mock) DoSomethingPtr() { + m.Moq.Scene.T.Helper() + params := MoqGeneric_indexListGenType_DoSomethingPtr_params{} + var results *MoqGeneric_indexListGenType_DoSomethingPtr_results + for _, resultsByParams := range m.Moq.ResultsByParams_DoSomethingPtr { + paramsKey := m.Moq.ParamsKey_DoSomethingPtr(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_DoSomethingPtr(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_DoSomethingPtr(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_DoSomethingPtr(params)) + } + } + + if result.DoFn != nil { + result.DoFn() + } + + if result.DoReturnFn != nil { + result.DoReturnFn() + } + return +} + +func (m *MoqGeneric_indexListGenType_mock) DoSomethingElsePtr() { + m.Moq.Scene.T.Helper() + params := MoqGeneric_indexListGenType_DoSomethingElsePtr_params{} + var results *MoqGeneric_indexListGenType_DoSomethingElsePtr_results + for _, resultsByParams := range m.Moq.ResultsByParams_DoSomethingElsePtr { + paramsKey := m.Moq.ParamsKey_DoSomethingElsePtr(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_DoSomethingElsePtr(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_DoSomethingElsePtr(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_DoSomethingElsePtr(params)) + } + } + + if result.DoFn != nil { + result.DoFn() + } + + if result.DoReturnFn != nil { + result.DoReturnFn() + } + return +} + +func (m *MoqGeneric_indexListGenType_mock) DoSomething() { + m.Moq.Scene.T.Helper() + params := MoqGeneric_indexListGenType_DoSomething_params{} + var results *MoqGeneric_indexListGenType_DoSomething_results + for _, resultsByParams := range m.Moq.ResultsByParams_DoSomething { + paramsKey := m.Moq.ParamsKey_DoSomething(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_DoSomething(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_DoSomething(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_DoSomething(params)) + } + } + + if result.DoFn != nil { + result.DoFn() + } + + if result.DoReturnFn != nil { + result.DoReturnFn() + } + return +} + +func (m *MoqGeneric_indexListGenType_mock) DoSomethingElse() { + m.Moq.Scene.T.Helper() + params := MoqGeneric_indexListGenType_DoSomethingElse_params{} + var results *MoqGeneric_indexListGenType_DoSomethingElse_results + for _, resultsByParams := range m.Moq.ResultsByParams_DoSomethingElse { + paramsKey := m.Moq.ParamsKey_DoSomethingElse(params, resultsByParams.AnyParams) + var ok bool + results, ok = resultsByParams.Results[paramsKey] + if ok { + break + } + } + if results == nil { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Unexpected call to %s", m.Moq.PrettyParams_DoSomethingElse(params)) + } + return + } + + i := int(atomic.AddUint32(&results.Index, 1)) - 1 + if i >= results.Repeat.ResultCount { + if !results.Repeat.AnyTimes { + if m.Moq.Config.Expectation == moq.Strict { + m.Moq.Scene.T.Fatalf("Too many calls to %s", m.Moq.PrettyParams_DoSomethingElse(params)) + } + return + } + i = results.Repeat.ResultCount - 1 + } + + result := results.Results[i] + if result.Sequence != 0 { + sequence := m.Moq.Scene.NextMockSequence() + if (!results.Repeat.AnyTimes && result.Sequence != sequence) || result.Sequence > sequence { + m.Moq.Scene.T.Fatalf("Call sequence does not match call to %s", m.Moq.PrettyParams_DoSomethingElse(params)) + } + } + + if result.DoFn != nil { + result.DoFn() + } + + if result.DoReturnFn != nil { + result.DoReturnFn() + } + return +} + +// OnCall returns the recorder implementation of the Generic_indexListGenType +// type +func (m *MoqGeneric_indexListGenType) OnCall() *MoqGeneric_indexListGenType_recorder { + return &MoqGeneric_indexListGenType_recorder{ + Moq: m, + } +} + +func (m *MoqGeneric_indexListGenType_recorder) DoSomethingPtr() *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder { + return &MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder{ + Params: MoqGeneric_indexListGenType_DoSomethingPtr_params{}, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder) Any() *MoqGeneric_indexListGenType_DoSomethingPtr_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomethingPtr(r.Params)) + return nil + } + return &MoqGeneric_indexListGenType_DoSomethingPtr_anyParams{Recorder: r} +} + +func (r *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder) Seq() *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomethingPtr(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder) NoSeq() *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomethingPtr(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder) ReturnResults() *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingPtr_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingPtr_doReturnFn + }{ + Values: &struct{}{}, + Sequence: sequence, + }) + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder) AndDo(fn MoqGeneric_indexListGenType_DoSomethingPtr_doFn) *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder) DoReturnResults(fn MoqGeneric_indexListGenType_DoSomethingPtr_doReturnFn) *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingPtr_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingPtr_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqGeneric_indexListGenType_DoSomethingPtr_resultsByParams + for n, res := range r.Moq.ResultsByParams_DoSomethingPtr { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqGeneric_indexListGenType_DoSomethingPtr_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqGeneric_indexListGenType_DoSomethingPtr_paramsKey]*MoqGeneric_indexListGenType_DoSomethingPtr_results{}, + } + r.Moq.ResultsByParams_DoSomethingPtr = append(r.Moq.ResultsByParams_DoSomethingPtr, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_DoSomethingPtr) { + copy(r.Moq.ResultsByParams_DoSomethingPtr[insertAt+1:], r.Moq.ResultsByParams_DoSomethingPtr[insertAt:0]) + r.Moq.ResultsByParams_DoSomethingPtr[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_DoSomethingPtr(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqGeneric_indexListGenType_DoSomethingPtr_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqGeneric_indexListGenType_DoSomethingPtr_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingPtr_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingPtr_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqGeneric_indexListGenType) PrettyParams_DoSomethingPtr(params MoqGeneric_indexListGenType_DoSomethingPtr_params) string { + return fmt.Sprintf("DoSomethingPtr()") +} + +func (m *MoqGeneric_indexListGenType) ParamsKey_DoSomethingPtr(params MoqGeneric_indexListGenType_DoSomethingPtr_params, anyParams uint64) MoqGeneric_indexListGenType_DoSomethingPtr_paramsKey { + m.Scene.T.Helper() + return MoqGeneric_indexListGenType_DoSomethingPtr_paramsKey{ + Params: struct{}{}, + Hashes: struct{}{}, + } +} + +func (m *MoqGeneric_indexListGenType_recorder) DoSomethingElsePtr() *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder { + return &MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder{ + Params: MoqGeneric_indexListGenType_DoSomethingElsePtr_params{}, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder) Any() *MoqGeneric_indexListGenType_DoSomethingElsePtr_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomethingElsePtr(r.Params)) + return nil + } + return &MoqGeneric_indexListGenType_DoSomethingElsePtr_anyParams{Recorder: r} +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder) Seq() *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomethingElsePtr(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder) NoSeq() *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomethingElsePtr(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder) ReturnResults() *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingElsePtr_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingElsePtr_doReturnFn + }{ + Values: &struct{}{}, + Sequence: sequence, + }) + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder) AndDo(fn MoqGeneric_indexListGenType_DoSomethingElsePtr_doFn) *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder) DoReturnResults(fn MoqGeneric_indexListGenType_DoSomethingElsePtr_doReturnFn) *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingElsePtr_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingElsePtr_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqGeneric_indexListGenType_DoSomethingElsePtr_resultsByParams + for n, res := range r.Moq.ResultsByParams_DoSomethingElsePtr { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqGeneric_indexListGenType_DoSomethingElsePtr_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqGeneric_indexListGenType_DoSomethingElsePtr_paramsKey]*MoqGeneric_indexListGenType_DoSomethingElsePtr_results{}, + } + r.Moq.ResultsByParams_DoSomethingElsePtr = append(r.Moq.ResultsByParams_DoSomethingElsePtr, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_DoSomethingElsePtr) { + copy(r.Moq.ResultsByParams_DoSomethingElsePtr[insertAt+1:], r.Moq.ResultsByParams_DoSomethingElsePtr[insertAt:0]) + r.Moq.ResultsByParams_DoSomethingElsePtr[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_DoSomethingElsePtr(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqGeneric_indexListGenType_DoSomethingElsePtr_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqGeneric_indexListGenType_DoSomethingElsePtr_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingElsePtr_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingElsePtr_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqGeneric_indexListGenType) PrettyParams_DoSomethingElsePtr(params MoqGeneric_indexListGenType_DoSomethingElsePtr_params) string { + return fmt.Sprintf("DoSomethingElsePtr()") +} + +func (m *MoqGeneric_indexListGenType) ParamsKey_DoSomethingElsePtr(params MoqGeneric_indexListGenType_DoSomethingElsePtr_params, anyParams uint64) MoqGeneric_indexListGenType_DoSomethingElsePtr_paramsKey { + m.Scene.T.Helper() + return MoqGeneric_indexListGenType_DoSomethingElsePtr_paramsKey{ + Params: struct{}{}, + Hashes: struct{}{}, + } +} + +func (m *MoqGeneric_indexListGenType_recorder) DoSomething() *MoqGeneric_indexListGenType_DoSomething_fnRecorder { + return &MoqGeneric_indexListGenType_DoSomething_fnRecorder{ + Params: MoqGeneric_indexListGenType_DoSomething_params{}, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqGeneric_indexListGenType_DoSomething_fnRecorder) Any() *MoqGeneric_indexListGenType_DoSomething_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomething(r.Params)) + return nil + } + return &MoqGeneric_indexListGenType_DoSomething_anyParams{Recorder: r} +} + +func (r *MoqGeneric_indexListGenType_DoSomething_fnRecorder) Seq() *MoqGeneric_indexListGenType_DoSomething_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomething(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomething_fnRecorder) NoSeq() *MoqGeneric_indexListGenType_DoSomething_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomething(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomething_fnRecorder) ReturnResults() *MoqGeneric_indexListGenType_DoSomething_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomething_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomething_doReturnFn + }{ + Values: &struct{}{}, + Sequence: sequence, + }) + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomething_fnRecorder) AndDo(fn MoqGeneric_indexListGenType_DoSomething_doFn) *MoqGeneric_indexListGenType_DoSomething_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomething_fnRecorder) DoReturnResults(fn MoqGeneric_indexListGenType_DoSomething_doReturnFn) *MoqGeneric_indexListGenType_DoSomething_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomething_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomething_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomething_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqGeneric_indexListGenType_DoSomething_resultsByParams + for n, res := range r.Moq.ResultsByParams_DoSomething { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqGeneric_indexListGenType_DoSomething_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqGeneric_indexListGenType_DoSomething_paramsKey]*MoqGeneric_indexListGenType_DoSomething_results{}, + } + r.Moq.ResultsByParams_DoSomething = append(r.Moq.ResultsByParams_DoSomething, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_DoSomething) { + copy(r.Moq.ResultsByParams_DoSomething[insertAt+1:], r.Moq.ResultsByParams_DoSomething[insertAt:0]) + r.Moq.ResultsByParams_DoSomething[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_DoSomething(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqGeneric_indexListGenType_DoSomething_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqGeneric_indexListGenType_DoSomething_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqGeneric_indexListGenType_DoSomething_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomething_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomething_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqGeneric_indexListGenType) PrettyParams_DoSomething(params MoqGeneric_indexListGenType_DoSomething_params) string { + return fmt.Sprintf("DoSomething()") +} + +func (m *MoqGeneric_indexListGenType) ParamsKey_DoSomething(params MoqGeneric_indexListGenType_DoSomething_params, anyParams uint64) MoqGeneric_indexListGenType_DoSomething_paramsKey { + m.Scene.T.Helper() + return MoqGeneric_indexListGenType_DoSomething_paramsKey{ + Params: struct{}{}, + Hashes: struct{}{}, + } +} + +func (m *MoqGeneric_indexListGenType_recorder) DoSomethingElse() *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder { + return &MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder{ + Params: MoqGeneric_indexListGenType_DoSomethingElse_params{}, + Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, + Moq: m.Moq, + } +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder) Any() *MoqGeneric_indexListGenType_DoSomethingElse_anyParams { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Any functions must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomethingElse(r.Params)) + return nil + } + return &MoqGeneric_indexListGenType_DoSomethingElse_anyParams{Recorder: r} +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder) Seq() *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("Seq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomethingElse(r.Params)) + return nil + } + r.Sequence = true + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder) NoSeq() *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Moq.Scene.T.Fatalf("NoSeq must be called before ReturnResults or DoReturnResults calls, recording %s", r.Moq.PrettyParams_DoSomethingElse(r.Params)) + return nil + } + r.Sequence = false + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder) ReturnResults() *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingElse_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingElse_doReturnFn + }{ + Values: &struct{}{}, + Sequence: sequence, + }) + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder) AndDo(fn MoqGeneric_indexListGenType_DoSomethingElse_doFn) *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") + return nil + } + last := &r.Results.Results[len(r.Results.Results)-1] + last.DoFn = fn + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder) DoReturnResults(fn MoqGeneric_indexListGenType_DoSomethingElse_doReturnFn) *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder { + r.Moq.Scene.T.Helper() + r.FindResults() + + var sequence uint32 + if r.Sequence { + sequence = r.Moq.Scene.NextRecorderSequence() + } + + r.Results.Results = append(r.Results.Results, struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingElse_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingElse_doReturnFn + }{Sequence: sequence, DoReturnFn: fn}) + return r +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder) FindResults() { + r.Moq.Scene.T.Helper() + if r.Results != nil { + r.Results.Repeat.Increment(r.Moq.Scene.T) + return + } + + anyCount := bits.OnesCount64(r.AnyParams) + insertAt := -1 + var results *MoqGeneric_indexListGenType_DoSomethingElse_resultsByParams + for n, res := range r.Moq.ResultsByParams_DoSomethingElse { + if res.AnyParams == r.AnyParams { + results = &res + break + } + if res.AnyCount > anyCount { + insertAt = n + } + } + if results == nil { + results = &MoqGeneric_indexListGenType_DoSomethingElse_resultsByParams{ + AnyCount: anyCount, + AnyParams: r.AnyParams, + Results: map[MoqGeneric_indexListGenType_DoSomethingElse_paramsKey]*MoqGeneric_indexListGenType_DoSomethingElse_results{}, + } + r.Moq.ResultsByParams_DoSomethingElse = append(r.Moq.ResultsByParams_DoSomethingElse, *results) + if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_DoSomethingElse) { + copy(r.Moq.ResultsByParams_DoSomethingElse[insertAt+1:], r.Moq.ResultsByParams_DoSomethingElse[insertAt:0]) + r.Moq.ResultsByParams_DoSomethingElse[insertAt] = *results + } + } + + paramsKey := r.Moq.ParamsKey_DoSomethingElse(r.Params, r.AnyParams) + + var ok bool + r.Results, ok = results.Results[paramsKey] + if !ok { + r.Results = &MoqGeneric_indexListGenType_DoSomethingElse_results{ + Params: r.Params, + Results: nil, + Index: 0, + Repeat: &moq.RepeatVal{}, + } + results.Results[paramsKey] = r.Results + } + + r.Results.Repeat.Increment(r.Moq.Scene.T) +} + +func (r *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqGeneric_indexListGenType_DoSomethingElse_fnRecorder { + r.Moq.Scene.T.Helper() + if r.Results == nil { + r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") + return nil + } + r.Results.Repeat.Repeat(r.Moq.Scene.T, repeaters) + last := r.Results.Results[len(r.Results.Results)-1] + for n := 0; n < r.Results.Repeat.ResultCount-1; n++ { + if r.Sequence { + last = struct { + Values *struct{} + Sequence uint32 + DoFn MoqGeneric_indexListGenType_DoSomethingElse_doFn + DoReturnFn MoqGeneric_indexListGenType_DoSomethingElse_doReturnFn + }{ + Values: last.Values, + Sequence: r.Moq.Scene.NextRecorderSequence(), + } + } + r.Results.Results = append(r.Results.Results, last) + } + return r +} + +func (m *MoqGeneric_indexListGenType) PrettyParams_DoSomethingElse(params MoqGeneric_indexListGenType_DoSomethingElse_params) string { + return fmt.Sprintf("DoSomethingElse()") +} + +func (m *MoqGeneric_indexListGenType) ParamsKey_DoSomethingElse(params MoqGeneric_indexListGenType_DoSomethingElse_params, anyParams uint64) MoqGeneric_indexListGenType_DoSomethingElse_paramsKey { + m.Scene.T.Helper() + return MoqGeneric_indexListGenType_DoSomethingElse_paramsKey{ + Params: struct{}{}, + Hashes: struct{}{}, + } +} + +// Reset resets the state of the moq +func (m *MoqGeneric_indexListGenType) Reset() { + m.ResultsByParams_DoSomethingPtr = nil + m.ResultsByParams_DoSomethingElsePtr = nil + m.ResultsByParams_DoSomething = nil + m.ResultsByParams_DoSomethingElse = nil +} + +// AssertExpectationsMet asserts that all expectations have been met +func (m *MoqGeneric_indexListGenType) AssertExpectationsMet() { + m.Scene.T.Helper() + for _, res := range m.ResultsByParams_DoSomethingPtr { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_DoSomethingPtr(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_DoSomethingElsePtr { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_DoSomethingElsePtr(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_DoSomething { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_DoSomething(results.Params)) + } + } + } + for _, res := range m.ResultsByParams_DoSomethingElse { + for _, results := range res.Results { + missing := results.Repeat.MinTimes - int(atomic.LoadUint32(&results.Index)) + if missing > 0 { + m.Scene.T.Errorf("Expected %d additional call(s) to %s", missing, m.PrettyParams_DoSomethingElse(results.Params)) + } + } + } +} diff --git a/pkg/testmoqs/types.go b/pkg/testmoqs/types.go index 7a2b2bc..c362f1e 100644 --- a/pkg/testmoqs/types.go +++ b/pkg/testmoqs/types.go @@ -25,3 +25,13 @@ type Reduced interface { Usual(sParam string, bParam bool) (sResult string, err error) notSoUsual() } + +type Generic[T any, V any] struct{} + +func (g *Generic[T, V]) DoSomethingPtr() {} + +func (g *Generic[X, Y]) DoSomethingElsePtr() {} + +func (g Generic[T, V]) DoSomething() {} + +func (g Generic[X, Y]) DoSomethingElse() {} diff --git a/pkg/testmoqs/types_test.go b/pkg/testmoqs/types_test.go index 2aa6191..e170ba7 100644 --- a/pkg/testmoqs/types_test.go +++ b/pkg/testmoqs/types_test.go @@ -49,8 +49,8 @@ func TestPackageGeneration(t *testing.T) { moqs[e.Name()] = struct{}{} } - if len(moqs) != 4 { - t.Errorf("got %#v mocks, want 3", moqs) + if len(moqs) != 5 { + t.Errorf("got %#v mocks, want 5", moqs) } if _, ok := moqs["moq_passbyrefsimple_stargentype.go"]; !ok { t.Errorf("got %#v, want to contain moq_passbyrefsimple_stargentype.go", moqs) @@ -64,6 +64,9 @@ func TestPackageGeneration(t *testing.T) { if _, ok := moqs["moq_reduced.go"]; !ok { t.Errorf("got %#v, want to contain moq_standalonefunc_gentype.go", moqs) } + if _, ok := moqs["moq_generic_indexlistgentype.go"]; !ok { + t.Errorf("got %#v, want to contain moq_standalonefunc_gentype.go", moqs) + } // Minimal testing here just to make sure the right types were found (full // mock testing in the generator package) }