diff --git a/.circleci/config.yml b/.circleci/config.yml index 869d8bd..d2a26fd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,7 @@ orbs: executors: go: docker: - - image: cimg/go:1.19 + - image: cimg/go:1.21 jobs: build: diff --git a/ast/dsl.go b/ast/dsl.go index e3d4736..f9223e3 100644 --- a/ast/dsl.go +++ b/ast/dsl.go @@ -3,6 +3,7 @@ package ast import ( "fmt" "go/token" + "slices" "strconv" "strings" @@ -94,10 +95,21 @@ func Call(fun dst.Expr) CallDSL { // Args specifies the arguments to a call func (d CallDSL) Args(args ...dst.Expr) CallDSL { - d.Obj.Args = args + d.Obj.Args = removeNils(args) return d } +// Decs specifies the decorations for a call +func (d CallDSL) Decs(decs dst.CallExprDecorations) CallDSL { + d.Obj.Decs = decs + return d +} + +// CallDecs creates a dst.CallExprDecorations +func CallDecs(before, after dst.SpaceType) dst.CallExprDecorations { + return dst.CallExprDecorations{NodeDecs: dst.NodeDecs{Before: before, After: after}} +} + // Ellipsis specifies if the last argument is variadic func (d CallDSL) Ellipsis(ellipsis bool) CallDSL { d.Obj.Ellipsis = ellipsis @@ -114,7 +126,7 @@ func Comp(typ dst.Expr) CompDSL { // Elts defines the elements of a CompDSL func (d CompDSL) Elts(elts ...dst.Expr) CompDSL { - d.Obj.Elts = elts + d.Obj.Elts = removeNils(elts) return d } @@ -238,7 +250,7 @@ func (d FnDSL) TypeParams(fieldList *dst.FieldList) FnDSL { // Body specifies the body for a function func (d FnDSL) Body(list ...dst.Stmt) FnDSL { - d.Obj.Body = Block(list...).Obj + d.Obj.Body = Block(removeNils(list)...).Obj return d } @@ -276,7 +288,7 @@ func (d FnTypeDSL) Results(resultFieldList *dst.FieldList) FnTypeDSL { return d } -// ForDSL translatesto a dst.ForStmt +// ForDSL translates to a dst.ForStmt type ForDSL struct{ Obj *dst.ForStmt } // For returns a new ForDSL @@ -317,6 +329,18 @@ func IdPath(name, path string) *dst.Ident { return &dst.Ident{Name: name, Path: path} } +// IdDecs adds decorations to a dst.Ident +func IdDecs(i *dst.Ident, decs dst.IdentDecorations) *dst.Ident { + return &dst.Ident{Name: i.Name, Decs: decs} +} + +// IdentDecs returns a dst.IdentDecorations +func IdentDecs(before, after dst.SpaceType) dst.IdentDecorations { + return dst.IdentDecorations{ + NodeDecs: dst.NodeDecs{Before: before, After: after}, + } +} + // IfDSL translates to a dst.IfStmt type IfDSL struct{ Obj *dst.IfStmt } @@ -325,6 +349,12 @@ func If(cond dst.Expr) IfDSL { return IfDSL{Obj: &dst.IfStmt{Cond: cond}} } +// Init specifies the initialization statement of the If +func (d IfDSL) Init(init dst.Stmt) IfDSL { + d.Obj.Init = init + return d +} + // Body specifies the body of the If func (d IfDSL) Body(list ...dst.Stmt) IfDSL { d.Obj.Body = Block(list...).Obj @@ -412,6 +442,11 @@ func (d KeyValueDecsDSL) After(after dst.SpaceType) KeyValueDecsDSL { return d } +// LitBool returns a dst.Ident with a literal bool value +func LitBool(value bool) *dst.Ident { + return Id(strconv.FormatBool(value)) +} + // LitInt returns a dst.BasicLit with a literal int value func LitInt(value int) *dst.BasicLit { return &dst.BasicLit{Kind: token.INT, Value: strconv.Itoa(value)} @@ -533,6 +568,19 @@ func (d SelDSL) Dot(sel *dst.Ident) SelDSL { return d } +// Decs add decorations to a SelDSL +func (d SelDSL) Decs(decs dst.SelectorExprDecorations) SelDSL { + d.Obj.Decs = decs + return d +} + +// SelDecs returns a dst.SelectorExprDecorations +func SelDecs(before, after dst.SpaceType) dst.SelectorExprDecorations { + return dst.SelectorExprDecorations{ + NodeDecs: dst.NodeDecs{Before: before, After: after}, + } +} + // SliceExprDSL translates to a dst.SliceExpr type SliceExprDSL struct{ Obj *dst.SliceExpr } @@ -558,9 +606,27 @@ func SliceType(elt dst.Expr) *dst.ArrayType { return &dst.ArrayType{Elt: elt} } -// Star returns a dst.StarExpr -func Star(x dst.Expr) *dst.StarExpr { - return &dst.StarExpr{X: x} +// StarDSL translates to a dst.StarExpr +type StarDSL struct{ Obj *dst.StarExpr } + +// Star returns a new star expression +func Star(x dst.Expr) StarDSL { + return StarDSL{ + Obj: &dst.StarExpr{X: x}, + } +} + +// Decs adds decorations to a StarDSL +func (d StarDSL) Decs(decs dst.StarExprDecorations) StarDSL { + d.Obj.Decs = decs + return d +} + +// StarDecs returns a dst.StarExprDecorations +func StarDecs(before, after dst.SpaceType) dst.StarExprDecorations { + return dst.StarExprDecorations{ + NodeDecs: dst.NodeDecs{Before: before, After: after}, + } } // Struct returns a dst.StructType @@ -661,3 +727,10 @@ func (d VarDeclDSL) Decs(decs dst.GenDeclDecorations) VarDeclDSL { func emptyFieldList() *dst.FieldList { return &dst.FieldList{Opening: true, Closing: true} } + +func removeNils[S ~[]E, E comparable](s S) S { + return slices.DeleteFunc(s, func(e E) bool { + var nilE E + return e == nilE + }) +} diff --git a/ast/dsl_test.go b/ast/dsl_test.go index 5790809..f66850c 100644 --- a/ast/dsl_test.go +++ b/ast/dsl_test.go @@ -191,14 +191,49 @@ func TestCall(t *testing.T) { t.Run("complete", func(t *testing.T) { // ASSEMBLE + decs := dst.CallExprDecorations{NodeDecs: dst.NodeDecs{Before: dst.EmptyLine}} expected := &dst.CallExpr{ Fun: id1, Args: []dst.Expr{id2, id3}, Ellipsis: true, + Decs: decs, } // ACT - actual := ast.Call(id1).Args(id2, id3).Ellipsis(true).Obj + actual := ast.Call(id1).Args(id2, id3).Ellipsis(true).Decs(decs).Obj + + // ASSERT + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %#v, want %#v", actual, expected) + } + }) + + t.Run("nil elements are removed", func(t *testing.T) { + // ASSEMBLE + expected := &dst.CallExpr{ + Fun: id1, + Args: []dst.Expr{id2, id3}, + } + + // ACT + actual := ast.Call(id1).Args(id2, nil, id3).Obj + + // ASSERT + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %#v, want %#v", actual, expected) + } + }) +} + +func TestCallDecs(t *testing.T) { + t.Run("simple", func(t *testing.T) { + // ASSEMBLE + expected := dst.CallExprDecorations{ + NodeDecs: dst.NodeDecs{Before: dst.EmptyLine}, + } + + // ACT + actual := ast.CallDecs(dst.EmptyLine, dst.None) // ASSERT if !reflect.DeepEqual(actual, expected) { @@ -238,6 +273,22 @@ func TestComp(t *testing.T) { t.Errorf("got %#v, want %#v", actual, expected) } }) + + t.Run("nil elements are removed", func(t *testing.T) { + // ASSEMBLE + expected := &dst.CompositeLit{ + Type: id1, + Elts: []dst.Expr{id2, id3}, + } + + // ACT + actual := ast.Comp(id1).Elts(id2, nil, id3).Obj + + // ASSERT + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %#v, want %#v", actual, expected) + } + }) } func TestContinue(t *testing.T) { @@ -476,6 +527,23 @@ func TestFn(t *testing.T) { t.Errorf("got %#v, want %#v", actual, expected) } }) + + t.Run("removes nils", func(t *testing.T) { + // ASSEMBLE + expected := &dst.FuncDecl{ + Name: dst.NewIdent("fn1"), + Type: &dst.FuncType{}, + Body: &dst.BlockStmt{List: []dst.Stmt{assign1, assign2}}, + } + + // ACT + actual := ast.Fn("fn1").Body(assign1, nil, assign2).Obj + + // ASSERT + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %#v, want %#v", actual, expected) + } + }) } func TestFnLit(t *testing.T) { @@ -617,6 +685,41 @@ func TestIdPath(t *testing.T) { }) } +func TestIdDecs(t *testing.T) { + t.Run("simple", func(t *testing.T) { + // ASSEMBLE + decs := dst.IdentDecorations{ + NodeDecs: dst.NodeDecs{Before: dst.EmptyLine, After: dst.NewLine}, + } + expected := &dst.Ident{Name: "xyz", Decs: decs} + + // ACT + actual := ast.IdDecs(&dst.Ident{Name: "xyz"}, decs) + + // ASSERT + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %#v, want %#v", actual, expected) + } + }) +} + +func TestIdentDecs(t *testing.T) { + t.Run("simple", func(t *testing.T) { + // ASSEMBLE + expected := dst.IdentDecorations{ + NodeDecs: dst.NodeDecs{Before: dst.EmptyLine, After: dst.NewLine}, + } + + // ACT + actual := ast.IdentDecs(dst.EmptyLine, dst.NewLine) + + // ASSERT + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %#v, want %#v", actual, expected) + } + }) +} + func TestIncStmt(t *testing.T) { t.Run("simple", func(t *testing.T) { // ASSEMBLE @@ -679,7 +782,9 @@ func TestIf(t *testing.T) { decs := dst.IfStmtDecorations{ NodeDecs: dst.NodeDecs{After: dst.EmptyLine}, } + init := &dst.ExprStmt{X: id1} expected := &dst.IfStmt{ + Init: init, Cond: id1, Body: &dst.BlockStmt{List: []dst.Stmt{assign1, assign2}}, Else: assign3, @@ -687,7 +792,7 @@ func TestIf(t *testing.T) { } // ACT - actual := ast.If(id1).Body(assign1, assign2).Else(assign3).Decs(decs).Obj + actual := ast.If(id1).Init(init).Body(assign1, assign2).Else(assign3).Decs(decs).Obj // ASSERT if !reflect.DeepEqual(actual, expected) { @@ -795,6 +900,21 @@ func TestKeyValueDecs(t *testing.T) { }) } +func TestLitBool(t *testing.T) { + t.Run("simple", func(t *testing.T) { + // ASSEMBLE + expected := &dst.Ident{Name: "true"} + + // ACT + actual := ast.LitBool(true) + + // ASSERT + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %#v, want %#v", actual, expected) + } + }) +} + func TestLitInt(t *testing.T) { t.Run("simple", func(t *testing.T) { // ASSEMBLE @@ -1042,10 +1162,28 @@ func TestSel(t *testing.T) { t.Run("complete", func(t *testing.T) { // ASSEMBLE - expected := &dst.SelectorExpr{X: id1, Sel: id2} + decs := dst.SelectorExprDecorations{NodeDecs: dst.NodeDecs{Before: dst.NewLine}} + expected := &dst.SelectorExpr{X: id1, Sel: id2, Decs: decs} + + // ACT + actual := ast.Sel(id1).Dot(id2).Decs(decs).Obj + + // ASSERT + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %#v, want %#v", actual, expected) + } + }) +} + +func TestSelDecs(t *testing.T) { + t.Run("simple", func(t *testing.T) { + // ASSEMBLE + expected := dst.SelectorExprDecorations{ + NodeDecs: dst.NodeDecs{Before: dst.EmptyLine, After: dst.NewLine}, + } // ACT - actual := ast.Sel(id1).Dot(id2).Obj + actual := ast.SelDecs(dst.EmptyLine, dst.NewLine) // ASSERT if !reflect.DeepEqual(actual, expected) { @@ -1103,7 +1241,38 @@ func TestStar(t *testing.T) { expected := &dst.StarExpr{X: id1} // ACT - actual := ast.Star(id1) + actual := ast.Star(id1).Obj + + // ASSERT + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %#v, want %#v", actual, expected) + } + }) + + t.Run("complete", func(t *testing.T) { + // ASSEMBLE + decs := dst.StarExprDecorations{NodeDecs: dst.NodeDecs{Before: dst.EmptyLine}} + expected := &dst.StarExpr{X: id1, Decs: decs} + + // ACT + actual := ast.Star(id1).Decs(decs).Obj + + // ASSERT + if !reflect.DeepEqual(actual, expected) { + t.Errorf("got %#v, want %#v", actual, expected) + } + }) +} + +func TestStarDecs(t *testing.T) { + t.Run("simple", func(t *testing.T) { + // ASSEMBLE + expected := dst.StarExprDecorations{ + NodeDecs: dst.NodeDecs{Before: dst.EmptyLine, After: dst.NewLine}, + } + + // ACT + actual := ast.StarDecs(dst.EmptyLine, dst.NewLine) // ASSERT if !reflect.DeepEqual(actual, expected) { diff --git a/ast/moq_loadfn_test.go b/ast/moq_loadfn_test.go index 966d5ea..608eb1f 100644 --- a/ast/moq_loadfn_test.go +++ b/ast/moq_loadfn_test.go @@ -4,33 +4,33 @@ package ast_test import ( "fmt" - "math/bits" - "sync/atomic" "golang.org/x/tools/go/packages" "moqueries.org/cli/ast" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqLoadFn holds the state of a moq of the LoadFn type type moqLoadFn struct { - scene *moq.Scene - config moq.Config - moq *moqLoadFn_mock + moq *impl.Moq[ + *moqLoadFn_adaptor, + moqLoadFn_params, + moqLoadFn_paramsKey, + moqLoadFn_results, + ] - resultsByParams []moqLoadFn_resultsByParams + runtime moqLoadFn_runtime +} - runtime struct { - parameterIndexing struct { - cfg moq.ParamIndexing - patterns moq.ParamIndexing - } - } +// moqLoadFn_runtime holds runtime configuration for the LoadFn type +type moqLoadFn_runtime struct { + parameterIndexing moqLoadFn_paramIndexing } -// moqLoadFn_mock isolates the mock interface of the LoadFn type -type moqLoadFn_mock struct { +// moqLoadFn_adaptor adapts moqLoadFn as needed by the runtime +type moqLoadFn_adaptor struct { moq *moqLoadFn } @@ -49,12 +49,17 @@ type moqLoadFn_paramsKey struct { } } -// moqLoadFn_resultsByParams contains the results for a given set of parameters +// moqLoadFn_results holds the results of the LoadFn type +type moqLoadFn_results struct { + result1 []*packages.Package + result2 error +} + +// moqLoadFn_paramIndexing holds the parameter indexing runtime configuration // for the LoadFn type -type moqLoadFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqLoadFn_paramsKey]*moqLoadFn_results +type moqLoadFn_paramIndexing struct { + cfg moq.ParamIndexing + patterns moq.ParamIndexing } // moqLoadFn_doFn defines the type of function needed when calling andDo for @@ -65,60 +70,38 @@ type moqLoadFn_doFn func(cfg *packages.Config, patterns ...string) // doReturnResults for the LoadFn type type moqLoadFn_doReturnFn func(cfg *packages.Config, patterns ...string) ([]*packages.Package, error) -// moqLoadFn_results holds the results of the LoadFn type -type moqLoadFn_results struct { - params moqLoadFn_params - results []struct { - values *struct { - result1 []*packages.Package - result2 error - } - sequence uint32 - doFn moqLoadFn_doFn - doReturnFn moqLoadFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqLoadFn_fnRecorder routes recorded function calls to the moqLoadFn moq -type moqLoadFn_fnRecorder struct { - params moqLoadFn_params - anyParams uint64 - sequence bool - results *moqLoadFn_results - moq *moqLoadFn +// moqLoadFn_recorder routes recorded function calls to the moqLoadFn moq +type moqLoadFn_recorder struct { + recorder *impl.Recorder[ + *moqLoadFn_adaptor, + moqLoadFn_params, + moqLoadFn_paramsKey, + moqLoadFn_results, + ] } // moqLoadFn_anyParams isolates the any params functions of the LoadFn type type moqLoadFn_anyParams struct { - recorder *moqLoadFn_fnRecorder + recorder *moqLoadFn_recorder } // newMoqLoadFn creates a new moq of the LoadFn type func newMoqLoadFn(scene *moq.Scene, config *moq.Config) *moqLoadFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqLoadFn_adaptor{} m := &moqLoadFn{ - scene: scene, - config: *config, - moq: &moqLoadFn_mock{}, - - runtime: struct { - parameterIndexing struct { - cfg moq.ParamIndexing - patterns moq.ParamIndexing - } - }{parameterIndexing: struct { - cfg moq.ParamIndexing - patterns moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqLoadFn_adaptor, + moqLoadFn_params, + moqLoadFn_paramsKey, + moqLoadFn_results, + ](scene, adaptor1, config), + + runtime: moqLoadFn_runtime{parameterIndexing: moqLoadFn_paramIndexing{ cfg: moq.ParamIndexByHash, patterns: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -127,278 +110,114 @@ func newMoqLoadFn(scene *moq.Scene, config *moq.Config) *moqLoadFn { // mock returns the moq implementation of the LoadFn type func (m *moqLoadFn) mock() ast.LoadFn { return func(cfg *packages.Config, patterns ...string) ([]*packages.Package, error) { - m.scene.T.Helper() - moq := &moqLoadFn_mock{moq: m} - return moq.fn(cfg, patterns...) - } -} - -func (m *moqLoadFn_mock) fn(cfg *packages.Config, patterns ...string) (result1 []*packages.Package, result2 error) { - m.moq.scene.T.Helper() - params := moqLoadFn_params{ - cfg: cfg, - patterns: patterns, - } - var results *moqLoadFn_results - 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 + m.moq.Scene.T.Helper() + params := moqLoadFn_params{ + cfg: cfg, + patterns: patterns, } - 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)) + var result1 []*packages.Package + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } + return result1, result2 } - - if result.doFn != nil { - result.doFn(cfg, patterns...) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(cfg, patterns...) - } - return } -func (m *moqLoadFn) onCall(cfg *packages.Config, patterns ...string) *moqLoadFn_fnRecorder { - return &moqLoadFn_fnRecorder{ - params: moqLoadFn_params{ +func (m *moqLoadFn) onCall(cfg *packages.Config, patterns ...string) *moqLoadFn_recorder { + return &moqLoadFn_recorder{ + recorder: m.moq.OnCall(moqLoadFn_params{ cfg: cfg, patterns: patterns, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqLoadFn_fnRecorder) any() *moqLoadFn_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(r.params)) +func (r *moqLoadFn_recorder) any() *moqLoadFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqLoadFn_anyParams{recorder: r} } -func (a *moqLoadFn_anyParams) cfg() *moqLoadFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqLoadFn_anyParams) cfg() *moqLoadFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqLoadFn_anyParams) patterns() *moqLoadFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqLoadFn_anyParams) patterns() *moqLoadFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqLoadFn_fnRecorder) seq() *moqLoadFn_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(r.params)) +func (r *moqLoadFn_recorder) seq() *moqLoadFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqLoadFn_fnRecorder) noSeq() *moqLoadFn_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(r.params)) +func (r *moqLoadFn_recorder) noSeq() *moqLoadFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqLoadFn_fnRecorder) returnResults(result1 []*packages.Package, result2 error) *moqLoadFn_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 []*packages.Package - result2 error - } - sequence uint32 - doFn moqLoadFn_doFn - doReturnFn moqLoadFn_doReturnFn - }{ - values: &struct { - result1 []*packages.Package - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqLoadFn_recorder) returnResults(result1 []*packages.Package, result2 error) *moqLoadFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqLoadFn_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqLoadFn_fnRecorder) andDo(fn moqLoadFn_doFn) *moqLoadFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqLoadFn_recorder) andDo(fn moqLoadFn_doFn) *moqLoadFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqLoadFn_params) { + fn(params.cfg, params.patterns...) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqLoadFn_fnRecorder) doReturnResults(fn moqLoadFn_doReturnFn) *moqLoadFn_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 []*packages.Package - result2 error +func (r *moqLoadFn_recorder) doReturnResults(fn moqLoadFn_doReturnFn) *moqLoadFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqLoadFn_params) *moqLoadFn_results { + result1, result2 := fn(params.cfg, params.patterns...) + return &moqLoadFn_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqLoadFn_doFn - doReturnFn moqLoadFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqLoadFn_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 *moqLoadFn_resultsByParams - 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 = &moqLoadFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqLoadFn_paramsKey]*moqLoadFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqLoadFn_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 *moqLoadFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqLoadFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqLoadFn_recorder) repeat(repeaters ...moq.Repeater) *moqLoadFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 []*packages.Package - result2 error - } - sequence uint32 - doFn moqLoadFn_doFn - doReturnFn moqLoadFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqLoadFn) prettyParams(params moqLoadFn_params) string { +func (*moqLoadFn_adaptor) PrettyParams(params moqLoadFn_params) string { return fmt.Sprintf("LoadFn(%#v, %#v)", params.cfg, params.patterns) } -func (m *moqLoadFn) paramsKey(params moqLoadFn_params, anyParams uint64) moqLoadFn_paramsKey { - m.scene.T.Helper() - var cfgUsed *packages.Config - var cfgUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.cfg == moq.ParamIndexByValue { - cfgUsed = params.cfg - } else { - cfgUsedHash = hash.DeepHash(params.cfg) - } - } - var patternsUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.patterns == moq.ParamIndexByValue { - m.scene.T.Fatalf("The patterns parameter can't be indexed by value") - } - patternsUsedHash = hash.DeepHash(params.patterns) - } +func (a *moqLoadFn_adaptor) ParamsKey(params moqLoadFn_params, anyParams uint64) moqLoadFn_paramsKey { + a.moq.moq.Scene.T.Helper() + cfgUsed, cfgUsedHash := impl.ParamKey( + params.cfg, 1, a.moq.runtime.parameterIndexing.cfg, anyParams) + patternsUsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.patterns, "patterns", 2, a.moq.runtime.parameterIndexing.patterns, anyParams) return moqLoadFn_paramsKey{ params: struct{ cfg *packages.Config }{ cfg: cfgUsed, @@ -414,17 +233,12 @@ func (m *moqLoadFn) paramsKey(params moqLoadFn_params, anyParams uint64) moqLoad } // Reset resets the state of the moq -func (m *moqLoadFn) Reset() { m.resultsByParams = nil } +func (m *moqLoadFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqLoadFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/ast/moq_readfilefn_test.go b/ast/moq_readfilefn_test.go index 66b243b..1169068 100644 --- a/ast/moq_readfilefn_test.go +++ b/ast/moq_readfilefn_test.go @@ -4,31 +4,32 @@ package ast_test import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/cli/ast" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqReadFileFn holds the state of a moq of the ReadFileFn type type moqReadFileFn struct { - scene *moq.Scene - config moq.Config - moq *moqReadFileFn_mock + moq *impl.Moq[ + *moqReadFileFn_adaptor, + moqReadFileFn_params, + moqReadFileFn_paramsKey, + moqReadFileFn_results, + ] - resultsByParams []moqReadFileFn_resultsByParams + runtime moqReadFileFn_runtime +} - runtime struct { - parameterIndexing struct { - name moq.ParamIndexing - } - } +// moqReadFileFn_runtime holds runtime configuration for the ReadFileFn type +type moqReadFileFn_runtime struct { + parameterIndexing moqReadFileFn_paramIndexing } -// moqReadFileFn_mock isolates the mock interface of the ReadFileFn type -type moqReadFileFn_mock struct { +// moqReadFileFn_adaptor adapts moqReadFileFn as needed by the runtime +type moqReadFileFn_adaptor struct { moq *moqReadFileFn } @@ -41,12 +42,16 @@ type moqReadFileFn_paramsKey struct { hashes struct{ name hash.Hash } } -// moqReadFileFn_resultsByParams contains the results for a given set of -// parameters for the ReadFileFn type -type moqReadFileFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqReadFileFn_paramsKey]*moqReadFileFn_results +// moqReadFileFn_results holds the results of the ReadFileFn type +type moqReadFileFn_results struct { + result1 []byte + result2 error +} + +// moqReadFileFn_paramIndexing holds the parameter indexing runtime +// configuration for the ReadFileFn type +type moqReadFileFn_paramIndexing struct { + name moq.ParamIndexing } // moqReadFileFn_doFn defines the type of function needed when calling andDo @@ -57,59 +62,39 @@ type moqReadFileFn_doFn func(name string) // doReturnResults for the ReadFileFn type type moqReadFileFn_doReturnFn func(name string) ([]byte, error) -// moqReadFileFn_results holds the results of the ReadFileFn type -type moqReadFileFn_results struct { - params moqReadFileFn_params - results []struct { - values *struct { - result1 []byte - result2 error - } - sequence uint32 - doFn moqReadFileFn_doFn - doReturnFn moqReadFileFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqReadFileFn_fnRecorder routes recorded function calls to the moqReadFileFn +// moqReadFileFn_recorder routes recorded function calls to the moqReadFileFn // moq -type moqReadFileFn_fnRecorder struct { - params moqReadFileFn_params - anyParams uint64 - sequence bool - results *moqReadFileFn_results - moq *moqReadFileFn +type moqReadFileFn_recorder struct { + recorder *impl.Recorder[ + *moqReadFileFn_adaptor, + moqReadFileFn_params, + moqReadFileFn_paramsKey, + moqReadFileFn_results, + ] } // moqReadFileFn_anyParams isolates the any params functions of the ReadFileFn // type type moqReadFileFn_anyParams struct { - recorder *moqReadFileFn_fnRecorder + recorder *moqReadFileFn_recorder } // newMoqReadFileFn creates a new moq of the ReadFileFn type func newMoqReadFileFn(scene *moq.Scene, config *moq.Config) *moqReadFileFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqReadFileFn_adaptor{} m := &moqReadFileFn{ - scene: scene, - config: *config, - moq: &moqReadFileFn_mock{}, - - runtime: struct { - parameterIndexing struct { - name moq.ParamIndexing - } - }{parameterIndexing: struct { - name moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqReadFileFn_adaptor, + moqReadFileFn_params, + moqReadFileFn_paramsKey, + moqReadFileFn_results, + ](scene, adaptor1, config), + + runtime: moqReadFileFn_runtime{parameterIndexing: moqReadFileFn_paramIndexing{ name: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -118,264 +103,105 @@ func newMoqReadFileFn(scene *moq.Scene, config *moq.Config) *moqReadFileFn { // mock returns the moq implementation of the ReadFileFn type func (m *moqReadFileFn) mock() ast.ReadFileFn { return func(name string) ([]byte, error) { - m.scene.T.Helper() - moq := &moqReadFileFn_mock{moq: m} - return moq.fn(name) - } -} - -func (m *moqReadFileFn_mock) fn(name string) (result1 []byte, result2 error) { - m.moq.scene.T.Helper() - params := moqReadFileFn_params{ - name: name, - } - var results *moqReadFileFn_results - 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 + m.moq.Scene.T.Helper() + params := moqReadFileFn_params{ + name: name, } - 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)) + var result1 []byte + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } + return result1, result2 } - - if result.doFn != nil { - result.doFn(name) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(name) - } - return } -func (m *moqReadFileFn) onCall(name string) *moqReadFileFn_fnRecorder { - return &moqReadFileFn_fnRecorder{ - params: moqReadFileFn_params{ +func (m *moqReadFileFn) onCall(name string) *moqReadFileFn_recorder { + return &moqReadFileFn_recorder{ + recorder: m.moq.OnCall(moqReadFileFn_params{ name: name, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqReadFileFn_fnRecorder) any() *moqReadFileFn_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(r.params)) +func (r *moqReadFileFn_recorder) any() *moqReadFileFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqReadFileFn_anyParams{recorder: r} } -func (a *moqReadFileFn_anyParams) name() *moqReadFileFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqReadFileFn_anyParams) name() *moqReadFileFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqReadFileFn_fnRecorder) seq() *moqReadFileFn_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(r.params)) +func (r *moqReadFileFn_recorder) seq() *moqReadFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqReadFileFn_fnRecorder) noSeq() *moqReadFileFn_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(r.params)) +func (r *moqReadFileFn_recorder) noSeq() *moqReadFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqReadFileFn_fnRecorder) returnResults(result1 []byte, result2 error) *moqReadFileFn_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 []byte - result2 error - } - sequence uint32 - doFn moqReadFileFn_doFn - doReturnFn moqReadFileFn_doReturnFn - }{ - values: &struct { - result1 []byte - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqReadFileFn_recorder) returnResults(result1 []byte, result2 error) *moqReadFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqReadFileFn_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqReadFileFn_fnRecorder) andDo(fn moqReadFileFn_doFn) *moqReadFileFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqReadFileFn_recorder) andDo(fn moqReadFileFn_doFn) *moqReadFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqReadFileFn_params) { + fn(params.name) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqReadFileFn_fnRecorder) doReturnResults(fn moqReadFileFn_doReturnFn) *moqReadFileFn_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 []byte - result2 error +func (r *moqReadFileFn_recorder) doReturnResults(fn moqReadFileFn_doReturnFn) *moqReadFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqReadFileFn_params) *moqReadFileFn_results { + result1, result2 := fn(params.name) + return &moqReadFileFn_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqReadFileFn_doFn - doReturnFn moqReadFileFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqReadFileFn_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 *moqReadFileFn_resultsByParams - 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 = &moqReadFileFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqReadFileFn_paramsKey]*moqReadFileFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqReadFileFn_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 *moqReadFileFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqReadFileFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqReadFileFn_recorder) repeat(repeaters ...moq.Repeater) *moqReadFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 []byte - result2 error - } - sequence uint32 - doFn moqReadFileFn_doFn - doReturnFn moqReadFileFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqReadFileFn) prettyParams(params moqReadFileFn_params) string { +func (*moqReadFileFn_adaptor) PrettyParams(params moqReadFileFn_params) string { return fmt.Sprintf("ReadFileFn(%#v)", params.name) } -func (m *moqReadFileFn) paramsKey(params moqReadFileFn_params, anyParams uint64) moqReadFileFn_paramsKey { - m.scene.T.Helper() - var nameUsed string - var nameUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.name == moq.ParamIndexByValue { - nameUsed = params.name - } else { - nameUsedHash = hash.DeepHash(params.name) - } - } +func (a *moqReadFileFn_adaptor) ParamsKey(params moqReadFileFn_params, anyParams uint64) moqReadFileFn_paramsKey { + a.moq.moq.Scene.T.Helper() + nameUsed, nameUsedHash := impl.ParamKey( + params.name, 1, a.moq.runtime.parameterIndexing.name, anyParams) return moqReadFileFn_paramsKey{ params: struct{ name string }{ name: nameUsed, @@ -387,17 +213,12 @@ func (m *moqReadFileFn) paramsKey(params moqReadFileFn_params, anyParams uint64) } // Reset resets the state of the moq -func (m *moqReadFileFn) Reset() { m.resultsByParams = nil } +func (m *moqReadFileFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqReadFileFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/ast/moq_statfn_test.go b/ast/moq_statfn_test.go index dc94d7d..0a5c61a 100644 --- a/ast/moq_statfn_test.go +++ b/ast/moq_statfn_test.go @@ -4,32 +4,33 @@ package ast_test import ( "fmt" - "math/bits" "os" - "sync/atomic" "moqueries.org/cli/ast" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqStatFn holds the state of a moq of the StatFn type type moqStatFn struct { - scene *moq.Scene - config moq.Config - moq *moqStatFn_mock + moq *impl.Moq[ + *moqStatFn_adaptor, + moqStatFn_params, + moqStatFn_paramsKey, + moqStatFn_results, + ] - resultsByParams []moqStatFn_resultsByParams + runtime moqStatFn_runtime +} - runtime struct { - parameterIndexing struct { - name moq.ParamIndexing - } - } +// moqStatFn_runtime holds runtime configuration for the StatFn type +type moqStatFn_runtime struct { + parameterIndexing moqStatFn_paramIndexing } -// moqStatFn_mock isolates the mock interface of the StatFn type -type moqStatFn_mock struct { +// moqStatFn_adaptor adapts moqStatFn as needed by the runtime +type moqStatFn_adaptor struct { moq *moqStatFn } @@ -42,12 +43,16 @@ type moqStatFn_paramsKey struct { hashes struct{ name hash.Hash } } -// moqStatFn_resultsByParams contains the results for a given set of parameters +// moqStatFn_results holds the results of the StatFn type +type moqStatFn_results struct { + result1 os.FileInfo + result2 error +} + +// moqStatFn_paramIndexing holds the parameter indexing runtime configuration // for the StatFn type -type moqStatFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqStatFn_paramsKey]*moqStatFn_results +type moqStatFn_paramIndexing struct { + name moq.ParamIndexing } // moqStatFn_doFn defines the type of function needed when calling andDo for @@ -58,57 +63,37 @@ type moqStatFn_doFn func(name string) // doReturnResults for the StatFn type type moqStatFn_doReturnFn func(name string) (os.FileInfo, error) -// moqStatFn_results holds the results of the StatFn type -type moqStatFn_results struct { - params moqStatFn_params - results []struct { - values *struct { - result1 os.FileInfo - result2 error - } - sequence uint32 - doFn moqStatFn_doFn - doReturnFn moqStatFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqStatFn_fnRecorder routes recorded function calls to the moqStatFn moq -type moqStatFn_fnRecorder struct { - params moqStatFn_params - anyParams uint64 - sequence bool - results *moqStatFn_results - moq *moqStatFn +// moqStatFn_recorder routes recorded function calls to the moqStatFn moq +type moqStatFn_recorder struct { + recorder *impl.Recorder[ + *moqStatFn_adaptor, + moqStatFn_params, + moqStatFn_paramsKey, + moqStatFn_results, + ] } // moqStatFn_anyParams isolates the any params functions of the StatFn type type moqStatFn_anyParams struct { - recorder *moqStatFn_fnRecorder + recorder *moqStatFn_recorder } // newMoqStatFn creates a new moq of the StatFn type func newMoqStatFn(scene *moq.Scene, config *moq.Config) *moqStatFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqStatFn_adaptor{} m := &moqStatFn{ - scene: scene, - config: *config, - moq: &moqStatFn_mock{}, - - runtime: struct { - parameterIndexing struct { - name moq.ParamIndexing - } - }{parameterIndexing: struct { - name moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqStatFn_adaptor, + moqStatFn_params, + moqStatFn_paramsKey, + moqStatFn_results, + ](scene, adaptor1, config), + + runtime: moqStatFn_runtime{parameterIndexing: moqStatFn_paramIndexing{ name: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -117,264 +102,105 @@ func newMoqStatFn(scene *moq.Scene, config *moq.Config) *moqStatFn { // mock returns the moq implementation of the StatFn type func (m *moqStatFn) mock() ast.StatFn { return func(name string) (os.FileInfo, error) { - m.scene.T.Helper() - moq := &moqStatFn_mock{moq: m} - return moq.fn(name) - } -} - -func (m *moqStatFn_mock) fn(name string) (result1 os.FileInfo, result2 error) { - m.moq.scene.T.Helper() - params := moqStatFn_params{ - name: name, - } - var results *moqStatFn_results - 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 + m.moq.Scene.T.Helper() + params := moqStatFn_params{ + name: name, } - 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)) + var result1 os.FileInfo + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } + return result1, result2 } - - if result.doFn != nil { - result.doFn(name) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(name) - } - return } -func (m *moqStatFn) onCall(name string) *moqStatFn_fnRecorder { - return &moqStatFn_fnRecorder{ - params: moqStatFn_params{ +func (m *moqStatFn) onCall(name string) *moqStatFn_recorder { + return &moqStatFn_recorder{ + recorder: m.moq.OnCall(moqStatFn_params{ name: name, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqStatFn_fnRecorder) any() *moqStatFn_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(r.params)) +func (r *moqStatFn_recorder) any() *moqStatFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqStatFn_anyParams{recorder: r} } -func (a *moqStatFn_anyParams) name() *moqStatFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqStatFn_anyParams) name() *moqStatFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqStatFn_fnRecorder) seq() *moqStatFn_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(r.params)) +func (r *moqStatFn_recorder) seq() *moqStatFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqStatFn_fnRecorder) noSeq() *moqStatFn_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(r.params)) +func (r *moqStatFn_recorder) noSeq() *moqStatFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqStatFn_fnRecorder) returnResults(result1 os.FileInfo, result2 error) *moqStatFn_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 os.FileInfo - result2 error - } - sequence uint32 - doFn moqStatFn_doFn - doReturnFn moqStatFn_doReturnFn - }{ - values: &struct { - result1 os.FileInfo - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqStatFn_recorder) returnResults(result1 os.FileInfo, result2 error) *moqStatFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqStatFn_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqStatFn_fnRecorder) andDo(fn moqStatFn_doFn) *moqStatFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqStatFn_recorder) andDo(fn moqStatFn_doFn) *moqStatFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqStatFn_params) { + fn(params.name) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqStatFn_fnRecorder) doReturnResults(fn moqStatFn_doReturnFn) *moqStatFn_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 os.FileInfo - result2 error +func (r *moqStatFn_recorder) doReturnResults(fn moqStatFn_doReturnFn) *moqStatFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqStatFn_params) *moqStatFn_results { + result1, result2 := fn(params.name) + return &moqStatFn_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqStatFn_doFn - doReturnFn moqStatFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqStatFn_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 *moqStatFn_resultsByParams - 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 = &moqStatFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqStatFn_paramsKey]*moqStatFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqStatFn_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 *moqStatFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqStatFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqStatFn_recorder) repeat(repeaters ...moq.Repeater) *moqStatFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 os.FileInfo - result2 error - } - sequence uint32 - doFn moqStatFn_doFn - doReturnFn moqStatFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqStatFn) prettyParams(params moqStatFn_params) string { +func (*moqStatFn_adaptor) PrettyParams(params moqStatFn_params) string { return fmt.Sprintf("StatFn(%#v)", params.name) } -func (m *moqStatFn) paramsKey(params moqStatFn_params, anyParams uint64) moqStatFn_paramsKey { - m.scene.T.Helper() - var nameUsed string - var nameUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.name == moq.ParamIndexByValue { - nameUsed = params.name - } else { - nameUsedHash = hash.DeepHash(params.name) - } - } +func (a *moqStatFn_adaptor) ParamsKey(params moqStatFn_params, anyParams uint64) moqStatFn_paramsKey { + a.moq.moq.Scene.T.Helper() + nameUsed, nameUsedHash := impl.ParamKey( + params.name, 1, a.moq.runtime.parameterIndexing.name, anyParams) return moqStatFn_paramsKey{ params: struct{ name string }{ name: nameUsed, @@ -386,17 +212,12 @@ func (m *moqStatFn) paramsKey(params moqStatFn_params, anyParams uint64) moqStat } // Reset resets the state of the moq -func (m *moqStatFn) Reset() { m.resultsByParams = nil } +func (m *moqStatFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqStatFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/bulk/internal/moq_createfn_test.go b/bulk/internal/moq_createfn_test.go index 5af457c..d7e8853 100644 --- a/bulk/internal/moq_createfn_test.go +++ b/bulk/internal/moq_createfn_test.go @@ -5,31 +5,32 @@ package internal_test import ( "fmt" "io" - "math/bits" - "sync/atomic" "moqueries.org/cli/bulk/internal" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqCreateFn holds the state of a moq of the CreateFn type type moqCreateFn struct { - scene *moq.Scene - config moq.Config - moq *moqCreateFn_mock + moq *impl.Moq[ + *moqCreateFn_adaptor, + moqCreateFn_params, + moqCreateFn_paramsKey, + moqCreateFn_results, + ] - resultsByParams []moqCreateFn_resultsByParams + runtime moqCreateFn_runtime +} - runtime struct { - parameterIndexing struct { - name moq.ParamIndexing - } - } +// moqCreateFn_runtime holds runtime configuration for the CreateFn type +type moqCreateFn_runtime struct { + parameterIndexing moqCreateFn_paramIndexing } -// moqCreateFn_mock isolates the mock interface of the CreateFn type -type moqCreateFn_mock struct { +// moqCreateFn_adaptor adapts moqCreateFn as needed by the runtime +type moqCreateFn_adaptor struct { moq *moqCreateFn } @@ -42,12 +43,16 @@ type moqCreateFn_paramsKey struct { hashes struct{ name hash.Hash } } -// moqCreateFn_resultsByParams contains the results for a given set of -// parameters for the CreateFn type -type moqCreateFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqCreateFn_paramsKey]*moqCreateFn_results +// moqCreateFn_results holds the results of the CreateFn type +type moqCreateFn_results struct { + file io.WriteCloser + err error +} + +// moqCreateFn_paramIndexing holds the parameter indexing runtime configuration +// for the CreateFn type +type moqCreateFn_paramIndexing struct { + name moq.ParamIndexing } // moqCreateFn_doFn defines the type of function needed when calling andDo for @@ -58,57 +63,37 @@ type moqCreateFn_doFn func(name string) // doReturnResults for the CreateFn type type moqCreateFn_doReturnFn func(name string) (file io.WriteCloser, err error) -// moqCreateFn_results holds the results of the CreateFn type -type moqCreateFn_results struct { - params moqCreateFn_params - results []struct { - values *struct { - file io.WriteCloser - err error - } - sequence uint32 - doFn moqCreateFn_doFn - doReturnFn moqCreateFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqCreateFn_fnRecorder routes recorded function calls to the moqCreateFn moq -type moqCreateFn_fnRecorder struct { - params moqCreateFn_params - anyParams uint64 - sequence bool - results *moqCreateFn_results - moq *moqCreateFn +// moqCreateFn_recorder routes recorded function calls to the moqCreateFn moq +type moqCreateFn_recorder struct { + recorder *impl.Recorder[ + *moqCreateFn_adaptor, + moqCreateFn_params, + moqCreateFn_paramsKey, + moqCreateFn_results, + ] } // moqCreateFn_anyParams isolates the any params functions of the CreateFn type type moqCreateFn_anyParams struct { - recorder *moqCreateFn_fnRecorder + recorder *moqCreateFn_recorder } // newMoqCreateFn creates a new moq of the CreateFn type func newMoqCreateFn(scene *moq.Scene, config *moq.Config) *moqCreateFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqCreateFn_adaptor{} m := &moqCreateFn{ - scene: scene, - config: *config, - moq: &moqCreateFn_mock{}, - - runtime: struct { - parameterIndexing struct { - name moq.ParamIndexing - } - }{parameterIndexing: struct { - name moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqCreateFn_adaptor, + moqCreateFn_params, + moqCreateFn_paramsKey, + moqCreateFn_results, + ](scene, adaptor1, config), + + runtime: moqCreateFn_runtime{parameterIndexing: moqCreateFn_paramIndexing{ name: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -116,265 +101,106 @@ func newMoqCreateFn(scene *moq.Scene, config *moq.Config) *moqCreateFn { // mock returns the moq implementation of the CreateFn type func (m *moqCreateFn) mock() internal.CreateFn { - return func(name string) (_ io.WriteCloser, _ error) { - m.scene.T.Helper() - moq := &moqCreateFn_mock{moq: m} - return moq.fn(name) - } -} - -func (m *moqCreateFn_mock) fn(name string) (file io.WriteCloser, err error) { - m.moq.scene.T.Helper() - params := moqCreateFn_params{ - name: name, - } - var results *moqCreateFn_results - 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 + return func(name string) (io.WriteCloser, error) { + m.moq.Scene.T.Helper() + params := moqCreateFn_params{ + name: name, } - 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)) + var result1 io.WriteCloser + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.file + result2 = result.err } + return result1, result2 } - - if result.doFn != nil { - result.doFn(name) - } - - if result.values != nil { - file = result.values.file - err = result.values.err - } - if result.doReturnFn != nil { - file, err = result.doReturnFn(name) - } - return } -func (m *moqCreateFn) onCall(name string) *moqCreateFn_fnRecorder { - return &moqCreateFn_fnRecorder{ - params: moqCreateFn_params{ +func (m *moqCreateFn) onCall(name string) *moqCreateFn_recorder { + return &moqCreateFn_recorder{ + recorder: m.moq.OnCall(moqCreateFn_params{ name: name, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqCreateFn_fnRecorder) any() *moqCreateFn_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(r.params)) +func (r *moqCreateFn_recorder) any() *moqCreateFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqCreateFn_anyParams{recorder: r} } -func (a *moqCreateFn_anyParams) name() *moqCreateFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqCreateFn_anyParams) name() *moqCreateFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqCreateFn_fnRecorder) seq() *moqCreateFn_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(r.params)) +func (r *moqCreateFn_recorder) seq() *moqCreateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqCreateFn_fnRecorder) noSeq() *moqCreateFn_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(r.params)) +func (r *moqCreateFn_recorder) noSeq() *moqCreateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqCreateFn_fnRecorder) returnResults(file io.WriteCloser, err error) *moqCreateFn_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 { - file io.WriteCloser - err error - } - sequence uint32 - doFn moqCreateFn_doFn - doReturnFn moqCreateFn_doReturnFn - }{ - values: &struct { - file io.WriteCloser - err error - }{ - file: file, - err: err, - }, - sequence: sequence, +func (r *moqCreateFn_recorder) returnResults(file io.WriteCloser, err error) *moqCreateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqCreateFn_results{ + file: file, + err: err, }) return r } -func (r *moqCreateFn_fnRecorder) andDo(fn moqCreateFn_doFn) *moqCreateFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqCreateFn_recorder) andDo(fn moqCreateFn_doFn) *moqCreateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqCreateFn_params) { + fn(params.name) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqCreateFn_fnRecorder) doReturnResults(fn moqCreateFn_doReturnFn) *moqCreateFn_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 { - file io.WriteCloser - err error +func (r *moqCreateFn_recorder) doReturnResults(fn moqCreateFn_doReturnFn) *moqCreateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqCreateFn_params) *moqCreateFn_results { + file, err := fn(params.name) + return &moqCreateFn_results{ + file: file, + err: err, } - sequence uint32 - doFn moqCreateFn_doFn - doReturnFn moqCreateFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqCreateFn_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 *moqCreateFn_resultsByParams - 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 = &moqCreateFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqCreateFn_paramsKey]*moqCreateFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqCreateFn_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 *moqCreateFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqCreateFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqCreateFn_recorder) repeat(repeaters ...moq.Repeater) *moqCreateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - file io.WriteCloser - err error - } - sequence uint32 - doFn moqCreateFn_doFn - doReturnFn moqCreateFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqCreateFn) prettyParams(params moqCreateFn_params) string { +func (*moqCreateFn_adaptor) PrettyParams(params moqCreateFn_params) string { return fmt.Sprintf("CreateFn(%#v)", params.name) } -func (m *moqCreateFn) paramsKey(params moqCreateFn_params, anyParams uint64) moqCreateFn_paramsKey { - m.scene.T.Helper() - var nameUsed string - var nameUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.name == moq.ParamIndexByValue { - nameUsed = params.name - } else { - nameUsedHash = hash.DeepHash(params.name) - } - } +func (a *moqCreateFn_adaptor) ParamsKey(params moqCreateFn_params, anyParams uint64) moqCreateFn_paramsKey { + a.moq.moq.Scene.T.Helper() + nameUsed, nameUsedHash := impl.ParamKey( + params.name, 1, a.moq.runtime.parameterIndexing.name, anyParams) return moqCreateFn_paramsKey{ params: struct{ name string }{ name: nameUsed, @@ -386,17 +212,12 @@ func (m *moqCreateFn) paramsKey(params moqCreateFn_params, anyParams uint64) moq } // Reset resets the state of the moq -func (m *moqCreateFn) Reset() { m.resultsByParams = nil } +func (m *moqCreateFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqCreateFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/bulk/internal/moq_generatefn_test.go b/bulk/internal/moq_generatefn_test.go index ae8cfe2..3736d81 100644 --- a/bulk/internal/moq_generatefn_test.go +++ b/bulk/internal/moq_generatefn_test.go @@ -4,32 +4,33 @@ package internal_test import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/cli/bulk/internal" "moqueries.org/cli/generator" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqGenerateFn holds the state of a moq of the GenerateFn type type moqGenerateFn struct { - scene *moq.Scene - config moq.Config - moq *moqGenerateFn_mock + moq *impl.Moq[ + *moqGenerateFn_adaptor, + moqGenerateFn_params, + moqGenerateFn_paramsKey, + moqGenerateFn_results, + ] - resultsByParams []moqGenerateFn_resultsByParams + runtime moqGenerateFn_runtime +} - runtime struct { - parameterIndexing struct { - reqs moq.ParamIndexing - } - } +// moqGenerateFn_runtime holds runtime configuration for the GenerateFn type +type moqGenerateFn_runtime struct { + parameterIndexing moqGenerateFn_paramIndexing } -// moqGenerateFn_mock isolates the mock interface of the GenerateFn type -type moqGenerateFn_mock struct { +// moqGenerateFn_adaptor adapts moqGenerateFn as needed by the runtime +type moqGenerateFn_adaptor struct { moq *moqGenerateFn } @@ -42,12 +43,15 @@ type moqGenerateFn_paramsKey struct { hashes struct{ reqs hash.Hash } } -// moqGenerateFn_resultsByParams contains the results for a given set of -// parameters for the GenerateFn type -type moqGenerateFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqGenerateFn_paramsKey]*moqGenerateFn_results +// moqGenerateFn_results holds the results of the GenerateFn type +type moqGenerateFn_results struct { + result1 error +} + +// moqGenerateFn_paramIndexing holds the parameter indexing runtime +// configuration for the GenerateFn type +type moqGenerateFn_paramIndexing struct { + reqs moq.ParamIndexing } // moqGenerateFn_doFn defines the type of function needed when calling andDo @@ -58,58 +62,39 @@ type moqGenerateFn_doFn func(reqs ...generator.GenerateRequest) // doReturnResults for the GenerateFn type type moqGenerateFn_doReturnFn func(reqs ...generator.GenerateRequest) error -// moqGenerateFn_results holds the results of the GenerateFn type -type moqGenerateFn_results struct { - params moqGenerateFn_params - results []struct { - values *struct { - result1 error - } - sequence uint32 - doFn moqGenerateFn_doFn - doReturnFn moqGenerateFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqGenerateFn_fnRecorder routes recorded function calls to the moqGenerateFn +// moqGenerateFn_recorder routes recorded function calls to the moqGenerateFn // moq -type moqGenerateFn_fnRecorder struct { - params moqGenerateFn_params - anyParams uint64 - sequence bool - results *moqGenerateFn_results - moq *moqGenerateFn +type moqGenerateFn_recorder struct { + recorder *impl.Recorder[ + *moqGenerateFn_adaptor, + moqGenerateFn_params, + moqGenerateFn_paramsKey, + moqGenerateFn_results, + ] } // moqGenerateFn_anyParams isolates the any params functions of the GenerateFn // type type moqGenerateFn_anyParams struct { - recorder *moqGenerateFn_fnRecorder + recorder *moqGenerateFn_recorder } // newMoqGenerateFn creates a new moq of the GenerateFn type func newMoqGenerateFn(scene *moq.Scene, config *moq.Config) *moqGenerateFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqGenerateFn_adaptor{} m := &moqGenerateFn{ - scene: scene, - config: *config, - moq: &moqGenerateFn_mock{}, - - runtime: struct { - parameterIndexing struct { - reqs moq.ParamIndexing - } - }{parameterIndexing: struct { - reqs moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqGenerateFn_adaptor, + moqGenerateFn_params, + moqGenerateFn_paramsKey, + moqGenerateFn_results, + ](scene, adaptor1, config), + + runtime: moqGenerateFn_runtime{parameterIndexing: moqGenerateFn_paramIndexing{ reqs: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -118,256 +103,101 @@ func newMoqGenerateFn(scene *moq.Scene, config *moq.Config) *moqGenerateFn { // mock returns the moq implementation of the GenerateFn type func (m *moqGenerateFn) mock() internal.GenerateFn { return func(reqs ...generator.GenerateRequest) error { - m.scene.T.Helper() - moq := &moqGenerateFn_mock{moq: m} - return moq.fn(reqs...) - } -} - -func (m *moqGenerateFn_mock) fn(reqs ...generator.GenerateRequest) (result1 error) { - m.moq.scene.T.Helper() - params := moqGenerateFn_params{ - reqs: reqs, - } - var results *moqGenerateFn_results - 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 + m.moq.Scene.T.Helper() + params := moqGenerateFn_params{ + reqs: reqs, } - 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)) + var result1 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } + return result1 } - - if result.doFn != nil { - result.doFn(reqs...) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(reqs...) - } - return } -func (m *moqGenerateFn) onCall(reqs ...generator.GenerateRequest) *moqGenerateFn_fnRecorder { - return &moqGenerateFn_fnRecorder{ - params: moqGenerateFn_params{ +func (m *moqGenerateFn) onCall(reqs ...generator.GenerateRequest) *moqGenerateFn_recorder { + return &moqGenerateFn_recorder{ + recorder: m.moq.OnCall(moqGenerateFn_params{ reqs: reqs, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqGenerateFn_fnRecorder) any() *moqGenerateFn_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(r.params)) +func (r *moqGenerateFn_recorder) any() *moqGenerateFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqGenerateFn_anyParams{recorder: r} } -func (a *moqGenerateFn_anyParams) reqs() *moqGenerateFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqGenerateFn_anyParams) reqs() *moqGenerateFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqGenerateFn_fnRecorder) seq() *moqGenerateFn_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(r.params)) +func (r *moqGenerateFn_recorder) seq() *moqGenerateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqGenerateFn_fnRecorder) noSeq() *moqGenerateFn_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(r.params)) +func (r *moqGenerateFn_recorder) noSeq() *moqGenerateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqGenerateFn_fnRecorder) returnResults(result1 error) *moqGenerateFn_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 error - } - sequence uint32 - doFn moqGenerateFn_doFn - doReturnFn moqGenerateFn_doReturnFn - }{ - values: &struct { - result1 error - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqGenerateFn_recorder) returnResults(result1 error) *moqGenerateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqGenerateFn_results{ + result1: result1, }) return r } -func (r *moqGenerateFn_fnRecorder) andDo(fn moqGenerateFn_doFn) *moqGenerateFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqGenerateFn_recorder) andDo(fn moqGenerateFn_doFn) *moqGenerateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqGenerateFn_params) { + fn(params.reqs...) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqGenerateFn_fnRecorder) doReturnResults(fn moqGenerateFn_doReturnFn) *moqGenerateFn_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 error +func (r *moqGenerateFn_recorder) doReturnResults(fn moqGenerateFn_doReturnFn) *moqGenerateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqGenerateFn_params) *moqGenerateFn_results { + result1 := fn(params.reqs...) + return &moqGenerateFn_results{ + result1: result1, } - sequence uint32 - doFn moqGenerateFn_doFn - doReturnFn moqGenerateFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqGenerateFn_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 *moqGenerateFn_resultsByParams - 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 = &moqGenerateFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqGenerateFn_paramsKey]*moqGenerateFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqGenerateFn_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 *moqGenerateFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqGenerateFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqGenerateFn_recorder) repeat(repeaters ...moq.Repeater) *moqGenerateFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 error - } - sequence uint32 - doFn moqGenerateFn_doFn - doReturnFn moqGenerateFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqGenerateFn) prettyParams(params moqGenerateFn_params) string { +func (*moqGenerateFn_adaptor) PrettyParams(params moqGenerateFn_params) string { return fmt.Sprintf("GenerateFn(%#v)", params.reqs) } -func (m *moqGenerateFn) paramsKey(params moqGenerateFn_params, anyParams uint64) moqGenerateFn_paramsKey { - m.scene.T.Helper() - var reqsUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.reqs == moq.ParamIndexByValue { - m.scene.T.Fatalf("The reqs parameter can't be indexed by value") - } - reqsUsedHash = hash.DeepHash(params.reqs) - } +func (a *moqGenerateFn_adaptor) ParamsKey(params moqGenerateFn_params, anyParams uint64) moqGenerateFn_paramsKey { + a.moq.moq.Scene.T.Helper() + reqsUsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.reqs, "reqs", 1, a.moq.runtime.parameterIndexing.reqs, anyParams) return moqGenerateFn_paramsKey{ params: struct{}{}, hashes: struct{ reqs hash.Hash }{ @@ -377,17 +207,12 @@ func (m *moqGenerateFn) paramsKey(params moqGenerateFn_params, anyParams uint64) } // Reset resets the state of the moq -func (m *moqGenerateFn) Reset() { m.resultsByParams = nil } +func (m *moqGenerateFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqGenerateFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/bulk/internal/moq_openfilefn_test.go b/bulk/internal/moq_openfilefn_test.go index cf0ad77..4ae97a2 100644 --- a/bulk/internal/moq_openfilefn_test.go +++ b/bulk/internal/moq_openfilefn_test.go @@ -4,34 +4,33 @@ package internal_test import ( "fmt" - "math/bits" "os" - "sync/atomic" "moqueries.org/cli/bulk/internal" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqOpenFileFn holds the state of a moq of the OpenFileFn type type moqOpenFileFn struct { - scene *moq.Scene - config moq.Config - moq *moqOpenFileFn_mock - - resultsByParams []moqOpenFileFn_resultsByParams + moq *impl.Moq[ + *moqOpenFileFn_adaptor, + moqOpenFileFn_params, + moqOpenFileFn_paramsKey, + moqOpenFileFn_results, + ] + + runtime moqOpenFileFn_runtime +} - runtime struct { - parameterIndexing struct { - name moq.ParamIndexing - flag moq.ParamIndexing - perm moq.ParamIndexing - } - } +// moqOpenFileFn_runtime holds runtime configuration for the OpenFileFn type +type moqOpenFileFn_runtime struct { + parameterIndexing moqOpenFileFn_paramIndexing } -// moqOpenFileFn_mock isolates the mock interface of the OpenFileFn type -type moqOpenFileFn_mock struct { +// moqOpenFileFn_adaptor adapts moqOpenFileFn as needed by the runtime +type moqOpenFileFn_adaptor struct { moq *moqOpenFileFn } @@ -56,12 +55,18 @@ type moqOpenFileFn_paramsKey struct { } } -// moqOpenFileFn_resultsByParams contains the results for a given set of -// parameters for the OpenFileFn type -type moqOpenFileFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqOpenFileFn_paramsKey]*moqOpenFileFn_results +// moqOpenFileFn_results holds the results of the OpenFileFn type +type moqOpenFileFn_results struct { + result1 internal.ReadWriteSeekCloser + result2 error +} + +// moqOpenFileFn_paramIndexing holds the parameter indexing runtime +// configuration for the OpenFileFn type +type moqOpenFileFn_paramIndexing struct { + name moq.ParamIndexing + flag moq.ParamIndexing + perm moq.ParamIndexing } // moqOpenFileFn_doFn defines the type of function needed when calling andDo @@ -72,65 +77,41 @@ type moqOpenFileFn_doFn func(name string, flag int, perm os.FileMode) // doReturnResults for the OpenFileFn type type moqOpenFileFn_doReturnFn func(name string, flag int, perm os.FileMode) (internal.ReadWriteSeekCloser, error) -// moqOpenFileFn_results holds the results of the OpenFileFn type -type moqOpenFileFn_results struct { - params moqOpenFileFn_params - results []struct { - values *struct { - result1 internal.ReadWriteSeekCloser - result2 error - } - sequence uint32 - doFn moqOpenFileFn_doFn - doReturnFn moqOpenFileFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqOpenFileFn_fnRecorder routes recorded function calls to the moqOpenFileFn +// moqOpenFileFn_recorder routes recorded function calls to the moqOpenFileFn // moq -type moqOpenFileFn_fnRecorder struct { - params moqOpenFileFn_params - anyParams uint64 - sequence bool - results *moqOpenFileFn_results - moq *moqOpenFileFn +type moqOpenFileFn_recorder struct { + recorder *impl.Recorder[ + *moqOpenFileFn_adaptor, + moqOpenFileFn_params, + moqOpenFileFn_paramsKey, + moqOpenFileFn_results, + ] } // moqOpenFileFn_anyParams isolates the any params functions of the OpenFileFn // type type moqOpenFileFn_anyParams struct { - recorder *moqOpenFileFn_fnRecorder + recorder *moqOpenFileFn_recorder } // newMoqOpenFileFn creates a new moq of the OpenFileFn type func newMoqOpenFileFn(scene *moq.Scene, config *moq.Config) *moqOpenFileFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqOpenFileFn_adaptor{} m := &moqOpenFileFn{ - scene: scene, - config: *config, - moq: &moqOpenFileFn_mock{}, - - runtime: struct { - parameterIndexing struct { - name moq.ParamIndexing - flag moq.ParamIndexing - perm moq.ParamIndexing - } - }{parameterIndexing: struct { - name moq.ParamIndexing - flag moq.ParamIndexing - perm moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqOpenFileFn_adaptor, + moqOpenFileFn_params, + moqOpenFileFn_paramsKey, + moqOpenFileFn_results, + ](scene, adaptor1, config), + + runtime: moqOpenFileFn_runtime{parameterIndexing: moqOpenFileFn_paramIndexing{ name: moq.ParamIndexByValue, flag: moq.ParamIndexByValue, perm: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -139,296 +120,123 @@ func newMoqOpenFileFn(scene *moq.Scene, config *moq.Config) *moqOpenFileFn { // mock returns the moq implementation of the OpenFileFn type func (m *moqOpenFileFn) mock() internal.OpenFileFn { return func(name string, flag int, perm os.FileMode) (internal.ReadWriteSeekCloser, error) { - m.scene.T.Helper() - moq := &moqOpenFileFn_mock{moq: m} - return moq.fn(name, flag, perm) - } -} - -func (m *moqOpenFileFn_mock) fn(name string, flag int, perm os.FileMode) (result1 internal.ReadWriteSeekCloser, result2 error) { - m.moq.scene.T.Helper() - params := moqOpenFileFn_params{ - name: name, - flag: flag, - perm: perm, - } - var results *moqOpenFileFn_results - 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 + m.moq.Scene.T.Helper() + params := moqOpenFileFn_params{ + name: name, + flag: flag, + perm: perm, } - 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)) + var result1 internal.ReadWriteSeekCloser + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } + return result1, result2 } - - if result.doFn != nil { - result.doFn(name, flag, perm) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(name, flag, perm) - } - return } -func (m *moqOpenFileFn) onCall(name string, flag int, perm os.FileMode) *moqOpenFileFn_fnRecorder { - return &moqOpenFileFn_fnRecorder{ - params: moqOpenFileFn_params{ +func (m *moqOpenFileFn) onCall(name string, flag int, perm os.FileMode) *moqOpenFileFn_recorder { + return &moqOpenFileFn_recorder{ + recorder: m.moq.OnCall(moqOpenFileFn_params{ name: name, flag: flag, perm: perm, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqOpenFileFn_fnRecorder) any() *moqOpenFileFn_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(r.params)) +func (r *moqOpenFileFn_recorder) any() *moqOpenFileFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqOpenFileFn_anyParams{recorder: r} } -func (a *moqOpenFileFn_anyParams) name() *moqOpenFileFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqOpenFileFn_anyParams) name() *moqOpenFileFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqOpenFileFn_anyParams) flag() *moqOpenFileFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqOpenFileFn_anyParams) flag() *moqOpenFileFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (a *moqOpenFileFn_anyParams) perm() *moqOpenFileFn_fnRecorder { - a.recorder.anyParams |= 1 << 2 +func (a *moqOpenFileFn_anyParams) perm() *moqOpenFileFn_recorder { + a.recorder.recorder.AnyParam(3) return a.recorder } -func (r *moqOpenFileFn_fnRecorder) seq() *moqOpenFileFn_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(r.params)) +func (r *moqOpenFileFn_recorder) seq() *moqOpenFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqOpenFileFn_fnRecorder) noSeq() *moqOpenFileFn_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(r.params)) +func (r *moqOpenFileFn_recorder) noSeq() *moqOpenFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqOpenFileFn_fnRecorder) returnResults(result1 internal.ReadWriteSeekCloser, result2 error) *moqOpenFileFn_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 internal.ReadWriteSeekCloser - result2 error - } - sequence uint32 - doFn moqOpenFileFn_doFn - doReturnFn moqOpenFileFn_doReturnFn - }{ - values: &struct { - result1 internal.ReadWriteSeekCloser - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqOpenFileFn_recorder) returnResults(result1 internal.ReadWriteSeekCloser, result2 error) *moqOpenFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqOpenFileFn_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqOpenFileFn_fnRecorder) andDo(fn moqOpenFileFn_doFn) *moqOpenFileFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqOpenFileFn_recorder) andDo(fn moqOpenFileFn_doFn) *moqOpenFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqOpenFileFn_params) { + fn(params.name, params.flag, params.perm) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqOpenFileFn_fnRecorder) doReturnResults(fn moqOpenFileFn_doReturnFn) *moqOpenFileFn_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 internal.ReadWriteSeekCloser - result2 error +func (r *moqOpenFileFn_recorder) doReturnResults(fn moqOpenFileFn_doReturnFn) *moqOpenFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqOpenFileFn_params) *moqOpenFileFn_results { + result1, result2 := fn(params.name, params.flag, params.perm) + return &moqOpenFileFn_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqOpenFileFn_doFn - doReturnFn moqOpenFileFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqOpenFileFn_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 *moqOpenFileFn_resultsByParams - 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 = &moqOpenFileFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqOpenFileFn_paramsKey]*moqOpenFileFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqOpenFileFn_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 *moqOpenFileFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqOpenFileFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqOpenFileFn_recorder) repeat(repeaters ...moq.Repeater) *moqOpenFileFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 internal.ReadWriteSeekCloser - result2 error - } - sequence uint32 - doFn moqOpenFileFn_doFn - doReturnFn moqOpenFileFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqOpenFileFn) prettyParams(params moqOpenFileFn_params) string { +func (*moqOpenFileFn_adaptor) PrettyParams(params moqOpenFileFn_params) string { return fmt.Sprintf("OpenFileFn(%#v, %#v, %#v)", params.name, params.flag, params.perm) } -func (m *moqOpenFileFn) paramsKey(params moqOpenFileFn_params, anyParams uint64) moqOpenFileFn_paramsKey { - m.scene.T.Helper() - var nameUsed string - var nameUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.name == moq.ParamIndexByValue { - nameUsed = params.name - } else { - nameUsedHash = hash.DeepHash(params.name) - } - } - var flagUsed int - var flagUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.flag == moq.ParamIndexByValue { - flagUsed = params.flag - } else { - flagUsedHash = hash.DeepHash(params.flag) - } - } - var permUsed os.FileMode - var permUsedHash hash.Hash - if anyParams&(1<<2) == 0 { - if m.runtime.parameterIndexing.perm == moq.ParamIndexByValue { - permUsed = params.perm - } else { - permUsedHash = hash.DeepHash(params.perm) - } - } +func (a *moqOpenFileFn_adaptor) ParamsKey(params moqOpenFileFn_params, anyParams uint64) moqOpenFileFn_paramsKey { + a.moq.moq.Scene.T.Helper() + nameUsed, nameUsedHash := impl.ParamKey( + params.name, 1, a.moq.runtime.parameterIndexing.name, anyParams) + flagUsed, flagUsedHash := impl.ParamKey( + params.flag, 2, a.moq.runtime.parameterIndexing.flag, anyParams) + permUsed, permUsedHash := impl.ParamKey( + params.perm, 3, a.moq.runtime.parameterIndexing.perm, anyParams) return moqOpenFileFn_paramsKey{ params: struct { name string @@ -452,17 +260,12 @@ func (m *moqOpenFileFn) paramsKey(params moqOpenFileFn_params, anyParams uint64) } // Reset resets the state of the moq -func (m *moqOpenFileFn) Reset() { m.resultsByParams = nil } +func (m *moqOpenFileFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqOpenFileFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/bulk/internal/moq_openfn_test.go b/bulk/internal/moq_openfn_test.go index 2ab934a..4269ef5 100644 --- a/bulk/internal/moq_openfn_test.go +++ b/bulk/internal/moq_openfn_test.go @@ -5,31 +5,32 @@ package internal_test import ( "fmt" "io" - "math/bits" - "sync/atomic" "moqueries.org/cli/bulk/internal" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqOpenFn holds the state of a moq of the OpenFn type type moqOpenFn struct { - scene *moq.Scene - config moq.Config - moq *moqOpenFn_mock + moq *impl.Moq[ + *moqOpenFn_adaptor, + moqOpenFn_params, + moqOpenFn_paramsKey, + moqOpenFn_results, + ] - resultsByParams []moqOpenFn_resultsByParams + runtime moqOpenFn_runtime +} - runtime struct { - parameterIndexing struct { - name moq.ParamIndexing - } - } +// moqOpenFn_runtime holds runtime configuration for the OpenFn type +type moqOpenFn_runtime struct { + parameterIndexing moqOpenFn_paramIndexing } -// moqOpenFn_mock isolates the mock interface of the OpenFn type -type moqOpenFn_mock struct { +// moqOpenFn_adaptor adapts moqOpenFn as needed by the runtime +type moqOpenFn_adaptor struct { moq *moqOpenFn } @@ -42,12 +43,16 @@ type moqOpenFn_paramsKey struct { hashes struct{ name hash.Hash } } -// moqOpenFn_resultsByParams contains the results for a given set of parameters +// moqOpenFn_results holds the results of the OpenFn type +type moqOpenFn_results struct { + file io.ReadCloser + err error +} + +// moqOpenFn_paramIndexing holds the parameter indexing runtime configuration // for the OpenFn type -type moqOpenFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqOpenFn_paramsKey]*moqOpenFn_results +type moqOpenFn_paramIndexing struct { + name moq.ParamIndexing } // moqOpenFn_doFn defines the type of function needed when calling andDo for @@ -58,57 +63,37 @@ type moqOpenFn_doFn func(name string) // doReturnResults for the OpenFn type type moqOpenFn_doReturnFn func(name string) (file io.ReadCloser, err error) -// moqOpenFn_results holds the results of the OpenFn type -type moqOpenFn_results struct { - params moqOpenFn_params - results []struct { - values *struct { - file io.ReadCloser - err error - } - sequence uint32 - doFn moqOpenFn_doFn - doReturnFn moqOpenFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqOpenFn_fnRecorder routes recorded function calls to the moqOpenFn moq -type moqOpenFn_fnRecorder struct { - params moqOpenFn_params - anyParams uint64 - sequence bool - results *moqOpenFn_results - moq *moqOpenFn +// moqOpenFn_recorder routes recorded function calls to the moqOpenFn moq +type moqOpenFn_recorder struct { + recorder *impl.Recorder[ + *moqOpenFn_adaptor, + moqOpenFn_params, + moqOpenFn_paramsKey, + moqOpenFn_results, + ] } // moqOpenFn_anyParams isolates the any params functions of the OpenFn type type moqOpenFn_anyParams struct { - recorder *moqOpenFn_fnRecorder + recorder *moqOpenFn_recorder } // newMoqOpenFn creates a new moq of the OpenFn type func newMoqOpenFn(scene *moq.Scene, config *moq.Config) *moqOpenFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqOpenFn_adaptor{} m := &moqOpenFn{ - scene: scene, - config: *config, - moq: &moqOpenFn_mock{}, - - runtime: struct { - parameterIndexing struct { - name moq.ParamIndexing - } - }{parameterIndexing: struct { - name moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqOpenFn_adaptor, + moqOpenFn_params, + moqOpenFn_paramsKey, + moqOpenFn_results, + ](scene, adaptor1, config), + + runtime: moqOpenFn_runtime{parameterIndexing: moqOpenFn_paramIndexing{ name: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -116,265 +101,106 @@ func newMoqOpenFn(scene *moq.Scene, config *moq.Config) *moqOpenFn { // mock returns the moq implementation of the OpenFn type func (m *moqOpenFn) mock() internal.OpenFn { - return func(name string) (_ io.ReadCloser, _ error) { - m.scene.T.Helper() - moq := &moqOpenFn_mock{moq: m} - return moq.fn(name) - } -} - -func (m *moqOpenFn_mock) fn(name string) (file io.ReadCloser, err error) { - m.moq.scene.T.Helper() - params := moqOpenFn_params{ - name: name, - } - var results *moqOpenFn_results - 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 + return func(name string) (io.ReadCloser, error) { + m.moq.Scene.T.Helper() + params := moqOpenFn_params{ + name: name, } - 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)) + var result1 io.ReadCloser + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.file + result2 = result.err } + return result1, result2 } - - if result.doFn != nil { - result.doFn(name) - } - - if result.values != nil { - file = result.values.file - err = result.values.err - } - if result.doReturnFn != nil { - file, err = result.doReturnFn(name) - } - return } -func (m *moqOpenFn) onCall(name string) *moqOpenFn_fnRecorder { - return &moqOpenFn_fnRecorder{ - params: moqOpenFn_params{ +func (m *moqOpenFn) onCall(name string) *moqOpenFn_recorder { + return &moqOpenFn_recorder{ + recorder: m.moq.OnCall(moqOpenFn_params{ name: name, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqOpenFn_fnRecorder) any() *moqOpenFn_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(r.params)) +func (r *moqOpenFn_recorder) any() *moqOpenFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqOpenFn_anyParams{recorder: r} } -func (a *moqOpenFn_anyParams) name() *moqOpenFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqOpenFn_anyParams) name() *moqOpenFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqOpenFn_fnRecorder) seq() *moqOpenFn_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(r.params)) +func (r *moqOpenFn_recorder) seq() *moqOpenFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqOpenFn_fnRecorder) noSeq() *moqOpenFn_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(r.params)) +func (r *moqOpenFn_recorder) noSeq() *moqOpenFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqOpenFn_fnRecorder) returnResults(file io.ReadCloser, err error) *moqOpenFn_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 { - file io.ReadCloser - err error - } - sequence uint32 - doFn moqOpenFn_doFn - doReturnFn moqOpenFn_doReturnFn - }{ - values: &struct { - file io.ReadCloser - err error - }{ - file: file, - err: err, - }, - sequence: sequence, +func (r *moqOpenFn_recorder) returnResults(file io.ReadCloser, err error) *moqOpenFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqOpenFn_results{ + file: file, + err: err, }) return r } -func (r *moqOpenFn_fnRecorder) andDo(fn moqOpenFn_doFn) *moqOpenFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqOpenFn_recorder) andDo(fn moqOpenFn_doFn) *moqOpenFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqOpenFn_params) { + fn(params.name) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqOpenFn_fnRecorder) doReturnResults(fn moqOpenFn_doReturnFn) *moqOpenFn_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 { - file io.ReadCloser - err error +func (r *moqOpenFn_recorder) doReturnResults(fn moqOpenFn_doReturnFn) *moqOpenFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqOpenFn_params) *moqOpenFn_results { + file, err := fn(params.name) + return &moqOpenFn_results{ + file: file, + err: err, } - sequence uint32 - doFn moqOpenFn_doFn - doReturnFn moqOpenFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqOpenFn_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 *moqOpenFn_resultsByParams - 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 = &moqOpenFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqOpenFn_paramsKey]*moqOpenFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqOpenFn_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 *moqOpenFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqOpenFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqOpenFn_recorder) repeat(repeaters ...moq.Repeater) *moqOpenFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - file io.ReadCloser - err error - } - sequence uint32 - doFn moqOpenFn_doFn - doReturnFn moqOpenFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqOpenFn) prettyParams(params moqOpenFn_params) string { +func (*moqOpenFn_adaptor) PrettyParams(params moqOpenFn_params) string { return fmt.Sprintf("OpenFn(%#v)", params.name) } -func (m *moqOpenFn) paramsKey(params moqOpenFn_params, anyParams uint64) moqOpenFn_paramsKey { - m.scene.T.Helper() - var nameUsed string - var nameUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.name == moq.ParamIndexByValue { - nameUsed = params.name - } else { - nameUsedHash = hash.DeepHash(params.name) - } - } +func (a *moqOpenFn_adaptor) ParamsKey(params moqOpenFn_params, anyParams uint64) moqOpenFn_paramsKey { + a.moq.moq.Scene.T.Helper() + nameUsed, nameUsedHash := impl.ParamKey( + params.name, 1, a.moq.runtime.parameterIndexing.name, anyParams) return moqOpenFn_paramsKey{ params: struct{ name string }{ name: nameUsed, @@ -386,17 +212,12 @@ func (m *moqOpenFn) paramsKey(params moqOpenFn_params, anyParams uint64) moqOpen } // Reset resets the state of the moq -func (m *moqOpenFn) Reset() { m.resultsByParams = nil } +func (m *moqOpenFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqOpenFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/bulk/internal/moq_readcloser_test.go b/bulk/internal/moq_readcloser_test.go index d38b754..d99a9d5 100644 --- a/bulk/internal/moq_readcloser_test.go +++ b/bulk/internal/moq_readcloser_test.go @@ -5,10 +5,9 @@ package internal_test import ( "fmt" "io" - "math/bits" - "sync/atomic" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -17,21 +16,22 @@ var _ io.ReadCloser = (*moqReadCloser_mock)(nil) // moqReadCloser holds the state of a moq of the ReadCloser type type moqReadCloser struct { - scene *moq.Scene - config moq.Config - moq *moqReadCloser_mock - - resultsByParams_Read []moqReadCloser_Read_resultsByParams - resultsByParams_Close []moqReadCloser_Close_resultsByParams - - runtime struct { - parameterIndexing struct { - Read struct { - p moq.ParamIndexing - } - Close struct{} - } - } + moq *moqReadCloser_mock + + moq_Read *impl.Moq[ + *moqReadCloser_Read_adaptor, + moqReadCloser_Read_params, + moqReadCloser_Read_paramsKey, + moqReadCloser_Read_results, + ] + moq_Close *impl.Moq[ + *moqReadCloser_Close_adaptor, + moqReadCloser_Close_params, + moqReadCloser_Close_paramsKey, + moqReadCloser_Close_results, + ] + + runtime moqReadCloser_runtime } // moqReadCloser_mock isolates the mock interface of the ReadCloser type @@ -45,6 +45,19 @@ type moqReadCloser_recorder struct { moq *moqReadCloser } +// moqReadCloser_runtime holds runtime configuration for the ReadCloser type +type moqReadCloser_runtime struct { + parameterIndexing struct { + Read moqReadCloser_Read_paramIndexing + Close moqReadCloser_Close_paramIndexing + } +} + +// moqReadCloser_Read_adaptor adapts moqReadCloser as needed by the runtime +type moqReadCloser_Read_adaptor struct { + moq *moqReadCloser +} + // moqReadCloser_Read_params holds the params of the ReadCloser type type moqReadCloser_Read_params struct{ p []byte } @@ -54,12 +67,16 @@ type moqReadCloser_Read_paramsKey struct { hashes struct{ p hash.Hash } } -// moqReadCloser_Read_resultsByParams contains the results for a given set of -// parameters for the ReadCloser type -type moqReadCloser_Read_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqReadCloser_Read_paramsKey]*moqReadCloser_Read_results +// moqReadCloser_Read_results holds the results of the ReadCloser type +type moqReadCloser_Read_results struct { + n int + err error +} + +// moqReadCloser_Read_paramIndexing holds the parameter indexing runtime +// configuration for the ReadCloser type +type moqReadCloser_Read_paramIndexing struct { + p moq.ParamIndexing } // moqReadCloser_Read_doFn defines the type of function needed when calling @@ -70,36 +87,26 @@ type moqReadCloser_Read_doFn func(p []byte) // calling doReturnResults for the ReadCloser type type moqReadCloser_Read_doReturnFn func(p []byte) (n int, err error) -// moqReadCloser_Read_results holds the results of the ReadCloser type -type moqReadCloser_Read_results struct { - params moqReadCloser_Read_params - results []struct { - values *struct { - n int - err error - } - sequence uint32 - doFn moqReadCloser_Read_doFn - doReturnFn moqReadCloser_Read_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqReadCloser_Read_fnRecorder routes recorded function calls to the +// moqReadCloser_Read_recorder routes recorded function calls to the // moqReadCloser moq -type moqReadCloser_Read_fnRecorder struct { - params moqReadCloser_Read_params - anyParams uint64 - sequence bool - results *moqReadCloser_Read_results - moq *moqReadCloser +type moqReadCloser_Read_recorder struct { + recorder *impl.Recorder[ + *moqReadCloser_Read_adaptor, + moqReadCloser_Read_params, + moqReadCloser_Read_paramsKey, + moqReadCloser_Read_results, + ] } // moqReadCloser_Read_anyParams isolates the any params functions of the // ReadCloser type type moqReadCloser_Read_anyParams struct { - recorder *moqReadCloser_Read_fnRecorder + recorder *moqReadCloser_Read_recorder +} + +// moqReadCloser_Close_adaptor adapts moqReadCloser as needed by the runtime +type moqReadCloser_Close_adaptor struct { + moq *moqReadCloser } // moqReadCloser_Close_params holds the params of the ReadCloser type @@ -112,14 +119,15 @@ type moqReadCloser_Close_paramsKey struct { hashes struct{} } -// moqReadCloser_Close_resultsByParams contains the results for a given set of -// parameters for the ReadCloser type -type moqReadCloser_Close_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqReadCloser_Close_paramsKey]*moqReadCloser_Close_results +// moqReadCloser_Close_results holds the results of the ReadCloser type +type moqReadCloser_Close_results struct { + result1 error } +// moqReadCloser_Close_paramIndexing holds the parameter indexing runtime +// configuration for the ReadCloser type +type moqReadCloser_Close_paramIndexing struct{} + // moqReadCloser_Close_doFn defines the type of function needed when calling // andDo for the ReadCloser type type moqReadCloser_Close_doFn func() @@ -128,70 +136,58 @@ type moqReadCloser_Close_doFn func() // calling doReturnResults for the ReadCloser type type moqReadCloser_Close_doReturnFn func() error -// moqReadCloser_Close_results holds the results of the ReadCloser type -type moqReadCloser_Close_results struct { - params moqReadCloser_Close_params - results []struct { - values *struct { - result1 error - } - sequence uint32 - doFn moqReadCloser_Close_doFn - doReturnFn moqReadCloser_Close_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqReadCloser_Close_fnRecorder routes recorded function calls to the +// moqReadCloser_Close_recorder routes recorded function calls to the // moqReadCloser moq -type moqReadCloser_Close_fnRecorder struct { - params moqReadCloser_Close_params - anyParams uint64 - sequence bool - results *moqReadCloser_Close_results - moq *moqReadCloser +type moqReadCloser_Close_recorder struct { + recorder *impl.Recorder[ + *moqReadCloser_Close_adaptor, + moqReadCloser_Close_params, + moqReadCloser_Close_paramsKey, + moqReadCloser_Close_results, + ] } // moqReadCloser_Close_anyParams isolates the any params functions of the // ReadCloser type type moqReadCloser_Close_anyParams struct { - recorder *moqReadCloser_Close_fnRecorder + recorder *moqReadCloser_Close_recorder } // newMoqReadCloser creates a new moq of the ReadCloser type func newMoqReadCloser(scene *moq.Scene, config *moq.Config) *moqReadCloser { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqReadCloser_Read_adaptor{} + adaptor2 := &moqReadCloser_Close_adaptor{} m := &moqReadCloser{ - scene: scene, - config: *config, - moq: &moqReadCloser_mock{}, - - runtime: struct { - parameterIndexing struct { - Read struct { - p moq.ParamIndexing - } - Close struct{} - } - }{parameterIndexing: struct { - Read struct { - p moq.ParamIndexing - } - Close struct{} + moq: &moqReadCloser_mock{}, + + moq_Read: impl.NewMoq[ + *moqReadCloser_Read_adaptor, + moqReadCloser_Read_params, + moqReadCloser_Read_paramsKey, + moqReadCloser_Read_results, + ](scene, adaptor1, config), + moq_Close: impl.NewMoq[ + *moqReadCloser_Close_adaptor, + moqReadCloser_Close_params, + moqReadCloser_Close_paramsKey, + moqReadCloser_Close_results, + ](scene, adaptor2, config), + + runtime: moqReadCloser_runtime{parameterIndexing: struct { + Read moqReadCloser_Read_paramIndexing + Close moqReadCloser_Close_paramIndexing }{ - Read: struct { - p moq.ParamIndexing - }{ + Read: moqReadCloser_Read_paramIndexing{ p: moq.ParamIndexByHash, }, - Close: struct{}{}, + Close: moqReadCloser_Close_paramIndexing{}, }}, } m.moq.moq = m + adaptor1.moq = m + adaptor2.moq = m + scene.AddMoq(m) return m } @@ -199,109 +195,30 @@ func newMoqReadCloser(scene *moq.Scene, config *moq.Config) *moqReadCloser { // mock returns the mock implementation of the ReadCloser type func (m *moqReadCloser) mock() *moqReadCloser_mock { return m.moq } -func (m *moqReadCloser_mock) Read(p []byte) (n int, err error) { - m.moq.scene.T.Helper() +func (m *moqReadCloser_mock) Read(p []byte) (int, error) { + m.moq.moq_Read.Scene.T.Helper() params := moqReadCloser_Read_params{ p: p, } - var results *moqReadCloser_Read_results - for _, resultsByParams := range m.moq.resultsByParams_Read { - paramsKey := m.moq.paramsKey_Read(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_Read(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_Read(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_Read(params)) - } - } - if result.doFn != nil { - result.doFn(p) + var result1 int + var result2 error + if result := m.moq.moq_Read.Function(params); result != nil { + result1 = result.n + result2 = result.err } - - if result.values != nil { - n = result.values.n - err = result.values.err - } - if result.doReturnFn != nil { - n, err = result.doReturnFn(p) - } - return + return result1, result2 } -func (m *moqReadCloser_mock) Close() (result1 error) { - m.moq.scene.T.Helper() +func (m *moqReadCloser_mock) Close() error { + m.moq.moq_Close.Scene.T.Helper() params := moqReadCloser_Close_params{} - var results *moqReadCloser_Close_results - for _, resultsByParams := range m.moq.resultsByParams_Close { - paramsKey := m.moq.paramsKey_Close(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_Close(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_Close(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_Close(params)) - } - } - - if result.doFn != nil { - result.doFn() - } - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn() + var result1 error + if result := m.moq.moq_Close.Function(params); result != nil { + result1 = result.result1 } - return + return result1 } // onCall returns the recorder implementation of the ReadCloser type @@ -311,202 +228,90 @@ func (m *moqReadCloser) onCall() *moqReadCloser_recorder { } } -func (m *moqReadCloser_recorder) Read(p []byte) *moqReadCloser_Read_fnRecorder { - return &moqReadCloser_Read_fnRecorder{ - params: moqReadCloser_Read_params{ +func (m *moqReadCloser_recorder) Read(p []byte) *moqReadCloser_Read_recorder { + return &moqReadCloser_Read_recorder{ + recorder: m.moq.moq_Read.OnCall(moqReadCloser_Read_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqReadCloser_Read_fnRecorder) any() *moqReadCloser_Read_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_Read(r.params)) +func (r *moqReadCloser_Read_recorder) any() *moqReadCloser_Read_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqReadCloser_Read_anyParams{recorder: r} } -func (a *moqReadCloser_Read_anyParams) p() *moqReadCloser_Read_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqReadCloser_Read_anyParams) p() *moqReadCloser_Read_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqReadCloser_Read_fnRecorder) seq() *moqReadCloser_Read_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_Read(r.params)) +func (r *moqReadCloser_Read_recorder) seq() *moqReadCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqReadCloser_Read_fnRecorder) noSeq() *moqReadCloser_Read_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_Read(r.params)) +func (r *moqReadCloser_Read_recorder) noSeq() *moqReadCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqReadCloser_Read_fnRecorder) returnResults(n int, err error) *moqReadCloser_Read_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 { - n int - err error - } - sequence uint32 - doFn moqReadCloser_Read_doFn - doReturnFn moqReadCloser_Read_doReturnFn - }{ - values: &struct { - n int - err error - }{ - n: n, - err: err, - }, - sequence: sequence, +func (r *moqReadCloser_Read_recorder) returnResults(n int, err error) *moqReadCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqReadCloser_Read_results{ + n: n, + err: err, }) return r } -func (r *moqReadCloser_Read_fnRecorder) andDo(fn moqReadCloser_Read_doFn) *moqReadCloser_Read_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqReadCloser_Read_recorder) andDo(fn moqReadCloser_Read_doFn) *moqReadCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqReadCloser_Read_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqReadCloser_Read_fnRecorder) doReturnResults(fn moqReadCloser_Read_doReturnFn) *moqReadCloser_Read_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 { - n int - err error +func (r *moqReadCloser_Read_recorder) doReturnResults(fn moqReadCloser_Read_doReturnFn) *moqReadCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqReadCloser_Read_params) *moqReadCloser_Read_results { + n, err := fn(params.p) + return &moqReadCloser_Read_results{ + n: n, + err: err, } - sequence uint32 - doFn moqReadCloser_Read_doFn - doReturnFn moqReadCloser_Read_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqReadCloser_Read_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 *moqReadCloser_Read_resultsByParams - for n, res := range r.moq.resultsByParams_Read { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqReadCloser_Read_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqReadCloser_Read_paramsKey]*moqReadCloser_Read_results{}, - } - r.moq.resultsByParams_Read = append(r.moq.resultsByParams_Read, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Read) { - copy(r.moq.resultsByParams_Read[insertAt+1:], r.moq.resultsByParams_Read[insertAt:0]) - r.moq.resultsByParams_Read[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Read(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqReadCloser_Read_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 *moqReadCloser_Read_fnRecorder) repeat(repeaters ...moq.Repeater) *moqReadCloser_Read_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqReadCloser_Read_recorder) repeat(repeaters ...moq.Repeater) *moqReadCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - n int - err error - } - sequence uint32 - doFn moqReadCloser_Read_doFn - doReturnFn moqReadCloser_Read_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqReadCloser) prettyParams_Read(params moqReadCloser_Read_params) string { +func (*moqReadCloser_Read_adaptor) PrettyParams(params moqReadCloser_Read_params) string { return fmt.Sprintf("Read(%#v)", params.p) } -func (m *moqReadCloser) paramsKey_Read(params moqReadCloser_Read_params, anyParams uint64) moqReadCloser_Read_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Read.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter of the Read function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqReadCloser_Read_adaptor) ParamsKey(params moqReadCloser_Read_params, anyParams uint64) moqReadCloser_Read_paramsKey { + a.moq.moq_Read.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq_Read.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.Read.p, anyParams) return moqReadCloser_Read_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -515,183 +320,79 @@ func (m *moqReadCloser) paramsKey_Read(params moqReadCloser_Read_params, anyPara } } -func (m *moqReadCloser_recorder) Close() *moqReadCloser_Close_fnRecorder { - return &moqReadCloser_Close_fnRecorder{ - params: moqReadCloser_Close_params{}, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, +func (m *moqReadCloser_recorder) Close() *moqReadCloser_Close_recorder { + return &moqReadCloser_Close_recorder{ + recorder: m.moq.moq_Close.OnCall(moqReadCloser_Close_params{}), } } -func (r *moqReadCloser_Close_fnRecorder) any() *moqReadCloser_Close_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_Close(r.params)) +func (r *moqReadCloser_Close_recorder) any() *moqReadCloser_Close_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqReadCloser_Close_anyParams{recorder: r} } -func (r *moqReadCloser_Close_fnRecorder) seq() *moqReadCloser_Close_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_Close(r.params)) +func (r *moqReadCloser_Close_recorder) seq() *moqReadCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqReadCloser_Close_fnRecorder) noSeq() *moqReadCloser_Close_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_Close(r.params)) +func (r *moqReadCloser_Close_recorder) noSeq() *moqReadCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqReadCloser_Close_fnRecorder) returnResults(result1 error) *moqReadCloser_Close_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 error - } - sequence uint32 - doFn moqReadCloser_Close_doFn - doReturnFn moqReadCloser_Close_doReturnFn - }{ - values: &struct { - result1 error - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqReadCloser_Close_recorder) returnResults(result1 error) *moqReadCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqReadCloser_Close_results{ + result1: result1, }) return r } -func (r *moqReadCloser_Close_fnRecorder) andDo(fn moqReadCloser_Close_doFn) *moqReadCloser_Close_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqReadCloser_Close_recorder) andDo(fn moqReadCloser_Close_doFn) *moqReadCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqReadCloser_Close_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqReadCloser_Close_fnRecorder) doReturnResults(fn moqReadCloser_Close_doReturnFn) *moqReadCloser_Close_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 error +func (r *moqReadCloser_Close_recorder) doReturnResults(fn moqReadCloser_Close_doReturnFn) *moqReadCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqReadCloser_Close_params) *moqReadCloser_Close_results { + result1 := fn() + return &moqReadCloser_Close_results{ + result1: result1, } - sequence uint32 - doFn moqReadCloser_Close_doFn - doReturnFn moqReadCloser_Close_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqReadCloser_Close_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 *moqReadCloser_Close_resultsByParams - for n, res := range r.moq.resultsByParams_Close { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqReadCloser_Close_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqReadCloser_Close_paramsKey]*moqReadCloser_Close_results{}, - } - r.moq.resultsByParams_Close = append(r.moq.resultsByParams_Close, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Close) { - copy(r.moq.resultsByParams_Close[insertAt+1:], r.moq.resultsByParams_Close[insertAt:0]) - r.moq.resultsByParams_Close[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Close(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqReadCloser_Close_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 *moqReadCloser_Close_fnRecorder) repeat(repeaters ...moq.Repeater) *moqReadCloser_Close_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqReadCloser_Close_recorder) repeat(repeaters ...moq.Repeater) *moqReadCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 error - } - sequence uint32 - doFn moqReadCloser_Close_doFn - doReturnFn moqReadCloser_Close_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqReadCloser) prettyParams_Close(params moqReadCloser_Close_params) string { +func (*moqReadCloser_Close_adaptor) PrettyParams(params moqReadCloser_Close_params) string { return fmt.Sprintf("Close()") } -func (m *moqReadCloser) paramsKey_Close(params moqReadCloser_Close_params, anyParams uint64) moqReadCloser_Close_paramsKey { - m.scene.T.Helper() +func (a *moqReadCloser_Close_adaptor) ParamsKey(params moqReadCloser_Close_params, anyParams uint64) moqReadCloser_Close_paramsKey { + a.moq.moq_Close.Scene.T.Helper() return moqReadCloser_Close_paramsKey{ params: struct{}{}, hashes: struct{}{}, @@ -699,25 +400,14 @@ func (m *moqReadCloser) paramsKey_Close(params moqReadCloser_Close_params, anyPa } // Reset resets the state of the moq -func (m *moqReadCloser) Reset() { m.resultsByParams_Read = nil; m.resultsByParams_Close = nil } +func (m *moqReadCloser) Reset() { + m.moq_Read.Reset() + m.moq_Close.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqReadCloser) AssertExpectationsMet() { - m.scene.T.Helper() - for _, res := range m.resultsByParams_Read { - 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_Read(results.params)) - } - } - } - for _, res := range m.resultsByParams_Close { - 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_Close(results.params)) - } - } - } + m.moq_Read.Scene.T.Helper() + m.moq_Read.AssertExpectationsMet() + m.moq_Close.AssertExpectationsMet() } diff --git a/bulk/internal/moq_readwriteseekcloser_test.go b/bulk/internal/moq_readwriteseekcloser_test.go index e23dcd3..a4d7235 100644 --- a/bulk/internal/moq_readwriteseekcloser_test.go +++ b/bulk/internal/moq_readwriteseekcloser_test.go @@ -4,11 +4,10 @@ package internal_test import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/cli/bulk/internal" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -19,30 +18,34 @@ var _ internal.ReadWriteSeekCloser = (*moqReadWriteSeekCloser_mock)(nil) // moqReadWriteSeekCloser holds the state of a moq of the ReadWriteSeekCloser // type type moqReadWriteSeekCloser struct { - scene *moq.Scene - config moq.Config - moq *moqReadWriteSeekCloser_mock - - resultsByParams_Read []moqReadWriteSeekCloser_Read_resultsByParams - resultsByParams_Write []moqReadWriteSeekCloser_Write_resultsByParams - resultsByParams_Seek []moqReadWriteSeekCloser_Seek_resultsByParams - resultsByParams_Close []moqReadWriteSeekCloser_Close_resultsByParams - - runtime struct { - parameterIndexing struct { - Read struct { - p moq.ParamIndexing - } - Write struct { - p moq.ParamIndexing - } - Seek struct { - offset moq.ParamIndexing - whence moq.ParamIndexing - } - Close struct{} - } - } + moq *moqReadWriteSeekCloser_mock + + moq_Read *impl.Moq[ + *moqReadWriteSeekCloser_Read_adaptor, + moqReadWriteSeekCloser_Read_params, + moqReadWriteSeekCloser_Read_paramsKey, + moqReadWriteSeekCloser_Read_results, + ] + moq_Write *impl.Moq[ + *moqReadWriteSeekCloser_Write_adaptor, + moqReadWriteSeekCloser_Write_params, + moqReadWriteSeekCloser_Write_paramsKey, + moqReadWriteSeekCloser_Write_results, + ] + moq_Seek *impl.Moq[ + *moqReadWriteSeekCloser_Seek_adaptor, + moqReadWriteSeekCloser_Seek_params, + moqReadWriteSeekCloser_Seek_paramsKey, + moqReadWriteSeekCloser_Seek_results, + ] + moq_Close *impl.Moq[ + *moqReadWriteSeekCloser_Close_adaptor, + moqReadWriteSeekCloser_Close_params, + moqReadWriteSeekCloser_Close_paramsKey, + moqReadWriteSeekCloser_Close_results, + ] + + runtime moqReadWriteSeekCloser_runtime } // moqReadWriteSeekCloser_mock isolates the mock interface of the @@ -57,6 +60,23 @@ type moqReadWriteSeekCloser_recorder struct { moq *moqReadWriteSeekCloser } +// moqReadWriteSeekCloser_runtime holds runtime configuration for the +// ReadWriteSeekCloser type +type moqReadWriteSeekCloser_runtime struct { + parameterIndexing struct { + Read moqReadWriteSeekCloser_Read_paramIndexing + Write moqReadWriteSeekCloser_Write_paramIndexing + Seek moqReadWriteSeekCloser_Seek_paramIndexing + Close moqReadWriteSeekCloser_Close_paramIndexing + } +} + +// moqReadWriteSeekCloser_Read_adaptor adapts moqReadWriteSeekCloser as needed +// by the runtime +type moqReadWriteSeekCloser_Read_adaptor struct { + moq *moqReadWriteSeekCloser +} + // moqReadWriteSeekCloser_Read_params holds the params of the // ReadWriteSeekCloser type type moqReadWriteSeekCloser_Read_params struct{ p []byte } @@ -68,12 +88,17 @@ type moqReadWriteSeekCloser_Read_paramsKey struct { hashes struct{ p hash.Hash } } -// moqReadWriteSeekCloser_Read_resultsByParams contains the results for a given -// set of parameters for the ReadWriteSeekCloser type -type moqReadWriteSeekCloser_Read_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqReadWriteSeekCloser_Read_paramsKey]*moqReadWriteSeekCloser_Read_results +// moqReadWriteSeekCloser_Read_results holds the results of the +// ReadWriteSeekCloser type +type moqReadWriteSeekCloser_Read_results struct { + n int + err error +} + +// moqReadWriteSeekCloser_Read_paramIndexing holds the parameter indexing +// runtime configuration for the ReadWriteSeekCloser type +type moqReadWriteSeekCloser_Read_paramIndexing struct { + p moq.ParamIndexing } // moqReadWriteSeekCloser_Read_doFn defines the type of function needed when @@ -84,37 +109,27 @@ type moqReadWriteSeekCloser_Read_doFn func(p []byte) // when calling doReturnResults for the ReadWriteSeekCloser type type moqReadWriteSeekCloser_Read_doReturnFn func(p []byte) (n int, err error) -// moqReadWriteSeekCloser_Read_results holds the results of the -// ReadWriteSeekCloser type -type moqReadWriteSeekCloser_Read_results struct { - params moqReadWriteSeekCloser_Read_params - results []struct { - values *struct { - n int - err error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Read_doFn - doReturnFn moqReadWriteSeekCloser_Read_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqReadWriteSeekCloser_Read_fnRecorder routes recorded function calls to the +// moqReadWriteSeekCloser_Read_recorder routes recorded function calls to the // moqReadWriteSeekCloser moq -type moqReadWriteSeekCloser_Read_fnRecorder struct { - params moqReadWriteSeekCloser_Read_params - anyParams uint64 - sequence bool - results *moqReadWriteSeekCloser_Read_results - moq *moqReadWriteSeekCloser +type moqReadWriteSeekCloser_Read_recorder struct { + recorder *impl.Recorder[ + *moqReadWriteSeekCloser_Read_adaptor, + moqReadWriteSeekCloser_Read_params, + moqReadWriteSeekCloser_Read_paramsKey, + moqReadWriteSeekCloser_Read_results, + ] } // moqReadWriteSeekCloser_Read_anyParams isolates the any params functions of // the ReadWriteSeekCloser type type moqReadWriteSeekCloser_Read_anyParams struct { - recorder *moqReadWriteSeekCloser_Read_fnRecorder + recorder *moqReadWriteSeekCloser_Read_recorder +} + +// moqReadWriteSeekCloser_Write_adaptor adapts moqReadWriteSeekCloser as needed +// by the runtime +type moqReadWriteSeekCloser_Write_adaptor struct { + moq *moqReadWriteSeekCloser } // moqReadWriteSeekCloser_Write_params holds the params of the @@ -128,12 +143,17 @@ type moqReadWriteSeekCloser_Write_paramsKey struct { hashes struct{ p hash.Hash } } -// moqReadWriteSeekCloser_Write_resultsByParams contains the results for a -// given set of parameters for the ReadWriteSeekCloser type -type moqReadWriteSeekCloser_Write_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqReadWriteSeekCloser_Write_paramsKey]*moqReadWriteSeekCloser_Write_results +// moqReadWriteSeekCloser_Write_results holds the results of the +// ReadWriteSeekCloser type +type moqReadWriteSeekCloser_Write_results struct { + n int + err error +} + +// moqReadWriteSeekCloser_Write_paramIndexing holds the parameter indexing +// runtime configuration for the ReadWriteSeekCloser type +type moqReadWriteSeekCloser_Write_paramIndexing struct { + p moq.ParamIndexing } // moqReadWriteSeekCloser_Write_doFn defines the type of function needed when @@ -144,37 +164,27 @@ type moqReadWriteSeekCloser_Write_doFn func(p []byte) // when calling doReturnResults for the ReadWriteSeekCloser type type moqReadWriteSeekCloser_Write_doReturnFn func(p []byte) (n int, err error) -// moqReadWriteSeekCloser_Write_results holds the results of the -// ReadWriteSeekCloser type -type moqReadWriteSeekCloser_Write_results struct { - params moqReadWriteSeekCloser_Write_params - results []struct { - values *struct { - n int - err error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Write_doFn - doReturnFn moqReadWriteSeekCloser_Write_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqReadWriteSeekCloser_Write_fnRecorder routes recorded function calls to -// the moqReadWriteSeekCloser moq -type moqReadWriteSeekCloser_Write_fnRecorder struct { - params moqReadWriteSeekCloser_Write_params - anyParams uint64 - sequence bool - results *moqReadWriteSeekCloser_Write_results - moq *moqReadWriteSeekCloser +// moqReadWriteSeekCloser_Write_recorder routes recorded function calls to the +// moqReadWriteSeekCloser moq +type moqReadWriteSeekCloser_Write_recorder struct { + recorder *impl.Recorder[ + *moqReadWriteSeekCloser_Write_adaptor, + moqReadWriteSeekCloser_Write_params, + moqReadWriteSeekCloser_Write_paramsKey, + moqReadWriteSeekCloser_Write_results, + ] } // moqReadWriteSeekCloser_Write_anyParams isolates the any params functions of // the ReadWriteSeekCloser type type moqReadWriteSeekCloser_Write_anyParams struct { - recorder *moqReadWriteSeekCloser_Write_fnRecorder + recorder *moqReadWriteSeekCloser_Write_recorder +} + +// moqReadWriteSeekCloser_Seek_adaptor adapts moqReadWriteSeekCloser as needed +// by the runtime +type moqReadWriteSeekCloser_Seek_adaptor struct { + moq *moqReadWriteSeekCloser } // moqReadWriteSeekCloser_Seek_params holds the params of the @@ -197,12 +207,18 @@ type moqReadWriteSeekCloser_Seek_paramsKey struct { } } -// moqReadWriteSeekCloser_Seek_resultsByParams contains the results for a given -// set of parameters for the ReadWriteSeekCloser type -type moqReadWriteSeekCloser_Seek_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqReadWriteSeekCloser_Seek_paramsKey]*moqReadWriteSeekCloser_Seek_results +// moqReadWriteSeekCloser_Seek_results holds the results of the +// ReadWriteSeekCloser type +type moqReadWriteSeekCloser_Seek_results struct { + result1 int64 + result2 error +} + +// moqReadWriteSeekCloser_Seek_paramIndexing holds the parameter indexing +// runtime configuration for the ReadWriteSeekCloser type +type moqReadWriteSeekCloser_Seek_paramIndexing struct { + offset moq.ParamIndexing + whence moq.ParamIndexing } // moqReadWriteSeekCloser_Seek_doFn defines the type of function needed when @@ -213,37 +229,27 @@ type moqReadWriteSeekCloser_Seek_doFn func(offset int64, whence int) // when calling doReturnResults for the ReadWriteSeekCloser type type moqReadWriteSeekCloser_Seek_doReturnFn func(offset int64, whence int) (int64, error) -// moqReadWriteSeekCloser_Seek_results holds the results of the -// ReadWriteSeekCloser type -type moqReadWriteSeekCloser_Seek_results struct { - params moqReadWriteSeekCloser_Seek_params - results []struct { - values *struct { - result1 int64 - result2 error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Seek_doFn - doReturnFn moqReadWriteSeekCloser_Seek_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqReadWriteSeekCloser_Seek_fnRecorder routes recorded function calls to the +// moqReadWriteSeekCloser_Seek_recorder routes recorded function calls to the // moqReadWriteSeekCloser moq -type moqReadWriteSeekCloser_Seek_fnRecorder struct { - params moqReadWriteSeekCloser_Seek_params - anyParams uint64 - sequence bool - results *moqReadWriteSeekCloser_Seek_results - moq *moqReadWriteSeekCloser +type moqReadWriteSeekCloser_Seek_recorder struct { + recorder *impl.Recorder[ + *moqReadWriteSeekCloser_Seek_adaptor, + moqReadWriteSeekCloser_Seek_params, + moqReadWriteSeekCloser_Seek_paramsKey, + moqReadWriteSeekCloser_Seek_results, + ] } // moqReadWriteSeekCloser_Seek_anyParams isolates the any params functions of // the ReadWriteSeekCloser type type moqReadWriteSeekCloser_Seek_anyParams struct { - recorder *moqReadWriteSeekCloser_Seek_fnRecorder + recorder *moqReadWriteSeekCloser_Seek_recorder +} + +// moqReadWriteSeekCloser_Close_adaptor adapts moqReadWriteSeekCloser as needed +// by the runtime +type moqReadWriteSeekCloser_Close_adaptor struct { + moq *moqReadWriteSeekCloser } // moqReadWriteSeekCloser_Close_params holds the params of the @@ -257,14 +263,16 @@ type moqReadWriteSeekCloser_Close_paramsKey struct { hashes struct{} } -// moqReadWriteSeekCloser_Close_resultsByParams contains the results for a -// given set of parameters for the ReadWriteSeekCloser type -type moqReadWriteSeekCloser_Close_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqReadWriteSeekCloser_Close_paramsKey]*moqReadWriteSeekCloser_Close_results +// moqReadWriteSeekCloser_Close_results holds the results of the +// ReadWriteSeekCloser type +type moqReadWriteSeekCloser_Close_results struct { + result1 error } +// moqReadWriteSeekCloser_Close_paramIndexing holds the parameter indexing +// runtime configuration for the ReadWriteSeekCloser type +type moqReadWriteSeekCloser_Close_paramIndexing struct{} + // moqReadWriteSeekCloser_Close_doFn defines the type of function needed when // calling andDo for the ReadWriteSeekCloser type type moqReadWriteSeekCloser_Close_doFn func() @@ -273,97 +281,83 @@ type moqReadWriteSeekCloser_Close_doFn func() // when calling doReturnResults for the ReadWriteSeekCloser type type moqReadWriteSeekCloser_Close_doReturnFn func() error -// moqReadWriteSeekCloser_Close_results holds the results of the -// ReadWriteSeekCloser type -type moqReadWriteSeekCloser_Close_results struct { - params moqReadWriteSeekCloser_Close_params - results []struct { - values *struct { - result1 error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Close_doFn - doReturnFn moqReadWriteSeekCloser_Close_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqReadWriteSeekCloser_Close_fnRecorder routes recorded function calls to -// the moqReadWriteSeekCloser moq -type moqReadWriteSeekCloser_Close_fnRecorder struct { - params moqReadWriteSeekCloser_Close_params - anyParams uint64 - sequence bool - results *moqReadWriteSeekCloser_Close_results - moq *moqReadWriteSeekCloser +// moqReadWriteSeekCloser_Close_recorder routes recorded function calls to the +// moqReadWriteSeekCloser moq +type moqReadWriteSeekCloser_Close_recorder struct { + recorder *impl.Recorder[ + *moqReadWriteSeekCloser_Close_adaptor, + moqReadWriteSeekCloser_Close_params, + moqReadWriteSeekCloser_Close_paramsKey, + moqReadWriteSeekCloser_Close_results, + ] } // moqReadWriteSeekCloser_Close_anyParams isolates the any params functions of // the ReadWriteSeekCloser type type moqReadWriteSeekCloser_Close_anyParams struct { - recorder *moqReadWriteSeekCloser_Close_fnRecorder + recorder *moqReadWriteSeekCloser_Close_recorder } // newMoqReadWriteSeekCloser creates a new moq of the ReadWriteSeekCloser type func newMoqReadWriteSeekCloser(scene *moq.Scene, config *moq.Config) *moqReadWriteSeekCloser { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqReadWriteSeekCloser_Read_adaptor{} + adaptor2 := &moqReadWriteSeekCloser_Write_adaptor{} + adaptor3 := &moqReadWriteSeekCloser_Seek_adaptor{} + adaptor4 := &moqReadWriteSeekCloser_Close_adaptor{} m := &moqReadWriteSeekCloser{ - scene: scene, - config: *config, - moq: &moqReadWriteSeekCloser_mock{}, - - runtime: struct { - parameterIndexing struct { - Read struct { - p moq.ParamIndexing - } - Write struct { - p moq.ParamIndexing - } - Seek struct { - offset moq.ParamIndexing - whence moq.ParamIndexing - } - Close struct{} - } - }{parameterIndexing: struct { - Read struct { - p moq.ParamIndexing - } - Write struct { - p moq.ParamIndexing - } - Seek struct { - offset moq.ParamIndexing - whence moq.ParamIndexing - } - Close struct{} + moq: &moqReadWriteSeekCloser_mock{}, + + moq_Read: impl.NewMoq[ + *moqReadWriteSeekCloser_Read_adaptor, + moqReadWriteSeekCloser_Read_params, + moqReadWriteSeekCloser_Read_paramsKey, + moqReadWriteSeekCloser_Read_results, + ](scene, adaptor1, config), + moq_Write: impl.NewMoq[ + *moqReadWriteSeekCloser_Write_adaptor, + moqReadWriteSeekCloser_Write_params, + moqReadWriteSeekCloser_Write_paramsKey, + moqReadWriteSeekCloser_Write_results, + ](scene, adaptor2, config), + moq_Seek: impl.NewMoq[ + *moqReadWriteSeekCloser_Seek_adaptor, + moqReadWriteSeekCloser_Seek_params, + moqReadWriteSeekCloser_Seek_paramsKey, + moqReadWriteSeekCloser_Seek_results, + ](scene, adaptor3, config), + moq_Close: impl.NewMoq[ + *moqReadWriteSeekCloser_Close_adaptor, + moqReadWriteSeekCloser_Close_params, + moqReadWriteSeekCloser_Close_paramsKey, + moqReadWriteSeekCloser_Close_results, + ](scene, adaptor4, config), + + runtime: moqReadWriteSeekCloser_runtime{parameterIndexing: struct { + Read moqReadWriteSeekCloser_Read_paramIndexing + Write moqReadWriteSeekCloser_Write_paramIndexing + Seek moqReadWriteSeekCloser_Seek_paramIndexing + Close moqReadWriteSeekCloser_Close_paramIndexing }{ - Read: struct { - p moq.ParamIndexing - }{ + Read: moqReadWriteSeekCloser_Read_paramIndexing{ p: moq.ParamIndexByHash, }, - Write: struct { - p moq.ParamIndexing - }{ + Write: moqReadWriteSeekCloser_Write_paramIndexing{ p: moq.ParamIndexByHash, }, - Seek: struct { - offset moq.ParamIndexing - whence moq.ParamIndexing - }{ + Seek: moqReadWriteSeekCloser_Seek_paramIndexing{ offset: moq.ParamIndexByValue, whence: moq.ParamIndexByValue, }, - Close: struct{}{}, + Close: moqReadWriteSeekCloser_Close_paramIndexing{}, }}, } m.moq.moq = m + adaptor1.moq = m + adaptor2.moq = m + adaptor3.moq = m + adaptor4.moq = m + scene.AddMoq(m) return m } @@ -371,218 +365,61 @@ func newMoqReadWriteSeekCloser(scene *moq.Scene, config *moq.Config) *moqReadWri // mock returns the mock implementation of the ReadWriteSeekCloser type func (m *moqReadWriteSeekCloser) mock() *moqReadWriteSeekCloser_mock { return m.moq } -func (m *moqReadWriteSeekCloser_mock) Read(p []byte) (n int, err error) { - m.moq.scene.T.Helper() +func (m *moqReadWriteSeekCloser_mock) Read(p []byte) (int, error) { + m.moq.moq_Read.Scene.T.Helper() params := moqReadWriteSeekCloser_Read_params{ p: p, } - var results *moqReadWriteSeekCloser_Read_results - for _, resultsByParams := range m.moq.resultsByParams_Read { - paramsKey := m.moq.paramsKey_Read(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_Read(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_Read(params)) - } - return - } - i = results.repeat.ResultCount - 1 + var result1 int + var result2 error + if result := m.moq.moq_Read.Function(params); result != nil { + result1 = result.n + result2 = result.err } - - 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_Read(params)) - } - } - - if result.doFn != nil { - result.doFn(p) - } - - if result.values != nil { - n = result.values.n - err = result.values.err - } - if result.doReturnFn != nil { - n, err = result.doReturnFn(p) - } - return + return result1, result2 } -func (m *moqReadWriteSeekCloser_mock) Write(p []byte) (n int, err error) { - m.moq.scene.T.Helper() +func (m *moqReadWriteSeekCloser_mock) Write(p []byte) (int, error) { + m.moq.moq_Write.Scene.T.Helper() params := moqReadWriteSeekCloser_Write_params{ p: p, } - var results *moqReadWriteSeekCloser_Write_results - for _, resultsByParams := range m.moq.resultsByParams_Write { - paramsKey := m.moq.paramsKey_Write(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_Write(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_Write(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_Write(params)) - } - } - - if result.doFn != nil { - result.doFn(p) - } - if result.values != nil { - n = result.values.n - err = result.values.err - } - if result.doReturnFn != nil { - n, err = result.doReturnFn(p) + var result1 int + var result2 error + if result := m.moq.moq_Write.Function(params); result != nil { + result1 = result.n + result2 = result.err } - return + return result1, result2 } -func (m *moqReadWriteSeekCloser_mock) Seek(offset int64, whence int) (result1 int64, result2 error) { - m.moq.scene.T.Helper() +func (m *moqReadWriteSeekCloser_mock) Seek(offset int64, whence int) (int64, error) { + m.moq.moq_Seek.Scene.T.Helper() params := moqReadWriteSeekCloser_Seek_params{ offset: offset, whence: whence, } - var results *moqReadWriteSeekCloser_Seek_results - for _, resultsByParams := range m.moq.resultsByParams_Seek { - paramsKey := m.moq.paramsKey_Seek(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_Seek(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_Seek(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_Seek(params)) - } - } - - if result.doFn != nil { - result.doFn(offset, whence) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 + var result1 int64 + var result2 error + if result := m.moq.moq_Seek.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(offset, whence) - } - return + return result1, result2 } -func (m *moqReadWriteSeekCloser_mock) Close() (result1 error) { - m.moq.scene.T.Helper() +func (m *moqReadWriteSeekCloser_mock) Close() error { + m.moq.moq_Close.Scene.T.Helper() params := moqReadWriteSeekCloser_Close_params{} - var results *moqReadWriteSeekCloser_Close_results - for _, resultsByParams := range m.moq.resultsByParams_Close { - paramsKey := m.moq.paramsKey_Close(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_Close(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_Close(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_Close(params)) - } - } - - if result.doFn != nil { - result.doFn() - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn() + var result1 error + if result := m.moq.moq_Close.Function(params); result != nil { + result1 = result.result1 } - return + return result1 } // onCall returns the recorder implementation of the ReadWriteSeekCloser type @@ -592,202 +429,90 @@ func (m *moqReadWriteSeekCloser) onCall() *moqReadWriteSeekCloser_recorder { } } -func (m *moqReadWriteSeekCloser_recorder) Read(p []byte) *moqReadWriteSeekCloser_Read_fnRecorder { - return &moqReadWriteSeekCloser_Read_fnRecorder{ - params: moqReadWriteSeekCloser_Read_params{ +func (m *moqReadWriteSeekCloser_recorder) Read(p []byte) *moqReadWriteSeekCloser_Read_recorder { + return &moqReadWriteSeekCloser_Read_recorder{ + recorder: m.moq.moq_Read.OnCall(moqReadWriteSeekCloser_Read_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqReadWriteSeekCloser_Read_fnRecorder) any() *moqReadWriteSeekCloser_Read_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_Read(r.params)) +func (r *moqReadWriteSeekCloser_Read_recorder) any() *moqReadWriteSeekCloser_Read_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqReadWriteSeekCloser_Read_anyParams{recorder: r} } -func (a *moqReadWriteSeekCloser_Read_anyParams) p() *moqReadWriteSeekCloser_Read_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqReadWriteSeekCloser_Read_anyParams) p() *moqReadWriteSeekCloser_Read_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqReadWriteSeekCloser_Read_fnRecorder) seq() *moqReadWriteSeekCloser_Read_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_Read(r.params)) +func (r *moqReadWriteSeekCloser_Read_recorder) seq() *moqReadWriteSeekCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqReadWriteSeekCloser_Read_fnRecorder) noSeq() *moqReadWriteSeekCloser_Read_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_Read(r.params)) +func (r *moqReadWriteSeekCloser_Read_recorder) noSeq() *moqReadWriteSeekCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqReadWriteSeekCloser_Read_fnRecorder) returnResults(n int, err error) *moqReadWriteSeekCloser_Read_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 { - n int - err error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Read_doFn - doReturnFn moqReadWriteSeekCloser_Read_doReturnFn - }{ - values: &struct { - n int - err error - }{ - n: n, - err: err, - }, - sequence: sequence, +func (r *moqReadWriteSeekCloser_Read_recorder) returnResults(n int, err error) *moqReadWriteSeekCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqReadWriteSeekCloser_Read_results{ + n: n, + err: err, }) return r } -func (r *moqReadWriteSeekCloser_Read_fnRecorder) andDo(fn moqReadWriteSeekCloser_Read_doFn) *moqReadWriteSeekCloser_Read_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqReadWriteSeekCloser_Read_recorder) andDo(fn moqReadWriteSeekCloser_Read_doFn) *moqReadWriteSeekCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqReadWriteSeekCloser_Read_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqReadWriteSeekCloser_Read_fnRecorder) doReturnResults(fn moqReadWriteSeekCloser_Read_doReturnFn) *moqReadWriteSeekCloser_Read_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 { - n int - err error +func (r *moqReadWriteSeekCloser_Read_recorder) doReturnResults(fn moqReadWriteSeekCloser_Read_doReturnFn) *moqReadWriteSeekCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqReadWriteSeekCloser_Read_params) *moqReadWriteSeekCloser_Read_results { + n, err := fn(params.p) + return &moqReadWriteSeekCloser_Read_results{ + n: n, + err: err, } - sequence uint32 - doFn moqReadWriteSeekCloser_Read_doFn - doReturnFn moqReadWriteSeekCloser_Read_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqReadWriteSeekCloser_Read_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 *moqReadWriteSeekCloser_Read_resultsByParams - for n, res := range r.moq.resultsByParams_Read { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqReadWriteSeekCloser_Read_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqReadWriteSeekCloser_Read_paramsKey]*moqReadWriteSeekCloser_Read_results{}, - } - r.moq.resultsByParams_Read = append(r.moq.resultsByParams_Read, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Read) { - copy(r.moq.resultsByParams_Read[insertAt+1:], r.moq.resultsByParams_Read[insertAt:0]) - r.moq.resultsByParams_Read[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Read(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqReadWriteSeekCloser_Read_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 *moqReadWriteSeekCloser_Read_fnRecorder) repeat(repeaters ...moq.Repeater) *moqReadWriteSeekCloser_Read_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqReadWriteSeekCloser_Read_recorder) repeat(repeaters ...moq.Repeater) *moqReadWriteSeekCloser_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - n int - err error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Read_doFn - doReturnFn moqReadWriteSeekCloser_Read_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqReadWriteSeekCloser) prettyParams_Read(params moqReadWriteSeekCloser_Read_params) string { +func (*moqReadWriteSeekCloser_Read_adaptor) PrettyParams(params moqReadWriteSeekCloser_Read_params) string { return fmt.Sprintf("Read(%#v)", params.p) } -func (m *moqReadWriteSeekCloser) paramsKey_Read(params moqReadWriteSeekCloser_Read_params, anyParams uint64) moqReadWriteSeekCloser_Read_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Read.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter of the Read function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqReadWriteSeekCloser_Read_adaptor) ParamsKey(params moqReadWriteSeekCloser_Read_params, anyParams uint64) moqReadWriteSeekCloser_Read_paramsKey { + a.moq.moq_Read.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq_Read.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.Read.p, anyParams) return moqReadWriteSeekCloser_Read_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -796,202 +521,90 @@ func (m *moqReadWriteSeekCloser) paramsKey_Read(params moqReadWriteSeekCloser_Re } } -func (m *moqReadWriteSeekCloser_recorder) Write(p []byte) *moqReadWriteSeekCloser_Write_fnRecorder { - return &moqReadWriteSeekCloser_Write_fnRecorder{ - params: moqReadWriteSeekCloser_Write_params{ +func (m *moqReadWriteSeekCloser_recorder) Write(p []byte) *moqReadWriteSeekCloser_Write_recorder { + return &moqReadWriteSeekCloser_Write_recorder{ + recorder: m.moq.moq_Write.OnCall(moqReadWriteSeekCloser_Write_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqReadWriteSeekCloser_Write_fnRecorder) any() *moqReadWriteSeekCloser_Write_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_Write(r.params)) +func (r *moqReadWriteSeekCloser_Write_recorder) any() *moqReadWriteSeekCloser_Write_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqReadWriteSeekCloser_Write_anyParams{recorder: r} } -func (a *moqReadWriteSeekCloser_Write_anyParams) p() *moqReadWriteSeekCloser_Write_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqReadWriteSeekCloser_Write_anyParams) p() *moqReadWriteSeekCloser_Write_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqReadWriteSeekCloser_Write_fnRecorder) seq() *moqReadWriteSeekCloser_Write_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_Write(r.params)) +func (r *moqReadWriteSeekCloser_Write_recorder) seq() *moqReadWriteSeekCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqReadWriteSeekCloser_Write_fnRecorder) noSeq() *moqReadWriteSeekCloser_Write_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_Write(r.params)) +func (r *moqReadWriteSeekCloser_Write_recorder) noSeq() *moqReadWriteSeekCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqReadWriteSeekCloser_Write_fnRecorder) returnResults(n int, err error) *moqReadWriteSeekCloser_Write_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 { - n int - err error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Write_doFn - doReturnFn moqReadWriteSeekCloser_Write_doReturnFn - }{ - values: &struct { - n int - err error - }{ - n: n, - err: err, - }, - sequence: sequence, +func (r *moqReadWriteSeekCloser_Write_recorder) returnResults(n int, err error) *moqReadWriteSeekCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqReadWriteSeekCloser_Write_results{ + n: n, + err: err, }) return r } -func (r *moqReadWriteSeekCloser_Write_fnRecorder) andDo(fn moqReadWriteSeekCloser_Write_doFn) *moqReadWriteSeekCloser_Write_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqReadWriteSeekCloser_Write_recorder) andDo(fn moqReadWriteSeekCloser_Write_doFn) *moqReadWriteSeekCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqReadWriteSeekCloser_Write_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqReadWriteSeekCloser_Write_fnRecorder) doReturnResults(fn moqReadWriteSeekCloser_Write_doReturnFn) *moqReadWriteSeekCloser_Write_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 { - n int - err error +func (r *moqReadWriteSeekCloser_Write_recorder) doReturnResults(fn moqReadWriteSeekCloser_Write_doReturnFn) *moqReadWriteSeekCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqReadWriteSeekCloser_Write_params) *moqReadWriteSeekCloser_Write_results { + n, err := fn(params.p) + return &moqReadWriteSeekCloser_Write_results{ + n: n, + err: err, } - sequence uint32 - doFn moqReadWriteSeekCloser_Write_doFn - doReturnFn moqReadWriteSeekCloser_Write_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqReadWriteSeekCloser_Write_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 *moqReadWriteSeekCloser_Write_resultsByParams - for n, res := range r.moq.resultsByParams_Write { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqReadWriteSeekCloser_Write_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqReadWriteSeekCloser_Write_paramsKey]*moqReadWriteSeekCloser_Write_results{}, - } - r.moq.resultsByParams_Write = append(r.moq.resultsByParams_Write, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Write) { - copy(r.moq.resultsByParams_Write[insertAt+1:], r.moq.resultsByParams_Write[insertAt:0]) - r.moq.resultsByParams_Write[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Write(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqReadWriteSeekCloser_Write_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 *moqReadWriteSeekCloser_Write_fnRecorder) repeat(repeaters ...moq.Repeater) *moqReadWriteSeekCloser_Write_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqReadWriteSeekCloser_Write_recorder) repeat(repeaters ...moq.Repeater) *moqReadWriteSeekCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - n int - err error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Write_doFn - doReturnFn moqReadWriteSeekCloser_Write_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqReadWriteSeekCloser) prettyParams_Write(params moqReadWriteSeekCloser_Write_params) string { +func (*moqReadWriteSeekCloser_Write_adaptor) PrettyParams(params moqReadWriteSeekCloser_Write_params) string { return fmt.Sprintf("Write(%#v)", params.p) } -func (m *moqReadWriteSeekCloser) paramsKey_Write(params moqReadWriteSeekCloser_Write_params, anyParams uint64) moqReadWriteSeekCloser_Write_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Write.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter of the Write function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqReadWriteSeekCloser_Write_adaptor) ParamsKey(params moqReadWriteSeekCloser_Write_params, anyParams uint64) moqReadWriteSeekCloser_Write_paramsKey { + a.moq.moq_Write.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq_Write.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.Write.p, anyParams) return moqReadWriteSeekCloser_Write_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -1000,219 +613,98 @@ func (m *moqReadWriteSeekCloser) paramsKey_Write(params moqReadWriteSeekCloser_W } } -func (m *moqReadWriteSeekCloser_recorder) Seek(offset int64, whence int) *moqReadWriteSeekCloser_Seek_fnRecorder { - return &moqReadWriteSeekCloser_Seek_fnRecorder{ - params: moqReadWriteSeekCloser_Seek_params{ +func (m *moqReadWriteSeekCloser_recorder) Seek(offset int64, whence int) *moqReadWriteSeekCloser_Seek_recorder { + return &moqReadWriteSeekCloser_Seek_recorder{ + recorder: m.moq.moq_Seek.OnCall(moqReadWriteSeekCloser_Seek_params{ offset: offset, whence: whence, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqReadWriteSeekCloser_Seek_fnRecorder) any() *moqReadWriteSeekCloser_Seek_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_Seek(r.params)) +func (r *moqReadWriteSeekCloser_Seek_recorder) any() *moqReadWriteSeekCloser_Seek_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqReadWriteSeekCloser_Seek_anyParams{recorder: r} } -func (a *moqReadWriteSeekCloser_Seek_anyParams) offset() *moqReadWriteSeekCloser_Seek_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqReadWriteSeekCloser_Seek_anyParams) offset() *moqReadWriteSeekCloser_Seek_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqReadWriteSeekCloser_Seek_anyParams) whence() *moqReadWriteSeekCloser_Seek_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqReadWriteSeekCloser_Seek_anyParams) whence() *moqReadWriteSeekCloser_Seek_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqReadWriteSeekCloser_Seek_fnRecorder) seq() *moqReadWriteSeekCloser_Seek_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_Seek(r.params)) +func (r *moqReadWriteSeekCloser_Seek_recorder) seq() *moqReadWriteSeekCloser_Seek_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqReadWriteSeekCloser_Seek_fnRecorder) noSeq() *moqReadWriteSeekCloser_Seek_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_Seek(r.params)) +func (r *moqReadWriteSeekCloser_Seek_recorder) noSeq() *moqReadWriteSeekCloser_Seek_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqReadWriteSeekCloser_Seek_fnRecorder) returnResults(result1 int64, result2 error) *moqReadWriteSeekCloser_Seek_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 int64 - result2 error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Seek_doFn - doReturnFn moqReadWriteSeekCloser_Seek_doReturnFn - }{ - values: &struct { - result1 int64 - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqReadWriteSeekCloser_Seek_recorder) returnResults(result1 int64, result2 error) *moqReadWriteSeekCloser_Seek_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqReadWriteSeekCloser_Seek_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqReadWriteSeekCloser_Seek_fnRecorder) andDo(fn moqReadWriteSeekCloser_Seek_doFn) *moqReadWriteSeekCloser_Seek_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqReadWriteSeekCloser_Seek_recorder) andDo(fn moqReadWriteSeekCloser_Seek_doFn) *moqReadWriteSeekCloser_Seek_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqReadWriteSeekCloser_Seek_params) { + fn(params.offset, params.whence) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqReadWriteSeekCloser_Seek_fnRecorder) doReturnResults(fn moqReadWriteSeekCloser_Seek_doReturnFn) *moqReadWriteSeekCloser_Seek_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 int64 - result2 error +func (r *moqReadWriteSeekCloser_Seek_recorder) doReturnResults(fn moqReadWriteSeekCloser_Seek_doReturnFn) *moqReadWriteSeekCloser_Seek_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqReadWriteSeekCloser_Seek_params) *moqReadWriteSeekCloser_Seek_results { + result1, result2 := fn(params.offset, params.whence) + return &moqReadWriteSeekCloser_Seek_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqReadWriteSeekCloser_Seek_doFn - doReturnFn moqReadWriteSeekCloser_Seek_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqReadWriteSeekCloser_Seek_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 *moqReadWriteSeekCloser_Seek_resultsByParams - for n, res := range r.moq.resultsByParams_Seek { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqReadWriteSeekCloser_Seek_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqReadWriteSeekCloser_Seek_paramsKey]*moqReadWriteSeekCloser_Seek_results{}, - } - r.moq.resultsByParams_Seek = append(r.moq.resultsByParams_Seek, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Seek) { - copy(r.moq.resultsByParams_Seek[insertAt+1:], r.moq.resultsByParams_Seek[insertAt:0]) - r.moq.resultsByParams_Seek[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Seek(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqReadWriteSeekCloser_Seek_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 *moqReadWriteSeekCloser_Seek_fnRecorder) repeat(repeaters ...moq.Repeater) *moqReadWriteSeekCloser_Seek_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqReadWriteSeekCloser_Seek_recorder) repeat(repeaters ...moq.Repeater) *moqReadWriteSeekCloser_Seek_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 int64 - result2 error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Seek_doFn - doReturnFn moqReadWriteSeekCloser_Seek_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqReadWriteSeekCloser) prettyParams_Seek(params moqReadWriteSeekCloser_Seek_params) string { +func (*moqReadWriteSeekCloser_Seek_adaptor) PrettyParams(params moqReadWriteSeekCloser_Seek_params) string { return fmt.Sprintf("Seek(%#v, %#v)", params.offset, params.whence) } -func (m *moqReadWriteSeekCloser) paramsKey_Seek(params moqReadWriteSeekCloser_Seek_params, anyParams uint64) moqReadWriteSeekCloser_Seek_paramsKey { - m.scene.T.Helper() - var offsetUsed int64 - var offsetUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Seek.offset == moq.ParamIndexByValue { - offsetUsed = params.offset - } else { - offsetUsedHash = hash.DeepHash(params.offset) - } - } - var whenceUsed int - var whenceUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.Seek.whence == moq.ParamIndexByValue { - whenceUsed = params.whence - } else { - whenceUsedHash = hash.DeepHash(params.whence) - } - } +func (a *moqReadWriteSeekCloser_Seek_adaptor) ParamsKey(params moqReadWriteSeekCloser_Seek_params, anyParams uint64) moqReadWriteSeekCloser_Seek_paramsKey { + a.moq.moq_Seek.Scene.T.Helper() + offsetUsed, offsetUsedHash := impl.ParamKey( + params.offset, 1, a.moq.runtime.parameterIndexing.Seek.offset, anyParams) + whenceUsed, whenceUsedHash := impl.ParamKey( + params.whence, 2, a.moq.runtime.parameterIndexing.Seek.whence, anyParams) return moqReadWriteSeekCloser_Seek_paramsKey{ params: struct { offset int64 @@ -1231,183 +723,79 @@ func (m *moqReadWriteSeekCloser) paramsKey_Seek(params moqReadWriteSeekCloser_Se } } -func (m *moqReadWriteSeekCloser_recorder) Close() *moqReadWriteSeekCloser_Close_fnRecorder { - return &moqReadWriteSeekCloser_Close_fnRecorder{ - params: moqReadWriteSeekCloser_Close_params{}, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, +func (m *moqReadWriteSeekCloser_recorder) Close() *moqReadWriteSeekCloser_Close_recorder { + return &moqReadWriteSeekCloser_Close_recorder{ + recorder: m.moq.moq_Close.OnCall(moqReadWriteSeekCloser_Close_params{}), } } -func (r *moqReadWriteSeekCloser_Close_fnRecorder) any() *moqReadWriteSeekCloser_Close_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_Close(r.params)) +func (r *moqReadWriteSeekCloser_Close_recorder) any() *moqReadWriteSeekCloser_Close_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqReadWriteSeekCloser_Close_anyParams{recorder: r} } -func (r *moqReadWriteSeekCloser_Close_fnRecorder) seq() *moqReadWriteSeekCloser_Close_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_Close(r.params)) +func (r *moqReadWriteSeekCloser_Close_recorder) seq() *moqReadWriteSeekCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqReadWriteSeekCloser_Close_fnRecorder) noSeq() *moqReadWriteSeekCloser_Close_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_Close(r.params)) +func (r *moqReadWriteSeekCloser_Close_recorder) noSeq() *moqReadWriteSeekCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqReadWriteSeekCloser_Close_fnRecorder) returnResults(result1 error) *moqReadWriteSeekCloser_Close_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 error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Close_doFn - doReturnFn moqReadWriteSeekCloser_Close_doReturnFn - }{ - values: &struct { - result1 error - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqReadWriteSeekCloser_Close_recorder) returnResults(result1 error) *moqReadWriteSeekCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqReadWriteSeekCloser_Close_results{ + result1: result1, }) return r } -func (r *moqReadWriteSeekCloser_Close_fnRecorder) andDo(fn moqReadWriteSeekCloser_Close_doFn) *moqReadWriteSeekCloser_Close_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqReadWriteSeekCloser_Close_recorder) andDo(fn moqReadWriteSeekCloser_Close_doFn) *moqReadWriteSeekCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqReadWriteSeekCloser_Close_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqReadWriteSeekCloser_Close_fnRecorder) doReturnResults(fn moqReadWriteSeekCloser_Close_doReturnFn) *moqReadWriteSeekCloser_Close_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 error +func (r *moqReadWriteSeekCloser_Close_recorder) doReturnResults(fn moqReadWriteSeekCloser_Close_doReturnFn) *moqReadWriteSeekCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqReadWriteSeekCloser_Close_params) *moqReadWriteSeekCloser_Close_results { + result1 := fn() + return &moqReadWriteSeekCloser_Close_results{ + result1: result1, } - sequence uint32 - doFn moqReadWriteSeekCloser_Close_doFn - doReturnFn moqReadWriteSeekCloser_Close_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqReadWriteSeekCloser_Close_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 *moqReadWriteSeekCloser_Close_resultsByParams - for n, res := range r.moq.resultsByParams_Close { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqReadWriteSeekCloser_Close_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqReadWriteSeekCloser_Close_paramsKey]*moqReadWriteSeekCloser_Close_results{}, - } - r.moq.resultsByParams_Close = append(r.moq.resultsByParams_Close, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Close) { - copy(r.moq.resultsByParams_Close[insertAt+1:], r.moq.resultsByParams_Close[insertAt:0]) - r.moq.resultsByParams_Close[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Close(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqReadWriteSeekCloser_Close_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 *moqReadWriteSeekCloser_Close_fnRecorder) repeat(repeaters ...moq.Repeater) *moqReadWriteSeekCloser_Close_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqReadWriteSeekCloser_Close_recorder) repeat(repeaters ...moq.Repeater) *moqReadWriteSeekCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 error - } - sequence uint32 - doFn moqReadWriteSeekCloser_Close_doFn - doReturnFn moqReadWriteSeekCloser_Close_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqReadWriteSeekCloser) prettyParams_Close(params moqReadWriteSeekCloser_Close_params) string { +func (*moqReadWriteSeekCloser_Close_adaptor) PrettyParams(params moqReadWriteSeekCloser_Close_params) string { return fmt.Sprintf("Close()") } -func (m *moqReadWriteSeekCloser) paramsKey_Close(params moqReadWriteSeekCloser_Close_params, anyParams uint64) moqReadWriteSeekCloser_Close_paramsKey { - m.scene.T.Helper() +func (a *moqReadWriteSeekCloser_Close_adaptor) ParamsKey(params moqReadWriteSeekCloser_Close_params, anyParams uint64) moqReadWriteSeekCloser_Close_paramsKey { + a.moq.moq_Close.Scene.T.Helper() return moqReadWriteSeekCloser_Close_paramsKey{ params: struct{}{}, hashes: struct{}{}, @@ -1416,45 +804,17 @@ func (m *moqReadWriteSeekCloser) paramsKey_Close(params moqReadWriteSeekCloser_C // Reset resets the state of the moq func (m *moqReadWriteSeekCloser) Reset() { - m.resultsByParams_Read = nil - m.resultsByParams_Write = nil - m.resultsByParams_Seek = nil - m.resultsByParams_Close = nil + m.moq_Read.Reset() + m.moq_Write.Reset() + m.moq_Seek.Reset() + m.moq_Close.Reset() } // AssertExpectationsMet asserts that all expectations have been met func (m *moqReadWriteSeekCloser) AssertExpectationsMet() { - m.scene.T.Helper() - for _, res := range m.resultsByParams_Read { - 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_Read(results.params)) - } - } - } - for _, res := range m.resultsByParams_Write { - 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_Write(results.params)) - } - } - } - for _, res := range m.resultsByParams_Seek { - 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_Seek(results.params)) - } - } - } - for _, res := range m.resultsByParams_Close { - 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_Close(results.params)) - } - } - } + m.moq_Read.Scene.T.Helper() + m.moq_Read.AssertExpectationsMet() + m.moq_Write.AssertExpectationsMet() + m.moq_Seek.AssertExpectationsMet() + m.moq_Close.AssertExpectationsMet() } diff --git a/bulk/internal/moq_writecloser_test.go b/bulk/internal/moq_writecloser_test.go index 76a6e6a..778ea03 100644 --- a/bulk/internal/moq_writecloser_test.go +++ b/bulk/internal/moq_writecloser_test.go @@ -5,10 +5,9 @@ package internal_test import ( "fmt" "io" - "math/bits" - "sync/atomic" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -18,21 +17,22 @@ var _ io.WriteCloser = (*moqWriteCloser_mock)(nil) // moqWriteCloser holds the state of a moq of the WriteCloser type type moqWriteCloser struct { - scene *moq.Scene - config moq.Config - moq *moqWriteCloser_mock - - resultsByParams_Write []moqWriteCloser_Write_resultsByParams - resultsByParams_Close []moqWriteCloser_Close_resultsByParams - - runtime struct { - parameterIndexing struct { - Write struct { - p moq.ParamIndexing - } - Close struct{} - } - } + moq *moqWriteCloser_mock + + moq_Write *impl.Moq[ + *moqWriteCloser_Write_adaptor, + moqWriteCloser_Write_params, + moqWriteCloser_Write_paramsKey, + moqWriteCloser_Write_results, + ] + moq_Close *impl.Moq[ + *moqWriteCloser_Close_adaptor, + moqWriteCloser_Close_params, + moqWriteCloser_Close_paramsKey, + moqWriteCloser_Close_results, + ] + + runtime moqWriteCloser_runtime } // moqWriteCloser_mock isolates the mock interface of the WriteCloser type @@ -46,6 +46,19 @@ type moqWriteCloser_recorder struct { moq *moqWriteCloser } +// moqWriteCloser_runtime holds runtime configuration for the WriteCloser type +type moqWriteCloser_runtime struct { + parameterIndexing struct { + Write moqWriteCloser_Write_paramIndexing + Close moqWriteCloser_Close_paramIndexing + } +} + +// moqWriteCloser_Write_adaptor adapts moqWriteCloser as needed by the runtime +type moqWriteCloser_Write_adaptor struct { + moq *moqWriteCloser +} + // moqWriteCloser_Write_params holds the params of the WriteCloser type type moqWriteCloser_Write_params struct{ p []byte } @@ -56,12 +69,16 @@ type moqWriteCloser_Write_paramsKey struct { hashes struct{ p hash.Hash } } -// moqWriteCloser_Write_resultsByParams contains the results for a given set of -// parameters for the WriteCloser type -type moqWriteCloser_Write_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqWriteCloser_Write_paramsKey]*moqWriteCloser_Write_results +// moqWriteCloser_Write_results holds the results of the WriteCloser type +type moqWriteCloser_Write_results struct { + n int + err error +} + +// moqWriteCloser_Write_paramIndexing holds the parameter indexing runtime +// configuration for the WriteCloser type +type moqWriteCloser_Write_paramIndexing struct { + p moq.ParamIndexing } // moqWriteCloser_Write_doFn defines the type of function needed when calling @@ -72,36 +89,26 @@ type moqWriteCloser_Write_doFn func(p []byte) // calling doReturnResults for the WriteCloser type type moqWriteCloser_Write_doReturnFn func(p []byte) (n int, err error) -// moqWriteCloser_Write_results holds the results of the WriteCloser type -type moqWriteCloser_Write_results struct { - params moqWriteCloser_Write_params - results []struct { - values *struct { - n int - err error - } - sequence uint32 - doFn moqWriteCloser_Write_doFn - doReturnFn moqWriteCloser_Write_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqWriteCloser_Write_fnRecorder routes recorded function calls to the +// moqWriteCloser_Write_recorder routes recorded function calls to the // moqWriteCloser moq -type moqWriteCloser_Write_fnRecorder struct { - params moqWriteCloser_Write_params - anyParams uint64 - sequence bool - results *moqWriteCloser_Write_results - moq *moqWriteCloser +type moqWriteCloser_Write_recorder struct { + recorder *impl.Recorder[ + *moqWriteCloser_Write_adaptor, + moqWriteCloser_Write_params, + moqWriteCloser_Write_paramsKey, + moqWriteCloser_Write_results, + ] } // moqWriteCloser_Write_anyParams isolates the any params functions of the // WriteCloser type type moqWriteCloser_Write_anyParams struct { - recorder *moqWriteCloser_Write_fnRecorder + recorder *moqWriteCloser_Write_recorder +} + +// moqWriteCloser_Close_adaptor adapts moqWriteCloser as needed by the runtime +type moqWriteCloser_Close_adaptor struct { + moq *moqWriteCloser } // moqWriteCloser_Close_params holds the params of the WriteCloser type @@ -114,14 +121,15 @@ type moqWriteCloser_Close_paramsKey struct { hashes struct{} } -// moqWriteCloser_Close_resultsByParams contains the results for a given set of -// parameters for the WriteCloser type -type moqWriteCloser_Close_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqWriteCloser_Close_paramsKey]*moqWriteCloser_Close_results +// moqWriteCloser_Close_results holds the results of the WriteCloser type +type moqWriteCloser_Close_results struct { + result1 error } +// moqWriteCloser_Close_paramIndexing holds the parameter indexing runtime +// configuration for the WriteCloser type +type moqWriteCloser_Close_paramIndexing struct{} + // moqWriteCloser_Close_doFn defines the type of function needed when calling // andDo for the WriteCloser type type moqWriteCloser_Close_doFn func() @@ -130,70 +138,58 @@ type moqWriteCloser_Close_doFn func() // calling doReturnResults for the WriteCloser type type moqWriteCloser_Close_doReturnFn func() error -// moqWriteCloser_Close_results holds the results of the WriteCloser type -type moqWriteCloser_Close_results struct { - params moqWriteCloser_Close_params - results []struct { - values *struct { - result1 error - } - sequence uint32 - doFn moqWriteCloser_Close_doFn - doReturnFn moqWriteCloser_Close_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqWriteCloser_Close_fnRecorder routes recorded function calls to the +// moqWriteCloser_Close_recorder routes recorded function calls to the // moqWriteCloser moq -type moqWriteCloser_Close_fnRecorder struct { - params moqWriteCloser_Close_params - anyParams uint64 - sequence bool - results *moqWriteCloser_Close_results - moq *moqWriteCloser +type moqWriteCloser_Close_recorder struct { + recorder *impl.Recorder[ + *moqWriteCloser_Close_adaptor, + moqWriteCloser_Close_params, + moqWriteCloser_Close_paramsKey, + moqWriteCloser_Close_results, + ] } // moqWriteCloser_Close_anyParams isolates the any params functions of the // WriteCloser type type moqWriteCloser_Close_anyParams struct { - recorder *moqWriteCloser_Close_fnRecorder + recorder *moqWriteCloser_Close_recorder } // newMoqWriteCloser creates a new moq of the WriteCloser type func newMoqWriteCloser(scene *moq.Scene, config *moq.Config) *moqWriteCloser { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqWriteCloser_Write_adaptor{} + adaptor2 := &moqWriteCloser_Close_adaptor{} m := &moqWriteCloser{ - scene: scene, - config: *config, - moq: &moqWriteCloser_mock{}, - - runtime: struct { - parameterIndexing struct { - Write struct { - p moq.ParamIndexing - } - Close struct{} - } - }{parameterIndexing: struct { - Write struct { - p moq.ParamIndexing - } - Close struct{} + moq: &moqWriteCloser_mock{}, + + moq_Write: impl.NewMoq[ + *moqWriteCloser_Write_adaptor, + moqWriteCloser_Write_params, + moqWriteCloser_Write_paramsKey, + moqWriteCloser_Write_results, + ](scene, adaptor1, config), + moq_Close: impl.NewMoq[ + *moqWriteCloser_Close_adaptor, + moqWriteCloser_Close_params, + moqWriteCloser_Close_paramsKey, + moqWriteCloser_Close_results, + ](scene, adaptor2, config), + + runtime: moqWriteCloser_runtime{parameterIndexing: struct { + Write moqWriteCloser_Write_paramIndexing + Close moqWriteCloser_Close_paramIndexing }{ - Write: struct { - p moq.ParamIndexing - }{ + Write: moqWriteCloser_Write_paramIndexing{ p: moq.ParamIndexByHash, }, - Close: struct{}{}, + Close: moqWriteCloser_Close_paramIndexing{}, }}, } m.moq.moq = m + adaptor1.moq = m + adaptor2.moq = m + scene.AddMoq(m) return m } @@ -201,109 +197,30 @@ func newMoqWriteCloser(scene *moq.Scene, config *moq.Config) *moqWriteCloser { // mock returns the mock implementation of the WriteCloser type func (m *moqWriteCloser) mock() *moqWriteCloser_mock { return m.moq } -func (m *moqWriteCloser_mock) Write(p []byte) (n int, err error) { - m.moq.scene.T.Helper() +func (m *moqWriteCloser_mock) Write(p []byte) (int, error) { + m.moq.moq_Write.Scene.T.Helper() params := moqWriteCloser_Write_params{ p: p, } - var results *moqWriteCloser_Write_results - for _, resultsByParams := range m.moq.resultsByParams_Write { - paramsKey := m.moq.paramsKey_Write(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_Write(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_Write(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_Write(params)) - } - } - if result.doFn != nil { - result.doFn(p) + var result1 int + var result2 error + if result := m.moq.moq_Write.Function(params); result != nil { + result1 = result.n + result2 = result.err } - - if result.values != nil { - n = result.values.n - err = result.values.err - } - if result.doReturnFn != nil { - n, err = result.doReturnFn(p) - } - return + return result1, result2 } -func (m *moqWriteCloser_mock) Close() (result1 error) { - m.moq.scene.T.Helper() +func (m *moqWriteCloser_mock) Close() error { + m.moq.moq_Close.Scene.T.Helper() params := moqWriteCloser_Close_params{} - var results *moqWriteCloser_Close_results - for _, resultsByParams := range m.moq.resultsByParams_Close { - paramsKey := m.moq.paramsKey_Close(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_Close(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_Close(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_Close(params)) - } - } - - if result.doFn != nil { - result.doFn() - } - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn() + var result1 error + if result := m.moq.moq_Close.Function(params); result != nil { + result1 = result.result1 } - return + return result1 } // onCall returns the recorder implementation of the WriteCloser type @@ -313,202 +230,90 @@ func (m *moqWriteCloser) onCall() *moqWriteCloser_recorder { } } -func (m *moqWriteCloser_recorder) Write(p []byte) *moqWriteCloser_Write_fnRecorder { - return &moqWriteCloser_Write_fnRecorder{ - params: moqWriteCloser_Write_params{ +func (m *moqWriteCloser_recorder) Write(p []byte) *moqWriteCloser_Write_recorder { + return &moqWriteCloser_Write_recorder{ + recorder: m.moq.moq_Write.OnCall(moqWriteCloser_Write_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqWriteCloser_Write_fnRecorder) any() *moqWriteCloser_Write_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_Write(r.params)) +func (r *moqWriteCloser_Write_recorder) any() *moqWriteCloser_Write_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqWriteCloser_Write_anyParams{recorder: r} } -func (a *moqWriteCloser_Write_anyParams) p() *moqWriteCloser_Write_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqWriteCloser_Write_anyParams) p() *moqWriteCloser_Write_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqWriteCloser_Write_fnRecorder) seq() *moqWriteCloser_Write_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_Write(r.params)) +func (r *moqWriteCloser_Write_recorder) seq() *moqWriteCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqWriteCloser_Write_fnRecorder) noSeq() *moqWriteCloser_Write_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_Write(r.params)) +func (r *moqWriteCloser_Write_recorder) noSeq() *moqWriteCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqWriteCloser_Write_fnRecorder) returnResults(n int, err error) *moqWriteCloser_Write_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 { - n int - err error - } - sequence uint32 - doFn moqWriteCloser_Write_doFn - doReturnFn moqWriteCloser_Write_doReturnFn - }{ - values: &struct { - n int - err error - }{ - n: n, - err: err, - }, - sequence: sequence, +func (r *moqWriteCloser_Write_recorder) returnResults(n int, err error) *moqWriteCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqWriteCloser_Write_results{ + n: n, + err: err, }) return r } -func (r *moqWriteCloser_Write_fnRecorder) andDo(fn moqWriteCloser_Write_doFn) *moqWriteCloser_Write_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqWriteCloser_Write_recorder) andDo(fn moqWriteCloser_Write_doFn) *moqWriteCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqWriteCloser_Write_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqWriteCloser_Write_fnRecorder) doReturnResults(fn moqWriteCloser_Write_doReturnFn) *moqWriteCloser_Write_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 { - n int - err error +func (r *moqWriteCloser_Write_recorder) doReturnResults(fn moqWriteCloser_Write_doReturnFn) *moqWriteCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqWriteCloser_Write_params) *moqWriteCloser_Write_results { + n, err := fn(params.p) + return &moqWriteCloser_Write_results{ + n: n, + err: err, } - sequence uint32 - doFn moqWriteCloser_Write_doFn - doReturnFn moqWriteCloser_Write_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqWriteCloser_Write_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 *moqWriteCloser_Write_resultsByParams - for n, res := range r.moq.resultsByParams_Write { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqWriteCloser_Write_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqWriteCloser_Write_paramsKey]*moqWriteCloser_Write_results{}, - } - r.moq.resultsByParams_Write = append(r.moq.resultsByParams_Write, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Write) { - copy(r.moq.resultsByParams_Write[insertAt+1:], r.moq.resultsByParams_Write[insertAt:0]) - r.moq.resultsByParams_Write[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Write(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqWriteCloser_Write_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 *moqWriteCloser_Write_fnRecorder) repeat(repeaters ...moq.Repeater) *moqWriteCloser_Write_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqWriteCloser_Write_recorder) repeat(repeaters ...moq.Repeater) *moqWriteCloser_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - n int - err error - } - sequence uint32 - doFn moqWriteCloser_Write_doFn - doReturnFn moqWriteCloser_Write_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqWriteCloser) prettyParams_Write(params moqWriteCloser_Write_params) string { +func (*moqWriteCloser_Write_adaptor) PrettyParams(params moqWriteCloser_Write_params) string { return fmt.Sprintf("Write(%#v)", params.p) } -func (m *moqWriteCloser) paramsKey_Write(params moqWriteCloser_Write_params, anyParams uint64) moqWriteCloser_Write_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Write.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter of the Write function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqWriteCloser_Write_adaptor) ParamsKey(params moqWriteCloser_Write_params, anyParams uint64) moqWriteCloser_Write_paramsKey { + a.moq.moq_Write.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq_Write.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.Write.p, anyParams) return moqWriteCloser_Write_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -517,183 +322,79 @@ func (m *moqWriteCloser) paramsKey_Write(params moqWriteCloser_Write_params, any } } -func (m *moqWriteCloser_recorder) Close() *moqWriteCloser_Close_fnRecorder { - return &moqWriteCloser_Close_fnRecorder{ - params: moqWriteCloser_Close_params{}, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, +func (m *moqWriteCloser_recorder) Close() *moqWriteCloser_Close_recorder { + return &moqWriteCloser_Close_recorder{ + recorder: m.moq.moq_Close.OnCall(moqWriteCloser_Close_params{}), } } -func (r *moqWriteCloser_Close_fnRecorder) any() *moqWriteCloser_Close_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_Close(r.params)) +func (r *moqWriteCloser_Close_recorder) any() *moqWriteCloser_Close_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqWriteCloser_Close_anyParams{recorder: r} } -func (r *moqWriteCloser_Close_fnRecorder) seq() *moqWriteCloser_Close_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_Close(r.params)) +func (r *moqWriteCloser_Close_recorder) seq() *moqWriteCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqWriteCloser_Close_fnRecorder) noSeq() *moqWriteCloser_Close_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_Close(r.params)) +func (r *moqWriteCloser_Close_recorder) noSeq() *moqWriteCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqWriteCloser_Close_fnRecorder) returnResults(result1 error) *moqWriteCloser_Close_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 error - } - sequence uint32 - doFn moqWriteCloser_Close_doFn - doReturnFn moqWriteCloser_Close_doReturnFn - }{ - values: &struct { - result1 error - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqWriteCloser_Close_recorder) returnResults(result1 error) *moqWriteCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqWriteCloser_Close_results{ + result1: result1, }) return r } -func (r *moqWriteCloser_Close_fnRecorder) andDo(fn moqWriteCloser_Close_doFn) *moqWriteCloser_Close_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqWriteCloser_Close_recorder) andDo(fn moqWriteCloser_Close_doFn) *moqWriteCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqWriteCloser_Close_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqWriteCloser_Close_fnRecorder) doReturnResults(fn moqWriteCloser_Close_doReturnFn) *moqWriteCloser_Close_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 error +func (r *moqWriteCloser_Close_recorder) doReturnResults(fn moqWriteCloser_Close_doReturnFn) *moqWriteCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqWriteCloser_Close_params) *moqWriteCloser_Close_results { + result1 := fn() + return &moqWriteCloser_Close_results{ + result1: result1, } - sequence uint32 - doFn moqWriteCloser_Close_doFn - doReturnFn moqWriteCloser_Close_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqWriteCloser_Close_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 *moqWriteCloser_Close_resultsByParams - for n, res := range r.moq.resultsByParams_Close { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqWriteCloser_Close_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqWriteCloser_Close_paramsKey]*moqWriteCloser_Close_results{}, - } - r.moq.resultsByParams_Close = append(r.moq.resultsByParams_Close, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Close) { - copy(r.moq.resultsByParams_Close[insertAt+1:], r.moq.resultsByParams_Close[insertAt:0]) - r.moq.resultsByParams_Close[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Close(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqWriteCloser_Close_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 *moqWriteCloser_Close_fnRecorder) repeat(repeaters ...moq.Repeater) *moqWriteCloser_Close_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqWriteCloser_Close_recorder) repeat(repeaters ...moq.Repeater) *moqWriteCloser_Close_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 error - } - sequence uint32 - doFn moqWriteCloser_Close_doFn - doReturnFn moqWriteCloser_Close_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqWriteCloser) prettyParams_Close(params moqWriteCloser_Close_params) string { +func (*moqWriteCloser_Close_adaptor) PrettyParams(params moqWriteCloser_Close_params) string { return fmt.Sprintf("Close()") } -func (m *moqWriteCloser) paramsKey_Close(params moqWriteCloser_Close_params, anyParams uint64) moqWriteCloser_Close_paramsKey { - m.scene.T.Helper() +func (a *moqWriteCloser_Close_adaptor) ParamsKey(params moqWriteCloser_Close_params, anyParams uint64) moqWriteCloser_Close_paramsKey { + a.moq.moq_Close.Scene.T.Helper() return moqWriteCloser_Close_paramsKey{ params: struct{}{}, hashes: struct{}{}, @@ -701,25 +402,14 @@ func (m *moqWriteCloser) paramsKey_Close(params moqWriteCloser_Close_params, any } // Reset resets the state of the moq -func (m *moqWriteCloser) Reset() { m.resultsByParams_Write = nil; m.resultsByParams_Close = nil } +func (m *moqWriteCloser) Reset() { + m.moq_Write.Reset() + m.moq_Close.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqWriteCloser) AssertExpectationsMet() { - m.scene.T.Helper() - for _, res := range m.resultsByParams_Write { - 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_Write(results.params)) - } - } - } - for _, res := range m.resultsByParams_Close { - 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_Close(results.params)) - } - } - } + m.moq_Write.Scene.T.Helper() + m.moq_Write.AssertExpectationsMet() + m.moq_Close.AssertExpectationsMet() } diff --git a/demo/moq_isfavorite_test.go b/demo/moq_isfavorite_test.go index f6cbd22..616efda 100644 --- a/demo/moq_isfavorite_test.go +++ b/demo/moq_isfavorite_test.go @@ -4,31 +4,32 @@ package demo_test import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/cli/demo" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqIsFavorite holds the state of a moq of the IsFavorite type type moqIsFavorite struct { - scene *moq.Scene - config moq.Config - moq *moqIsFavorite_mock + moq *impl.Moq[ + *moqIsFavorite_adaptor, + moqIsFavorite_params, + moqIsFavorite_paramsKey, + moqIsFavorite_results, + ] - resultsByParams []moqIsFavorite_resultsByParams + runtime moqIsFavorite_runtime +} - runtime struct { - parameterIndexing struct { - n moq.ParamIndexing - } - } +// moqIsFavorite_runtime holds runtime configuration for the IsFavorite type +type moqIsFavorite_runtime struct { + parameterIndexing moqIsFavorite_paramIndexing } -// moqIsFavorite_mock isolates the mock interface of the IsFavorite type -type moqIsFavorite_mock struct { +// moqIsFavorite_adaptor adapts moqIsFavorite as needed by the runtime +type moqIsFavorite_adaptor struct { moq *moqIsFavorite } @@ -41,12 +42,15 @@ type moqIsFavorite_paramsKey struct { hashes struct{ n hash.Hash } } -// moqIsFavorite_resultsByParams contains the results for a given set of -// parameters for the IsFavorite type -type moqIsFavorite_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqIsFavorite_paramsKey]*moqIsFavorite_results +// moqIsFavorite_results holds the results of the IsFavorite type +type moqIsFavorite_results struct { + result1 bool +} + +// moqIsFavorite_paramIndexing holds the parameter indexing runtime +// configuration for the IsFavorite type +type moqIsFavorite_paramIndexing struct { + n moq.ParamIndexing } // moqIsFavorite_doFn defines the type of function needed when calling andDo @@ -57,58 +61,39 @@ type moqIsFavorite_doFn func(n int) // doReturnResults for the IsFavorite type type moqIsFavorite_doReturnFn func(n int) bool -// moqIsFavorite_results holds the results of the IsFavorite type -type moqIsFavorite_results struct { - params moqIsFavorite_params - results []struct { - values *struct { - result1 bool - } - sequence uint32 - doFn moqIsFavorite_doFn - doReturnFn moqIsFavorite_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqIsFavorite_fnRecorder routes recorded function calls to the moqIsFavorite +// moqIsFavorite_recorder routes recorded function calls to the moqIsFavorite // moq -type moqIsFavorite_fnRecorder struct { - params moqIsFavorite_params - anyParams uint64 - sequence bool - results *moqIsFavorite_results - moq *moqIsFavorite +type moqIsFavorite_recorder struct { + recorder *impl.Recorder[ + *moqIsFavorite_adaptor, + moqIsFavorite_params, + moqIsFavorite_paramsKey, + moqIsFavorite_results, + ] } // moqIsFavorite_anyParams isolates the any params functions of the IsFavorite // type type moqIsFavorite_anyParams struct { - recorder *moqIsFavorite_fnRecorder + recorder *moqIsFavorite_recorder } // newMoqIsFavorite creates a new moq of the IsFavorite type func newMoqIsFavorite(scene *moq.Scene, config *moq.Config) *moqIsFavorite { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqIsFavorite_adaptor{} m := &moqIsFavorite{ - scene: scene, - config: *config, - moq: &moqIsFavorite_mock{}, - - runtime: struct { - parameterIndexing struct { - n moq.ParamIndexing - } - }{parameterIndexing: struct { - n moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqIsFavorite_adaptor, + moqIsFavorite_params, + moqIsFavorite_paramsKey, + moqIsFavorite_results, + ](scene, adaptor1, config), + + runtime: moqIsFavorite_runtime{parameterIndexing: moqIsFavorite_paramIndexing{ n: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -116,255 +101,102 @@ func newMoqIsFavorite(scene *moq.Scene, config *moq.Config) *moqIsFavorite { // mock returns the moq implementation of the IsFavorite type func (m *moqIsFavorite) mock() demo.IsFavorite { - return func(n int) bool { m.scene.T.Helper(); moq := &moqIsFavorite_mock{moq: m}; return moq.fn(n) } -} - -func (m *moqIsFavorite_mock) fn(n int) (result1 bool) { - m.moq.scene.T.Helper() - params := moqIsFavorite_params{ - n: n, - } - var results *moqIsFavorite_results - 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 + return func(n int) bool { + m.moq.Scene.T.Helper() + params := moqIsFavorite_params{ + n: n, } - 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)) + var result1 bool + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } + return result1 } - - if result.doFn != nil { - result.doFn(n) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(n) - } - return } -func (m *moqIsFavorite) onCall(n int) *moqIsFavorite_fnRecorder { - return &moqIsFavorite_fnRecorder{ - params: moqIsFavorite_params{ +func (m *moqIsFavorite) onCall(n int) *moqIsFavorite_recorder { + return &moqIsFavorite_recorder{ + recorder: m.moq.OnCall(moqIsFavorite_params{ n: n, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqIsFavorite_fnRecorder) any() *moqIsFavorite_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(r.params)) +func (r *moqIsFavorite_recorder) any() *moqIsFavorite_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqIsFavorite_anyParams{recorder: r} } -func (a *moqIsFavorite_anyParams) n() *moqIsFavorite_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqIsFavorite_anyParams) n() *moqIsFavorite_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqIsFavorite_fnRecorder) seq() *moqIsFavorite_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(r.params)) +func (r *moqIsFavorite_recorder) seq() *moqIsFavorite_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqIsFavorite_fnRecorder) noSeq() *moqIsFavorite_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(r.params)) +func (r *moqIsFavorite_recorder) noSeq() *moqIsFavorite_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqIsFavorite_fnRecorder) returnResults(result1 bool) *moqIsFavorite_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 bool - } - sequence uint32 - doFn moqIsFavorite_doFn - doReturnFn moqIsFavorite_doReturnFn - }{ - values: &struct { - result1 bool - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqIsFavorite_recorder) returnResults(result1 bool) *moqIsFavorite_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqIsFavorite_results{ + result1: result1, }) return r } -func (r *moqIsFavorite_fnRecorder) andDo(fn moqIsFavorite_doFn) *moqIsFavorite_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqIsFavorite_recorder) andDo(fn moqIsFavorite_doFn) *moqIsFavorite_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqIsFavorite_params) { + fn(params.n) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqIsFavorite_fnRecorder) doReturnResults(fn moqIsFavorite_doReturnFn) *moqIsFavorite_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 bool +func (r *moqIsFavorite_recorder) doReturnResults(fn moqIsFavorite_doReturnFn) *moqIsFavorite_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqIsFavorite_params) *moqIsFavorite_results { + result1 := fn(params.n) + return &moqIsFavorite_results{ + result1: result1, } - sequence uint32 - doFn moqIsFavorite_doFn - doReturnFn moqIsFavorite_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqIsFavorite_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 *moqIsFavorite_resultsByParams - 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 = &moqIsFavorite_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqIsFavorite_paramsKey]*moqIsFavorite_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqIsFavorite_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 *moqIsFavorite_fnRecorder) repeat(repeaters ...moq.Repeater) *moqIsFavorite_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqIsFavorite_recorder) repeat(repeaters ...moq.Repeater) *moqIsFavorite_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 bool - } - sequence uint32 - doFn moqIsFavorite_doFn - doReturnFn moqIsFavorite_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqIsFavorite) prettyParams(params moqIsFavorite_params) string { +func (*moqIsFavorite_adaptor) PrettyParams(params moqIsFavorite_params) string { return fmt.Sprintf("IsFavorite(%#v)", params.n) } -func (m *moqIsFavorite) paramsKey(params moqIsFavorite_params, anyParams uint64) moqIsFavorite_paramsKey { - m.scene.T.Helper() - var nUsed int - var nUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.n == moq.ParamIndexByValue { - nUsed = params.n - } else { - nUsedHash = hash.DeepHash(params.n) - } - } +func (a *moqIsFavorite_adaptor) ParamsKey(params moqIsFavorite_params, anyParams uint64) moqIsFavorite_paramsKey { + a.moq.moq.Scene.T.Helper() + nUsed, nUsedHash := impl.ParamKey( + params.n, 1, a.moq.runtime.parameterIndexing.n, anyParams) return moqIsFavorite_paramsKey{ params: struct{ n int }{ n: nUsed, @@ -376,17 +208,12 @@ func (m *moqIsFavorite) paramsKey(params moqIsFavorite_params, anyParams uint64) } // Reset resets the state of the moq -func (m *moqIsFavorite) Reset() { m.resultsByParams = nil } +func (m *moqIsFavorite) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqIsFavorite) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/demo/moq_store_test.go b/demo/moq_store_test.go index 67d2bc8..32d23ae 100644 --- a/demo/moq_store_test.go +++ b/demo/moq_store_test.go @@ -4,11 +4,10 @@ package demo_test import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/cli/demo" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -17,29 +16,31 @@ var _ demo.Store = (*moqStore_mock)(nil) // moqStore holds the state of a moq of the Store type type moqStore struct { - scene *moq.Scene - config moq.Config - moq *moqStore_mock - - resultsByParams_AllWidgetsIds []moqStore_AllWidgetsIds_resultsByParams - resultsByParams_GadgetsByWidgetId []moqStore_GadgetsByWidgetId_resultsByParams - resultsByParams_LightGadgetsByWidgetId []moqStore_LightGadgetsByWidgetId_resultsByParams - - runtime struct { - parameterIndexing struct { - AllWidgetsIds struct{} - GadgetsByWidgetId struct { - widgetId moq.ParamIndexing - } - LightGadgetsByWidgetId struct { - widgetId moq.ParamIndexing - maxWeight moq.ParamIndexing - } - } - } - // moqStore_mock isolates the mock interface of the Store type -} - + moq *moqStore_mock + + moq_AllWidgetsIds *impl.Moq[ + *moqStore_AllWidgetsIds_adaptor, + moqStore_AllWidgetsIds_params, + moqStore_AllWidgetsIds_paramsKey, + moqStore_AllWidgetsIds_results, + ] + moq_GadgetsByWidgetId *impl.Moq[ + *moqStore_GadgetsByWidgetId_adaptor, + moqStore_GadgetsByWidgetId_params, + moqStore_GadgetsByWidgetId_paramsKey, + moqStore_GadgetsByWidgetId_results, + ] + moq_LightGadgetsByWidgetId *impl.Moq[ + *moqStore_LightGadgetsByWidgetId_adaptor, + moqStore_LightGadgetsByWidgetId_params, + moqStore_LightGadgetsByWidgetId_paramsKey, + moqStore_LightGadgetsByWidgetId_results, + ] + + runtime moqStore_runtime +} + +// moqStore_mock isolates the mock interface of the Store type type moqStore_mock struct { moq *moqStore } @@ -49,6 +50,20 @@ type moqStore_recorder struct { moq *moqStore } +// moqStore_runtime holds runtime configuration for the Store type +type moqStore_runtime struct { + parameterIndexing struct { + AllWidgetsIds moqStore_AllWidgetsIds_paramIndexing + GadgetsByWidgetId moqStore_GadgetsByWidgetId_paramIndexing + LightGadgetsByWidgetId moqStore_LightGadgetsByWidgetId_paramIndexing + } +} + +// moqStore_AllWidgetsIds_adaptor adapts moqStore as needed by the runtime +type moqStore_AllWidgetsIds_adaptor struct { + moq *moqStore +} + // moqStore_AllWidgetsIds_params holds the params of the Store type type moqStore_AllWidgetsIds_params struct{} @@ -58,14 +73,16 @@ type moqStore_AllWidgetsIds_paramsKey struct { hashes struct{} } -// moqStore_AllWidgetsIds_resultsByParams contains the results for a given set -// of parameters for the Store type -type moqStore_AllWidgetsIds_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqStore_AllWidgetsIds_paramsKey]*moqStore_AllWidgetsIds_results +// moqStore_AllWidgetsIds_results holds the results of the Store type +type moqStore_AllWidgetsIds_results struct { + result1 []int + result2 error } +// moqStore_AllWidgetsIds_paramIndexing holds the parameter indexing runtime +// configuration for the Store type +type moqStore_AllWidgetsIds_paramIndexing struct{} + // moqStore_AllWidgetsIds_doFn defines the type of function needed when calling // andDo for the Store type type moqStore_AllWidgetsIds_doFn func() @@ -74,36 +91,26 @@ type moqStore_AllWidgetsIds_doFn func() // calling doReturnResults for the Store type type moqStore_AllWidgetsIds_doReturnFn func() ([]int, error) -// moqStore_AllWidgetsIds_results holds the results of the Store type -type moqStore_AllWidgetsIds_results struct { - params moqStore_AllWidgetsIds_params - results []struct { - values *struct { - result1 []int - result2 error - } - sequence uint32 - doFn moqStore_AllWidgetsIds_doFn - doReturnFn moqStore_AllWidgetsIds_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqStore_AllWidgetsIds_fnRecorder routes recorded function calls to the +// moqStore_AllWidgetsIds_recorder routes recorded function calls to the // moqStore moq -type moqStore_AllWidgetsIds_fnRecorder struct { - params moqStore_AllWidgetsIds_params - anyParams uint64 - sequence bool - results *moqStore_AllWidgetsIds_results - moq *moqStore +type moqStore_AllWidgetsIds_recorder struct { + recorder *impl.Recorder[ + *moqStore_AllWidgetsIds_adaptor, + moqStore_AllWidgetsIds_params, + moqStore_AllWidgetsIds_paramsKey, + moqStore_AllWidgetsIds_results, + ] } // moqStore_AllWidgetsIds_anyParams isolates the any params functions of the // Store type type moqStore_AllWidgetsIds_anyParams struct { - recorder *moqStore_AllWidgetsIds_fnRecorder + recorder *moqStore_AllWidgetsIds_recorder +} + +// moqStore_GadgetsByWidgetId_adaptor adapts moqStore as needed by the runtime +type moqStore_GadgetsByWidgetId_adaptor struct { + moq *moqStore } // moqStore_GadgetsByWidgetId_params holds the params of the Store type @@ -116,12 +123,16 @@ type moqStore_GadgetsByWidgetId_paramsKey struct { hashes struct{ widgetId hash.Hash } } -// moqStore_GadgetsByWidgetId_resultsByParams contains the results for a given -// set of parameters for the Store type -type moqStore_GadgetsByWidgetId_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqStore_GadgetsByWidgetId_paramsKey]*moqStore_GadgetsByWidgetId_results +// moqStore_GadgetsByWidgetId_results holds the results of the Store type +type moqStore_GadgetsByWidgetId_results struct { + result1 []demo.Gadget + result2 error +} + +// moqStore_GadgetsByWidgetId_paramIndexing holds the parameter indexing +// runtime configuration for the Store type +type moqStore_GadgetsByWidgetId_paramIndexing struct { + widgetId moq.ParamIndexing } // moqStore_GadgetsByWidgetId_doFn defines the type of function needed when @@ -132,36 +143,27 @@ type moqStore_GadgetsByWidgetId_doFn func(widgetId int) // when calling doReturnResults for the Store type type moqStore_GadgetsByWidgetId_doReturnFn func(widgetId int) ([]demo.Gadget, error) -// moqStore_GadgetsByWidgetId_results holds the results of the Store type -type moqStore_GadgetsByWidgetId_results struct { - params moqStore_GadgetsByWidgetId_params - results []struct { - values *struct { - result1 []demo.Gadget - result2 error - } - sequence uint32 - doFn moqStore_GadgetsByWidgetId_doFn - doReturnFn moqStore_GadgetsByWidgetId_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqStore_GadgetsByWidgetId_fnRecorder routes recorded function calls to the +// moqStore_GadgetsByWidgetId_recorder routes recorded function calls to the // moqStore moq -type moqStore_GadgetsByWidgetId_fnRecorder struct { - params moqStore_GadgetsByWidgetId_params - anyParams uint64 - sequence bool - results *moqStore_GadgetsByWidgetId_results - moq *moqStore +type moqStore_GadgetsByWidgetId_recorder struct { + recorder *impl.Recorder[ + *moqStore_GadgetsByWidgetId_adaptor, + moqStore_GadgetsByWidgetId_params, + moqStore_GadgetsByWidgetId_paramsKey, + moqStore_GadgetsByWidgetId_results, + ] } // moqStore_GadgetsByWidgetId_anyParams isolates the any params functions of // the Store type type moqStore_GadgetsByWidgetId_anyParams struct { - recorder *moqStore_GadgetsByWidgetId_fnRecorder + recorder *moqStore_GadgetsByWidgetId_recorder +} + +// moqStore_LightGadgetsByWidgetId_adaptor adapts moqStore as needed by the +// runtime +type moqStore_LightGadgetsByWidgetId_adaptor struct { + moq *moqStore } // moqStore_LightGadgetsByWidgetId_params holds the params of the Store type @@ -183,12 +185,17 @@ type moqStore_LightGadgetsByWidgetId_paramsKey struct { } } -// moqStore_LightGadgetsByWidgetId_resultsByParams contains the results for a -// given set of parameters for the Store type -type moqStore_LightGadgetsByWidgetId_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqStore_LightGadgetsByWidgetId_paramsKey]*moqStore_LightGadgetsByWidgetId_results +// moqStore_LightGadgetsByWidgetId_results holds the results of the Store type +type moqStore_LightGadgetsByWidgetId_results struct { + result1 []demo.Gadget + result2 error +} + +// moqStore_LightGadgetsByWidgetId_paramIndexing holds the parameter indexing +// runtime configuration for the Store type +type moqStore_LightGadgetsByWidgetId_paramIndexing struct { + widgetId moq.ParamIndexing + maxWeight moq.ParamIndexing } // moqStore_LightGadgetsByWidgetId_doFn defines the type of function needed @@ -199,79 +206,60 @@ type moqStore_LightGadgetsByWidgetId_doFn func(widgetId int, maxWeight uint32) // needed when calling doReturnResults for the Store type type moqStore_LightGadgetsByWidgetId_doReturnFn func(widgetId int, maxWeight uint32) ([]demo.Gadget, error) -// moqStore_LightGadgetsByWidgetId_results holds the results of the Store type -type moqStore_LightGadgetsByWidgetId_results struct { - params moqStore_LightGadgetsByWidgetId_params - results []struct { - values *struct { - result1 []demo.Gadget - result2 error - } - sequence uint32 - doFn moqStore_LightGadgetsByWidgetId_doFn - doReturnFn moqStore_LightGadgetsByWidgetId_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqStore_LightGadgetsByWidgetId_fnRecorder routes recorded function calls to +// moqStore_LightGadgetsByWidgetId_recorder routes recorded function calls to // the moqStore moq -type moqStore_LightGadgetsByWidgetId_fnRecorder struct { - params moqStore_LightGadgetsByWidgetId_params - anyParams uint64 - sequence bool - results *moqStore_LightGadgetsByWidgetId_results - moq *moqStore +type moqStore_LightGadgetsByWidgetId_recorder struct { + recorder *impl.Recorder[ + *moqStore_LightGadgetsByWidgetId_adaptor, + moqStore_LightGadgetsByWidgetId_params, + moqStore_LightGadgetsByWidgetId_paramsKey, + moqStore_LightGadgetsByWidgetId_results, + ] } // moqStore_LightGadgetsByWidgetId_anyParams isolates the any params functions // of the Store type type moqStore_LightGadgetsByWidgetId_anyParams struct { - recorder *moqStore_LightGadgetsByWidgetId_fnRecorder + recorder *moqStore_LightGadgetsByWidgetId_recorder } // newMoqStore creates a new moq of the Store type func newMoqStore(scene *moq.Scene, config *moq.Config) *moqStore { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqStore_AllWidgetsIds_adaptor{} + adaptor2 := &moqStore_GadgetsByWidgetId_adaptor{} + adaptor3 := &moqStore_LightGadgetsByWidgetId_adaptor{} m := &moqStore{ - scene: scene, - config: *config, - moq: &moqStore_mock{}, - - runtime: struct { - parameterIndexing struct { - AllWidgetsIds struct{} - GadgetsByWidgetId struct { - widgetId moq.ParamIndexing - } - LightGadgetsByWidgetId struct { - widgetId moq.ParamIndexing - maxWeight moq.ParamIndexing - } - } - }{parameterIndexing: struct { - AllWidgetsIds struct{} - GadgetsByWidgetId struct { - widgetId moq.ParamIndexing - } - LightGadgetsByWidgetId struct { - widgetId moq.ParamIndexing - maxWeight moq.ParamIndexing - } + moq: &moqStore_mock{}, + + moq_AllWidgetsIds: impl.NewMoq[ + *moqStore_AllWidgetsIds_adaptor, + moqStore_AllWidgetsIds_params, + moqStore_AllWidgetsIds_paramsKey, + moqStore_AllWidgetsIds_results, + ](scene, adaptor1, config), + moq_GadgetsByWidgetId: impl.NewMoq[ + *moqStore_GadgetsByWidgetId_adaptor, + moqStore_GadgetsByWidgetId_params, + moqStore_GadgetsByWidgetId_paramsKey, + moqStore_GadgetsByWidgetId_results, + ](scene, adaptor2, config), + moq_LightGadgetsByWidgetId: impl.NewMoq[ + *moqStore_LightGadgetsByWidgetId_adaptor, + moqStore_LightGadgetsByWidgetId_params, + moqStore_LightGadgetsByWidgetId_paramsKey, + moqStore_LightGadgetsByWidgetId_results, + ](scene, adaptor3, config), + + runtime: moqStore_runtime{parameterIndexing: struct { + AllWidgetsIds moqStore_AllWidgetsIds_paramIndexing + GadgetsByWidgetId moqStore_GadgetsByWidgetId_paramIndexing + LightGadgetsByWidgetId moqStore_LightGadgetsByWidgetId_paramIndexing }{ - AllWidgetsIds: struct{}{}, - GadgetsByWidgetId: struct { - widgetId moq.ParamIndexing - }{ + AllWidgetsIds: moqStore_AllWidgetsIds_paramIndexing{}, + GadgetsByWidgetId: moqStore_GadgetsByWidgetId_paramIndexing{ widgetId: moq.ParamIndexByValue, }, - LightGadgetsByWidgetId: struct { - widgetId moq.ParamIndexing - maxWeight moq.ParamIndexing - }{ + LightGadgetsByWidgetId: moqStore_LightGadgetsByWidgetId_paramIndexing{ widgetId: moq.ParamIndexByValue, maxWeight: moq.ParamIndexByValue, }, @@ -279,6 +267,10 @@ func newMoqStore(scene *moq.Scene, config *moq.Config) *moqStore { } m.moq.moq = m + adaptor1.moq = m + adaptor2.moq = m + adaptor3.moq = m + scene.AddMoq(m) return m } @@ -286,165 +278,48 @@ func newMoqStore(scene *moq.Scene, config *moq.Config) *moqStore { // mock returns the mock implementation of the Store type func (m *moqStore) mock() *moqStore_mock { return m.moq } -func (m *moqStore_mock) AllWidgetsIds() (result1 []int, result2 error) { - m.moq.scene.T.Helper() +func (m *moqStore_mock) AllWidgetsIds() ([]int, error) { + m.moq.moq_AllWidgetsIds.Scene.T.Helper() params := moqStore_AllWidgetsIds_params{} - var results *moqStore_AllWidgetsIds_results - for _, resultsByParams := range m.moq.resultsByParams_AllWidgetsIds { - paramsKey := m.moq.paramsKey_AllWidgetsIds(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_AllWidgetsIds(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_AllWidgetsIds(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_AllWidgetsIds(params)) - } - } - - if result.doFn != nil { - result.doFn() - } - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn() + var result1 []int + var result2 error + if result := m.moq.moq_AllWidgetsIds.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - return + return result1, result2 } -func (m *moqStore_mock) GadgetsByWidgetId(widgetId int) (result1 []demo.Gadget, result2 error) { - m.moq.scene.T.Helper() +func (m *moqStore_mock) GadgetsByWidgetId(widgetId int) ([]demo.Gadget, error) { + m.moq.moq_GadgetsByWidgetId.Scene.T.Helper() params := moqStore_GadgetsByWidgetId_params{ widgetId: widgetId, } - var results *moqStore_GadgetsByWidgetId_results - for _, resultsByParams := range m.moq.resultsByParams_GadgetsByWidgetId { - paramsKey := m.moq.paramsKey_GadgetsByWidgetId(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_GadgetsByWidgetId(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_GadgetsByWidgetId(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_GadgetsByWidgetId(params)) - } - } - - if result.doFn != nil { - result.doFn(widgetId) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(widgetId) + var result1 []demo.Gadget + var result2 error + if result := m.moq.moq_GadgetsByWidgetId.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - return + return result1, result2 } -func (m *moqStore_mock) LightGadgetsByWidgetId(widgetId int, maxWeight uint32) (result1 []demo.Gadget, result2 error) { - m.moq.scene.T.Helper() +func (m *moqStore_mock) LightGadgetsByWidgetId(widgetId int, maxWeight uint32) ([]demo.Gadget, error) { + m.moq.moq_LightGadgetsByWidgetId.Scene.T.Helper() params := moqStore_LightGadgetsByWidgetId_params{ widgetId: widgetId, maxWeight: maxWeight, } - var results *moqStore_LightGadgetsByWidgetId_results - for _, resultsByParams := range m.moq.resultsByParams_LightGadgetsByWidgetId { - paramsKey := m.moq.paramsKey_LightGadgetsByWidgetId(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_LightGadgetsByWidgetId(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_LightGadgetsByWidgetId(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_LightGadgetsByWidgetId(params)) - } - } - - if result.doFn != nil { - result.doFn(widgetId, maxWeight) - } - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 + var result1 []demo.Gadget + var result2 error + if result := m.moq.moq_LightGadgetsByWidgetId.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(widgetId, maxWeight) - } - return + return result1, result2 } // onCall returns the recorder implementation of the Store type @@ -454,392 +329,171 @@ func (m *moqStore) onCall() *moqStore_recorder { } } -func (m *moqStore_recorder) AllWidgetsIds() *moqStore_AllWidgetsIds_fnRecorder { - return &moqStore_AllWidgetsIds_fnRecorder{ - params: moqStore_AllWidgetsIds_params{}, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, +func (m *moqStore_recorder) AllWidgetsIds() *moqStore_AllWidgetsIds_recorder { + return &moqStore_AllWidgetsIds_recorder{ + recorder: m.moq.moq_AllWidgetsIds.OnCall(moqStore_AllWidgetsIds_params{}), } } -func (r *moqStore_AllWidgetsIds_fnRecorder) any() *moqStore_AllWidgetsIds_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_AllWidgetsIds(r.params)) +func (r *moqStore_AllWidgetsIds_recorder) any() *moqStore_AllWidgetsIds_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqStore_AllWidgetsIds_anyParams{recorder: r} } -func (r *moqStore_AllWidgetsIds_fnRecorder) seq() *moqStore_AllWidgetsIds_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_AllWidgetsIds(r.params)) +func (r *moqStore_AllWidgetsIds_recorder) seq() *moqStore_AllWidgetsIds_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqStore_AllWidgetsIds_fnRecorder) noSeq() *moqStore_AllWidgetsIds_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_AllWidgetsIds(r.params)) +func (r *moqStore_AllWidgetsIds_recorder) noSeq() *moqStore_AllWidgetsIds_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqStore_AllWidgetsIds_fnRecorder) returnResults(result1 []int, result2 error) *moqStore_AllWidgetsIds_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 []int - result2 error - } - sequence uint32 - doFn moqStore_AllWidgetsIds_doFn - doReturnFn moqStore_AllWidgetsIds_doReturnFn - }{ - values: &struct { - result1 []int - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqStore_AllWidgetsIds_recorder) returnResults(result1 []int, result2 error) *moqStore_AllWidgetsIds_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqStore_AllWidgetsIds_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqStore_AllWidgetsIds_fnRecorder) andDo(fn moqStore_AllWidgetsIds_doFn) *moqStore_AllWidgetsIds_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqStore_AllWidgetsIds_recorder) andDo(fn moqStore_AllWidgetsIds_doFn) *moqStore_AllWidgetsIds_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqStore_AllWidgetsIds_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqStore_AllWidgetsIds_fnRecorder) doReturnResults(fn moqStore_AllWidgetsIds_doReturnFn) *moqStore_AllWidgetsIds_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 []int - result2 error +func (r *moqStore_AllWidgetsIds_recorder) doReturnResults(fn moqStore_AllWidgetsIds_doReturnFn) *moqStore_AllWidgetsIds_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqStore_AllWidgetsIds_params) *moqStore_AllWidgetsIds_results { + result1, result2 := fn() + return &moqStore_AllWidgetsIds_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqStore_AllWidgetsIds_doFn - doReturnFn moqStore_AllWidgetsIds_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqStore_AllWidgetsIds_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 *moqStore_AllWidgetsIds_resultsByParams - for n, res := range r.moq.resultsByParams_AllWidgetsIds { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqStore_AllWidgetsIds_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqStore_AllWidgetsIds_paramsKey]*moqStore_AllWidgetsIds_results{}, - } - r.moq.resultsByParams_AllWidgetsIds = append(r.moq.resultsByParams_AllWidgetsIds, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_AllWidgetsIds) { - copy(r.moq.resultsByParams_AllWidgetsIds[insertAt+1:], r.moq.resultsByParams_AllWidgetsIds[insertAt:0]) - r.moq.resultsByParams_AllWidgetsIds[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_AllWidgetsIds(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqStore_AllWidgetsIds_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 *moqStore_AllWidgetsIds_fnRecorder) repeat(repeaters ...moq.Repeater) *moqStore_AllWidgetsIds_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqStore_AllWidgetsIds_recorder) repeat(repeaters ...moq.Repeater) *moqStore_AllWidgetsIds_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 []int - result2 error - } - sequence uint32 - doFn moqStore_AllWidgetsIds_doFn - doReturnFn moqStore_AllWidgetsIds_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqStore) prettyParams_AllWidgetsIds(params moqStore_AllWidgetsIds_params) string { +func (*moqStore_AllWidgetsIds_adaptor) PrettyParams(params moqStore_AllWidgetsIds_params) string { return fmt.Sprintf("AllWidgetsIds()") } -func (m *moqStore) paramsKey_AllWidgetsIds(params moqStore_AllWidgetsIds_params, anyParams uint64) moqStore_AllWidgetsIds_paramsKey { - m.scene.T.Helper() +func (a *moqStore_AllWidgetsIds_adaptor) ParamsKey(params moqStore_AllWidgetsIds_params, anyParams uint64) moqStore_AllWidgetsIds_paramsKey { + a.moq.moq_AllWidgetsIds.Scene.T.Helper() return moqStore_AllWidgetsIds_paramsKey{ params: struct{}{}, hashes: struct{}{}, } } -func (m *moqStore_recorder) GadgetsByWidgetId(widgetId int) *moqStore_GadgetsByWidgetId_fnRecorder { - return &moqStore_GadgetsByWidgetId_fnRecorder{ - params: moqStore_GadgetsByWidgetId_params{ +func (m *moqStore_recorder) GadgetsByWidgetId(widgetId int) *moqStore_GadgetsByWidgetId_recorder { + return &moqStore_GadgetsByWidgetId_recorder{ + recorder: m.moq.moq_GadgetsByWidgetId.OnCall(moqStore_GadgetsByWidgetId_params{ widgetId: widgetId, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqStore_GadgetsByWidgetId_fnRecorder) any() *moqStore_GadgetsByWidgetId_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_GadgetsByWidgetId(r.params)) +func (r *moqStore_GadgetsByWidgetId_recorder) any() *moqStore_GadgetsByWidgetId_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqStore_GadgetsByWidgetId_anyParams{recorder: r} } -func (a *moqStore_GadgetsByWidgetId_anyParams) widgetId() *moqStore_GadgetsByWidgetId_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqStore_GadgetsByWidgetId_anyParams) widgetId() *moqStore_GadgetsByWidgetId_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqStore_GadgetsByWidgetId_fnRecorder) seq() *moqStore_GadgetsByWidgetId_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_GadgetsByWidgetId(r.params)) +func (r *moqStore_GadgetsByWidgetId_recorder) seq() *moqStore_GadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqStore_GadgetsByWidgetId_fnRecorder) noSeq() *moqStore_GadgetsByWidgetId_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_GadgetsByWidgetId(r.params)) +func (r *moqStore_GadgetsByWidgetId_recorder) noSeq() *moqStore_GadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqStore_GadgetsByWidgetId_fnRecorder) returnResults(result1 []demo.Gadget, result2 error) *moqStore_GadgetsByWidgetId_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 []demo.Gadget - result2 error - } - sequence uint32 - doFn moqStore_GadgetsByWidgetId_doFn - doReturnFn moqStore_GadgetsByWidgetId_doReturnFn - }{ - values: &struct { - result1 []demo.Gadget - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqStore_GadgetsByWidgetId_recorder) returnResults(result1 []demo.Gadget, result2 error) *moqStore_GadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqStore_GadgetsByWidgetId_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqStore_GadgetsByWidgetId_fnRecorder) andDo(fn moqStore_GadgetsByWidgetId_doFn) *moqStore_GadgetsByWidgetId_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqStore_GadgetsByWidgetId_recorder) andDo(fn moqStore_GadgetsByWidgetId_doFn) *moqStore_GadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqStore_GadgetsByWidgetId_params) { + fn(params.widgetId) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqStore_GadgetsByWidgetId_fnRecorder) doReturnResults(fn moqStore_GadgetsByWidgetId_doReturnFn) *moqStore_GadgetsByWidgetId_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 []demo.Gadget - result2 error +func (r *moqStore_GadgetsByWidgetId_recorder) doReturnResults(fn moqStore_GadgetsByWidgetId_doReturnFn) *moqStore_GadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqStore_GadgetsByWidgetId_params) *moqStore_GadgetsByWidgetId_results { + result1, result2 := fn(params.widgetId) + return &moqStore_GadgetsByWidgetId_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqStore_GadgetsByWidgetId_doFn - doReturnFn moqStore_GadgetsByWidgetId_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqStore_GadgetsByWidgetId_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 *moqStore_GadgetsByWidgetId_resultsByParams - for n, res := range r.moq.resultsByParams_GadgetsByWidgetId { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqStore_GadgetsByWidgetId_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqStore_GadgetsByWidgetId_paramsKey]*moqStore_GadgetsByWidgetId_results{}, - } - r.moq.resultsByParams_GadgetsByWidgetId = append(r.moq.resultsByParams_GadgetsByWidgetId, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_GadgetsByWidgetId) { - copy(r.moq.resultsByParams_GadgetsByWidgetId[insertAt+1:], r.moq.resultsByParams_GadgetsByWidgetId[insertAt:0]) - r.moq.resultsByParams_GadgetsByWidgetId[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_GadgetsByWidgetId(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqStore_GadgetsByWidgetId_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 *moqStore_GadgetsByWidgetId_fnRecorder) repeat(repeaters ...moq.Repeater) *moqStore_GadgetsByWidgetId_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqStore_GadgetsByWidgetId_recorder) repeat(repeaters ...moq.Repeater) *moqStore_GadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 []demo.Gadget - result2 error - } - sequence uint32 - doFn moqStore_GadgetsByWidgetId_doFn - doReturnFn moqStore_GadgetsByWidgetId_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqStore) prettyParams_GadgetsByWidgetId(params moqStore_GadgetsByWidgetId_params) string { +func (*moqStore_GadgetsByWidgetId_adaptor) PrettyParams(params moqStore_GadgetsByWidgetId_params) string { return fmt.Sprintf("GadgetsByWidgetId(%#v)", params.widgetId) } -func (m *moqStore) paramsKey_GadgetsByWidgetId(params moqStore_GadgetsByWidgetId_params, anyParams uint64) moqStore_GadgetsByWidgetId_paramsKey { - m.scene.T.Helper() - var widgetIdUsed int - var widgetIdUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.GadgetsByWidgetId.widgetId == moq.ParamIndexByValue { - widgetIdUsed = params.widgetId - } else { - widgetIdUsedHash = hash.DeepHash(params.widgetId) - } - } +func (a *moqStore_GadgetsByWidgetId_adaptor) ParamsKey(params moqStore_GadgetsByWidgetId_params, anyParams uint64) moqStore_GadgetsByWidgetId_paramsKey { + a.moq.moq_GadgetsByWidgetId.Scene.T.Helper() + widgetIdUsed, widgetIdUsedHash := impl.ParamKey( + params.widgetId, 1, a.moq.runtime.parameterIndexing.GadgetsByWidgetId.widgetId, anyParams) return moqStore_GadgetsByWidgetId_paramsKey{ params: struct{ widgetId int }{ widgetId: widgetIdUsed, @@ -850,219 +504,98 @@ func (m *moqStore) paramsKey_GadgetsByWidgetId(params moqStore_GadgetsByWidgetId } } -func (m *moqStore_recorder) LightGadgetsByWidgetId(widgetId int, maxWeight uint32) *moqStore_LightGadgetsByWidgetId_fnRecorder { - return &moqStore_LightGadgetsByWidgetId_fnRecorder{ - params: moqStore_LightGadgetsByWidgetId_params{ +func (m *moqStore_recorder) LightGadgetsByWidgetId(widgetId int, maxWeight uint32) *moqStore_LightGadgetsByWidgetId_recorder { + return &moqStore_LightGadgetsByWidgetId_recorder{ + recorder: m.moq.moq_LightGadgetsByWidgetId.OnCall(moqStore_LightGadgetsByWidgetId_params{ widgetId: widgetId, maxWeight: maxWeight, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqStore_LightGadgetsByWidgetId_fnRecorder) any() *moqStore_LightGadgetsByWidgetId_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_LightGadgetsByWidgetId(r.params)) +func (r *moqStore_LightGadgetsByWidgetId_recorder) any() *moqStore_LightGadgetsByWidgetId_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqStore_LightGadgetsByWidgetId_anyParams{recorder: r} } -func (a *moqStore_LightGadgetsByWidgetId_anyParams) widgetId() *moqStore_LightGadgetsByWidgetId_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqStore_LightGadgetsByWidgetId_anyParams) widgetId() *moqStore_LightGadgetsByWidgetId_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqStore_LightGadgetsByWidgetId_anyParams) maxWeight() *moqStore_LightGadgetsByWidgetId_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqStore_LightGadgetsByWidgetId_anyParams) maxWeight() *moqStore_LightGadgetsByWidgetId_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqStore_LightGadgetsByWidgetId_fnRecorder) seq() *moqStore_LightGadgetsByWidgetId_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_LightGadgetsByWidgetId(r.params)) +func (r *moqStore_LightGadgetsByWidgetId_recorder) seq() *moqStore_LightGadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqStore_LightGadgetsByWidgetId_fnRecorder) noSeq() *moqStore_LightGadgetsByWidgetId_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_LightGadgetsByWidgetId(r.params)) +func (r *moqStore_LightGadgetsByWidgetId_recorder) noSeq() *moqStore_LightGadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqStore_LightGadgetsByWidgetId_fnRecorder) returnResults(result1 []demo.Gadget, result2 error) *moqStore_LightGadgetsByWidgetId_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 []demo.Gadget - result2 error - } - sequence uint32 - doFn moqStore_LightGadgetsByWidgetId_doFn - doReturnFn moqStore_LightGadgetsByWidgetId_doReturnFn - }{ - values: &struct { - result1 []demo.Gadget - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqStore_LightGadgetsByWidgetId_recorder) returnResults(result1 []demo.Gadget, result2 error) *moqStore_LightGadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqStore_LightGadgetsByWidgetId_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqStore_LightGadgetsByWidgetId_fnRecorder) andDo(fn moqStore_LightGadgetsByWidgetId_doFn) *moqStore_LightGadgetsByWidgetId_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqStore_LightGadgetsByWidgetId_recorder) andDo(fn moqStore_LightGadgetsByWidgetId_doFn) *moqStore_LightGadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqStore_LightGadgetsByWidgetId_params) { + fn(params.widgetId, params.maxWeight) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqStore_LightGadgetsByWidgetId_fnRecorder) doReturnResults(fn moqStore_LightGadgetsByWidgetId_doReturnFn) *moqStore_LightGadgetsByWidgetId_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 []demo.Gadget - result2 error +func (r *moqStore_LightGadgetsByWidgetId_recorder) doReturnResults(fn moqStore_LightGadgetsByWidgetId_doReturnFn) *moqStore_LightGadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqStore_LightGadgetsByWidgetId_params) *moqStore_LightGadgetsByWidgetId_results { + result1, result2 := fn(params.widgetId, params.maxWeight) + return &moqStore_LightGadgetsByWidgetId_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqStore_LightGadgetsByWidgetId_doFn - doReturnFn moqStore_LightGadgetsByWidgetId_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqStore_LightGadgetsByWidgetId_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 *moqStore_LightGadgetsByWidgetId_resultsByParams - for n, res := range r.moq.resultsByParams_LightGadgetsByWidgetId { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqStore_LightGadgetsByWidgetId_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqStore_LightGadgetsByWidgetId_paramsKey]*moqStore_LightGadgetsByWidgetId_results{}, - } - r.moq.resultsByParams_LightGadgetsByWidgetId = append(r.moq.resultsByParams_LightGadgetsByWidgetId, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_LightGadgetsByWidgetId) { - copy(r.moq.resultsByParams_LightGadgetsByWidgetId[insertAt+1:], r.moq.resultsByParams_LightGadgetsByWidgetId[insertAt:0]) - r.moq.resultsByParams_LightGadgetsByWidgetId[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_LightGadgetsByWidgetId(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqStore_LightGadgetsByWidgetId_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 *moqStore_LightGadgetsByWidgetId_fnRecorder) repeat(repeaters ...moq.Repeater) *moqStore_LightGadgetsByWidgetId_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqStore_LightGadgetsByWidgetId_recorder) repeat(repeaters ...moq.Repeater) *moqStore_LightGadgetsByWidgetId_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 []demo.Gadget - result2 error - } - sequence uint32 - doFn moqStore_LightGadgetsByWidgetId_doFn - doReturnFn moqStore_LightGadgetsByWidgetId_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqStore) prettyParams_LightGadgetsByWidgetId(params moqStore_LightGadgetsByWidgetId_params) string { +func (*moqStore_LightGadgetsByWidgetId_adaptor) PrettyParams(params moqStore_LightGadgetsByWidgetId_params) string { return fmt.Sprintf("LightGadgetsByWidgetId(%#v, %#v)", params.widgetId, params.maxWeight) } -func (m *moqStore) paramsKey_LightGadgetsByWidgetId(params moqStore_LightGadgetsByWidgetId_params, anyParams uint64) moqStore_LightGadgetsByWidgetId_paramsKey { - m.scene.T.Helper() - var widgetIdUsed int - var widgetIdUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.LightGadgetsByWidgetId.widgetId == moq.ParamIndexByValue { - widgetIdUsed = params.widgetId - } else { - widgetIdUsedHash = hash.DeepHash(params.widgetId) - } - } - var maxWeightUsed uint32 - var maxWeightUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.LightGadgetsByWidgetId.maxWeight == moq.ParamIndexByValue { - maxWeightUsed = params.maxWeight - } else { - maxWeightUsedHash = hash.DeepHash(params.maxWeight) - } - } +func (a *moqStore_LightGadgetsByWidgetId_adaptor) ParamsKey(params moqStore_LightGadgetsByWidgetId_params, anyParams uint64) moqStore_LightGadgetsByWidgetId_paramsKey { + a.moq.moq_LightGadgetsByWidgetId.Scene.T.Helper() + widgetIdUsed, widgetIdUsedHash := impl.ParamKey( + params.widgetId, 1, a.moq.runtime.parameterIndexing.LightGadgetsByWidgetId.widgetId, anyParams) + maxWeightUsed, maxWeightUsedHash := impl.ParamKey( + params.maxWeight, 2, a.moq.runtime.parameterIndexing.LightGadgetsByWidgetId.maxWeight, anyParams) return moqStore_LightGadgetsByWidgetId_paramsKey{ params: struct { widgetId int @@ -1083,36 +616,15 @@ func (m *moqStore) paramsKey_LightGadgetsByWidgetId(params moqStore_LightGadgets // Reset resets the state of the moq func (m *moqStore) Reset() { - m.resultsByParams_AllWidgetsIds = nil - m.resultsByParams_GadgetsByWidgetId = nil - m.resultsByParams_LightGadgetsByWidgetId = nil + m.moq_AllWidgetsIds.Reset() + m.moq_GadgetsByWidgetId.Reset() + m.moq_LightGadgetsByWidgetId.Reset() } // AssertExpectationsMet asserts that all expectations have been met func (m *moqStore) AssertExpectationsMet() { - m.scene.T.Helper() - for _, res := range m.resultsByParams_AllWidgetsIds { - 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_AllWidgetsIds(results.params)) - } - } - } - for _, res := range m.resultsByParams_GadgetsByWidgetId { - 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_GadgetsByWidgetId(results.params)) - } - } - } - for _, res := range m.resultsByParams_LightGadgetsByWidgetId { - 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_LightGadgetsByWidgetId(results.params)) - } - } - } + m.moq_AllWidgetsIds.Scene.T.Helper() + m.moq_AllWidgetsIds.AssertExpectationsMet() + m.moq_GadgetsByWidgetId.AssertExpectationsMet() + m.moq_LightGadgetsByWidgetId.AssertExpectationsMet() } diff --git a/demo/moq_writer_test.go b/demo/moq_writer_test.go index 03e146a..a91c208 100644 --- a/demo/moq_writer_test.go +++ b/demo/moq_writer_test.go @@ -5,10 +5,9 @@ package demo_test import ( "fmt" "io" - "math/bits" - "sync/atomic" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -17,22 +16,19 @@ var _ io.Writer = (*moqWriter_mock)(nil) // moqWriter holds the state of a moq of the Writer type type moqWriter struct { - scene *moq.Scene - config moq.Config - moq *moqWriter_mock + moq *moqWriter_mock - resultsByParams_Write []moqWriter_Write_resultsByParams + moq_Write *impl.Moq[ + *moqWriter_Write_adaptor, + moqWriter_Write_params, + moqWriter_Write_paramsKey, + moqWriter_Write_results, + ] - runtime struct { - parameterIndexing struct { - Write struct { - p moq.ParamIndexing - } - } - } - // moqWriter_mock isolates the mock interface of the Writer type + runtime moqWriter_runtime } +// moqWriter_mock isolates the mock interface of the Writer type type moqWriter_mock struct { moq *moqWriter } @@ -42,6 +38,18 @@ type moqWriter_recorder struct { moq *moqWriter } +// moqWriter_runtime holds runtime configuration for the Writer type +type moqWriter_runtime struct { + parameterIndexing struct { + Write moqWriter_Write_paramIndexing + } +} + +// moqWriter_Write_adaptor adapts moqWriter as needed by the runtime +type moqWriter_Write_adaptor struct { + moq *moqWriter +} + // moqWriter_Write_params holds the params of the Writer type type moqWriter_Write_params struct{ p []byte } @@ -51,12 +59,16 @@ type moqWriter_Write_paramsKey struct { hashes struct{ p hash.Hash } } -// moqWriter_Write_resultsByParams contains the results for a given set of -// parameters for the Writer type -type moqWriter_Write_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqWriter_Write_paramsKey]*moqWriter_Write_results +// moqWriter_Write_results holds the results of the Writer type +type moqWriter_Write_results struct { + n int + err error +} + +// moqWriter_Write_paramIndexing holds the parameter indexing runtime +// configuration for the Writer type +type moqWriter_Write_paramIndexing struct { + p moq.ParamIndexing } // moqWriter_Write_doFn defines the type of function needed when calling andDo @@ -67,68 +79,47 @@ type moqWriter_Write_doFn func(p []byte) // doReturnResults for the Writer type type moqWriter_Write_doReturnFn func(p []byte) (n int, err error) -// moqWriter_Write_results holds the results of the Writer type -type moqWriter_Write_results struct { - params moqWriter_Write_params - results []struct { - values *struct { - n int - err error - } - sequence uint32 - doFn moqWriter_Write_doFn - doReturnFn moqWriter_Write_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqWriter_Write_fnRecorder routes recorded function calls to the moqWriter -// moq -type moqWriter_Write_fnRecorder struct { - params moqWriter_Write_params - anyParams uint64 - sequence bool - results *moqWriter_Write_results - moq *moqWriter +// moqWriter_Write_recorder routes recorded function calls to the moqWriter moq +type moqWriter_Write_recorder struct { + recorder *impl.Recorder[ + *moqWriter_Write_adaptor, + moqWriter_Write_params, + moqWriter_Write_paramsKey, + moqWriter_Write_results, + ] } // moqWriter_Write_anyParams isolates the any params functions of the Writer // type type moqWriter_Write_anyParams struct { - recorder *moqWriter_Write_fnRecorder + recorder *moqWriter_Write_recorder } // newMoqWriter creates a new moq of the Writer type func newMoqWriter(scene *moq.Scene, config *moq.Config) *moqWriter { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqWriter_Write_adaptor{} m := &moqWriter{ - scene: scene, - config: *config, - moq: &moqWriter_mock{}, - - runtime: struct { - parameterIndexing struct { - Write struct { - p moq.ParamIndexing - } - } - }{parameterIndexing: struct { - Write struct { - p moq.ParamIndexing - } + moq: &moqWriter_mock{}, + + moq_Write: impl.NewMoq[ + *moqWriter_Write_adaptor, + moqWriter_Write_params, + moqWriter_Write_paramsKey, + moqWriter_Write_results, + ](scene, adaptor1, config), + + runtime: moqWriter_runtime{parameterIndexing: struct { + Write moqWriter_Write_paramIndexing }{ - Write: struct { - p moq.ParamIndexing - }{ + Write: moqWriter_Write_paramIndexing{ p: moq.ParamIndexByHash, }, }}, } m.moq.moq = m + adaptor1.moq = m + scene.AddMoq(m) return m } @@ -136,58 +127,19 @@ func newMoqWriter(scene *moq.Scene, config *moq.Config) *moqWriter { // mock returns the mock implementation of the Writer type func (m *moqWriter) mock() *moqWriter_mock { return m.moq } -func (m *moqWriter_mock) Write(p []byte) (n int, err error) { - m.moq.scene.T.Helper() +func (m *moqWriter_mock) Write(p []byte) (int, error) { + m.moq.moq_Write.Scene.T.Helper() params := moqWriter_Write_params{ p: p, } - var results *moqWriter_Write_results - for _, resultsByParams := range m.moq.resultsByParams_Write { - paramsKey := m.moq.paramsKey_Write(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_Write(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_Write(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_Write(params)) - } - } - if result.doFn != nil { - result.doFn(p) + var result1 int + var result2 error + if result := m.moq.moq_Write.Function(params); result != nil { + result1 = result.n + result2 = result.err } - - if result.values != nil { - n = result.values.n - err = result.values.err - } - if result.doReturnFn != nil { - n, err = result.doReturnFn(p) - } - return + return result1, result2 } // onCall returns the recorder implementation of the Writer type @@ -197,202 +149,90 @@ func (m *moqWriter) onCall() *moqWriter_recorder { } } -func (m *moqWriter_recorder) Write(p []byte) *moqWriter_Write_fnRecorder { - return &moqWriter_Write_fnRecorder{ - params: moqWriter_Write_params{ +func (m *moqWriter_recorder) Write(p []byte) *moqWriter_Write_recorder { + return &moqWriter_Write_recorder{ + recorder: m.moq.moq_Write.OnCall(moqWriter_Write_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqWriter_Write_fnRecorder) any() *moqWriter_Write_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_Write(r.params)) +func (r *moqWriter_Write_recorder) any() *moqWriter_Write_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqWriter_Write_anyParams{recorder: r} } -func (a *moqWriter_Write_anyParams) p() *moqWriter_Write_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqWriter_Write_anyParams) p() *moqWriter_Write_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqWriter_Write_fnRecorder) seq() *moqWriter_Write_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_Write(r.params)) +func (r *moqWriter_Write_recorder) seq() *moqWriter_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqWriter_Write_fnRecorder) noSeq() *moqWriter_Write_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_Write(r.params)) +func (r *moqWriter_Write_recorder) noSeq() *moqWriter_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqWriter_Write_fnRecorder) returnResults(n int, err error) *moqWriter_Write_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 { - n int - err error - } - sequence uint32 - doFn moqWriter_Write_doFn - doReturnFn moqWriter_Write_doReturnFn - }{ - values: &struct { - n int - err error - }{ - n: n, - err: err, - }, - sequence: sequence, +func (r *moqWriter_Write_recorder) returnResults(n int, err error) *moqWriter_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqWriter_Write_results{ + n: n, + err: err, }) return r } -func (r *moqWriter_Write_fnRecorder) andDo(fn moqWriter_Write_doFn) *moqWriter_Write_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqWriter_Write_recorder) andDo(fn moqWriter_Write_doFn) *moqWriter_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqWriter_Write_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqWriter_Write_fnRecorder) doReturnResults(fn moqWriter_Write_doReturnFn) *moqWriter_Write_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 { - n int - err error +func (r *moqWriter_Write_recorder) doReturnResults(fn moqWriter_Write_doReturnFn) *moqWriter_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqWriter_Write_params) *moqWriter_Write_results { + n, err := fn(params.p) + return &moqWriter_Write_results{ + n: n, + err: err, } - sequence uint32 - doFn moqWriter_Write_doFn - doReturnFn moqWriter_Write_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqWriter_Write_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 *moqWriter_Write_resultsByParams - for n, res := range r.moq.resultsByParams_Write { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqWriter_Write_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqWriter_Write_paramsKey]*moqWriter_Write_results{}, - } - r.moq.resultsByParams_Write = append(r.moq.resultsByParams_Write, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Write) { - copy(r.moq.resultsByParams_Write[insertAt+1:], r.moq.resultsByParams_Write[insertAt:0]) - r.moq.resultsByParams_Write[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Write(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqWriter_Write_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 *moqWriter_Write_fnRecorder) repeat(repeaters ...moq.Repeater) *moqWriter_Write_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqWriter_Write_recorder) repeat(repeaters ...moq.Repeater) *moqWriter_Write_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - n int - err error - } - sequence uint32 - doFn moqWriter_Write_doFn - doReturnFn moqWriter_Write_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqWriter) prettyParams_Write(params moqWriter_Write_params) string { +func (*moqWriter_Write_adaptor) PrettyParams(params moqWriter_Write_params) string { return fmt.Sprintf("Write(%#v)", params.p) } -func (m *moqWriter) paramsKey_Write(params moqWriter_Write_params, anyParams uint64) moqWriter_Write_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Write.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter of the Write function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqWriter_Write_adaptor) ParamsKey(params moqWriter_Write_params, anyParams uint64) moqWriter_Write_paramsKey { + a.moq.moq_Write.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq_Write.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.Write.p, anyParams) return moqWriter_Write_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -402,17 +242,12 @@ func (m *moqWriter) paramsKey_Write(params moqWriter_Write_params, anyParams uin } // Reset resets the state of the moq -func (m *moqWriter) Reset() { m.resultsByParams_Write = nil } +func (m *moqWriter) Reset() { + m.moq_Write.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqWriter) AssertExpectationsMet() { - m.scene.T.Helper() - for _, res := range m.resultsByParams_Write { - 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_Write(results.params)) - } - } - } + m.moq_Write.Scene.T.Helper() + m.moq_Write.AssertExpectationsMet() } diff --git a/generator/converter.go b/generator/converter.go index fc2858c..acf0c37 100644 --- a/generator/converter.go +++ b/generator/converter.go @@ -16,42 +16,36 @@ import ( ) const ( - moqueriesPkg = "moqueries.org/runtime" - hashPkg = moqueriesPkg + "/hash" - moqPkg = moqueriesPkg + "/moq" - syncAtomicPkg = "sync/atomic" + moqueriesPkg = "moqueries.org/runtime" + hashPkg = moqueriesPkg + "/hash" + implPkg = moqueriesPkg + "/impl" + moqPkg = moqueriesPkg + "/moq" intType = "int" configType = "Config" hashType = "Hash" + moqType = "Moq" paramIndexingType = "ParamIndexing" + recorderType = "Recorder" repeaterType = "Repeater" - repeatValType = "RepeatVal" sceneType = "Scene" tType = "T" - anyCountIdent = "anyCount" + adaptorIdent = "adaptor" + adaptorReceiverIdent = "a" anyParamsIdent = "anyParams" anyParamsReceiverIdent = "a" - anyTimesIdent = "AnyTimes" blankIdent = "_" configIdent = "config" doFnIdent = "doFn" doReturnFnIdent = "doReturnFn" - expectationIdent = "Expectation" hashesIdent = "hashes" iIdent = "i" - indexIdent = "index" - insertAtIdent = "insertAt" - lastIdent = "last" - minTimesIdent = "MinTimes" - missingIdent = "missing" mockIdent = "mock" moqIdent = "moq" moqReceiverIdent = "m" - nIdent = "n" nilIdent = "nil" - okIdent = "ok" + paramIndexingIdent = "paramIndexing" parameterIndexingIdent = "parameterIndexing" paramIndexByValueIdent = "ParamIndexByValue" paramIndexByHashIdent = "ParamIndexByHash" @@ -59,42 +53,38 @@ const ( paramsKeyIdent = "paramsKey" recorderIdent = "recorder" recorderReceiverIdent = "r" - repeatIdent = "repeat" repeatersIdent = "repeaters" - resultsByParamsIdent = "resultsByParams" - resIdent = "res" resultIdent = "result" - resultCountIdent = "ResultCount" resultsIdent = "results" runtimeIdent = "runtime" sceneIdent = "scene" sequenceIdent = "sequence" - strictIdent = "Strict" - valuesIdent = "values" - - andDoFnName = "andDo" - assertFnName = "AssertExpectationsMet" - doReturnResultsFnName = "doReturnResults" - errorfFnName = "Errorf" - fatalfFnName = "Fatalf" - findResultsFnName = "findResults" - fnFnName = "fn" - helperFnName = "Helper" - incrementFnName = "Increment" - lenFnName = "len" - mockFnName = "mock" - onCallFnName = "onCall" - paramsKeyFnName = "paramsKey" - prettyParamsFnName = "prettyParams" - repeatFnName = "repeat" - resetFnName = "Reset" - returnFnName = "returnResults" - - fnRecorderSuffix = "fnRecorder" - paramPrefix = "param" - resultPrefix = "result" - usedSuffix = "Used" - usedHashSuffix = "UsedHash" + + andDoFnName = "andDo" + anyParamFnName = "AnyParam" + assertFnName = "AssertExpectationsMet" + doReturnResultsFnName = "doReturnResults" + fnFnName = "fn" + functionFnName = "Function" + hashOnlyParamKeyFnName = "HashOnlyParamKey" + helperFnName = "Helper" + isAnyPermittedFnName = "IsAnyPermitted" + mockFnName = "mock" + newMoqFnName = "NewMoq" + onCallFnName = "onCall" + paramKeyFnName = "ParamKey" + paramsKeyFnName = "paramsKey" + prettyParamsFnName = "prettyParams" + repeatFnName = "repeat" + resetFnName = "Reset" + returnResultsFnName = "returnResults" + seqFnName = "Seq" + + recorderSuffix = "recorder" + paramPrefix = "param" + resultPrefix = "result" + usedSuffix = "Used" + usedHashSuffix = "UsedHash" sep = "_" double = "%s" + sep + "%s" @@ -152,27 +142,23 @@ 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(c.genericExpr(Id(moqName), clone))).Names(c.exportId(moqIdent)). - Decs(FieldDecs(dst.None, dst.EmptyLine).Obj).Obj, + var fields []*dst.Field + if c.isInterface() { + fields = append(fields, Field(Star(c.genericExpr(Id(moqName), clone)).Obj).Names(c.exportId(moqIdent)). + Decs(FieldDecs(dst.None, dst.EmptyLine).Obj).Obj) } - _, isInterface := c.typ.TypeInfo.Type.Type.(*dst.InterfaceType) for _, fn := range c.typ.Funcs { - typePrefix := c.typePrefix(fn) - fieldSuffix := "" - if isInterface { - fieldSuffix = sep + fn.Name + fnPrefix := c.export(moqIdent) + if fn.Name != "" { + fnPrefix += sep + fn.Name } fields = append(fields, - Field(SliceType(c.genericExpr(Idf( - double, typePrefix, resultsByParamsIdent), clone))). - Names(c.exportId(resultsByParamsIdent+fieldSuffix)).Obj) + Field(Star(Index(IdPath(moqType, implPkg)). + Sub(c.baseTypeParams(fn)...).Obj).Obj).Names(c.exportId(fnPrefix)).Obj) } - fields = append(fields, Field(c.runtimeStruct()). + fields = append(fields, Field(c.exportId(fmt.Sprintf(double, mName, runtimeIdent))). Names(c.exportId(runtimeIdent)). Decs(FieldDecs(dst.EmptyLine, dst.None).Obj).Obj) @@ -187,15 +173,15 @@ func (c *Converter) BaseDecls() ([]dst.Decl, error) { idStr = typeName } - if isInterface { + if c.isInterface() { if c.typ.TypeInfo.Fabricated { id = Id(id.Name) } decls = append(decls, VarDecl( Value(c.genericExpr(id, typeAssertSafe)).Names(Id(blankIdent)). - Values(Call(Paren(Star(c.genericExpr(Id(moqName), typeAssertSafe)))). + Values(Call(Paren(Star(c.genericExpr(Id(moqName), typeAssertSafe)).Obj)). Args(Id(nilIdent)).Obj).Obj). - Decs(genDeclDec("// The following type assertion assures"+ + Decs(genDeclDecf("// The following type assertion assures"+ " that %s is mocked completely", idStr)).Obj, ) } @@ -203,20 +189,20 @@ func (c *Converter) BaseDecls() ([]dst.Decl, error) { if c.typ.TypeInfo.Fabricated || c.typ.Reduced { typ := c.resolveExpr(cloneExpr(c.typ.TypeInfo.Type.Type), c.typ.TypeInfo) msg := "emitted when mocking functions directly and not from a function type" - if isInterface { + if c.isInterface() { msg = "emitted when mocking a collections of methods directly and not from an interface type" } if !c.typ.TypeInfo.Fabricated { msg = "emitted when the original interface contains non-exported methods" } decls = append(decls, TypeDecl(TypeSpec(typeName).Type(typ).TypeParams(c.typeParams()).Obj). - Decs(genDeclDec("// %s is the fabricated implementation type of this mock (%s)", + Decs(genDeclDecf("// %s is the fabricated implementation type of this mock (%s)", typeName, msg)).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", + Decs(genDeclDecf("// %s holds the state of a moq of the %s type", mName, typeName)).Obj) if c.err != nil { @@ -226,21 +212,40 @@ func (c *Converter) BaseDecls() ([]dst.Decl, error) { return decls, nil } -// IsolationStruct generates a struct used to isolate an interface for the moq -func (c *Converter) IsolationStruct(suffix string) (*dst.GenDecl, error) { +// MockStructs generates several structs used to isolate functionality +// for the moq +func (c *Converter) MockStructs() ([]dst.Decl, error) { mName := c.moqName() - iName := fmt.Sprintf(double, mName, suffix) - 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.typeName())).Obj + gen := func(suffix string) *dst.GenDecl { + iName := fmt.Sprintf(double, mName, suffix) + + return TypeDecl(TypeSpec(iName).Type(Struct(Field(Star(c.genericExpr(Id(mName), clone)).Obj). + Names(c.exportId(moqIdent)).Obj)).TypeParams(c.typeParams()).Obj). + Decs(genDeclDecf("// %s isolates the %s interface of the %s type", + iName, suffix, c.typeName())).Obj + } + + var iStructs []dst.Decl + if c.isInterface() { + iStructs = append(iStructs, gen(mockIdent)) + } + + _, isId := c.typ.TypeInfo.Type.Type.(*dst.Ident) + if c.isInterface() || isId { + iStructs = append(iStructs, gen(recorderIdent)) + } + + rName := fmt.Sprintf(double, mName, runtimeIdent) + iStructs = append(iStructs, TypeDecl(TypeSpec(rName).Type(c.runtimeStruct()).Obj). + Decs(genDeclDecf("// %s holds runtime configuration for the %s type", + rName, c.typeName())).Obj) if c.err != nil { return nil, c.err } - return iStruct, nil + return iStructs, nil } // MethodStructs generates a structure for storing a set of parameters or @@ -249,13 +254,14 @@ func (c *Converter) MethodStructs(fn Func) ([]dst.Decl, error) { prefix := c.typePrefix(fn) decls := []dst.Decl{ + c.adaptorStructDecl(prefix), c.paramsStructDecl(prefix, false, fn.FuncType.Params, fn.ParentType), c.paramsStructDecl(prefix, true, fn.FuncType.Params, fn.ParentType), - c.resultByParamsStruct(prefix), + c.resultsStruct(prefix, fn.FuncType.Results, fn.ParentType), + c.fnParamIndexingStruct(prefix, fn.FuncType.Params, fn.ParentType), c.doFuncType(prefix, fn.FuncType.Params, fn.ParentType), c.doReturnFuncType(prefix, fn), - c.resultsStruct(prefix, fn.FuncType.Results, fn.ParentType), - c.fnRecorderStruct(prefix), + c.recorderStruct(prefix, fn), c.anyParamsStruct(prefix), } @@ -270,42 +276,46 @@ func (c *Converter) MethodStructs(fn Func) ([]dst.Decl, error) { func (c *Converter) NewFunc() (*dst.FuncDecl, error) { fnName := c.export("newMoq" + c.typeName()) mName := c.moqName() + body := c.defineAdaptors() + var elts []dst.Expr + var moqStmt dst.Stmt + if c.isInterface() { + elts = append(elts, Key(c.exportId(moqIdent)).Value(Un(token.AND, Comp( + c.genericExpr(Id(fmt.Sprintf(double, mName, mockIdent)), clone)).Obj)). + Decs(KeyValueDecs(dst.None).After(dst.EmptyLine).Obj).Obj) + moqStmt = Assign(Sel(Sel(Id(moqReceiverIdent)). + Dot(c.exportId(moqIdent)).Obj). + Dot(c.exportId(moqIdent)).Obj). + Tok(token.ASSIGN). + Rhs(Id(moqReceiverIdent)). + Decs(AssignDecs(dst.None).After(dst.EmptyLine).Obj).Obj + } + elts = append(elts, c.newMoqs()...) + elts = append(elts, Key(c.exportId(runtimeIdent)).Value(Comp( + c.exportId(fmt.Sprintf(double, mName, runtimeIdent))). + Elts(c.runtimeValues()...).Obj).Decs(kvExprDec(dst.None)). + Decs(kvExprDec(dst.EmptyLine)).Obj) + body = append(body, + Assign(Id(moqReceiverIdent)).Tok(token.DEFINE).Rhs(Un(token.AND, + Comp(c.genericExpr(Id(mName), clone)).Elts(elts...).Decs(litDec()).Obj)).Obj, + moqStmt, + ) + body = append(body, c.updateAdaptors()...) + body = append(body, + Expr(Call(Sel(Id(sceneIdent)).Dot(Id("AddMoq")).Obj). + Args(Id(moqReceiverIdent)).Decs(CallDecs(dst.EmptyLine, dst.None)).Obj).Obj, + Return(Id(moqReceiverIdent)), + ) 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(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(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(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)). - Decs(kvExprDec(dst.EmptyLine)).Obj, - ).Decs(litDec()).Obj)).Obj, - Assign(Sel(Sel(Id(moqReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj). - Dot(c.exportId(moqIdent)).Obj). - Tok(token.ASSIGN). - Rhs(Id(moqReceiverIdent)). - Decs(AssignDecs(dst.None).After(dst.EmptyLine).Obj).Obj, - Expr(Call(Sel(Id(sceneIdent)).Dot(Id("AddMoq")).Obj). - Args(Id(moqReceiverIdent)).Obj).Obj, - Return(Id(moqReceiverIdent)), + Field(Star(c.idPath(sceneType, moqPkg)).Obj).Names(Id(sceneIdent)).Obj, + Field(Star(c.idPath(configType, moqPkg)).Obj).Names(Id(configIdent)).Obj, ). - Decs(fnDeclDec("// %s creates a new moq of the %s type", + Results(Field(Star(c.genericExpr(Id(mName), clone)).Obj).Obj). + Body(body...). + Decs(fnDeclDecf("// %s creates a new moq of the %s type", fnName, c.typeName())).Obj if c.err != nil { @@ -331,10 +341,10 @@ func (c *Converter) IsolationAccessor(suffix, fnName string) (*dst.FuncDecl, err fnName = c.export(fnName) decl := Fn(fnName). - Recv(Field(Star(c.genericExpr(Id(mName), clone))).Names(Id(moqReceiverIdent)).Obj). - Results(Field(Star(iName)).Obj). + Recv(Field(Star(c.genericExpr(Id(mName), clone)).Obj).Names(Id(moqReceiverIdent)).Obj). + Results(Field(Star(iName).Obj).Obj). Body(Return(retVal)). - Decs(fnDeclDec("// %s returns the %s implementation of the %s type", + Decs(fnDeclDecf("// %s returns the %s implementation of the %s type", fnName, suffix, c.typeName())).Obj if c.err != nil { @@ -348,35 +358,18 @@ func (c *Converter) IsolationAccessor(suffix, fnName string) (*dst.FuncDecl, err // closure 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.FuncType.Params)...). - Ellipsis(isVariadic(fn.FuncType.Params)).Obj - var fnLitRetStmt dst.Stmt - fnLitRetStmt = Return(fnLitCall) - if fn.FuncType.Results == nil { - fnLitRetStmt = Expr(fnLitCall).Obj - } - resType := c.idPath(c.typeName(), c.typ.TypeInfo.Type.Name.Path) if c.typ.TypeInfo.Fabricated { resType = Id(c.typeName()) } decl := Fn(c.export(mockFnName)). - Recv(Field(Star(c.genericExpr(Id(mName), clone))).Names(Id(moqReceiverIdent)).Obj). + Recv(Field(Star(c.genericExpr(Id(mName), clone)).Obj).Names(Id(moqReceiverIdent)).Obj). Results(Field(c.genericExpr(resType, clone)).Obj). Body(Return(FnLit(FnType(c.cloneAndNameUnnamed(paramPrefix, fn.FuncType.Params, fn.ParentType)). Results(c.cloneFieldList(fn.FuncType.Results, true, fn.ParentType)).Obj). - Body(c.helperCallExpr(Id(moqReceiverIdent)), - Assign(Id(moqIdent)).Tok(token.DEFINE).Rhs(Un( - token.AND, - Comp(c.genericExpr(Idf(double, mName, mockIdent), clone)). - Elts(Key(c.exportId(moqIdent)). - Value(Id(moqReceiverIdent)).Obj).Obj, - )).Obj, - fnLitRetStmt, - ).Obj)). - Decs(fnDeclDec("// %s returns the %s implementation of the %s type", + Body(c.mockFunc(c.typePrefix(fn), fn)...).Obj)). + Decs(fnDeclDecf("// %s returns the %s implementation of the %s type", c.export(mockFnName), moqIdent, c.typeName())).Obj if c.err != nil { @@ -391,18 +384,17 @@ func (c *Converter) MockMethod(fn Func) (*dst.FuncDecl, error) { mName := c.moqName() fnName := fn.Name - fieldSuffix := sep + fn.Name typePrefix := c.typePrefix(fn) if fnName == "" { fnName = c.export(fnFnName) - fieldSuffix = "" } decl := Fn(fnName). - Recv(Field(Star(c.genericExpr(Id(fmt.Sprintf(double, mName, mockIdent)), clone))).Names(Id(moqReceiverIdent)).Obj). + Recv(Field(Star(c.genericExpr(Id(fmt.Sprintf(double, mName, mockIdent)), clone)).Obj). + Names(Id(moqReceiverIdent)).Obj). ParamList(c.cloneAndNameUnnamed(paramPrefix, fn.FuncType.Params, fn.ParentType)). - ResultList(c.cloneAndNameUnnamed(resultPrefix, fn.FuncType.Results, fn.ParentType)). - Body(c.mockFunc(typePrefix, fieldSuffix, fn)...). + ResultList(c.cloneFieldList(fn.FuncType.Results, true, fn.ParentType)). + Body(c.mockFunc(typePrefix, fn)...). Decs(stdFuncDec()).Obj if c.err != nil { @@ -423,7 +415,6 @@ func (c *Converter) RecorderMethods(fn Func) ([]dst.Decl, error) { c.returnResultsFn(fn), c.andDoFn(fn), c.doReturnResultsFn(fn), - c.findResultsFn(fn), c.recorderRepeatFn(fn), c.prettyParamsFn(fn), c.paramsKeyFn(fn), @@ -441,20 +432,20 @@ func (c *Converter) ResetMethod() (*dst.FuncDecl, error) { var stmts []dst.Stmt for _, fn := range c.typ.Funcs { fieldSuffix := "" - if _, ok := c.typ.TypeInfo.Type.Type.(*dst.InterfaceType); ok { + if c.isInterface() { fieldSuffix = sep + fn.Name } - stmts = append(stmts, Assign(Sel(Id(moqReceiverIdent)). - Dot(c.exportId(resultsByParamsIdent+fieldSuffix)).Obj). - Tok(token.ASSIGN). - Rhs(Id(nilIdent)).Obj) + stmts = append(stmts, + Expr(Call(Sel(Sel(Id(moqReceiverIdent)). + Dot(c.exportId(moqIdent+fieldSuffix)).Obj).Dot(Id(resetFnName)).Obj).Obj). + Decs(ExprDecs(dst.NewLine).Obj).Obj) } decl := Fn(resetFnName). - Recv(Field(Star(c.genericExpr(Id(c.moqName()), clone))).Names(Id(moqReceiverIdent)).Obj). + Recv(Field(Star(c.genericExpr(Id(c.moqName()), clone)).Obj).Names(Id(moqReceiverIdent)).Obj). Body(stmts...). - Decs(fnDeclDec("// %s resets the state of the moq", resetFnName)).Obj + Decs(fnDeclDecf("// %s resets the state of the moq", resetFnName)).Obj if c.err != nil { return nil, c.err @@ -465,53 +456,25 @@ func (c *Converter) ResetMethod() (*dst.FuncDecl, error) { // AssertMethod generates a method to assert all expectations are met func (c *Converter) AssertMethod() (*dst.FuncDecl, error) { - stmts := []dst.Stmt{ - c.helperCallExpr(Id(moqReceiverIdent)), + sel := func(fn Func) dst.Expr { + dotId := moqIdent + if c.isInterface() { + dotId = fmt.Sprintf(double, moqIdent, fn.Name) + } + return Sel(Id(moqReceiverIdent)).Dot(c.exportId(dotId)).Obj + } + var stmts []dst.Stmt + if len(c.typ.Funcs) != 0 { + stmts = append(stmts, c.helperCallExpr(sel(c.typ.Funcs[0]))) } for _, fn := range c.typ.Funcs { - fieldSuffix := "" - if _, ok := c.typ.TypeInfo.Type.Type.(*dst.InterfaceType); ok { - fieldSuffix = sep + fn.Name - } - - stmts = append(stmts, Range(Sel(Id(moqReceiverIdent)). - Dot(c.exportId(resultsByParamsIdent+fieldSuffix)).Obj). - Key(Id(sep)).Value(Id(resIdent)).Tok(token.DEFINE). - Body(Range(Sel(Id(resIdent)).Dot(c.exportId(resultsIdent)).Obj). - Key(Id(sep)).Value(Id(resultsIdent)).Tok(token.DEFINE). - Body( - Assign(Id(missingIdent)). - Tok(token.DEFINE). - Rhs(Bin(Sel(Sel(Id(resultsIdent)). - Dot(c.exportId(repeatIdent)).Obj). - Dot(Id(minTimesIdent)).Obj). - Op(token.SUB). - Y(Call(Id(intType)).Args( - Call(c.idPath("LoadUint32", syncAtomicPkg)).Args(Un( - token.AND, - Sel(Id(resultsIdent)). - Dot(c.exportId(indexIdent)).Obj)).Obj).Obj).Obj).Obj, - If(Bin(Id(missingIdent)).Op(token.GTR). - Y(LitInt(0)).Obj). - Body( - Expr(Call(Sel(Sel(Sel(Id(moqReceiverIdent)). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id(tType)).Obj).Dot(Id(errorfFnName)).Obj). - Args( - LitString("Expected %d additional call(s) to %s"), - Id(missingIdent), - c.callPrettyParams(fn, - Id(moqReceiverIdent), - Id(resultsIdent))).Obj).Obj, - ).Obj, - ).Obj, - ).Obj) + stmts = append(stmts, Expr(Call(Sel(sel(fn)).Dot(Id(titler.String(assertFnName))).Obj).Obj).Obj) } decl := Fn(assertFnName). - Recv(Field(Star(c.genericExpr(Id(c.moqName()), clone))).Names(Id(moqReceiverIdent)).Obj). + Recv(Field(Star(c.genericExpr(Id(c.moqName()), clone)).Obj).Names(Id(moqReceiverIdent)).Obj). Body(stmts...). - Decs(fnDeclDec("// %s asserts that all expectations have been met", + Decs(fnDeclDecf("// %s asserts that all expectations have been met", assertFnName)).Obj if c.err != nil { @@ -523,113 +486,49 @@ func (c *Converter) AssertMethod() (*dst.FuncDecl, error) { func (c *Converter) typePrefix(fn Func) string { mName := c.moqName() - typePrefix := fmt.Sprintf(double, mName, fn.Name) - if fn.Name == "" { - typePrefix = mName + typePrefix := mName + if c.isInterface() { + typePrefix = fmt.Sprintf(double, mName, fn.Name) } return typePrefix } -func (c *Converter) runtimeStruct() *dst.StructType { - return Struct(Field(c.paramIndexingStruct()). - Names(c.exportId(parameterIndexingIdent)).Obj) +func (c *Converter) baseTypeParams(fn Func) []dst.Expr { + typePrefix := c.typePrefix(fn) + return []dst.Expr{ + Star(c.genericExpr(Idf(double, typePrefix, adaptorIdent), clone)). + Decs(StarDecs(dst.NewLine, dst.NewLine)).Obj, + c.genericExpr(IdDecs(Idf(double, typePrefix, paramsIdent), IdentDecs(dst.NewLine, dst.NewLine)), clone), + c.genericExpr(IdDecs(Idf(double, typePrefix, paramsKeyIdent), IdentDecs(dst.NewLine, dst.NewLine)), clone), + c.genericExpr(IdDecs(Idf(double, typePrefix, resultsIdent), IdentDecs(dst.NewLine, dst.NewLine)), clone), + } } -func (c *Converter) paramIndexingStruct() *dst.StructType { +func (c *Converter) runtimeStruct() *dst.StructType { + mName := c.moqName() + var piExpr dst.Expr var piFields []*dst.Field for _, fn := range c.typ.Funcs { - if fn.Name == "" { - piFields = append(piFields, c.paramIndexingFnStruct(fn).Fields.List...) - } else { + if c.isInterface() { piFields = append(piFields, - Field(c.paramIndexingFnStruct(fn)).Names(Id(fn.Name)).Obj) - } - } - - return Struct(piFields...) -} - -func (c *Converter) paramIndexingFnStruct(fn Func) *dst.StructType { - var piParamFields []*dst.Field - count := 0 - for _, f := range fn.FuncType.Params.List { - if len(f.Names) == 0 { - piParamFields = append(piParamFields, - c.paramIndexingField(fmt.Sprintf(unnamed, paramPrefix, count+1))) - count++ - } - - for _, name := range f.Names { - piParamFields = append(piParamFields, - c.paramIndexingField(validName(name.Name, paramPrefix, count))) - count++ - } - } - - return Struct(piParamFields...) -} - -func (c *Converter) paramIndexingField(name string) *dst.Field { - return Field(c.idPath(paramIndexingType, moqPkg)).Names(c.exportId(name)).Obj -} - -func (c *Converter) runtimeValues() []dst.Expr { - var vals []dst.Expr - kvDec := dst.NewLine - for _, fn := range c.typ.Funcs { - if fn.Name == "" { - vals = append(vals, c.paramIndexingFnValues(fn)...) + Field(Idf(triple, mName, fn.Name, paramIndexingIdent)).Names(Id(fn.Name)).Obj) } else { - vals = append(vals, Key(Id(fn.Name)).Value(Comp(c.paramIndexingFnStruct(fn)). - Elts(c.paramIndexingFnValues(fn)...).Obj).Decs(kvExprDec(kvDec)).Obj) + piExpr = Idf(double, mName, paramIndexingIdent) } - kvDec = dst.None } - - return []dst.Expr{Key(c.exportId(parameterIndexingIdent)). - Value(Comp(c.paramIndexingStruct()).Elts(vals...).Obj).Obj} -} - -func (c *Converter) paramIndexingFnValues(fn Func) []dst.Expr { - var vals []dst.Expr - kvDec := dst.NewLine - count := 0 - for _, f := range fn.FuncType.Params.List { - typ := c.resolveExpr(f.Type, fn.ParentType) - - 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 { - vals = append(vals, c.paramIndexingValue( - typ, validName(name.Name, paramPrefix, count), kvDec)) - count++ - kvDec = dst.None - } + if c.isInterface() { + piExpr = Struct(piFields...) } - - return vals + return Struct(Field(piExpr).Names(c.exportId(parameterIndexingIdent)).Obj) } -func (c *Converter) paramIndexingValue(typ dst.Expr, name string, kvDec dst.SpaceType) *dst.KeyValueExpr { - comp, err := c.typeCache.IsDefaultComparable(typ, c.typ.TypeInfo) - if err != nil { - if c.err == nil { - c.err = err - } - return nil - } - - val := paramIndexByValueIdent - if !comp { - val = paramIndexByHashIdent - } - - return Key(c.exportId(name)).Value(c.idPath(val, moqPkg)).Decs(kvExprDec(kvDec)).Obj +func (c *Converter) adaptorStructDecl(prefix string) *dst.GenDecl { + aName := fmt.Sprintf(double, prefix, adaptorIdent) + return TypeDecl(TypeSpec(aName). + Type(Struct(Field(Star(c.genericExpr(Id(c.moqName()), clone)).Obj). + Names(c.exportId(moqIdent)).Obj)). + TypeParams(c.typeParams()).Obj). + Decs(genDeclDecf("// %s adapts %s as needed by the runtime", aName, c.moqName())).Obj } func (c *Converter) paramsStructDecl( @@ -654,7 +553,7 @@ func (c *Converter) paramsStructDecl( structName := fmt.Sprintf(double, prefix, label) return TypeDecl(TypeSpec(structName).Type(mStruct).TypeParams(c.typeParams()).Obj). - Decs(genDeclDec("// %s holds the %s of the %s type", + Decs(genDeclDecf("// %s holds the %s of the %s type", structName, goDocDesc, c.typeName())).Obj } @@ -662,26 +561,25 @@ func (c *Converter) methodStruct(label string, fieldList *dst.FieldList, parentT unnamedPrefix, _ := labelDirection(label) fieldList = c.cloneFieldList(fieldList, false, parentType) - if fieldList == nil { - return StructFromList(nil) - } - - count := 0 var fList []*dst.Field - for _, f := range fieldList.List { - if len(f.Names) == 0 { - f.Names = []*dst.Ident{Idf(unnamed, unnamedPrefix, count+1)} - } + if fieldList != nil { + count := 1 + for _, f := range fieldList.List { + for n, name := range f.Names { + f.Names[n] = Id(c.export(validName(name.Name, unnamedPrefix, count))) + count++ + } - for n, name := range f.Names { - f.Names[n] = Id(c.export(validName(name.Name, unnamedPrefix, count))) - count++ - } + if len(f.Names) == 0 { + f.Names = []*dst.Ident{c.exportId(fmt.Sprintf(unnamed, unnamedPrefix, count))} + count++ + } - typ := c.comparableType(label, f.Type) - if typ != nil { - f.Type = typ - fList = append(fList, f) + typ := c.comparableType(label, f.Type) + if typ != nil { + f.Type = typ + fList = append(fList, f) + } } } @@ -726,19 +624,41 @@ func (c *Converter) comparableType(label string, typ dst.Expr) dst.Expr { return typ } -func (c *Converter) resultByParamsStruct(prefix string) *dst.GenDecl { - structName := fmt.Sprintf(double, prefix, resultsByParamsIdent) +func (c *Converter) resultsStruct(prefix string, results *dst.FieldList, parentType TypeInfo) *dst.GenDecl { + structName := fmt.Sprintf(double, prefix, resultsIdent) - return TypeDecl(TypeSpec(structName).Type(Struct( - Field(Id(intType)).Names(c.exportId(anyCountIdent)).Obj, - Field(Id("uint64")).Names(c.exportId(anyParamsIdent)).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, - )).TypeParams(c.typeParams()).Obj).Decs(genDeclDec( - "// %s contains the results for a given set of parameters for the %s type", - structName, - c.typeName())).Obj + return TypeDecl(TypeSpec(structName). + Type(c.methodStruct(resultsIdent, results, parentType)).TypeParams(c.typeParams()).Obj). + Decs(genDeclDecf("// %s holds the results of the %s type", structName, c.typeName())).Obj +} + +func (c *Converter) fnParamIndexingStruct(prefix string, params *dst.FieldList, parentType TypeInfo) *dst.GenDecl { + structName := fmt.Sprintf(double, prefix, paramIndexingIdent) + unnamedPrefix, _ := labelDirection(paramsIdent) + params = c.cloneFieldList(params, false, parentType) + + var fList []*dst.Field + if params != nil { + count := 1 + for _, f := range params.List { + for n, name := range f.Names { + f.Names[n] = Id(c.export(validName(name.Name, unnamedPrefix, count))) + count++ + } + + if len(f.Names) == 0 { + f.Names = []*dst.Ident{c.exportId(fmt.Sprintf(unnamed, unnamedPrefix, count))} + count++ + } + + f.Type = IdPath(paramIndexingType, moqPkg) + fList = append(fList, f) + } + } + + return TypeDecl(TypeSpec(structName).Type(Struct(fList...)).Obj). + Decs(genDeclDecf("// %s holds the parameter indexing runtime configuration for the %s type", + structName, c.typeName())).Obj } func (c *Converter) doFuncType(prefix string, params *dst.FieldList, parentType TypeInfo) *dst.GenDecl { @@ -746,7 +666,7 @@ func (c *Converter) doFuncType(prefix string, params *dst.FieldList, parentType return TypeDecl(TypeSpec(fnName). Type(FnType(c.cloneFieldList(params, false, parentType)).Obj). TypeParams(c.typeParams()).Obj). - Decs(genDeclDec( + Decs(genDeclDecf( "// %s defines the type of function needed when calling %s for the %s type", fnName, c.export(andDoFnName), @@ -759,52 +679,19 @@ func (c *Converter) doReturnFuncType(prefix string, fn Func) *dst.GenDecl { Type(FnType(c.cloneFieldList(fn.FuncType.Params, false, fn.ParentType)). Results(c.cloneFieldList(fn.FuncType.Results, false, fn.ParentType)).Obj). TypeParams(c.typeParams()).Obj). - Decs(genDeclDec( + Decs(genDeclDecf( "// %s defines the type of function needed when calling %s for the %s type", fnName, c.export(doReturnResultsFnName), c.typeName())).Obj } -func (c *Converter) resultsStruct(prefix string, results *dst.FieldList, parentType TypeInfo) *dst.GenDecl { - structName := fmt.Sprintf(double, prefix, resultsIdent) - - return TypeDecl(TypeSpec(structName).Type(Struct( - Field(c.genericExpr(Idf(double, prefix, paramsIdent), clone)). - Names(c.exportId(paramsIdent)).Obj, - Field(SliceType(c.innerResultsStruct(prefix, results, parentType))). - Names(c.exportId(resultsIdent)).Obj, - Field(Id("uint32")).Names(c.exportId(indexIdent)).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.typeName())).Obj -} - -func (c *Converter) innerResultsStruct(prefix string, results *dst.FieldList, parentType TypeInfo) *dst.StructType { - return Struct( - Field(Star(c.methodStruct(resultsIdent, results, parentType))). - Names(c.exportId(valuesIdent)).Obj, - Field(Id("uint32")).Names(c.exportId(sequenceIdent)).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, - ) -} - -func (c *Converter) fnRecorderStruct(prefix string) *dst.GenDecl { +func (c *Converter) recorderStruct(prefix string, fn Func) *dst.GenDecl { mName := c.moqName() - structName := fmt.Sprintf(double, prefix, fnRecorderSuffix) - return TypeDecl(TypeSpec(structName).Type(Struct( - 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( + structName := fmt.Sprintf(double, prefix, recorderSuffix) + return TypeDecl(TypeSpec(structName).Type(Struct(Field(Star(Index(IdPath(recorderType, implPkg)). + Sub(c.baseTypeParams(fn)...).Obj).Obj).Names(c.exportId(recorderIdent)).Obj, + )).TypeParams(c.typeParams()).Obj).Decs(genDeclDecf( "// %s routes recorded function calls to the %s moq", structName, mName)).Obj } @@ -812,667 +699,512 @@ func (c *Converter) fnRecorderStruct(prefix string) *dst.GenDecl { func (c *Converter) anyParamsStruct(prefix string) *dst.GenDecl { structName := fmt.Sprintf(double, prefix, anyParamsIdent) return TypeDecl(TypeSpec(structName).Type(Struct( - Field(Star(c.genericExpr(Id(fmt.Sprintf(double, prefix, fnRecorderSuffix)), clone))). + Field(Star(c.genericExpr(Id(fmt.Sprintf(double, prefix, recorderSuffix)), clone)).Obj). Names(c.exportId(recorderIdent)).Obj)).TypeParams(c.typeParams()).Obj). - Decs(genDeclDec("// %s isolates the any params functions of the %s type", + Decs(genDeclDecf("// %s isolates the any params functions of the %s type", structName, c.typeName())).Obj } -func (c *Converter) mockFunc(typePrefix, fieldSuffix string, fn Func) []dst.Stmt { - stateSelector := Sel(Id(moqReceiverIdent)).Dot(c.exportId(moqIdent)).Obj +func (c *Converter) defineAdaptors() []dst.Stmt { + var stmts []dst.Stmt + for n, fn := range c.typ.Funcs { + stmts = append(stmts, Assign(Idf(unnamed, adaptorIdent, n+1)).Tok(token.DEFINE). + Rhs(Un(token.AND, Comp(c.genericExpr(Idf(double, c.typePrefix(fn), adaptorIdent), clone)).Obj)).Obj) + } + return stmts +} + +func (c *Converter) updateAdaptors() []dst.Stmt { + var stmts []dst.Stmt + for n := range c.typ.Funcs { + stmts = append(stmts, Assign(Sel(Idf(unnamed, adaptorIdent, n+1)). + Dot(c.exportId(moqIdent)).Obj).Tok(token.ASSIGN).Rhs(Id(moqReceiverIdent)).Obj) + } + return stmts +} + +func (c *Converter) newMoqs() []dst.Expr { + var elts []dst.Expr + for n, fn := range c.typ.Funcs { + name := c.exportId(moqIdent) + if c.isInterface() { + name = c.exportId(fmt.Sprintf(double, moqIdent, fn.Name)) + } + elts = append(elts, Key(name).Value(Call( + Index(IdPath(newMoqFnName, implPkg)).Sub(c.baseTypeParams(fn)...).Obj). + Args(Id(sceneIdent), Id(fmt.Sprintf(unnamed, adaptorIdent, n+1)), Id(configIdent)).Obj). + Decs(kvExprDec(dst.NewLine)).Obj) + } + return elts +} - paramsKeyFn := c.export(paramsKeyFnName) - if fn.Name != "" { - paramsKeyFn = c.export(fmt.Sprintf(double, paramsKeyFnName, fn.Name)) +func (c *Converter) runtimeValues() []dst.Expr { + var vals []dst.Expr + kvDec := dst.NewLine + for _, fn := range c.typ.Funcs { + subVals := c.paramIndexingFnValues(fn) + if c.isInterface() { + subVals = []dst.Expr{Key(Id(fn.Name)).Value(Comp(c.exportId( + fmt.Sprintf(double, c.typePrefix(fn), paramIndexingIdent))). + Elts(subVals...).Obj).Decs(kvExprDec(kvDec)).Obj} + } + vals = append(vals, subVals...) + kvDec = dst.None } + + return []dst.Expr{Key(c.exportId(parameterIndexingIdent)). + Value(Comp(c.paramIndexingStruct()).Elts(vals...).Obj).Obj} +} + +func (c *Converter) paramIndexingFnValues(fn Func) []dst.Expr { + var vals []dst.Expr + kvDec := dst.NewLine + count := 1 + for _, f := range fn.FuncType.Params.List { + typ := c.resolveExpr(f.Type, fn.ParentType) + + for _, name := range f.Names { + vals = append(vals, c.paramIndexingValue( + typ, validName(name.Name, paramPrefix, count), kvDec)) + count++ + kvDec = dst.None + } + + if len(f.Names) == 0 { + vals = append(vals, c.paramIndexingValue( + typ, fmt.Sprintf(unnamed, paramPrefix, count), kvDec)) + count++ + kvDec = dst.None + } + } + + return vals +} + +func (c *Converter) paramIndexingValue(typ dst.Expr, name string, kvDec dst.SpaceType) *dst.KeyValueExpr { + comp, err := c.typeCache.IsDefaultComparable(typ, c.typ.TypeInfo) + if err != nil { + if c.err == nil { + c.err = err + } + return nil + } + + val := paramIndexByValueIdent + if !comp { + val = paramIndexByHashIdent + } + + return Key(c.exportId(name)).Value(c.idPath(val, moqPkg)).Decs(kvExprDec(kvDec)).Obj +} + +func (c *Converter) paramIndexingStruct() dst.Expr { + if !c.isInterface() { + return c.exportId(fmt.Sprintf(double, c.moqName(), paramIndexingIdent)) + } + var piFields []*dst.Field + for _, fn := range c.typ.Funcs { + piFields = append(piFields, Field(Idf( + double, c.typePrefix(fn), paramIndexingIdent)).Names(Id(fn.Name)).Obj) + } + + return Struct(piFields...) +} + +func (c *Converter) mockFunc(typePrefix string, fn Func) []dst.Stmt { moqSel := Sel(Id(moqReceiverIdent)).Dot(c.exportId(moqIdent)).Obj + if c.isInterface() { + moqSel = Sel(Sel(Id(moqReceiverIdent)).Dot(c.exportId(moqIdent)).Obj). + Dot(c.exportId(fmt.Sprintf(double, moqIdent, fn.Name))).Obj + } stmts := []dst.Stmt{ - c.helperCallExpr(Sel(Id(moqReceiverIdent)).Dot(c.exportId(moqIdent)).Obj), + c.helperCallExpr(moqSel), Assign(Id(paramsIdent)). Tok(token.DEFINE). Rhs(Comp(c.genericExpr(Idf(double, typePrefix, paramsIdent), clone)). - Elts(c.passthroughElements( - fn.FuncType.Params, paramsIdent, "", fn.ParentType)...).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). - Key(Id(sep)). - Value(Id(resultsByParamsIdent)). - Tok(token.DEFINE). - Body( - Assign(Id(paramsKeyIdent)). - Tok(token.DEFINE). - Rhs(Call(Sel(Sel(Id(moqReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj). - Dot(Id(paramsKeyFn)).Obj). - Args(Id(paramsIdent), Sel(Id(resultsByParamsIdent)). - Dot(c.exportId(anyParamsIdent)).Obj).Obj).Obj, - Var(Value(Id("bool")).Names(Id(okIdent)).Obj), - Assign(Id(resultsIdent), Id(okIdent)). - Tok(token.ASSIGN). - Rhs(Index(Sel(Id(resultsByParamsIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Sub(Id(paramsKeyIdent)).Obj).Obj, - If(Id(okIdent)).Body(Break()).Obj, - ).Obj, + Elts(c.passthroughKeyValues( + fn.FuncType.Params, paramsIdent, "", fn.ParentType)...).Obj). + Decs(AssignDecs(dst.None).After(dst.EmptyLine).Obj).Obj, } - stmts = append(stmts, - If(Bin(Id(resultsIdent)).Op(token.EQL).Y(Id(nilIdent)).Obj).Body( - If(Bin(Sel(Sel(cloneExpr(stateSelector)). - Dot(c.exportId(configIdent)).Obj). - Dot(Id(expectationIdent)).Obj). - Op(token.EQL). - Y(c.idPath(strictIdent, moqPkg)).Obj). - Body( - Expr(Call(Sel(Sel(Sel(cloneExpr(stateSelector)). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id(tType)).Obj). - Dot(Id(fatalfFnName)).Obj). - Args(LitString("Unexpected call to %s"), - c.callPrettyParams(fn, moqSel, nil)).Obj).Obj).Obj, - Return(), - ).Obj) - - stmts = append(stmts, Assign(Id(iIdent)). - Tok(token.DEFINE). - Rhs(Bin(Call(Id(intType)). - Args(Call(c.idPath("AddUint32", syncAtomicPkg)).Args(Un( - token.AND, - Sel(Id(resultsIdent)).Dot(c.exportId(indexIdent)).Obj), - LitInt(1)).Obj).Obj). - Op(token.SUB). - Y(LitInt(1)).Obj). - Decs(AssignDecs(dst.EmptyLine).Obj).Obj) - stmts = append(stmts, - If(Bin(Id(iIdent)).Op(token.GEQ).Y( - Sel(Sel(Id(resultsIdent)).Dot(c.exportId(repeatIdent)).Obj). - Dot(Id(resultCountIdent)).Obj).Obj). - Body( - If(Un(token.NOT, Sel(Sel(Id(resultsIdent)). - Dot(c.exportId(repeatIdent)).Obj).Dot(Id(anyTimesIdent)).Obj)). - Body( - If(Bin(Sel(Sel(cloneExpr(stateSelector)). - Dot(c.exportId(configIdent)).Obj). - Dot(Id(expectationIdent)).Obj). - Op(token.EQL). - Y(c.idPath(strictIdent, moqPkg)).Obj). - Body(Expr(Call(Sel(Sel(Sel(cloneExpr(stateSelector)). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id(tType)).Obj). - Dot(Id(fatalfFnName)).Obj). - Args( - LitString("Too many calls to %s"), - c.callPrettyParams(fn, moqSel, nil), - ).Obj).Obj).Obj, - Return(), - ).Obj, - Assign(Id(iIdent)). - Tok(token.ASSIGN). - Rhs(Bin(Sel(Sel(Id(resultsIdent)). - Dot(c.exportId(repeatIdent)).Obj).Dot(Id(resultCountIdent)).Obj). - Op(token.SUB). - Y(LitInt(1)).Obj).Obj, - ).Decs(IfDecs(dst.EmptyLine).Obj).Obj) - - stmts = append(stmts, Assign(Id(resultIdent)). - Tok(token.DEFINE). - Rhs(Index(Sel(Id(resultsIdent)).Dot(c.exportId(resultsIdent)).Obj). - Sub(Id(iIdent)).Obj).Obj) - stmts = append(stmts, If(Bin( - Sel(Id(resultIdent)).Dot(c.exportId(sequenceIdent)).Obj). - Op(token.NEQ). - Y(LitInt(0)).Obj).Body( - Assign(Id(sequenceIdent)).Tok(token.DEFINE).Rhs(Call( - Sel(Sel(Sel(Id(moqReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj).Dot(c.exportId(sceneIdent)).Obj). - Dot(Id("NextMockSequence")).Obj).Obj).Obj, - If(Bin(Paren(Bin(Un(token.NOT, Sel(Sel(Id(resultsIdent)). - Dot(c.exportId(repeatIdent)).Obj).Dot(Id(anyTimesIdent)).Obj)).Op(token.LAND). - Y(Bin(Sel(Id(resultIdent)).Dot(c.exportId(sequenceIdent)).Obj). - Op(token.NEQ).Y(Id(sequenceIdent)).Obj).Obj)).Op(token.LOR). - Y(Bin(Sel(Id(resultIdent)).Dot(c.exportId(sequenceIdent)).Obj). - Op(token.GTR).Y(Id(sequenceIdent)).Obj).Obj).Body( - Expr(Call(Sel(Sel(Sel(cloneExpr(stateSelector)). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id(tType)).Obj). - Dot(Id(fatalfFnName)).Obj). - Args(LitString("Call sequence does not match call to %s"), - c.callPrettyParams(fn, moqSel, nil)).Obj).Obj, - ).Obj, - ).Decs(IfDecs(dst.EmptyLine).Obj).Obj) - - 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.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.FuncType.Params)...).Ellipsis(variadic).Obj - var doReturnStmt dst.Stmt = Expr(doReturnCall).Obj + count := 1 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.FuncType.Results)...).Obj) - doReturnStmt = Assign(passthroughFields(resultPrefix, fn.FuncType.Results)...). - Tok(token.ASSIGN).Rhs(doReturnCall).Obj + for _, res := range fn.FuncType.Results.List { + for range res.Names { + stmts = append(stmts, Var(Value(c.resolveExpr(cloneExpr(res.Type), fn.ParentType)). + Names(Idf(unnamed, resultPrefix, count)).Obj)) + count++ + } + if len(res.Names) == 0 { + stmts = append(stmts, Var(Value(c.resolveExpr(cloneExpr(res.Type), fn.ParentType)). + Names(Idf(unnamed, resultPrefix, count)).Obj)) + count++ + } + } + } + fnCall := Call(Sel(cloneExpr(moqSel)).Dot(Id(functionFnName)).Obj).Args(Id(paramsIdent)).Obj + if fn.FuncType.Results == nil { + stmts = append(stmts, Expr(fnCall).Obj) + return stmts } - stmts = append(stmts, If(Bin(Sel(Id(resultIdent)). - Dot(c.exportId(doReturnFnIdent)).Obj).Op(token.NEQ).Y(Id(nilIdent)).Obj). - Body(doReturnStmt).Obj) - stmts = append(stmts, Return()) + stmts = append(stmts, If(Bin(Id(resultIdent)).Op(token.NEQ).Y(Id(nilIdent)).Obj). + Init(Assign(Id(resultIdent)).Tok(token.DEFINE).Rhs(fnCall).Obj). + Body(c.assignResult(fn.FuncType.Results)...).Obj) + + var rets []dst.Expr + for n := 1; n < count; n++ { + rets = append(rets, Idf(unnamed, resultPrefix, n)) + } + stmts = append(stmts, Return(rets...)) return stmts } +func (c *Converter) assignResult(resFL *dst.FieldList) []dst.Stmt { + var assigns []dst.Stmt + if resFL != nil { + count := 1 + for _, result := range resFL.List { + for _, name := range result.Names { + rName := fmt.Sprintf(unnamed, resultPrefix, count) + vName := validName(name.Name, resultPrefix, count) + assigns = append(assigns, Assign(Id(rName)). + Tok(token.ASSIGN). + Rhs(Sel(Id(resultIdent)).Dot(c.exportId(vName)).Obj).Obj) + count++ + } + + if len(result.Names) == 0 { + rName := fmt.Sprintf(unnamed, resultPrefix, count) + assigns = append(assigns, Assign(Id(rName)). + Tok(token.ASSIGN). + Rhs(Sel(Id(resultIdent)).Dot(c.exportId(rName)).Obj).Obj) + count++ + } + } + } + return assigns +} + func (c *Converter) recorderFn(fn Func) *dst.FuncDecl { mName := c.moqName() - recvType := fmt.Sprintf(double, mName, recorderIdent) - fnName := fn.Name - fnRecName := fmt.Sprintf(triple, mName, fn.Name, fnRecorderSuffix) - var moqVal dst.Expr = Sel(Id(moqReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj - if fn.Name == "" { - recvType = mName - fnName = c.export(onCallFnName) - fnRecName = fmt.Sprintf(double, mName, fnRecorderSuffix) - moqVal = Id(moqReceiverIdent) + recvType := mName + fnName := onCallFnName + fnRecName := fmt.Sprintf(double, mName, recorderSuffix) + if c.isInterface() { + recvType = fmt.Sprintf(double, mName, recorderIdent) + fnName = fn.Name + fnRecName = fmt.Sprintf(triple, mName, fn.Name, recorderSuffix) } - return Fn(fnName). - Recv(Field(Star(c.genericExpr(Id(recvType), clone))).Names(Id(moqReceiverIdent)).Obj). + return Fn(c.export(fnName)). + Recv(Field(Star(c.genericExpr(Id(recvType), clone)).Obj).Names(Id(moqReceiverIdent)).Obj). ParamList(c.cloneAndNameUnnamed(paramPrefix, fn.FuncType.Params, fn.ParentType)). - Results(Field(Star(c.genericExpr(Id(fnRecName), clone))).Obj). - Body(c.recorderFnInterfaceBody(fnRecName, c.typePrefix(fn), moqVal, fn)...). + Results(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj).Obj). + Body(c.recorderFnInterfaceBody(fnRecName, c.typePrefix(fn), fn)...). Decs(stdFuncDec()).Obj } -func (c *Converter) recorderFnInterfaceBody( - fnRecName, typePrefix string, moqVal dst.Expr, fn Func, -) []dst.Stmt { - return []dst.Stmt{Return(Un( - token.AND, - Comp(c.genericExpr(Id(fnRecName), clone)). - Elts( - Key(c.exportId(paramsIdent)).Value(Comp( - c.genericExpr(Idf(double, typePrefix, paramsIdent), clone)). - Elts(c.passthroughElements( - fn.FuncType.Params, paramsIdent, "", fn.ParentType)...).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). - Decs(kvExprDec(dst.None)).Obj, - Key(c.exportId(moqIdent)). - Value(cloneExpr(moqVal)).Decs(kvExprDec(dst.None)).Obj, - ).Decs(litDec()).Obj, +func (c *Converter) recorderFnInterfaceBody(fnRecName, typePrefix string, fn Func) []dst.Stmt { + var onCallSel dst.Expr = Sel(Id(moqReceiverIdent)).Dot(c.exportId(moqIdent)).Obj + if c.isInterface() { + onCallSel = Sel(onCallSel).Dot(c.exportId(fmt.Sprintf(double, moqIdent, fn.Name))).Obj + } + return []dst.Stmt{Return(Un(token.AND, Comp(c.genericExpr(Id(fnRecName), clone)). + Elts(Key(c.exportId(recorderIdent)).Value(Call(Sel(onCallSel). + Dot(Id(titler.String(onCallFnName))).Obj). + Args(Comp(c.genericExpr(Idf(double, typePrefix, paramsIdent), clone)).Elts( + c.passthroughKeyValues(fn.FuncType.Params, paramsIdent, "", fn.ParentType)...).Obj, + ).Obj).Decs(kvExprDec(dst.None)).Obj).Decs(litDec()).Obj, ))} } func (c *Converter) anyParamFns(fn Func) []dst.Decl { mName := c.moqName() - fnRecName := fmt.Sprintf(triple, mName, fn.Name, fnRecorderSuffix) - anyParamsName := fmt.Sprintf(triple, mName, fn.Name, anyParamsIdent) - if fn.Name == "" { - fnRecName = fmt.Sprintf(double, mName, fnRecorderSuffix) - anyParamsName = fmt.Sprintf(double, mName, anyParamsIdent) + fnRecName := fmt.Sprintf(double, mName, recorderSuffix) + anyParamsName := fmt.Sprintf(double, mName, anyParamsIdent) + if c.isInterface() { + fnRecName = fmt.Sprintf(triple, mName, fn.Name, recorderSuffix) + anyParamsName = fmt.Sprintf(triple, mName, fn.Name, anyParamsIdent) } - decls := []dst.Decl{c.anyParamAnyFn(fn, anyParamsName, fnRecName)} - count := 0 + decls := []dst.Decl{c.anyRecorderFn(anyParamsName, fnRecName)} + count := 1 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)) - count++ - } - for _, name := range param.Names { decls = append(decls, c.anyParamFn(anyParamsName, fnRecName, validName(name.Name, paramPrefix, count), count)) count++ } + + if len(param.Names) == 0 { + pName := fmt.Sprintf(unnamed, paramPrefix, count) + decls = append(decls, c.anyParamFn(anyParamsName, fnRecName, pName, count)) + count++ + } } return decls } -func (c *Converter) anyParamAnyFn(fn Func, anyParamsName, fnRecName string) *dst.FuncDecl { - moqSel := Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj - +func (c *Converter) anyRecorderFn(anyParamsName, fnRecName string) *dst.FuncDecl { return Fn(c.export("any")). - Recv(Field(Star(c.genericExpr(Id(fnRecName), clone))). + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj). Names(Id(recorderReceiverIdent)).Obj). - Results(Field(Star(c.genericExpr(Id(anyParamsName), clone))).Obj). + Results(Field(Star(c.genericExpr(Id(anyParamsName), clone)).Obj).Obj). Body( - c.helperCallExpr(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj), - If(Bin(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(resultsIdent)).Obj). - Op(token.NEQ). - Y(Id(nilIdent)).Obj). - Body( - Expr(Call(Sel(Sel(c.selExport(moqSel, sceneIdent)). - Dot(Id(tType)).Obj). - Dot(Id(fatalfFnName)).Obj). - Args(LitStringf( - "Any functions must be called before %s or %s calls, recording %%s", - c.export(returnFnName), c.export(doReturnResultsFnName)), - c.callPrettyParams(fn, moqSel, Id(recorderReceiverIdent)), - ).Obj).Obj, - Return(Id(nilIdent))).Obj, - Return(Un( - token.AND, - Comp(cloneExpr(c.genericExpr(Id(anyParamsName), clone))). - Elts(Key(c.exportId(recorderIdent)). - Value(Id(recorderReceiverIdent)).Obj).Obj)), + c.helperCallExpr(Sel(Sel(Id(recorderReceiverIdent)). + Dot(c.exportId(recorderIdent)).Obj).Dot(Id(titler.String(moqIdent))).Obj), + If(Un(token.NOT, Call(Sel(Sel(Id(recorderReceiverIdent)). + Dot(c.exportId(recorderIdent)).Obj).Dot(Id(isAnyPermittedFnName)).Obj). + Args(LitBool(c.isExported)).Obj)).Body( + Return(Id(nilIdent)), + ).Obj, + Return(Un(token.AND, 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(c.genericExpr(Id(anyParamsName), clone))).Names(Id(anyParamsReceiverIdent)).Obj). - Results(Field(Star(c.genericExpr(Id(fnRecName), clone))).Obj). + Recv(Field(Star(c.genericExpr(Id(anyParamsName), clone)).Obj).Names(Id(anyParamsReceiverIdent)).Obj). + Results(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj).Obj). Body( - Assign(Sel(Sel(Id(anyParamsReceiverIdent)). - Dot(c.exportId(recorderIdent)).Obj). - Dot(c.exportId(anyParamsIdent)).Obj). - Tok(token.OR_ASSIGN). - Rhs(Bin(LitInt(1)).Op(token.SHL).Y(LitInt(paramPos)).Obj).Obj, + Expr(Call(Sel(Sel(Sel(Id(anyParamsReceiverIdent)).Dot(c.exportId(recorderIdent)).Obj). + Dot(c.exportId(recorderIdent)).Obj).Dot(Id(anyParamFnName)).Obj). + Args(LitInt(paramPos)).Obj).Obj, Return(Sel(Id(anyParamsReceiverIdent)).Dot(c.exportId(recorderIdent)).Obj), ). Decs(stdFuncDec()).Obj } -func (c *Converter) returnResultsFn(fn Func) *dst.FuncDecl { - return c.returnFn(returnFnName, fn, - c.cloneAndNameUnnamed(resultPrefix, fn.FuncType.Results, fn.ParentType), []dst.Expr{ - Key(c.exportId(valuesIdent)).Value(Un(token.AND, - Comp(c.methodStruct(resultsIdent, fn.FuncType.Results, fn.ParentType)). - Elts(c.passthroughElements( - fn.FuncType.Results, resultsIdent, "", fn.ParentType)...).Obj)). - Decs(kvExprDec(dst.NewLine)).Obj, - Key(c.exportId(sequenceIdent)). - Value(Id(sequenceIdent)).Decs(kvExprDec(dst.None)).Obj, - }) -} - -func (c *Converter) returnFn( - fnName string, - fn Func, - params *dst.FieldList, - resultExprs []dst.Expr, -) *dst.FuncDecl { +func (c *Converter) recorderSeqFns(fn Func) []dst.Decl { + return []dst.Decl{ + c.recorderSeqFn(fn, "seq", true), + c.recorderSeqFn(fn, "noSeq", false), + } +} + +func (c *Converter) recorderSeqFn(fn Func, fnName string, seq bool) *dst.FuncDecl { mName := c.moqName() - fnRecName := fmt.Sprintf(triple, mName, fn.Name, fnRecorderSuffix) - if fn.Name == "" { - fnRecName = fmt.Sprintf(double, mName, fnRecorderSuffix) + fnRecName := fmt.Sprintf(double, mName, recorderSuffix) + if c.isInterface() { + fnRecName = fmt.Sprintf(triple, mName, fn.Name, recorderSuffix) } - resStruct := c.innerResultsStruct(c.typePrefix(fn), fn.FuncType.Results, fn.ParentType) + fnName = c.export(fnName) + return Fn(fnName). + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj).Names(Id(recorderReceiverIdent)).Obj). + Results(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj).Obj). + Body( + c.helperCallExpr(Sel(Sel(Id(recorderReceiverIdent)). + Dot(c.exportId(recorderIdent)).Obj).Dot(Id(titler.String(moqIdent))).Obj), + If(Un(token.NOT, Call(Sel(Sel(Id(recorderReceiverIdent)). + Dot(c.exportId(recorderIdent)).Obj).Dot(Id(seqFnName)).Obj). + Args(LitBool(seq), LitString(fnName), LitBool(c.isExported)).Obj)).Body( + Return(Id(nilIdent)), + ).Obj, + Return(Id(recorderReceiverIdent)), + ).Decs(stdFuncDec()).Obj +} - return Fn(c.export(fnName)). - Recv(Field(Star(c.genericExpr(Id(fnRecName), clone))).Names(Id(recorderReceiverIdent)).Obj). - ParamList(params). - Results(Field(Star(c.genericExpr(Id(fnRecName), clone))).Obj). +func (c *Converter) returnResultsFn(fn Func) *dst.FuncDecl { + mName := c.moqName() + + fnRecName := fmt.Sprintf(double, mName, recorderSuffix) + resType := fmt.Sprintf(double, mName, resultsIdent) + if c.isInterface() { + fnRecName = fmt.Sprintf(triple, mName, fn.Name, recorderSuffix) + resType = fmt.Sprintf(triple, mName, fn.Name, resultsIdent) + } + + return Fn(c.export(returnResultsFnName)). + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj). + Names(Id(recorderReceiverIdent)).Obj). + ParamList(c.cloneAndNameUnnamed(resultPrefix, fn.FuncType.Results, fn.ParentType)). + Results(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj).Obj). Body( - c.helperCallExpr(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj), - Expr(Call(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(findResultsFnName)).Obj).Obj). - Decs(ExprDecs(dst.EmptyLine).Obj).Obj, - Var(Value(Id("uint32")).Names(Id(sequenceIdent)).Obj), - If(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(sequenceIdent)).Obj). - Body(Assign(Id(sequenceIdent)).Tok(token.ASSIGN).Rhs( - Call(Sel(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id("NextRecorderSequence")).Obj).Obj, - ).Obj). - Decs(IfDecs(dst.EmptyLine).Obj).Obj, - Assign( - Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Dot(c.exportId(resultsIdent)).Obj). - Tok(token.ASSIGN). - Rhs(Call(Id("append")).Args(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Dot(c.exportId(resultsIdent)).Obj, - Comp(resStruct).Elts(resultExprs...).Obj).Obj).Obj, + c.helperCallExpr(Sel(Sel(Id(recorderReceiverIdent)). + Dot(c.exportId(recorderIdent)).Obj).Dot(Id(titler.String(moqIdent))).Obj), + Expr(Call(Sel(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(recorderIdent)).Obj). + Dot(Id(titler.String(returnResultsFnName))).Obj). + Args(Comp(c.genericExpr(Id(resType), clone)). + Elts(c.passthroughKeyValues(fn.FuncType.Results, + resultsIdent, "", fn.ParentType)...).Obj).Obj).Obj, Return(Id(recorderReceiverIdent)), - ). - Decs(stdFuncDec()).Obj + ).Obj } func (c *Converter) andDoFn(fn Func) *dst.FuncDecl { mName := c.moqName() - fnRecName := fmt.Sprintf(triple, mName, fn.Name, fnRecorderSuffix) - if fn.Name == "" { - fnRecName = fmt.Sprintf(double, mName, fnRecorderSuffix) + fnRecName := fmt.Sprintf(double, mName, recorderSuffix) + paramsType := fmt.Sprintf(double, mName, paramsIdent) + if c.isInterface() { + fnRecName = fmt.Sprintf(triple, mName, fn.Name, recorderSuffix) + paramsType = fmt.Sprintf(triple, mName, fn.Name, paramsIdent) } typePrefix := c.typePrefix(fn) fnName := fmt.Sprintf(double, typePrefix, doFnIdent) + ell := false + if fn.FuncType.Params != nil && len(fn.FuncType.Params.List) > 0 { + last := fn.FuncType.Params.List[len(fn.FuncType.Params.List)-1] + _, ell = last.Type.(*dst.Ellipsis) + } + return Fn(c.export(andDoFnName)). - Recv(Field(Star(c.genericExpr(Id(fnRecName), clone))).Names(Id(recorderReceiverIdent)).Obj). + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj). + 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). - Op(token.EQL). - Y(Id(nilIdent)).Obj). - Body(Expr(Call(Sel(Sel(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id(tType)).Obj).Dot(Id(fatalfFnName)).Obj). - Args(LitStringf("%s must be called before calling %s", - c.export(returnFnName), c.export(andDoFnName))).Obj).Obj, - Return(Id(nilIdent))).Obj, - c.lastResult(true), - Assign(Sel(Id(lastIdent)).Dot(c.exportId(doFnIdent)).Obj). - Tok(token.ASSIGN).Rhs(Id(fnFnName)).Obj, + Results(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj).Obj).Body( + c.helperCallExpr(Sel(Sel(Id(recorderReceiverIdent)). + Dot(c.exportId(recorderIdent)).Obj).Dot(Id(titler.String(moqIdent))).Obj), + If(Un(token.NOT, Call(Sel(Sel(Id(recorderReceiverIdent)). + Dot(c.exportId(recorderIdent)).Obj).Dot(Id(titler.String(andDoFnName))).Obj). + Args(FnLit(FnType(FieldList(Field(c.genericExpr(Id(paramsType), clone)). + Names(Id(paramsIdent)).Obj)).Obj).Body( + Expr(Call(Id(fnFnName)).Args(c.passthroughValues( + fn.FuncType.Params, paramPrefix, Id(paramsIdent))...).Ellipsis(ell).Obj). + Decs(ExprDecs(dst.NewLine).Obj).Obj, + ).Obj, LitBool(c.isExported)).Obj)). + Body(Return(Id(nilIdent))).Obj, Return(Id(recorderReceiverIdent)), ).Decs(stdFuncDec()).Obj } func (c *Converter) doReturnResultsFn(fn Func) *dst.FuncDecl { - typePrefix := c.typePrefix(fn) - fnName := fmt.Sprintf(double, typePrefix, doReturnFnIdent) - 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, + mName := c.moqName() + + fnRecName := fmt.Sprintf(double, mName, recorderSuffix) + paramsType := fmt.Sprintf(double, mName, paramsIdent) + resType := fmt.Sprintf(double, mName, resultsIdent) + fnType := fmt.Sprintf(double, mName, doReturnFnIdent) + if c.isInterface() { + fnRecName = fmt.Sprintf(triple, mName, fn.Name, recorderSuffix) + paramsType = fmt.Sprintf(triple, mName, fn.Name, paramsIdent) + resType = fmt.Sprintf(triple, mName, fn.Name, resultsIdent) + fnType = fmt.Sprintf(triple, mName, fn.Name, doReturnFnIdent) } - return c.returnFn(doReturnResultsFnName, fn, params, resExprs) + return Fn(c.export(doReturnResultsFnName)). + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj). + Names(Id(recorderReceiverIdent)).Obj). + Params(Field(c.genericExpr(Id(fnType), clone)).Names(Id(fnFnName)).Obj). + Results(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj).Obj). + Body( + c.helperCallExpr(Sel(Sel(Id(recorderReceiverIdent)). + Dot(c.exportId(recorderIdent)).Obj).Dot(Id(titler.String(moqIdent))).Obj), + Expr(Call(Sel(Sel(Id(recorderReceiverIdent)). + Dot(c.exportId(recorderIdent)).Obj). + Dot(Id(titler.String(doReturnResultsFnName))).Obj). + Args(FnLit(FnType(FieldList(Field(c.genericExpr(Id(paramsType), clone)). + Names(Id(paramsIdent)).Obj)). + Results(FieldList(Field(Star(c.genericExpr(Id(resType), clone)).Obj).Obj)).Obj).Body( + c.doReturnResultsFnLitBody(fn)..., + ).Obj).Obj).Obj, + Return(Id(recorderReceiverIdent)), + ).Obj } -func (c *Converter) findResultsFn(fn Func) *dst.FuncDecl { +func (c *Converter) doReturnResultsFnLitBody(fn Func) []dst.Stmt { mName := c.moqName() + resType := fmt.Sprintf(double, mName, resultsIdent) + if c.isInterface() { + resType = fmt.Sprintf(triple, mName, fn.Name, resultsIdent) + } - fnRecName := fmt.Sprintf(triple, mName, fn.Name, fnRecorderSuffix) - if fn.Name == "" { - fnRecName = fmt.Sprintf(double, mName, fnRecorderSuffix) + ell := false + if fn.FuncType.Params != nil && len(fn.FuncType.Params.List) > 0 { + last := fn.FuncType.Params.List[len(fn.FuncType.Params.List)-1] + _, ell = last.Type.(*dst.Ellipsis) } - incrRepeat := Expr(Call(Sel(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Dot(c.exportId(repeatIdent)).Obj). - Dot(Id(incrementFnName)).Obj). - Args(Sel(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id(tType)).Obj).Obj).Obj - body := []dst.Stmt{ - c.helperCallExpr(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj), - If(Bin(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Op(token.NEQ). - Y(Id(nilIdent)).Obj). - Body( - cloneStmt(incrRepeat), - Return(), - ).Decs(IfDecs(dst.EmptyLine).Obj).Obj, - } - body = append(body, c.findRecorderResults(fn)...) - body = append(body, cloneStmt(incrRepeat)) - - return Fn(c.export(findResultsFnName)). - Recv(Field(Star(c.genericExpr(Id(fnRecName), clone))).Names(Id(recorderReceiverIdent)).Obj). - Body(body...).Decs(stdFuncDec()).Obj -} - -func (c *Converter) findRecorderResults(fn Func) []dst.Stmt { - mName := c.moqName() + call := Call(Id(fnFnName)). + Args(c.passthroughValues(fn.FuncType.Params, paramPrefix, Id(paramsIdent))...).Ellipsis(ell).Obj - results := fmt.Sprintf(triple, mName, fn.Name, resultsIdent) - resultsByParamsType := fmt.Sprintf(triple, mName, fn.Name, resultsByParamsIdent) - paramsKey := fmt.Sprintf(triple, mName, fn.Name, paramsKeyIdent) - paramsKeyFn := c.export(fmt.Sprintf(double, paramsKeyFnName, fn.Name)) - resultsByParams := fmt.Sprintf(double, resultsByParamsIdent, fn.Name) - if fn.Name == "" { - results = fmt.Sprintf(double, mName, resultsIdent) - resultsByParamsType = fmt.Sprintf(double, mName, resultsByParamsIdent) - paramsKey = fmt.Sprintf(double, mName, paramsKeyIdent) - paramsKeyFn = c.export(paramsKeyFnName) - resultsByParams = resultsByParamsIdent + var fnCall dst.Stmt = Assign(c.passthroughValues(fn.FuncType.Results, resultPrefix, nil)...). + Tok(token.DEFINE).Rhs(call).Decs(AssignDecs(dst.NewLine).Obj).Obj + if fn.FuncType.Results == nil { + fnCall = Expr(call).Decs(ExprDecs(dst.NewLine).Obj).Obj } - moqSel := Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj - return []dst.Stmt{ - Assign(Id(anyCountIdent)). - Tok(token.DEFINE). - Rhs(Call(c.idPath("OnesCount64", "math/bits")).Args( - Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(anyParamsIdent)).Obj).Obj).Obj, - Assign(Id(insertAtIdent)).Tok(token.DEFINE).Rhs(LitInt(-1)).Obj, - Var(Value(Star(c.genericExpr(Id(resultsByParamsType), clone))). - Names(Id(resultsIdent)).Obj), - Range(c.selExport(moqSel, resultsByParams)). - Key(Id(nIdent)). - Value(Id(resIdent)). - Tok(token.DEFINE). - Body( - If(Bin(Sel(Id(resIdent)).Dot(c.exportId(anyParamsIdent)).Obj). - Op(token.EQL). - Y(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(anyParamsIdent)).Obj).Obj).Body( - Assign(Id(resultsIdent)). - Tok(token.ASSIGN). - Rhs(Un(token.AND, Id(resIdent))).Obj, - Break(), - ).Obj, - If(Bin(Sel(Id(resIdent)).Dot(c.exportId(anyCountIdent)).Obj). - Op(token.GTR). - Y(Id(anyCountIdent)).Obj).Body( - Assign(Id(insertAtIdent)). - Tok(token.ASSIGN). - Rhs(Id(nIdent)).Obj, - ).Obj, - ).Obj, - If(Bin(Id(resultsIdent)).Op(token.EQL).Y(Id(nilIdent)).Obj).Body( - Assign(Id(resultsIdent)).Tok(token.ASSIGN).Rhs(Un( - 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(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)). - Tok(token.ASSIGN).Rhs(Call(Id("append")).Args( - c.selExport(moqSel, resultsByParams), - Star(Id(resultsIdent))).Obj).Obj, - If(Bin(Bin(Id(insertAtIdent)).Op(token.NEQ). - Y(LitInt(-1)).Obj).Op(token.LAND). - Y(Bin(Bin(Id(insertAtIdent)).Op(token.ADD). - Y(LitInt(1)).Obj).Op(token.LSS).Y(Call(Id(lenFnName)). - Args(c.selExport(moqSel, resultsByParams)).Obj).Obj).Obj).Body( - Expr(Call(Id("copy")).Args( - SliceExpr(c.selExport(moqSel, resultsByParams)). - Low(Bin(Id(insertAtIdent)).Op(token.ADD).Y(LitInt(1)).Obj).Obj, - SliceExpr(c.selExport(moqSel, resultsByParams)). - Low(Id(insertAtIdent)).High(LitInt(0)).Obj).Obj).Obj, - Assign(Index(c.selExport(moqSel, resultsByParams)). - Sub(Id(insertAtIdent)).Obj). - Tok(token.ASSIGN). - Rhs(Star(Id(resultsIdent))).Obj, - ).Obj, - ).Decs(IfDecs(dst.EmptyLine).Obj).Obj, - Assign(Id(paramsKeyIdent)). - Tok(token.DEFINE). - Rhs(Call(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj).Dot(Id(paramsKeyFn)).Obj). - Args(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(paramsIdent)).Obj, - Sel(Id(recorderReceiverIdent)).Dot(c.exportId(anyParamsIdent)).Obj).Obj). - Decs(AssignDecs(dst.None).After(dst.EmptyLine).Obj).Obj, - Var(Value(Id("bool")).Names(Id(okIdent)).Obj), - Assign(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(resultsIdent)).Obj, Id(okIdent)). - Tok(token.ASSIGN). - Rhs(Index(Sel(Id(resultsIdent)).Dot(c.exportId(resultsIdent)).Obj). - Sub(Id(paramsKeyIdent)).Obj).Obj, - If(Un(token.NOT, Id(okIdent))). - Body( - Assign(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Tok(token.ASSIGN). - Rhs(Un( - token.AND, - Comp(c.genericExpr(c.exportId(results), clone)). - Elts( - Key(c.exportId(paramsIdent)). - Value(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(paramsIdent)).Obj). - Decs(kvExprDec(dst.NewLine)).Obj, - Key(c.exportId(resultsIdent)).Value(Id(nilIdent)). - Decs(kvExprDec(dst.None)).Obj, - Key(c.exportId(indexIdent)).Value( - LitInt(0)).Decs(kvExprDec(dst.None)).Obj, - Key(c.exportId(repeatIdent)).Value( - Un(token.AND, Comp(c.idPath(repeatValType, moqPkg)).Obj)). - Decs(kvExprDec(dst.None)).Obj, - ).Obj, - )).Obj, - Assign(Index(Sel(Id(resultsIdent)).Dot(c.exportId(resultsIdent)).Obj). - Sub(Id(paramsKeyIdent)).Obj). - Tok(token.ASSIGN). - Rhs(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj).Obj, - ).Decs(IfDecs(dst.EmptyLine).Obj).Obj, + fnCall, + Return(Un(token.AND, Comp(c.genericExpr(Id(resType), clone)). + Elts(c.passthroughKeyValues( + fn.FuncType.Results, resultsIdent, "", fn.ParentType)...).Obj)), } } func (c *Converter) recorderRepeatFn(fn Func) *dst.FuncDecl { mName := c.moqName() - fnRecName := fmt.Sprintf(triple, mName, fn.Name, fnRecorderSuffix) - if fn.Name == "" { - fnRecName = fmt.Sprintf(double, mName, fnRecorderSuffix) + fnRecName := fmt.Sprintf(double, mName, recorderSuffix) + if c.isInterface() { + fnRecName = fmt.Sprintf(triple, mName, fn.Name, recorderSuffix) } - lastVal := Comp(c.innerResultsStruct(c.typePrefix(fn), fn.FuncType.Results, fn.ParentType)).Elts( - Key(c.exportId(valuesIdent)). - Value(Sel(Id(lastIdent)).Dot(c.exportId(valuesIdent)).Obj). - Decs(kvExprDec(dst.NewLine)).Obj, - Key(c.exportId(sequenceIdent)). - Value(Call(Sel(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id("NextRecorderSequence")).Obj).Obj). - Decs(kvExprDec(dst.None)).Obj, - ).Obj - return Fn(c.export(repeatFnName)). - Recv(Field(Star(c.genericExpr(Id(fnRecName), clone))).Names(Id(recorderReceiverIdent)).Obj). + Recv(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj). + Names(Id(recorderReceiverIdent)).Obj). Params(Field(Ellipsis(c.idPath(repeaterType, moqPkg))).Names(Id(repeatersIdent)).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). - Op(token.EQL). - Y(Id(nilIdent)).Obj). - Body( - Expr(Call(Sel(Sel(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id(tType)).Obj).Dot(Id(fatalfFnName)).Obj). - Args(LitStringf("%s or %s must be called before calling %s", - c.export(returnFnName), - c.export(doReturnResultsFnName), - c.export(repeatFnName))).Obj).Obj, - Return(Id(nilIdent)), - ).Obj, - Expr(Call(Sel(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Dot(c.exportId(repeatIdent)).Obj). - Dot(Id(titler.String(repeatFnName))).Obj). - Args(Sel(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id(tType)).Obj, - Id(repeatersIdent)).Obj).Obj, - c.lastResult(false), - For(Assign(Id(nIdent)).Tok(token.DEFINE).Rhs(LitInt(0)).Obj). - Cond(Bin(Id(nIdent)).Op(token.LSS). - Y(Bin(Sel(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Dot(c.exportId(repeatIdent)).Obj). - Dot(Id(resultCountIdent)).Obj). - Op(token.SUB).Y(LitInt(1)).Obj).Obj). - Post(IncStmt(Id(nIdent))).Body( - If(Sel(Id(recorderReceiverIdent)).Dot(c.exportId(sequenceIdent)).Obj).Body( - Assign(Id(lastIdent)).Tok(token.ASSIGN).Rhs(lastVal).Obj).Obj, - Assign(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Dot(c.exportId(resultsIdent)).Obj). - Tok(token.ASSIGN). - Rhs(Call(Id("append")).Args(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Dot(c.exportId(resultsIdent)).Obj, - Id(lastIdent)).Obj).Obj, - ).Obj, - Return(Id(recorderReceiverIdent)), - ). - Decs(stdFuncDec()).Obj + Results(Field(Star(c.genericExpr(Id(fnRecName), clone)).Obj).Obj).Body( + c.helperCallExpr(Sel(Sel(Id(recorderReceiverIdent)). + Dot(c.exportId(recorderIdent)).Obj).Dot(Id(titler.String(moqIdent))).Obj), + If(Un(token.NOT, Call(Sel(Sel(Id(recorderReceiverIdent)). + Dot(c.exportId(recorderIdent)).Obj).Dot(Id(titler.String(repeatFnName))).Obj). + Args(Id(repeatersIdent), LitBool(c.isExported)).Obj)). + Body(Return(Id(nilIdent))).Obj, + Return(Id(recorderReceiverIdent)), + ).Decs(stdFuncDec()).Obj } func (c *Converter) prettyParamsFn(fn Func) *dst.FuncDecl { mName := c.moqName() - params := fmt.Sprintf(triple, mName, fn.Name, paramsIdent) - fnName := fmt.Sprintf(double, prettyParamsFnName, fn.Name) - sfmt := fn.Name + "(" - if fn.Name == "" { - sfmt = c.typeName() + "(" - params = fmt.Sprintf(double, mName, paramsIdent) - fnName = prettyParamsFnName + rType := fmt.Sprintf(double, mName, adaptorIdent) + params := fmt.Sprintf(double, mName, paramsIdent) + sfmt := c.typeName() + "(" + if c.isInterface() { + rType = fmt.Sprintf(triple, mName, fn.Name, adaptorIdent) + params = fmt.Sprintf(triple, mName, fn.Name, paramsIdent) + sfmt = fn.Name + "(" } var pExprs []dst.Expr - count := 0 + count := 1 for _, param := range fn.FuncType.Params.List { - if len(param.Names) == 0 { + for _, name := range param.Names { sfmt += "%#v, " - pExpr := Sel(Id(paramsIdent)). - Dot(c.exportId(fmt.Sprintf(unnamed, paramPrefix, count+1))).Obj + vName := validName(name.Name, paramPrefix, count) + pExpr := Sel(Id(paramsIdent)).Dot(c.exportId(vName)).Obj pExprs = append(pExprs, c.prettyParam(param, pExpr)) count++ } - for _, name := range param.Names { + if len(param.Names) == 0 { sfmt += "%#v, " - vName := validName(name.Name, paramPrefix, count) - pExpr := Sel(Id(paramsIdent)).Dot(c.exportId(vName)).Obj + pExpr := Sel(Id(paramsIdent)). + Dot(c.exportId(fmt.Sprintf(unnamed, paramPrefix, count))).Obj pExprs = append(pExprs, c.prettyParam(param, pExpr)) count++ } } - if count > 0 { + if count > 1 { sfmt = sfmt[0 : len(sfmt)-2] } sfmt += ")" pExprs = append([]dst.Expr{LitString(sfmt)}, pExprs...) - return Fn(c.export(fnName)). - Recv(Field(Star(c.genericExpr(Id(mName), clone))).Names(Id(moqReceiverIdent)).Obj). + return Fn(titler.String(prettyParamsFnName)). + Recv(Field(Star(c.genericExpr(Id(rType), clone)).Obj).Obj). Params(Field(c.genericExpr(Id(params), clone)).Names(Id(paramsIdent)).Obj). Results(Field(Id("string")).Obj). Body(Return( - Call(IdPath("Sprintf", "fmt")). - Args(pExprs...).Obj)). + Call(IdPath("Sprintf", "fmt")).Args(pExprs...).Obj)). Decs(stdFuncDec()).Obj } @@ -1485,50 +1217,53 @@ func (c *Converter) prettyParam(param *dst.Field, expr *dst.SelectorExpr) dst.Ex } func (c *Converter) paramsKeyFn(fn Func) *dst.FuncDecl { + mName := c.moqName() + rType := fmt.Sprintf(double, mName, adaptorIdent) + params := fmt.Sprintf(double, mName, paramsIdent) + paramsKey := fmt.Sprintf(double, mName, paramsKeyIdent) + hSel := moqIdent + if c.isInterface() { + rType = fmt.Sprintf(triple, mName, fn.Name, adaptorIdent) + params = fmt.Sprintf(triple, mName, fn.Name, paramsIdent) + paramsKey = fmt.Sprintf(triple, mName, fn.Name, paramsKeyIdent) + hSel = fmt.Sprintf(double, moqIdent, fn.Name) + } + stmts := []dst.Stmt{ - c.helperCallExpr(Id(moqReceiverIdent)), + c.helperCallExpr(Sel(Sel(Id(adaptorReceiverIdent)). + Dot(c.exportId(moqIdent)).Obj).Dot(c.exportId(hSel)).Obj), } - count := 0 + count := 1 for _, param := range fn.FuncType.Params.List { typ := c.resolveExpr(param.Type, fn.ParentType) - if len(param.Names) == 0 { - stmts = append(stmts, c.mockFuncFindResultsParam( - fn, fmt.Sprintf(unnamed, paramPrefix, count+1), count, typ)...) - count++ - } - for _, name := range param.Names { stmts = append(stmts, c.mockFuncFindResultsParam(fn, name.Name, count, typ)...) count++ } - } - mName := c.moqName() - params := fmt.Sprintf(triple, mName, fn.Name, paramsIdent) - paramsKey := fmt.Sprintf(triple, mName, fn.Name, paramsKeyIdent) - fnName := fmt.Sprintf(double, paramsKeyFnName, fn.Name) - if fn.Name == "" { - params = fmt.Sprintf(double, mName, paramsIdent) - paramsKey = fmt.Sprintf(double, mName, paramsKeyIdent) - fnName = paramsKeyFnName + if len(param.Names) == 0 { + stmts = append(stmts, c.mockFuncFindResultsParam( + fn, fmt.Sprintf(unnamed, paramPrefix, count), count, typ)...) + count++ + } } stmts = append(stmts, Return(Comp(c.genericExpr(Id(paramsKey), clone)).Elts( Key(c.exportId(paramsIdent)).Value(Comp( c.methodStruct(paramsKeyIdent, fn.FuncType.Params, fn.ParentType)). - Elts(c.passthroughElements( + Elts(c.passthroughKeyValues( fn.FuncType.Params, paramsKeyIdent, usedSuffix, fn.ParentType)...).Obj). Decs(kvExprDec(dst.NewLine)).Obj, Key(c.exportId(hashesIdent)).Value(Comp( c.methodStruct(hashesIdent, fn.FuncType.Params, fn.ParentType)). - Elts(c.passthroughElements( + Elts(c.passthroughKeyValues( fn.FuncType.Params, hashesIdent, usedHashSuffix, fn.ParentType)...).Obj). Decs(kvExprDec(dst.NewLine)).Obj).Obj)) - return Fn(c.export(fnName)). - Recv(Field(Star(c.genericExpr(Id(mName), clone))).Names(Id(moqReceiverIdent)).Obj). + return Fn(titler.String(paramsKeyFnName)). + Recv(Field(Star(c.genericExpr(Id(rType), clone)).Obj).Names(Id(adaptorReceiverIdent)).Obj). Params(Field(c.genericExpr(Id(params), clone)).Names(Id(paramsIdent)).Obj, Field(Id("uint64")).Names(Id(anyParamsIdent)).Obj). Results(Field(c.genericExpr(Id(paramsKey), clone)).Obj). @@ -1539,6 +1274,15 @@ func (c *Converter) paramsKeyFn(fn Func) *dst.FuncDecl { func (c *Converter) mockFuncFindResultsParam( fn Func, pName string, paramPos int, typ dst.Expr, ) []dst.Stmt { + pSel := Sel(Sel(Sel(Sel(Id(adaptorReceiverIdent)). + Dot(c.exportId(moqIdent)).Obj). + Dot(c.exportId(runtimeIdent)).Obj). + Dot(c.exportId(parameterIndexingIdent)).Obj) + sSel := moqIdent + if c.isInterface() { + pSel = Sel(pSel.Dot(Id(fn.Name)).Obj) + sSel = fmt.Sprintf(double, moqIdent, fn.Name) + } comp, err := c.typeCache.IsComparable(typ, c.typ.TypeInfo) if err != nil { if c.err == nil { @@ -1548,128 +1292,30 @@ func (c *Converter) mockFuncFindResultsParam( } vName := validName(pName, paramPrefix, paramPos) - - var stmts []dst.Stmt pUsed := fmt.Sprintf("%s%s", vName, usedSuffix) - if comp { - stmts = append(stmts, Var(Value(cloneExpr(typ)).Names(Id(pUsed)).Obj)) - } hashUsed := fmt.Sprintf("%s%s", vName, usedHashSuffix) - stmts = append(stmts, Var(Value(c.idPath(hashType, hashPkg)).Names(Id(hashUsed)).Obj)) - ifSel := Sel(Sel(Sel(Sel(Id(moqReceiverIdent)). - Dot(c.exportId(runtimeIdent)).Obj). - Dot(c.exportId(parameterIndexingIdent)).Obj). - Dot(Id(fn.Name)).Obj). - Dot(c.exportId(vName)).Obj - fatalMsg := LitStringf("The %s parameter of the %s function can't be indexed by value", - vName, fn.Name) - if fn.Name == "" { - ifSel = Sel(Sel(Sel(Id(moqReceiverIdent)). - Dot(c.exportId(runtimeIdent)).Obj). - Dot(c.exportId(parameterIndexingIdent)).Obj). - Dot(c.exportId(vName)).Obj - fatalMsg = LitStringf("The %s parameter can't be indexed by value", vName) - } - - ifCond := If(Bin(ifSel). - Op(token.EQL). - Y(c.idPath(paramIndexByValueIdent, moqPkg)).Obj) - pKeySel := Id(paramsIdent) - hashAssign := Assign(Id(hashUsed)). - Tok(token.ASSIGN). - Rhs(c.passthroughValue(Id(vName), true, pKeySel)).Obj - var usedBody []dst.Stmt + lhs := []dst.Expr{Id(hashUsed)} + fnName := hashOnlyParamKeyFnName + var tExpr dst.Expr = Sel(Sel(Sel(Sel(Id(adaptorReceiverIdent)).Dot(c.exportId(moqIdent)).Obj). + Dot(c.exportId(sSel)).Obj).Dot(Id(titler.String(sceneIdent))).Obj).Dot(Id(tType)).Obj + var pNameLit dst.Expr = LitString(vName) if comp { - usedBody = append(usedBody, ifCond.Body( - Assign(Id(pUsed)). - Tok(token.ASSIGN). - Rhs(c.passthroughValue(Id(vName), false, pKeySel)).Obj). - Else(hashAssign).Obj) - } else { - usedBody = append(usedBody, ifCond.Body(Expr(Call(Sel(Sel(Sel(Id(moqReceiverIdent)). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id(tType)).Obj). - Dot(Id(fatalfFnName)).Obj). - Args(fatalMsg).Obj).Obj).Obj) - usedBody = append(usedBody, hashAssign) - } - - stmts = append(stmts, If(Bin(Bin(Id(anyParamsIdent)). - Op(token.AND). - Y(Paren(Bin(LitInt(1)).Op(token.SHL).Y(LitInt(paramPos)).Obj)).Obj). - Op(token.EQL). - Y(LitInt(0)).Obj). - Body(usedBody...).Obj) - return stmts -} - -func (c *Converter) lastResult(forUpdate bool) *dst.AssignStmt { - var rhs dst.Expr = Index(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Dot(c.exportId(resultsIdent)).Obj). - Sub(Bin(Call(Id(lenFnName)). - Args(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(resultsIdent)).Obj). - Dot(c.exportId(resultsIdent)).Obj).Obj). - Op(token.SUB). - Y(LitInt(1)).Obj).Obj - if forUpdate { - rhs = Un(token.AND, rhs) + lhs = append([]dst.Expr{Id(pUsed)}, lhs...) + fnName = paramKeyFnName + tExpr = nil + pNameLit = nil } - return Assign(Id(lastIdent)). - Tok(token.DEFINE). - Rhs(rhs).Obj -} - -func (c *Converter) recorderSeqFns(fn Func) []dst.Decl { - return []dst.Decl{ - c.recorderSeqFn(fn, "seq", "true"), - c.recorderSeqFn(fn, "noSeq", "false"), - } -} - -func (c *Converter) recorderSeqFn(fn Func, fnName, assign string) *dst.FuncDecl { - mName := c.moqName() - - fnRecName := fmt.Sprintf(triple, mName, fn.Name, fnRecorderSuffix) - if fn.Name == "" { - fnRecName = fmt.Sprintf(double, mName, fnRecorderSuffix) + return []dst.Stmt{ + Assign(lhs...).Tok(token.DEFINE).Rhs(Call(IdPath(fnName, implPkg)).Args( + tExpr, + Sel(Id(paramsIdent)).Dot(c.exportId(vName)).Decs(SelDecs(dst.NewLine, dst.None)).Obj, + pNameLit, + LitInt(paramPos), + pSel.Dot(c.exportId(vName)).Obj, + Id(anyParamsIdent)).Obj).Obj, } - - moqSel := Sel(Id(recorderReceiverIdent)).Dot(c.exportId(moqIdent)).Obj - - fnName = c.export(fnName) - return Fn(fnName). - 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)). - Dot(c.exportId(resultsIdent)).Obj). - Op(token.NEQ). - Y(Id(nilIdent)).Obj). - Body( - Expr(Call(Sel(Sel(Sel(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(moqIdent)).Obj). - Dot(c.exportId(sceneIdent)).Obj). - Dot(Id(tType)).Obj). - Dot(Id(fatalfFnName)).Obj). - Args(LitStringf( - "%s must be called before %s or %s calls, recording %%s", - fnName, c.export(returnFnName), c.export(doReturnResultsFnName)), - c.callPrettyParams(fn, moqSel, - Id(recorderReceiverIdent))).Obj).Obj, - Return(Id(nilIdent)), - ).Obj, - Assign(Sel(Id(recorderReceiverIdent)). - Dot(c.exportId(sequenceIdent)).Obj). - Tok(token.ASSIGN). - Rhs(Id(assign)). - Decs(AssignDecs(dst.NewLine).Obj).Obj, - Return(Id(recorderReceiverIdent)), - ).Decs(stdFuncDec()).Obj } func (c *Converter) typeParams() *dst.FieldList { @@ -1712,17 +1358,7 @@ func (c *Converter) genericExpr(in dst.Expr, mode genericExprMode) dst.Expr { return Index(in).Sub(subs...).Obj } -func (c *Converter) callPrettyParams(fn Func, moqExpr, paramsExpr dst.Expr) *dst.CallExpr { - prettyParamsFn := prettyParamsFnName - if fn.Name != "" { - prettyParamsFn = fmt.Sprintf(double, prettyParamsFnName, fn.Name) - } - - return Call(c.selExport(moqExpr, prettyParamsFn)). - Args(c.selExport(paramsExpr, paramsIdent)).Obj -} - -func (c *Converter) passthroughElements(fl *dst.FieldList, label, valSuffix string, parentType TypeInfo) []dst.Expr { +func (c *Converter) passthroughKeyValues(fl *dst.FieldList, label, valSuffix string, parentType TypeInfo) []dst.Expr { if fl == nil { return nil } @@ -1730,7 +1366,7 @@ func (c *Converter) passthroughElements(fl *dst.FieldList, label, valSuffix stri unnamedPrefix, dropNonComparable := labelDirection(label) var elts []dst.Expr beforeDec := dst.NewLine - count := 0 + count := 1 for _, field := range fl.List { comp, err := c.typeCache.IsComparable(c.resolveExpr(field.Type, parentType), c.typ.TypeInfo) if err != nil { @@ -1740,22 +1376,22 @@ func (c *Converter) passthroughElements(fl *dst.FieldList, label, valSuffix stri return nil } - if len(field.Names) == 0 { + for _, name := range field.Names { if comp || !dropNonComparable { - pName := fmt.Sprintf(unnamed, unnamedPrefix, count+1) - elts = append(elts, Key(c.exportId(pName)).Value( - c.passthroughValue(Id(pName+valSuffix), false, nil)). + vName := validName(name.Name, unnamedPrefix, count) + elts = append(elts, Key(c.exportId(vName)).Value( + c.passthroughValue(Id(vName+valSuffix), false, nil)). Decs(kvExprDec(beforeDec)).Obj) beforeDec = dst.None } count++ } - for _, name := range field.Names { + if len(field.Names) == 0 { if comp || !dropNonComparable { - vName := validName(name.Name, unnamedPrefix, count) - elts = append(elts, Key(c.exportId(vName)).Value( - c.passthroughValue(Id(vName+valSuffix), false, nil)). + pName := fmt.Sprintf(unnamed, unnamedPrefix, count) + elts = append(elts, Key(c.exportId(pName)).Value( + c.passthroughValue(Id(pName+valSuffix), false, nil)). Decs(kvExprDec(beforeDec)).Obj) beforeDec = dst.None } @@ -1766,77 +1402,63 @@ func (c *Converter) passthroughElements(fl *dst.FieldList, label, valSuffix stri return elts } -func (c *Converter) passthroughValue( - src *dst.Ident, needComparable bool, sel dst.Expr, -) dst.Expr { - var val dst.Expr = src - if sel != nil { - val = c.selExport(sel, src.Name) +func (c *Converter) passthroughValues(fl *dst.FieldList, prefix string, sel dst.Expr) []dst.Expr { + if fl == nil { + return nil } - if needComparable { - val = Call(c.idPath("DeepHash", hashPkg)).Args(val).Obj + + pass := func(name string) dst.Expr { + if sel != nil { + // If we are selecting off of something, we need to use an + // exported name + name = c.export(name) + } + return c.passthroughValue(Id(name), false, sel) } - return val -} -func passthroughFields(prefix string, fields *dst.FieldList) []dst.Expr { - var exprs []dst.Expr - count := 0 - for _, f := range fields.List { - if len(f.Names) == 0 { - exprs = append(exprs, Idf(unnamed, prefix, count+1)) + var elts []dst.Expr + count := 1 + for _, field := range fl.List { + for _, name := range field.Names { + elts = append(elts, pass(validName(name.Name, prefix, count))) count++ } - for _, name := range f.Names { - exprs = append(exprs, Id(validName(name.Name, prefix, count))) + if len(field.Names) == 0 { + elts = append(elts, pass(fmt.Sprintf(unnamed, prefix, count))) count++ } } - return exprs -} -func (c *Converter) assignResult(resFL *dst.FieldList) []dst.Stmt { - var assigns []dst.Stmt - if resFL != nil { - count := 0 - for _, result := range resFL.List { - if len(result.Names) == 0 { - rName := fmt.Sprintf(unnamed, resultPrefix, count+1) - assigns = append(assigns, Assign(Id(rName)). - Tok(token.ASSIGN). - Rhs(Sel(Sel(Id(resultIdent)). - Dot(c.exportId(valuesIdent)).Obj). - Dot(c.exportId(rName)).Obj).Obj) - count++ - } + return elts +} - for _, name := range result.Names { - vName := validName(name.Name, resultPrefix, count) - assigns = append(assigns, Assign(Id(vName)). - Tok(token.ASSIGN). - Rhs(Sel(Sel(Id(resultIdent)). - Dot(c.exportId(valuesIdent)).Obj). - Dot(c.exportId(vName)).Obj).Obj) - count++ - } - } +func (c *Converter) passthroughValue( + src *dst.Ident, needComparable bool, sel dst.Expr, +) dst.Expr { + var val dst.Expr = src + if sel != nil { + val = c.selExport(sel, src.Name) } - return assigns + if needComparable { + val = Call(c.idPath("DeepHash", hashPkg)).Args(val).Obj + } + return val } func (c *Converter) cloneAndNameUnnamed(prefix string, fieldList *dst.FieldList, parentType TypeInfo) *dst.FieldList { fieldList = c.cloneFieldList(fieldList, false, parentType) if fieldList != nil { - count := 0 + count := 1 for _, f := range fieldList.List { - if len(f.Names) == 0 { - f.Names = []*dst.Ident{Idf(unnamed, prefix, count+1)} - } for n, name := range f.Names { f.Names[n] = Idf(validName(name.Name, prefix, count)) count++ } + if len(f.Names) == 0 { + f.Names = []*dst.Ident{Idf(unnamed, prefix, count)} + count++ + } } } return fieldList @@ -1844,7 +1466,7 @@ func (c *Converter) cloneAndNameUnnamed(prefix string, fieldList *dst.FieldList, func validName(name, prefix string, count int) string { if _, ok := invalidNames[name]; ok { - name = fmt.Sprintf(unnamed, prefix, count+1) + name = fmt.Sprintf(unnamed, prefix, count) } return name } @@ -1862,6 +1484,13 @@ func (c *Converter) typeName() string { return typ } +func (c *Converter) isInterface() bool { + if _, ok := c.typ.TypeInfo.Type.Type.(*dst.InterfaceType); ok { + return true + } + return false +} + func (c *Converter) export(name string) string { if c.isExported { name = titler.String(name) @@ -1886,9 +1515,10 @@ func (c *Converter) idPath(name, path string) *dst.Ident { func (c *Converter) helperCallExpr(selector dst.Expr) dst.Stmt { return Expr(Call(Sel(Sel(Sel(selector). - Dot(c.exportId(sceneIdent)).Obj). + Dot(Id(titler.String(sceneIdent))).Obj). Dot(Id(tType)).Obj). - Dot(Id(helperFnName)).Obj).Obj).Obj + Dot(Id(helperFnName)).Obj).Obj). + Decs(ExprDecs(dst.NewLine).Obj).Obj } func (c *Converter) selExport(x dst.Expr, sel string) dst.Expr { @@ -1936,26 +1566,23 @@ func labelDirection(label string) (string, bool) { return unnamedPrefix, dropNonComparable } -func isVariadic(fl *dst.FieldList) bool { - if len(fl.List) > 0 { - if _, ok := fl.List[len(fl.List)-1].Type.(*dst.Ellipsis); ok { - return true - } - } - return false -} - func (c *Converter) cloneFieldList(fl *dst.FieldList, removeNames bool, parentType TypeInfo) *dst.FieldList { if fl != nil { //nolint:forcetypeassert // if dst.Clone returns a different type, panic fl = dst.Clone(fl).(*dst.FieldList) c.resolveFieldList(fl, parentType) if removeNames { + var fields []*dst.Field for _, field := range fl.List { - for n := range field.Names { - field.Names[n] = Id(sep) + for range field.Names { + fields = append(fields, Field(cloneExpr(field.Type)).Obj) + } + if len(field.Names) == 0 { + fields = append(fields, field) } + field.Names = nil } + fl.List = fields } } return fl @@ -2047,18 +1674,13 @@ func cloneExpr(expr dst.Expr) dst.Expr { return dst.Clone(expr).(dst.Expr) } -func cloneStmt(stmt dst.Stmt) dst.Stmt { - //nolint:forcetypeassert // if dst.Clone returns a different type, panic - return dst.Clone(stmt).(dst.Stmt) -} - -func genDeclDec(format string, a ...interface{}) dst.GenDeclDecorations { +func genDeclDecf(format string, a ...interface{}) dst.GenDeclDecorations { return dst.GenDeclDecorations{ NodeDecs: NodeDecsf(format, a...), } } -func fnDeclDec(format string, a ...interface{}) dst.FuncDeclDecorations { +func fnDeclDecf(format string, a ...interface{}) dst.FuncDeclDecorations { return dst.FuncDeclDecorations{ NodeDecs: NodeDecsf(format, a...), } diff --git a/generator/converter_test.go b/generator/converter_test.go index bd89a45..ed0554b 100644 --- a/generator/converter_test.go +++ b/generator/converter_test.go @@ -313,8 +313,8 @@ func TestConverter(t *testing.T) { }) }) - t.Run("IsolationStruct", func(t *testing.T) { - t.Run("creates a struct", func(t *testing.T) { + t.Run("MockStructs", func(t *testing.T) { + t.Run("create structs", func(t *testing.T) { // ASSEMBLE beforeEach(t) defer afterEach(t) @@ -322,16 +322,22 @@ func TestConverter(t *testing.T) { typ := generator.Type{ TypeInfo: ast.TypeInfo{Type: &dst.TypeSpec{ Name: dst.NewIdent("MyInterface"), + Type: &dst.InterfaceType{}, }}, } converter := generator.NewConverter(typ, isExported, typeCacheMoq.mock()) // ACT - decl, err := converter.IsolationStruct("mock") + decls, err := converter.MockStructs() // ASSERT if err != nil { t.Fatalf("got %#v, want no error", err) } + if len(decls) != 3 { + t.Fatalf("got %#v, want 1 decl", decls) + } + + decl := decls[0].(*dst.GenDecl) if len(decl.Decs.Start) < 1 { t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) } @@ -340,6 +346,30 @@ func TestConverter(t *testing.T) { if decl.Decs.Start[0] != expectedStart { t.Errorf("got %s, wanted %s", decl.Decs.Start[0], expectedStart) } + + decl = decls[1].(*dst.GenDecl) + if len(decl.Decs.Start) < 2 { + t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) + } + expectedStart = fmt.Sprintf("// %s isolates the recorder interface of the MyInterface", + exported("moqMyInterface_recorder")) + if decl.Decs.Start[0] != expectedStart { + t.Errorf("got %s, wanted %s", decl.Decs.Start[0], expectedStart) + } + expectedStart = "// type" + if decl.Decs.Start[1] != expectedStart { + t.Errorf("got %s, wanted %s", decl.Decs.Start[1], expectedStart) + } + + decl = decls[2].(*dst.GenDecl) + if len(decl.Decs.Start) < 1 { + t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) + } + expectedStart = fmt.Sprintf("// %s holds runtime configuration for the MyInterface type", + exported("moqMyInterface_runtime")) + if decl.Decs.Start[0] != expectedStart { + t.Errorf("got %s, wanted %s", decl.Decs.Start[0], expectedStart) + } }) }) @@ -416,9 +446,10 @@ func TestConverter(t *testing.T) { if err != nil { t.Errorf("got %#v, wanted nil err", err) } - if len(decls) != 8 { - t.Errorf("got len %d, wanted 8", len(decls)) + if len(decls) != 9 { + t.Errorf("got len %d, wanted 9", len(decls)) } + decl, ok := decls[0].(*dst.GenDecl) if !ok { t.Errorf("got %#v, wanted GenDecl type", decls[0]) @@ -426,13 +457,27 @@ func TestConverter(t *testing.T) { if len(decl.Decs.Start) < 1 { t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) } - expectedStart := fmt.Sprintf("// %s holds the params of the PublicInterface type", - exported("moqPublicInterface_Func1_params")) + expectedStart := fmt.Sprintf("// %s adapts %s as needed by the", + exported("moqPublicInterface_Func1_adaptor"), + exported("moqPublicInterface")) if decl.Decs.Start[0] != expectedStart { t.Errorf("got %s, wanted %s", decl.Decs.Start[0], expectedStart) } decl, ok = decls[1].(*dst.GenDecl) + if !ok { + t.Errorf("got %#v, wanted GenDecl type", decls[0]) + } + if len(decl.Decs.Start) < 1 { + t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) + } + expectedStart = fmt.Sprintf("// %s holds the params of the PublicInterface type", + exported("moqPublicInterface_Func1_params")) + if decl.Decs.Start[0] != expectedStart { + t.Errorf("got %s, wanted %s", decl.Decs.Start[0], expectedStart) + } + + decl, ok = decls[2].(*dst.GenDecl) if !ok { t.Errorf("got %#v, wanted GenDecl type", decls[1]) } @@ -449,42 +494,41 @@ func TestConverter(t *testing.T) { t.Errorf("got %s, want %s", decl.Decs.Start[0], expectedStart) } - decl, ok = decls[2].(*dst.GenDecl) + decl, ok = decls[3].(*dst.GenDecl) if !ok { t.Errorf("got %#v, wanted GenDecl type", decls[2]) } if len(decl.Decs.Start) < 1 { t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) } - expectedStart = fmt.Sprintf("// %s contains the results for a given", - exported("moqPublicInterface_Func1_resultsByParams")) + expectedStart = fmt.Sprintf("// %s holds the results of the PublicInterface", + exported("moqPublicInterface_Func1_results")) if decl.Decs.Start[0] != expectedStart { t.Errorf("got %s, wanted %s", decl.Decs.Start[0], expectedStart) } - expectedStart = "// set of parameters for the PublicInterface type" + expectedStart = "// type" if decl.Decs.Start[1] != expectedStart { - t.Errorf("got %s, want %s", decl.Decs.Start[0], expectedStart) + t.Errorf("got %s, want %s", decl.Decs.Start[1], expectedStart) } - decl, ok = decls[3].(*dst.GenDecl) + decl, ok = decls[4].(*dst.GenDecl) if !ok { t.Errorf("got %#v, wanted GenDecl type", decls[3]) } if len(decl.Decs.Start) < 1 { t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) } - expectedStart = fmt.Sprintf("// %s defines the type of function needed when", - exported("moqPublicInterface_Func1_doFn")) + expectedStart = fmt.Sprintf("// %s holds the parameter indexing runtime", + exported("moqPublicInterface_Func1_paramIndexing")) if decl.Decs.Start[0] != expectedStart { t.Errorf("got %s, wanted %s", decl.Decs.Start[0], expectedStart) } - expectedStart = fmt.Sprintf("// calling %s for the PublicInterface type", - exported("andDo")) + expectedStart = "// configuration for the PublicInterface type" if decl.Decs.Start[1] != expectedStart { - t.Errorf("got %s, want %s", decl.Decs.Start[0], expectedStart) + t.Errorf("got %s, want %s", decl.Decs.Start[1], expectedStart) } - decl, ok = decls[4].(*dst.GenDecl) + decl, ok = decls[5].(*dst.GenDecl) if !ok { t.Errorf("got %#v, wanted GenDecl type", decls[4]) } @@ -492,34 +536,35 @@ func TestConverter(t *testing.T) { t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) } expectedStart = fmt.Sprintf("// %s defines the type of function needed when", - exported("moqPublicInterface_Func1_doReturnFn")) + exported("moqPublicInterface_Func1_doFn")) if decl.Decs.Start[0] != expectedStart { t.Errorf("got %s, wanted %s", decl.Decs.Start[0], expectedStart) } expectedStart = fmt.Sprintf("// calling %s for the PublicInterface type", - exported("doReturnResults")) + exported("andDo")) if decl.Decs.Start[1] != expectedStart { - t.Errorf("got %s, want %s", decl.Decs.Start[0], expectedStart) + t.Errorf("got %s, want %s", decl.Decs.Start[1], expectedStart) } - decl, ok = decls[5].(*dst.GenDecl) + decl, ok = decls[6].(*dst.GenDecl) if !ok { t.Errorf("got %#v, wanted GenDecl type", decls[5]) } if len(decl.Decs.Start) < 1 { t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) } - expectedStart = fmt.Sprintf("// %s holds the results of the PublicInterface", - exported("moqPublicInterface_Func1_results")) + expectedStart = fmt.Sprintf("// %s defines the type of function needed when", + exported("moqPublicInterface_Func1_doReturnFn")) if decl.Decs.Start[0] != expectedStart { t.Errorf("got %s, wanted %s", decl.Decs.Start[0], expectedStart) } - expectedStart = "// type" + expectedStart = fmt.Sprintf("// calling %s for the PublicInterface type", + exported("doReturnResults")) if decl.Decs.Start[1] != expectedStart { - t.Errorf("got %s, want %s", decl.Decs.Start[0], expectedStart) + t.Errorf("got %s, want %s", decl.Decs.Start[1], expectedStart) } - decl, ok = decls[6].(*dst.GenDecl) + decl, ok = decls[7].(*dst.GenDecl) if !ok { t.Errorf("got %#v, wanted GenDecl type", decls[6]) } @@ -527,17 +572,17 @@ func TestConverter(t *testing.T) { t.Errorf("got len %d, wanted < 1", len(decl.Decs.Start)) } expectedStart = fmt.Sprintf("// %s routes recorded function calls to the", - exported("moqPublicInterface_Func1_fnRecorder")) + exported("moqPublicInterface_Func1_recorder")) if decl.Decs.Start[0] != expectedStart { t.Errorf("got %s, wanted %s", decl.Decs.Start[0], expectedStart) } expectedStart = fmt.Sprintf("// %s moq", exported("moqPublicInterface")) if decl.Decs.Start[1] != expectedStart { - t.Errorf("got %s, want %s", decl.Decs.Start[0], expectedStart) + t.Errorf("got %s, want %s", decl.Decs.Start[1], expectedStart) } - decl, ok = decls[7].(*dst.GenDecl) + decl, ok = decls[8].(*dst.GenDecl) if !ok { t.Errorf("got %#v, wanted GenDecl type", decls[7]) } @@ -551,7 +596,7 @@ func TestConverter(t *testing.T) { } expectedStart = "// PublicInterface type" if decl.Decs.Start[1] != expectedStart { - t.Errorf("got %s, want %s", decl.Decs.Start[0], expectedStart) + t.Errorf("got %s, want %s", decl.Decs.Start[1], expectedStart) } }) @@ -710,7 +755,9 @@ func TestConverter(t *testing.T) { t.Errorf("got %s, wanted %s", decl.Decs.Start[0], expectedStart) } }) + }) + t.Run("FuncClosure", func(t *testing.T) { t.Run("creates a closure function for a function type", func(t *testing.T) { // ASSEMBLE beforeEach(t) @@ -749,6 +796,14 @@ func TestConverter(t *testing.T) { returnResults(ast.TypeInfo{ Type: &dst.TypeSpec{Name: id}, }, nil).repeat(moq.AnyTimes()) + typeCacheMoq.onCall().IsComparable(func1Param1, typ.TypeInfo). + returnResults(true, nil) + typeCacheMoq.onCall().IsComparable(func1Param2, typ.TypeInfo). + returnResults(true, nil) + typeCacheMoq.onCall().IsComparable(func1Param3, typ.TypeInfo). + returnResults(true, nil) + typeCacheMoq.onCall().IsComparable(func1Param4, typ.TypeInfo). + returnResults(true, nil) // ACT decl, err := converter.FuncClosure(fnSpecFuncs[0]) diff --git a/generator/generator_test.go b/generator/generator_test.go index eea29b4..f4718c6 100644 --- a/generator/generator_test.go +++ b/generator/generator_test.go @@ -143,7 +143,7 @@ func TestGenerating(t *testing.T) { t.Run("dumps the DST of a moq", func(t *testing.T) { t.SkipNow() - filePath := "./moq_usual_test.go" + filePath := "./testmoqs/exported/moqusual.go" outPath := "./dst.txt" fSet := token.NewFileSet() diff --git a/generator/moq_converterer_test.go b/generator/moq_converterer_test.go index c191bd8..aefc6c0 100644 --- a/generator/moq_converterer_test.go +++ b/generator/moq_converterer_test.go @@ -4,12 +4,11 @@ package generator_test import ( "fmt" - "math/bits" - "sync/atomic" "github.com/dave/dst" "moqueries.org/cli/generator" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -19,48 +18,70 @@ var _ generator.Converterer = (*moqConverterer_mock)(nil) // moqConverterer holds the state of a moq of the Converterer type type moqConverterer struct { - scene *moq.Scene - config moq.Config - moq *moqConverterer_mock - - resultsByParams_BaseDecls []moqConverterer_BaseDecls_resultsByParams - resultsByParams_IsolationStruct []moqConverterer_IsolationStruct_resultsByParams - resultsByParams_MethodStructs []moqConverterer_MethodStructs_resultsByParams - resultsByParams_NewFunc []moqConverterer_NewFunc_resultsByParams - resultsByParams_IsolationAccessor []moqConverterer_IsolationAccessor_resultsByParams - resultsByParams_FuncClosure []moqConverterer_FuncClosure_resultsByParams - resultsByParams_MockMethod []moqConverterer_MockMethod_resultsByParams - resultsByParams_RecorderMethods []moqConverterer_RecorderMethods_resultsByParams - resultsByParams_ResetMethod []moqConverterer_ResetMethod_resultsByParams - resultsByParams_AssertMethod []moqConverterer_AssertMethod_resultsByParams - - runtime struct { - parameterIndexing struct { - BaseDecls struct{} - IsolationStruct struct { - suffix moq.ParamIndexing - } - MethodStructs struct { - fn moq.ParamIndexing - } - NewFunc struct{} - IsolationAccessor struct { - suffix moq.ParamIndexing - fnName moq.ParamIndexing - } - FuncClosure struct { - fn moq.ParamIndexing - } - MockMethod struct { - fn moq.ParamIndexing - } - RecorderMethods struct { - fn moq.ParamIndexing - } - ResetMethod struct{} - AssertMethod struct{} - } - } + moq *moqConverterer_mock + + moq_BaseDecls *impl.Moq[ + *moqConverterer_BaseDecls_adaptor, + moqConverterer_BaseDecls_params, + moqConverterer_BaseDecls_paramsKey, + moqConverterer_BaseDecls_results, + ] + moq_MockStructs *impl.Moq[ + *moqConverterer_MockStructs_adaptor, + moqConverterer_MockStructs_params, + moqConverterer_MockStructs_paramsKey, + moqConverterer_MockStructs_results, + ] + moq_MethodStructs *impl.Moq[ + *moqConverterer_MethodStructs_adaptor, + moqConverterer_MethodStructs_params, + moqConverterer_MethodStructs_paramsKey, + moqConverterer_MethodStructs_results, + ] + moq_NewFunc *impl.Moq[ + *moqConverterer_NewFunc_adaptor, + moqConverterer_NewFunc_params, + moqConverterer_NewFunc_paramsKey, + moqConverterer_NewFunc_results, + ] + moq_IsolationAccessor *impl.Moq[ + *moqConverterer_IsolationAccessor_adaptor, + moqConverterer_IsolationAccessor_params, + moqConverterer_IsolationAccessor_paramsKey, + moqConverterer_IsolationAccessor_results, + ] + moq_FuncClosure *impl.Moq[ + *moqConverterer_FuncClosure_adaptor, + moqConverterer_FuncClosure_params, + moqConverterer_FuncClosure_paramsKey, + moqConverterer_FuncClosure_results, + ] + moq_MockMethod *impl.Moq[ + *moqConverterer_MockMethod_adaptor, + moqConverterer_MockMethod_params, + moqConverterer_MockMethod_paramsKey, + moqConverterer_MockMethod_results, + ] + moq_RecorderMethods *impl.Moq[ + *moqConverterer_RecorderMethods_adaptor, + moqConverterer_RecorderMethods_params, + moqConverterer_RecorderMethods_paramsKey, + moqConverterer_RecorderMethods_results, + ] + moq_ResetMethod *impl.Moq[ + *moqConverterer_ResetMethod_adaptor, + moqConverterer_ResetMethod_params, + moqConverterer_ResetMethod_paramsKey, + moqConverterer_ResetMethod_results, + ] + moq_AssertMethod *impl.Moq[ + *moqConverterer_AssertMethod_adaptor, + moqConverterer_AssertMethod_params, + moqConverterer_AssertMethod_paramsKey, + moqConverterer_AssertMethod_results, + ] + + runtime moqConverterer_runtime } // moqConverterer_mock isolates the mock interface of the Converterer type @@ -74,6 +95,28 @@ type moqConverterer_recorder struct { moq *moqConverterer } +// moqConverterer_runtime holds runtime configuration for the Converterer type +type moqConverterer_runtime struct { + parameterIndexing struct { + BaseDecls moqConverterer_BaseDecls_paramIndexing + MockStructs moqConverterer_MockStructs_paramIndexing + MethodStructs moqConverterer_MethodStructs_paramIndexing + NewFunc moqConverterer_NewFunc_paramIndexing + IsolationAccessor moqConverterer_IsolationAccessor_paramIndexing + FuncClosure moqConverterer_FuncClosure_paramIndexing + MockMethod moqConverterer_MockMethod_paramIndexing + RecorderMethods moqConverterer_RecorderMethods_paramIndexing + ResetMethod moqConverterer_ResetMethod_paramIndexing + AssertMethod moqConverterer_AssertMethod_paramIndexing + } +} + +// moqConverterer_BaseDecls_adaptor adapts moqConverterer as needed by the +// runtime +type moqConverterer_BaseDecls_adaptor struct { + moq *moqConverterer +} + // moqConverterer_BaseDecls_params holds the params of the Converterer type type moqConverterer_BaseDecls_params struct{} @@ -84,14 +127,16 @@ type moqConverterer_BaseDecls_paramsKey struct { hashes struct{} } -// moqConverterer_BaseDecls_resultsByParams contains the results for a given -// set of parameters for the Converterer type -type moqConverterer_BaseDecls_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqConverterer_BaseDecls_paramsKey]*moqConverterer_BaseDecls_results +// moqConverterer_BaseDecls_results holds the results of the Converterer type +type moqConverterer_BaseDecls_results struct { + baseDecls []dst.Decl + err error } +// moqConverterer_BaseDecls_paramIndexing holds the parameter indexing runtime +// configuration for the Converterer type +type moqConverterer_BaseDecls_paramIndexing struct{} + // moqConverterer_BaseDecls_doFn defines the type of function needed when // calling andDo for the Converterer type type moqConverterer_BaseDecls_doFn func() @@ -100,96 +145,78 @@ type moqConverterer_BaseDecls_doFn func() // calling doReturnResults for the Converterer type 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 - err error - } - sequence uint32 - doFn moqConverterer_BaseDecls_doFn - doReturnFn moqConverterer_BaseDecls_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqConverterer_BaseDecls_fnRecorder routes recorded function calls to the +// moqConverterer_BaseDecls_recorder routes recorded function calls to the // moqConverterer moq -type moqConverterer_BaseDecls_fnRecorder struct { - params moqConverterer_BaseDecls_params - anyParams uint64 - sequence bool - results *moqConverterer_BaseDecls_results - moq *moqConverterer +type moqConverterer_BaseDecls_recorder struct { + recorder *impl.Recorder[ + *moqConverterer_BaseDecls_adaptor, + moqConverterer_BaseDecls_params, + moqConverterer_BaseDecls_paramsKey, + moqConverterer_BaseDecls_results, + ] } // moqConverterer_BaseDecls_anyParams isolates the any params functions of the // Converterer type type moqConverterer_BaseDecls_anyParams struct { - recorder *moqConverterer_BaseDecls_fnRecorder + recorder *moqConverterer_BaseDecls_recorder } -// moqConverterer_IsolationStruct_params holds the params of the Converterer -// type -type moqConverterer_IsolationStruct_params struct{ suffix string } +// moqConverterer_MockStructs_adaptor adapts moqConverterer as needed by the +// runtime +type moqConverterer_MockStructs_adaptor struct { + moq *moqConverterer +} + +// moqConverterer_MockStructs_params holds the params of the Converterer type +type moqConverterer_MockStructs_params struct{} -// moqConverterer_IsolationStruct_paramsKey holds the map key params of the +// moqConverterer_MockStructs_paramsKey holds the map key params of the // Converterer type -type moqConverterer_IsolationStruct_paramsKey struct { - params struct{ suffix string } - hashes struct{ suffix hash.Hash } +type moqConverterer_MockStructs_paramsKey struct { + params struct{} + hashes struct{} } -// moqConverterer_IsolationStruct_resultsByParams contains the results for a -// given set of parameters for the Converterer type -type moqConverterer_IsolationStruct_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqConverterer_IsolationStruct_paramsKey]*moqConverterer_IsolationStruct_results +// moqConverterer_MockStructs_results holds the results of the Converterer type +type moqConverterer_MockStructs_results struct { + structDecls []dst.Decl + err error } -// moqConverterer_IsolationStruct_doFn defines the type of function needed when +// moqConverterer_MockStructs_paramIndexing holds the parameter indexing +// runtime configuration for the Converterer type +type moqConverterer_MockStructs_paramIndexing struct{} + +// moqConverterer_MockStructs_doFn defines the type of function needed when // calling andDo for the Converterer type -type moqConverterer_IsolationStruct_doFn func(suffix string) +type moqConverterer_MockStructs_doFn func() -// 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, err error) +// moqConverterer_MockStructs_doReturnFn defines the type of function needed +// when calling doReturnResults for the Converterer type +type moqConverterer_MockStructs_doReturnFn func() (structDecls []dst.Decl, 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 - err error - } - sequence uint32 - doFn moqConverterer_IsolationStruct_doFn - doReturnFn moqConverterer_IsolationStruct_doReturnFn - } - index uint32 - repeat *moq.RepeatVal +// moqConverterer_MockStructs_recorder routes recorded function calls to the +// moqConverterer moq +type moqConverterer_MockStructs_recorder struct { + recorder *impl.Recorder[ + *moqConverterer_MockStructs_adaptor, + moqConverterer_MockStructs_params, + moqConverterer_MockStructs_paramsKey, + moqConverterer_MockStructs_results, + ] } -// moqConverterer_IsolationStruct_fnRecorder routes recorded function calls to -// the moqConverterer moq -type moqConverterer_IsolationStruct_fnRecorder struct { - params moqConverterer_IsolationStruct_params - anyParams uint64 - sequence bool - results *moqConverterer_IsolationStruct_results - moq *moqConverterer +// moqConverterer_MockStructs_anyParams isolates the any params functions of +// the Converterer type +type moqConverterer_MockStructs_anyParams struct { + recorder *moqConverterer_MockStructs_recorder } -// moqConverterer_IsolationStruct_anyParams isolates the any params functions -// of the Converterer type -type moqConverterer_IsolationStruct_anyParams struct { - recorder *moqConverterer_IsolationStruct_fnRecorder +// moqConverterer_MethodStructs_adaptor adapts moqConverterer as needed by the +// runtime +type moqConverterer_MethodStructs_adaptor struct { + moq *moqConverterer } // moqConverterer_MethodStructs_params holds the params of the Converterer type @@ -202,12 +229,17 @@ type moqConverterer_MethodStructs_paramsKey struct { hashes struct{ fn hash.Hash } } -// moqConverterer_MethodStructs_resultsByParams contains the results for a -// given set of parameters for the Converterer type -type moqConverterer_MethodStructs_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqConverterer_MethodStructs_paramsKey]*moqConverterer_MethodStructs_results +// moqConverterer_MethodStructs_results holds the results of the Converterer +// type +type moqConverterer_MethodStructs_results struct { + structDecls []dst.Decl + err error +} + +// moqConverterer_MethodStructs_paramIndexing holds the parameter indexing +// runtime configuration for the Converterer type +type moqConverterer_MethodStructs_paramIndexing struct { + fn moq.ParamIndexing } // moqConverterer_MethodStructs_doFn defines the type of function needed when @@ -218,37 +250,27 @@ type moqConverterer_MethodStructs_doFn func(fn generator.Func) // when calling doReturnResults for the Converterer type type moqConverterer_MethodStructs_doReturnFn func(fn generator.Func) (structDecls []dst.Decl, err error) -// moqConverterer_MethodStructs_results holds the results of the Converterer -// type -type moqConverterer_MethodStructs_results struct { - params moqConverterer_MethodStructs_params - results []struct { - values *struct { - structDecls []dst.Decl - err error - } - sequence uint32 - doFn moqConverterer_MethodStructs_doFn - doReturnFn moqConverterer_MethodStructs_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqConverterer_MethodStructs_fnRecorder routes recorded function calls to -// the moqConverterer moq -type moqConverterer_MethodStructs_fnRecorder struct { - params moqConverterer_MethodStructs_params - anyParams uint64 - sequence bool - results *moqConverterer_MethodStructs_results - moq *moqConverterer +// moqConverterer_MethodStructs_recorder routes recorded function calls to the +// moqConverterer moq +type moqConverterer_MethodStructs_recorder struct { + recorder *impl.Recorder[ + *moqConverterer_MethodStructs_adaptor, + moqConverterer_MethodStructs_params, + moqConverterer_MethodStructs_paramsKey, + moqConverterer_MethodStructs_results, + ] } // moqConverterer_MethodStructs_anyParams isolates the any params functions of // the Converterer type type moqConverterer_MethodStructs_anyParams struct { - recorder *moqConverterer_MethodStructs_fnRecorder + recorder *moqConverterer_MethodStructs_recorder +} + +// moqConverterer_NewFunc_adaptor adapts moqConverterer as needed by the +// runtime +type moqConverterer_NewFunc_adaptor struct { + moq *moqConverterer } // moqConverterer_NewFunc_params holds the params of the Converterer type @@ -261,14 +283,16 @@ type moqConverterer_NewFunc_paramsKey struct { hashes struct{} } -// moqConverterer_NewFunc_resultsByParams contains the results for a given set -// of parameters for the Converterer type -type moqConverterer_NewFunc_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqConverterer_NewFunc_paramsKey]*moqConverterer_NewFunc_results +// moqConverterer_NewFunc_results holds the results of the Converterer type +type moqConverterer_NewFunc_results struct { + funcDecl *dst.FuncDecl + err error } +// moqConverterer_NewFunc_paramIndexing holds the parameter indexing runtime +// configuration for the Converterer type +type moqConverterer_NewFunc_paramIndexing struct{} + // moqConverterer_NewFunc_doFn defines the type of function needed when calling // andDo for the Converterer type type moqConverterer_NewFunc_doFn func() @@ -277,36 +301,27 @@ type moqConverterer_NewFunc_doFn func() // calling doReturnResults for the Converterer type 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 - err error - } - sequence uint32 - doFn moqConverterer_NewFunc_doFn - doReturnFn moqConverterer_NewFunc_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqConverterer_NewFunc_fnRecorder routes recorded function calls to the +// moqConverterer_NewFunc_recorder routes recorded function calls to the // moqConverterer moq -type moqConverterer_NewFunc_fnRecorder struct { - params moqConverterer_NewFunc_params - anyParams uint64 - sequence bool - results *moqConverterer_NewFunc_results - moq *moqConverterer +type moqConverterer_NewFunc_recorder struct { + recorder *impl.Recorder[ + *moqConverterer_NewFunc_adaptor, + moqConverterer_NewFunc_params, + moqConverterer_NewFunc_paramsKey, + moqConverterer_NewFunc_results, + ] } // moqConverterer_NewFunc_anyParams isolates the any params functions of the // Converterer type type moqConverterer_NewFunc_anyParams struct { - recorder *moqConverterer_NewFunc_fnRecorder + recorder *moqConverterer_NewFunc_recorder +} + +// moqConverterer_IsolationAccessor_adaptor adapts moqConverterer as needed by +// the runtime +type moqConverterer_IsolationAccessor_adaptor struct { + moq *moqConverterer } // moqConverterer_IsolationAccessor_params holds the params of the Converterer @@ -320,12 +335,17 @@ type moqConverterer_IsolationAccessor_paramsKey struct { hashes struct{ suffix, fnName hash.Hash } } -// moqConverterer_IsolationAccessor_resultsByParams contains the results for a -// given set of parameters for the Converterer type -type moqConverterer_IsolationAccessor_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqConverterer_IsolationAccessor_paramsKey]*moqConverterer_IsolationAccessor_results +// moqConverterer_IsolationAccessor_results holds the results of the +// Converterer type +type moqConverterer_IsolationAccessor_results struct { + funcDecl *dst.FuncDecl + err error +} + +// moqConverterer_IsolationAccessor_paramIndexing holds the parameter indexing +// runtime configuration for the Converterer type +type moqConverterer_IsolationAccessor_paramIndexing struct { + suffix, fnName moq.ParamIndexing } // moqConverterer_IsolationAccessor_doFn defines the type of function needed @@ -336,37 +356,27 @@ type moqConverterer_IsolationAccessor_doFn func(suffix, fnName string) // needed when calling doReturnResults for the Converterer type 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 - err error - } - sequence uint32 - doFn moqConverterer_IsolationAccessor_doFn - doReturnFn moqConverterer_IsolationAccessor_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqConverterer_IsolationAccessor_fnRecorder routes recorded function calls -// to the moqConverterer moq -type moqConverterer_IsolationAccessor_fnRecorder struct { - params moqConverterer_IsolationAccessor_params - anyParams uint64 - sequence bool - results *moqConverterer_IsolationAccessor_results - moq *moqConverterer +// moqConverterer_IsolationAccessor_recorder routes recorded function calls to +// the moqConverterer moq +type moqConverterer_IsolationAccessor_recorder struct { + recorder *impl.Recorder[ + *moqConverterer_IsolationAccessor_adaptor, + moqConverterer_IsolationAccessor_params, + moqConverterer_IsolationAccessor_paramsKey, + moqConverterer_IsolationAccessor_results, + ] } // moqConverterer_IsolationAccessor_anyParams isolates the any params functions // of the Converterer type type moqConverterer_IsolationAccessor_anyParams struct { - recorder *moqConverterer_IsolationAccessor_fnRecorder + recorder *moqConverterer_IsolationAccessor_recorder +} + +// moqConverterer_FuncClosure_adaptor adapts moqConverterer as needed by the +// runtime +type moqConverterer_FuncClosure_adaptor struct { + moq *moqConverterer } // moqConverterer_FuncClosure_params holds the params of the Converterer type @@ -379,12 +389,16 @@ type moqConverterer_FuncClosure_paramsKey struct { hashes struct{ fn hash.Hash } } -// moqConverterer_FuncClosure_resultsByParams contains the results for a given -// set of parameters for the Converterer type -type moqConverterer_FuncClosure_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqConverterer_FuncClosure_paramsKey]*moqConverterer_FuncClosure_results +// moqConverterer_FuncClosure_results holds the results of the Converterer type +type moqConverterer_FuncClosure_results struct { + funcDecl *dst.FuncDecl + err error +} + +// moqConverterer_FuncClosure_paramIndexing holds the parameter indexing +// runtime configuration for the Converterer type +type moqConverterer_FuncClosure_paramIndexing struct { + fn moq.ParamIndexing } // moqConverterer_FuncClosure_doFn defines the type of function needed when @@ -395,36 +409,27 @@ type moqConverterer_FuncClosure_doFn func(fn generator.Func) // when calling doReturnResults for the Converterer type 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 - err error - } - sequence uint32 - doFn moqConverterer_FuncClosure_doFn - doReturnFn moqConverterer_FuncClosure_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqConverterer_FuncClosure_fnRecorder routes recorded function calls to the +// moqConverterer_FuncClosure_recorder routes recorded function calls to the // moqConverterer moq -type moqConverterer_FuncClosure_fnRecorder struct { - params moqConverterer_FuncClosure_params - anyParams uint64 - sequence bool - results *moqConverterer_FuncClosure_results - moq *moqConverterer +type moqConverterer_FuncClosure_recorder struct { + recorder *impl.Recorder[ + *moqConverterer_FuncClosure_adaptor, + moqConverterer_FuncClosure_params, + moqConverterer_FuncClosure_paramsKey, + moqConverterer_FuncClosure_results, + ] } // moqConverterer_FuncClosure_anyParams isolates the any params functions of // the Converterer type type moqConverterer_FuncClosure_anyParams struct { - recorder *moqConverterer_FuncClosure_fnRecorder + recorder *moqConverterer_FuncClosure_recorder +} + +// moqConverterer_MockMethod_adaptor adapts moqConverterer as needed by the +// runtime +type moqConverterer_MockMethod_adaptor struct { + moq *moqConverterer } // moqConverterer_MockMethod_params holds the params of the Converterer type @@ -437,12 +442,16 @@ type moqConverterer_MockMethod_paramsKey struct { hashes struct{ fn hash.Hash } } -// moqConverterer_MockMethod_resultsByParams contains the results for a given -// set of parameters for the Converterer type -type moqConverterer_MockMethod_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqConverterer_MockMethod_paramsKey]*moqConverterer_MockMethod_results +// moqConverterer_MockMethod_results holds the results of the Converterer type +type moqConverterer_MockMethod_results struct { + funcDecl *dst.FuncDecl + err error +} + +// moqConverterer_MockMethod_paramIndexing holds the parameter indexing runtime +// configuration for the Converterer type +type moqConverterer_MockMethod_paramIndexing struct { + fn moq.ParamIndexing } // moqConverterer_MockMethod_doFn defines the type of function needed when @@ -453,36 +462,27 @@ type moqConverterer_MockMethod_doFn func(fn generator.Func) // when calling doReturnResults for the Converterer type 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 - err error - } - sequence uint32 - doFn moqConverterer_MockMethod_doFn - doReturnFn moqConverterer_MockMethod_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqConverterer_MockMethod_fnRecorder routes recorded function calls to the +// moqConverterer_MockMethod_recorder routes recorded function calls to the // moqConverterer moq -type moqConverterer_MockMethod_fnRecorder struct { - params moqConverterer_MockMethod_params - anyParams uint64 - sequence bool - results *moqConverterer_MockMethod_results - moq *moqConverterer +type moqConverterer_MockMethod_recorder struct { + recorder *impl.Recorder[ + *moqConverterer_MockMethod_adaptor, + moqConverterer_MockMethod_params, + moqConverterer_MockMethod_paramsKey, + moqConverterer_MockMethod_results, + ] } // moqConverterer_MockMethod_anyParams isolates the any params functions of the // Converterer type type moqConverterer_MockMethod_anyParams struct { - recorder *moqConverterer_MockMethod_fnRecorder + recorder *moqConverterer_MockMethod_recorder +} + +// moqConverterer_RecorderMethods_adaptor adapts moqConverterer as needed by +// the runtime +type moqConverterer_RecorderMethods_adaptor struct { + moq *moqConverterer } // moqConverterer_RecorderMethods_params holds the params of the Converterer @@ -496,12 +496,17 @@ type moqConverterer_RecorderMethods_paramsKey struct { hashes struct{ fn hash.Hash } } -// moqConverterer_RecorderMethods_resultsByParams contains the results for a -// given set of parameters for the Converterer type -type moqConverterer_RecorderMethods_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqConverterer_RecorderMethods_paramsKey]*moqConverterer_RecorderMethods_results +// moqConverterer_RecorderMethods_results holds the results of the Converterer +// type +type moqConverterer_RecorderMethods_results struct { + funcDecls []dst.Decl + err error +} + +// moqConverterer_RecorderMethods_paramIndexing holds the parameter indexing +// runtime configuration for the Converterer type +type moqConverterer_RecorderMethods_paramIndexing struct { + fn moq.ParamIndexing } // moqConverterer_RecorderMethods_doFn defines the type of function needed when @@ -512,37 +517,27 @@ type moqConverterer_RecorderMethods_doFn func(fn generator.Func) // needed when calling doReturnResults for the Converterer type 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 - err error - } - sequence uint32 - doFn moqConverterer_RecorderMethods_doFn - doReturnFn moqConverterer_RecorderMethods_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqConverterer_RecorderMethods_fnRecorder routes recorded function calls to +// moqConverterer_RecorderMethods_recorder routes recorded function calls to // the moqConverterer moq -type moqConverterer_RecorderMethods_fnRecorder struct { - params moqConverterer_RecorderMethods_params - anyParams uint64 - sequence bool - results *moqConverterer_RecorderMethods_results - moq *moqConverterer +type moqConverterer_RecorderMethods_recorder struct { + recorder *impl.Recorder[ + *moqConverterer_RecorderMethods_adaptor, + moqConverterer_RecorderMethods_params, + moqConverterer_RecorderMethods_paramsKey, + moqConverterer_RecorderMethods_results, + ] } // moqConverterer_RecorderMethods_anyParams isolates the any params functions // of the Converterer type type moqConverterer_RecorderMethods_anyParams struct { - recorder *moqConverterer_RecorderMethods_fnRecorder + recorder *moqConverterer_RecorderMethods_recorder +} + +// moqConverterer_ResetMethod_adaptor adapts moqConverterer as needed by the +// runtime +type moqConverterer_ResetMethod_adaptor struct { + moq *moqConverterer } // moqConverterer_ResetMethod_params holds the params of the Converterer type @@ -555,14 +550,16 @@ type moqConverterer_ResetMethod_paramsKey struct { hashes struct{} } -// moqConverterer_ResetMethod_resultsByParams contains the results for a given -// set of parameters for the Converterer type -type moqConverterer_ResetMethod_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqConverterer_ResetMethod_paramsKey]*moqConverterer_ResetMethod_results +// moqConverterer_ResetMethod_results holds the results of the Converterer type +type moqConverterer_ResetMethod_results struct { + funcDecl *dst.FuncDecl + err error } +// moqConverterer_ResetMethod_paramIndexing holds the parameter indexing +// runtime configuration for the Converterer type +type moqConverterer_ResetMethod_paramIndexing struct{} + // moqConverterer_ResetMethod_doFn defines the type of function needed when // calling andDo for the Converterer type type moqConverterer_ResetMethod_doFn func() @@ -571,36 +568,27 @@ type moqConverterer_ResetMethod_doFn func() // when calling doReturnResults for the Converterer type 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 - err error - } - sequence uint32 - doFn moqConverterer_ResetMethod_doFn - doReturnFn moqConverterer_ResetMethod_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqConverterer_ResetMethod_fnRecorder routes recorded function calls to the +// moqConverterer_ResetMethod_recorder routes recorded function calls to the // moqConverterer moq -type moqConverterer_ResetMethod_fnRecorder struct { - params moqConverterer_ResetMethod_params - anyParams uint64 - sequence bool - results *moqConverterer_ResetMethod_results - moq *moqConverterer +type moqConverterer_ResetMethod_recorder struct { + recorder *impl.Recorder[ + *moqConverterer_ResetMethod_adaptor, + moqConverterer_ResetMethod_params, + moqConverterer_ResetMethod_paramsKey, + moqConverterer_ResetMethod_results, + ] } // moqConverterer_ResetMethod_anyParams isolates the any params functions of // the Converterer type type moqConverterer_ResetMethod_anyParams struct { - recorder *moqConverterer_ResetMethod_fnRecorder + recorder *moqConverterer_ResetMethod_recorder +} + +// moqConverterer_AssertMethod_adaptor adapts moqConverterer as needed by the +// runtime +type moqConverterer_AssertMethod_adaptor struct { + moq *moqConverterer } // moqConverterer_AssertMethod_params holds the params of the Converterer type @@ -613,14 +601,17 @@ type moqConverterer_AssertMethod_paramsKey struct { hashes struct{} } -// moqConverterer_AssertMethod_resultsByParams contains the results for a given -// set of parameters for the Converterer type -type moqConverterer_AssertMethod_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqConverterer_AssertMethod_paramsKey]*moqConverterer_AssertMethod_results +// moqConverterer_AssertMethod_results holds the results of the Converterer +// type +type moqConverterer_AssertMethod_results struct { + funcDecl *dst.FuncDecl + err error } +// moqConverterer_AssertMethod_paramIndexing holds the parameter indexing +// runtime configuration for the Converterer type +type moqConverterer_AssertMethod_paramIndexing struct{} + // moqConverterer_AssertMethod_doFn defines the type of function needed when // calling andDo for the Converterer type type moqConverterer_AssertMethod_doFn func() @@ -629,140 +620,147 @@ type moqConverterer_AssertMethod_doFn func() // when calling doReturnResults for the Converterer type 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 - err error - } - sequence uint32 - doFn moqConverterer_AssertMethod_doFn - doReturnFn moqConverterer_AssertMethod_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqConverterer_AssertMethod_fnRecorder routes recorded function calls to the +// moqConverterer_AssertMethod_recorder routes recorded function calls to the // moqConverterer moq -type moqConverterer_AssertMethod_fnRecorder struct { - params moqConverterer_AssertMethod_params - anyParams uint64 - sequence bool - results *moqConverterer_AssertMethod_results - moq *moqConverterer +type moqConverterer_AssertMethod_recorder struct { + recorder *impl.Recorder[ + *moqConverterer_AssertMethod_adaptor, + moqConverterer_AssertMethod_params, + moqConverterer_AssertMethod_paramsKey, + moqConverterer_AssertMethod_results, + ] } // moqConverterer_AssertMethod_anyParams isolates the any params functions of // the Converterer type type moqConverterer_AssertMethod_anyParams struct { - recorder *moqConverterer_AssertMethod_fnRecorder + recorder *moqConverterer_AssertMethod_recorder } // newMoqConverterer creates a new moq of the Converterer type func newMoqConverterer(scene *moq.Scene, config *moq.Config) *moqConverterer { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqConverterer_BaseDecls_adaptor{} + adaptor2 := &moqConverterer_MockStructs_adaptor{} + adaptor3 := &moqConverterer_MethodStructs_adaptor{} + adaptor4 := &moqConverterer_NewFunc_adaptor{} + adaptor5 := &moqConverterer_IsolationAccessor_adaptor{} + adaptor6 := &moqConverterer_FuncClosure_adaptor{} + adaptor7 := &moqConverterer_MockMethod_adaptor{} + adaptor8 := &moqConverterer_RecorderMethods_adaptor{} + adaptor9 := &moqConverterer_ResetMethod_adaptor{} + adaptor10 := &moqConverterer_AssertMethod_adaptor{} m := &moqConverterer{ - scene: scene, - config: *config, - moq: &moqConverterer_mock{}, - - runtime: struct { - parameterIndexing struct { - BaseDecls struct{} - IsolationStruct struct { - suffix moq.ParamIndexing - } - MethodStructs struct { - fn moq.ParamIndexing - } - NewFunc struct{} - IsolationAccessor struct { - suffix moq.ParamIndexing - fnName moq.ParamIndexing - } - FuncClosure struct { - fn moq.ParamIndexing - } - MockMethod struct { - fn moq.ParamIndexing - } - RecorderMethods struct { - fn moq.ParamIndexing - } - ResetMethod struct{} - AssertMethod struct{} - } - }{parameterIndexing: struct { - BaseDecls struct{} - IsolationStruct struct { - suffix moq.ParamIndexing - } - MethodStructs struct { - fn moq.ParamIndexing - } - NewFunc struct{} - IsolationAccessor struct { - suffix moq.ParamIndexing - fnName moq.ParamIndexing - } - FuncClosure struct { - fn moq.ParamIndexing - } - MockMethod struct { - fn moq.ParamIndexing - } - RecorderMethods struct { - fn moq.ParamIndexing - } - ResetMethod struct{} - AssertMethod struct{} + moq: &moqConverterer_mock{}, + + moq_BaseDecls: impl.NewMoq[ + *moqConverterer_BaseDecls_adaptor, + moqConverterer_BaseDecls_params, + moqConverterer_BaseDecls_paramsKey, + moqConverterer_BaseDecls_results, + ](scene, adaptor1, config), + moq_MockStructs: impl.NewMoq[ + *moqConverterer_MockStructs_adaptor, + moqConverterer_MockStructs_params, + moqConverterer_MockStructs_paramsKey, + moqConverterer_MockStructs_results, + ](scene, adaptor2, config), + moq_MethodStructs: impl.NewMoq[ + *moqConverterer_MethodStructs_adaptor, + moqConverterer_MethodStructs_params, + moqConverterer_MethodStructs_paramsKey, + moqConverterer_MethodStructs_results, + ](scene, adaptor3, config), + moq_NewFunc: impl.NewMoq[ + *moqConverterer_NewFunc_adaptor, + moqConverterer_NewFunc_params, + moqConverterer_NewFunc_paramsKey, + moqConverterer_NewFunc_results, + ](scene, adaptor4, config), + moq_IsolationAccessor: impl.NewMoq[ + *moqConverterer_IsolationAccessor_adaptor, + moqConverterer_IsolationAccessor_params, + moqConverterer_IsolationAccessor_paramsKey, + moqConverterer_IsolationAccessor_results, + ](scene, adaptor5, config), + moq_FuncClosure: impl.NewMoq[ + *moqConverterer_FuncClosure_adaptor, + moqConverterer_FuncClosure_params, + moqConverterer_FuncClosure_paramsKey, + moqConverterer_FuncClosure_results, + ](scene, adaptor6, config), + moq_MockMethod: impl.NewMoq[ + *moqConverterer_MockMethod_adaptor, + moqConverterer_MockMethod_params, + moqConverterer_MockMethod_paramsKey, + moqConverterer_MockMethod_results, + ](scene, adaptor7, config), + moq_RecorderMethods: impl.NewMoq[ + *moqConverterer_RecorderMethods_adaptor, + moqConverterer_RecorderMethods_params, + moqConverterer_RecorderMethods_paramsKey, + moqConverterer_RecorderMethods_results, + ](scene, adaptor8, config), + moq_ResetMethod: impl.NewMoq[ + *moqConverterer_ResetMethod_adaptor, + moqConverterer_ResetMethod_params, + moqConverterer_ResetMethod_paramsKey, + moqConverterer_ResetMethod_results, + ](scene, adaptor9, config), + moq_AssertMethod: impl.NewMoq[ + *moqConverterer_AssertMethod_adaptor, + moqConverterer_AssertMethod_params, + moqConverterer_AssertMethod_paramsKey, + moqConverterer_AssertMethod_results, + ](scene, adaptor10, config), + + runtime: moqConverterer_runtime{parameterIndexing: struct { + BaseDecls moqConverterer_BaseDecls_paramIndexing + MockStructs moqConverterer_MockStructs_paramIndexing + MethodStructs moqConverterer_MethodStructs_paramIndexing + NewFunc moqConverterer_NewFunc_paramIndexing + IsolationAccessor moqConverterer_IsolationAccessor_paramIndexing + FuncClosure moqConverterer_FuncClosure_paramIndexing + MockMethod moqConverterer_MockMethod_paramIndexing + RecorderMethods moqConverterer_RecorderMethods_paramIndexing + ResetMethod moqConverterer_ResetMethod_paramIndexing + AssertMethod moqConverterer_AssertMethod_paramIndexing }{ - BaseDecls: struct{}{}, - IsolationStruct: struct { - suffix moq.ParamIndexing - }{ - suffix: moq.ParamIndexByValue, - }, - MethodStructs: struct { - fn moq.ParamIndexing - }{ + BaseDecls: moqConverterer_BaseDecls_paramIndexing{}, + MockStructs: moqConverterer_MockStructs_paramIndexing{}, + MethodStructs: moqConverterer_MethodStructs_paramIndexing{ fn: moq.ParamIndexByHash, }, - NewFunc: struct{}{}, - IsolationAccessor: struct { - suffix moq.ParamIndexing - fnName moq.ParamIndexing - }{ + NewFunc: moqConverterer_NewFunc_paramIndexing{}, + IsolationAccessor: moqConverterer_IsolationAccessor_paramIndexing{ suffix: moq.ParamIndexByValue, fnName: moq.ParamIndexByValue, }, - FuncClosure: struct { - fn moq.ParamIndexing - }{ + FuncClosure: moqConverterer_FuncClosure_paramIndexing{ fn: moq.ParamIndexByHash, }, - MockMethod: struct { - fn moq.ParamIndexing - }{ + MockMethod: moqConverterer_MockMethod_paramIndexing{ fn: moq.ParamIndexByHash, }, - RecorderMethods: struct { - fn moq.ParamIndexing - }{ + RecorderMethods: moqConverterer_RecorderMethods_paramIndexing{ fn: moq.ParamIndexByHash, }, - ResetMethod: struct{}{}, - AssertMethod: struct{}{}, + ResetMethod: moqConverterer_ResetMethod_paramIndexing{}, + AssertMethod: moqConverterer_AssertMethod_paramIndexing{}, }}, } m.moq.moq = m + adaptor1.moq = m + adaptor2.moq = m + adaptor3.moq = m + adaptor4.moq = m + adaptor5.moq = m + adaptor6.moq = m + adaptor7.moq = m + adaptor8.moq = m + adaptor9.moq = m + adaptor10.moq = m + scene.AddMoq(m) return m } @@ -770,537 +768,145 @@ 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, err error) { - m.moq.scene.T.Helper() +func (m *moqConverterer_mock) BaseDecls() ([]dst.Decl, error) { + m.moq.moq_BaseDecls.Scene.T.Helper() params := moqConverterer_BaseDecls_params{} - var results *moqConverterer_BaseDecls_results - for _, resultsByParams := range m.moq.resultsByParams_BaseDecls { - paramsKey := m.moq.paramsKey_BaseDecls(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_BaseDecls(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_BaseDecls(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_BaseDecls(params)) - } - } - - if result.doFn != nil { - result.doFn() - } - if result.values != nil { - baseDecls = result.values.baseDecls - err = result.values.err + var result1 []dst.Decl + var result2 error + if result := m.moq.moq_BaseDecls.Function(params); result != nil { + result1 = result.baseDecls + result2 = result.err } - if result.doReturnFn != nil { - baseDecls, err = result.doReturnFn() - } - return + return result1, result2 } -func (m *moqConverterer_mock) IsolationStruct(suffix string) (structDecl *dst.GenDecl, err error) { - m.moq.scene.T.Helper() - params := moqConverterer_IsolationStruct_params{ - suffix: suffix, - } - var results *moqConverterer_IsolationStruct_results - for _, resultsByParams := range m.moq.resultsByParams_IsolationStruct { - paramsKey := m.moq.paramsKey_IsolationStruct(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_IsolationStruct(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_IsolationStruct(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_IsolationStruct(params)) - } - } - - if result.doFn != nil { - result.doFn(suffix) - } +func (m *moqConverterer_mock) MockStructs() ([]dst.Decl, error) { + m.moq.moq_MockStructs.Scene.T.Helper() + params := moqConverterer_MockStructs_params{} - if result.values != nil { - structDecl = result.values.structDecl - err = result.values.err + var result1 []dst.Decl + var result2 error + if result := m.moq.moq_MockStructs.Function(params); result != nil { + result1 = result.structDecls + result2 = result.err } - if result.doReturnFn != nil { - structDecl, err = result.doReturnFn(suffix) - } - return + return result1, result2 } -func (m *moqConverterer_mock) MethodStructs(fn generator.Func) (structDecls []dst.Decl, err error) { - m.moq.scene.T.Helper() +func (m *moqConverterer_mock) MethodStructs(fn generator.Func) ([]dst.Decl, error) { + m.moq.moq_MethodStructs.Scene.T.Helper() params := moqConverterer_MethodStructs_params{ fn: fn, } - var results *moqConverterer_MethodStructs_results - for _, resultsByParams := range m.moq.resultsByParams_MethodStructs { - paramsKey := m.moq.paramsKey_MethodStructs(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_MethodStructs(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_MethodStructs(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_MethodStructs(params)) - } - } - - if result.doFn != nil { - result.doFn(fn) - } - if result.values != nil { - structDecls = result.values.structDecls - err = result.values.err - } - if result.doReturnFn != nil { - structDecls, err = result.doReturnFn(fn) + var result1 []dst.Decl + var result2 error + if result := m.moq.moq_MethodStructs.Function(params); result != nil { + result1 = result.structDecls + result2 = result.err } - return + return result1, result2 } -func (m *moqConverterer_mock) NewFunc() (funcDecl *dst.FuncDecl, err error) { - m.moq.scene.T.Helper() +func (m *moqConverterer_mock) NewFunc() (*dst.FuncDecl, error) { + m.moq.moq_NewFunc.Scene.T.Helper() params := moqConverterer_NewFunc_params{} - var results *moqConverterer_NewFunc_results - for _, resultsByParams := range m.moq.resultsByParams_NewFunc { - paramsKey := m.moq.paramsKey_NewFunc(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_NewFunc(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_NewFunc(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_NewFunc(params)) - } - } - - if result.doFn != nil { - result.doFn() + var result1 *dst.FuncDecl + var result2 error + if result := m.moq.moq_NewFunc.Function(params); result != nil { + result1 = result.funcDecl + result2 = result.err } - - if result.values != nil { - funcDecl = result.values.funcDecl - err = result.values.err - } - if result.doReturnFn != nil { - funcDecl, err = result.doReturnFn() - } - return + return result1, result2 } -func (m *moqConverterer_mock) IsolationAccessor(suffix, fnName string) (funcDecl *dst.FuncDecl, err error) { - m.moq.scene.T.Helper() +func (m *moqConverterer_mock) IsolationAccessor(suffix, fnName string) (*dst.FuncDecl, error) { + m.moq.moq_IsolationAccessor.Scene.T.Helper() params := moqConverterer_IsolationAccessor_params{ suffix: suffix, fnName: fnName, } - var results *moqConverterer_IsolationAccessor_results - for _, resultsByParams := range m.moq.resultsByParams_IsolationAccessor { - paramsKey := m.moq.paramsKey_IsolationAccessor(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_IsolationAccessor(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_IsolationAccessor(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_IsolationAccessor(params)) - } - } - - if result.doFn != nil { - result.doFn(suffix, fnName) - } - if result.values != nil { - funcDecl = result.values.funcDecl - err = result.values.err + var result1 *dst.FuncDecl + var result2 error + if result := m.moq.moq_IsolationAccessor.Function(params); result != nil { + result1 = result.funcDecl + result2 = result.err } - if result.doReturnFn != nil { - funcDecl, err = result.doReturnFn(suffix, fnName) - } - return + return result1, result2 } -func (m *moqConverterer_mock) FuncClosure(fn generator.Func) (funcDecl *dst.FuncDecl, err error) { - m.moq.scene.T.Helper() +func (m *moqConverterer_mock) FuncClosure(fn generator.Func) (*dst.FuncDecl, error) { + m.moq.moq_FuncClosure.Scene.T.Helper() params := moqConverterer_FuncClosure_params{ fn: fn, } - var results *moqConverterer_FuncClosure_results - for _, resultsByParams := range m.moq.resultsByParams_FuncClosure { - paramsKey := m.moq.paramsKey_FuncClosure(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_FuncClosure(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_FuncClosure(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_FuncClosure(params)) - } - } - - if result.doFn != nil { - result.doFn(fn) - } - if result.values != nil { - funcDecl = result.values.funcDecl - err = result.values.err - } - if result.doReturnFn != nil { - funcDecl, err = result.doReturnFn(fn) + var result1 *dst.FuncDecl + var result2 error + if result := m.moq.moq_FuncClosure.Function(params); result != nil { + result1 = result.funcDecl + result2 = result.err } - return + return result1, result2 } -func (m *moqConverterer_mock) MockMethod(fn generator.Func) (funcDecl *dst.FuncDecl, err error) { - m.moq.scene.T.Helper() +func (m *moqConverterer_mock) MockMethod(fn generator.Func) (*dst.FuncDecl, error) { + m.moq.moq_MockMethod.Scene.T.Helper() params := moqConverterer_MockMethod_params{ fn: fn, } - var results *moqConverterer_MockMethod_results - for _, resultsByParams := range m.moq.resultsByParams_MockMethod { - paramsKey := m.moq.paramsKey_MockMethod(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_MockMethod(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_MockMethod(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_MockMethod(params)) - } - } - - if result.doFn != nil { - result.doFn(fn) - } - - if result.values != nil { - funcDecl = result.values.funcDecl - err = result.values.err - } - if result.doReturnFn != nil { - funcDecl, err = result.doReturnFn(fn) + var result1 *dst.FuncDecl + var result2 error + if result := m.moq.moq_MockMethod.Function(params); result != nil { + result1 = result.funcDecl + result2 = result.err } - return + return result1, result2 } -func (m *moqConverterer_mock) RecorderMethods(fn generator.Func) (funcDecls []dst.Decl, err error) { - m.moq.scene.T.Helper() +func (m *moqConverterer_mock) RecorderMethods(fn generator.Func) ([]dst.Decl, error) { + m.moq.moq_RecorderMethods.Scene.T.Helper() params := moqConverterer_RecorderMethods_params{ fn: fn, } - var results *moqConverterer_RecorderMethods_results - for _, resultsByParams := range m.moq.resultsByParams_RecorderMethods { - paramsKey := m.moq.paramsKey_RecorderMethods(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_RecorderMethods(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_RecorderMethods(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_RecorderMethods(params)) - } - } - - if result.doFn != nil { - result.doFn(fn) - } - if result.values != nil { - funcDecls = result.values.funcDecls - err = result.values.err + var result1 []dst.Decl + var result2 error + if result := m.moq.moq_RecorderMethods.Function(params); result != nil { + result1 = result.funcDecls + result2 = result.err } - if result.doReturnFn != nil { - funcDecls, err = result.doReturnFn(fn) - } - return + return result1, result2 } -func (m *moqConverterer_mock) ResetMethod() (funcDecl *dst.FuncDecl, err error) { - m.moq.scene.T.Helper() +func (m *moqConverterer_mock) ResetMethod() (*dst.FuncDecl, error) { + m.moq.moq_ResetMethod.Scene.T.Helper() params := moqConverterer_ResetMethod_params{} - var results *moqConverterer_ResetMethod_results - for _, resultsByParams := range m.moq.resultsByParams_ResetMethod { - paramsKey := m.moq.paramsKey_ResetMethod(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_ResetMethod(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_ResetMethod(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_ResetMethod(params)) - } - } - - if result.doFn != nil { - result.doFn() - } - if result.values != nil { - funcDecl = result.values.funcDecl - err = result.values.err - } - if result.doReturnFn != nil { - funcDecl, err = result.doReturnFn() + var result1 *dst.FuncDecl + var result2 error + if result := m.moq.moq_ResetMethod.Function(params); result != nil { + result1 = result.funcDecl + result2 = result.err } - return + return result1, result2 } -func (m *moqConverterer_mock) AssertMethod() (funcDecl *dst.FuncDecl, err error) { - m.moq.scene.T.Helper() +func (m *moqConverterer_mock) AssertMethod() (*dst.FuncDecl, error) { + m.moq.moq_AssertMethod.Scene.T.Helper() params := moqConverterer_AssertMethod_params{} - var results *moqConverterer_AssertMethod_results - for _, resultsByParams := range m.moq.resultsByParams_AssertMethod { - paramsKey := m.moq.paramsKey_AssertMethod(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_AssertMethod(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_AssertMethod(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_AssertMethod(params)) - } - } - if result.doFn != nil { - result.doFn() + var result1 *dst.FuncDecl + var result2 error + if result := m.moq.moq_AssertMethod.Function(params); result != nil { + result1 = result.funcDecl + result2 = result.err } - - if result.values != nil { - funcDecl = result.values.funcDecl - err = result.values.err - } - if result.doReturnFn != nil { - funcDecl, err = result.doReturnFn() - } - return + return result1, result2 } // onCall returns the recorder implementation of the Converterer type @@ -1310,600 +916,252 @@ func (m *moqConverterer) onCall() *moqConverterer_recorder { } } -func (m *moqConverterer_recorder) BaseDecls() *moqConverterer_BaseDecls_fnRecorder { - return &moqConverterer_BaseDecls_fnRecorder{ - params: moqConverterer_BaseDecls_params{}, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, +func (m *moqConverterer_recorder) BaseDecls() *moqConverterer_BaseDecls_recorder { + return &moqConverterer_BaseDecls_recorder{ + recorder: m.moq.moq_BaseDecls.OnCall(moqConverterer_BaseDecls_params{}), } } -func (r *moqConverterer_BaseDecls_fnRecorder) any() *moqConverterer_BaseDecls_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_BaseDecls(r.params)) +func (r *moqConverterer_BaseDecls_recorder) any() *moqConverterer_BaseDecls_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqConverterer_BaseDecls_anyParams{recorder: r} } -func (r *moqConverterer_BaseDecls_fnRecorder) seq() *moqConverterer_BaseDecls_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_BaseDecls(r.params)) +func (r *moqConverterer_BaseDecls_recorder) seq() *moqConverterer_BaseDecls_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqConverterer_BaseDecls_fnRecorder) noSeq() *moqConverterer_BaseDecls_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_BaseDecls(r.params)) +func (r *moqConverterer_BaseDecls_recorder) noSeq() *moqConverterer_BaseDecls_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqConverterer_BaseDecls_fnRecorder) returnResults(baseDecls []dst.Decl, err error) *moqConverterer_BaseDecls_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 { - baseDecls []dst.Decl - err error - } - sequence uint32 - doFn moqConverterer_BaseDecls_doFn - doReturnFn moqConverterer_BaseDecls_doReturnFn - }{ - values: &struct { - baseDecls []dst.Decl - err error - }{ - baseDecls: baseDecls, - err: err, - }, - sequence: sequence, +func (r *moqConverterer_BaseDecls_recorder) returnResults(baseDecls []dst.Decl, err error) *moqConverterer_BaseDecls_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqConverterer_BaseDecls_results{ + baseDecls: baseDecls, + err: err, }) return r } -func (r *moqConverterer_BaseDecls_fnRecorder) andDo(fn moqConverterer_BaseDecls_doFn) *moqConverterer_BaseDecls_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqConverterer_BaseDecls_recorder) andDo(fn moqConverterer_BaseDecls_doFn) *moqConverterer_BaseDecls_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqConverterer_BaseDecls_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqConverterer_BaseDecls_fnRecorder) doReturnResults(fn moqConverterer_BaseDecls_doReturnFn) *moqConverterer_BaseDecls_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 { - baseDecls []dst.Decl - err error +func (r *moqConverterer_BaseDecls_recorder) doReturnResults(fn moqConverterer_BaseDecls_doReturnFn) *moqConverterer_BaseDecls_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqConverterer_BaseDecls_params) *moqConverterer_BaseDecls_results { + baseDecls, err := fn() + return &moqConverterer_BaseDecls_results{ + baseDecls: baseDecls, + err: err, } - sequence uint32 - doFn moqConverterer_BaseDecls_doFn - doReturnFn moqConverterer_BaseDecls_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqConverterer_BaseDecls_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 *moqConverterer_BaseDecls_resultsByParams - for n, res := range r.moq.resultsByParams_BaseDecls { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqConverterer_BaseDecls_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqConverterer_BaseDecls_paramsKey]*moqConverterer_BaseDecls_results{}, - } - r.moq.resultsByParams_BaseDecls = append(r.moq.resultsByParams_BaseDecls, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_BaseDecls) { - copy(r.moq.resultsByParams_BaseDecls[insertAt+1:], r.moq.resultsByParams_BaseDecls[insertAt:0]) - r.moq.resultsByParams_BaseDecls[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_BaseDecls(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqConverterer_BaseDecls_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 *moqConverterer_BaseDecls_fnRecorder) repeat(repeaters ...moq.Repeater) *moqConverterer_BaseDecls_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqConverterer_BaseDecls_recorder) repeat(repeaters ...moq.Repeater) *moqConverterer_BaseDecls_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - baseDecls []dst.Decl - err error - } - sequence uint32 - doFn moqConverterer_BaseDecls_doFn - doReturnFn moqConverterer_BaseDecls_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqConverterer) prettyParams_BaseDecls(params moqConverterer_BaseDecls_params) string { +func (*moqConverterer_BaseDecls_adaptor) PrettyParams(params moqConverterer_BaseDecls_params) string { return fmt.Sprintf("BaseDecls()") } -func (m *moqConverterer) paramsKey_BaseDecls(params moqConverterer_BaseDecls_params, anyParams uint64) moqConverterer_BaseDecls_paramsKey { - m.scene.T.Helper() +func (a *moqConverterer_BaseDecls_adaptor) ParamsKey(params moqConverterer_BaseDecls_params, anyParams uint64) moqConverterer_BaseDecls_paramsKey { + a.moq.moq_BaseDecls.Scene.T.Helper() return moqConverterer_BaseDecls_paramsKey{ params: struct{}{}, hashes: struct{}{}, } } -func (m *moqConverterer_recorder) IsolationStruct(suffix string) *moqConverterer_IsolationStruct_fnRecorder { - return &moqConverterer_IsolationStruct_fnRecorder{ - params: moqConverterer_IsolationStruct_params{ - suffix: suffix, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, +func (m *moqConverterer_recorder) MockStructs() *moqConverterer_MockStructs_recorder { + return &moqConverterer_MockStructs_recorder{ + recorder: m.moq.moq_MockStructs.OnCall(moqConverterer_MockStructs_params{}), } } -func (r *moqConverterer_IsolationStruct_fnRecorder) any() *moqConverterer_IsolationStruct_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_IsolationStruct(r.params)) +func (r *moqConverterer_MockStructs_recorder) any() *moqConverterer_MockStructs_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } - return &moqConverterer_IsolationStruct_anyParams{recorder: r} + return &moqConverterer_MockStructs_anyParams{recorder: r} } -func (a *moqConverterer_IsolationStruct_anyParams) suffix() *moqConverterer_IsolationStruct_fnRecorder { - a.recorder.anyParams |= 1 << 0 - return a.recorder -} - -func (r *moqConverterer_IsolationStruct_fnRecorder) seq() *moqConverterer_IsolationStruct_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_IsolationStruct(r.params)) +func (r *moqConverterer_MockStructs_recorder) seq() *moqConverterer_MockStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqConverterer_IsolationStruct_fnRecorder) noSeq() *moqConverterer_IsolationStruct_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_IsolationStruct(r.params)) +func (r *moqConverterer_MockStructs_recorder) noSeq() *moqConverterer_MockStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqConverterer_IsolationStruct_fnRecorder) returnResults(structDecl *dst.GenDecl, err error) *moqConverterer_IsolationStruct_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 { - structDecl *dst.GenDecl - err error - } - sequence uint32 - doFn moqConverterer_IsolationStruct_doFn - doReturnFn moqConverterer_IsolationStruct_doReturnFn - }{ - values: &struct { - structDecl *dst.GenDecl - err error - }{ - structDecl: structDecl, - err: err, - }, - sequence: sequence, +func (r *moqConverterer_MockStructs_recorder) returnResults(structDecls []dst.Decl, err error) *moqConverterer_MockStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqConverterer_MockStructs_results{ + structDecls: structDecls, + err: err, }) return r } -func (r *moqConverterer_IsolationStruct_fnRecorder) andDo(fn moqConverterer_IsolationStruct_doFn) *moqConverterer_IsolationStruct_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqConverterer_MockStructs_recorder) andDo(fn moqConverterer_MockStructs_doFn) *moqConverterer_MockStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqConverterer_MockStructs_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqConverterer_IsolationStruct_fnRecorder) doReturnResults(fn moqConverterer_IsolationStruct_doReturnFn) *moqConverterer_IsolationStruct_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 { - structDecl *dst.GenDecl - err error +func (r *moqConverterer_MockStructs_recorder) doReturnResults(fn moqConverterer_MockStructs_doReturnFn) *moqConverterer_MockStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqConverterer_MockStructs_params) *moqConverterer_MockStructs_results { + structDecls, err := fn() + return &moqConverterer_MockStructs_results{ + structDecls: structDecls, + err: err, } - sequence uint32 - doFn moqConverterer_IsolationStruct_doFn - doReturnFn moqConverterer_IsolationStruct_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqConverterer_IsolationStruct_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 *moqConverterer_IsolationStruct_resultsByParams - for n, res := range r.moq.resultsByParams_IsolationStruct { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqConverterer_IsolationStruct_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqConverterer_IsolationStruct_paramsKey]*moqConverterer_IsolationStruct_results{}, - } - r.moq.resultsByParams_IsolationStruct = append(r.moq.resultsByParams_IsolationStruct, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_IsolationStruct) { - copy(r.moq.resultsByParams_IsolationStruct[insertAt+1:], r.moq.resultsByParams_IsolationStruct[insertAt:0]) - r.moq.resultsByParams_IsolationStruct[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_IsolationStruct(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqConverterer_IsolationStruct_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 *moqConverterer_IsolationStruct_fnRecorder) repeat(repeaters ...moq.Repeater) *moqConverterer_IsolationStruct_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqConverterer_MockStructs_recorder) repeat(repeaters ...moq.Repeater) *moqConverterer_MockStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - structDecl *dst.GenDecl - err error - } - sequence uint32 - doFn moqConverterer_IsolationStruct_doFn - doReturnFn moqConverterer_IsolationStruct_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqConverterer) prettyParams_IsolationStruct(params moqConverterer_IsolationStruct_params) string { - return fmt.Sprintf("IsolationStruct(%#v)", params.suffix) +func (*moqConverterer_MockStructs_adaptor) PrettyParams(params moqConverterer_MockStructs_params) string { + return fmt.Sprintf("MockStructs()") } -func (m *moqConverterer) paramsKey_IsolationStruct(params moqConverterer_IsolationStruct_params, anyParams uint64) moqConverterer_IsolationStruct_paramsKey { - m.scene.T.Helper() - var suffixUsed string - var suffixUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.IsolationStruct.suffix == moq.ParamIndexByValue { - suffixUsed = params.suffix - } else { - suffixUsedHash = hash.DeepHash(params.suffix) - } - } - return moqConverterer_IsolationStruct_paramsKey{ - params: struct{ suffix string }{ - suffix: suffixUsed, - }, - hashes: struct{ suffix hash.Hash }{ - suffix: suffixUsedHash, - }, +func (a *moqConverterer_MockStructs_adaptor) ParamsKey(params moqConverterer_MockStructs_params, anyParams uint64) moqConverterer_MockStructs_paramsKey { + a.moq.moq_MockStructs.Scene.T.Helper() + return moqConverterer_MockStructs_paramsKey{ + params: struct{}{}, + hashes: struct{}{}, } } -func (m *moqConverterer_recorder) MethodStructs(fn generator.Func) *moqConverterer_MethodStructs_fnRecorder { - return &moqConverterer_MethodStructs_fnRecorder{ - params: moqConverterer_MethodStructs_params{ +func (m *moqConverterer_recorder) MethodStructs(fn generator.Func) *moqConverterer_MethodStructs_recorder { + return &moqConverterer_MethodStructs_recorder{ + recorder: m.moq.moq_MethodStructs.OnCall(moqConverterer_MethodStructs_params{ fn: fn, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqConverterer_MethodStructs_fnRecorder) any() *moqConverterer_MethodStructs_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_MethodStructs(r.params)) +func (r *moqConverterer_MethodStructs_recorder) any() *moqConverterer_MethodStructs_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqConverterer_MethodStructs_anyParams{recorder: r} } -func (a *moqConverterer_MethodStructs_anyParams) fn() *moqConverterer_MethodStructs_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqConverterer_MethodStructs_anyParams) fn() *moqConverterer_MethodStructs_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqConverterer_MethodStructs_fnRecorder) seq() *moqConverterer_MethodStructs_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_MethodStructs(r.params)) +func (r *moqConverterer_MethodStructs_recorder) seq() *moqConverterer_MethodStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqConverterer_MethodStructs_fnRecorder) noSeq() *moqConverterer_MethodStructs_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_MethodStructs(r.params)) +func (r *moqConverterer_MethodStructs_recorder) noSeq() *moqConverterer_MethodStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqConverterer_MethodStructs_fnRecorder) returnResults(structDecls []dst.Decl, err error) *moqConverterer_MethodStructs_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 { - structDecls []dst.Decl - err error - } - sequence uint32 - doFn moqConverterer_MethodStructs_doFn - doReturnFn moqConverterer_MethodStructs_doReturnFn - }{ - values: &struct { - structDecls []dst.Decl - err error - }{ - structDecls: structDecls, - err: err, - }, - sequence: sequence, +func (r *moqConverterer_MethodStructs_recorder) returnResults(structDecls []dst.Decl, err error) *moqConverterer_MethodStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqConverterer_MethodStructs_results{ + structDecls: structDecls, + err: err, }) return r } -func (r *moqConverterer_MethodStructs_fnRecorder) andDo(fn moqConverterer_MethodStructs_doFn) *moqConverterer_MethodStructs_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqConverterer_MethodStructs_recorder) andDo(fn moqConverterer_MethodStructs_doFn) *moqConverterer_MethodStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqConverterer_MethodStructs_params) { + fn(params.fn) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn - return r -} - -func (r *moqConverterer_MethodStructs_fnRecorder) doReturnResults(fn moqConverterer_MethodStructs_doReturnFn) *moqConverterer_MethodStructs_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 { - structDecls []dst.Decl - err error - } - sequence uint32 - doFn moqConverterer_MethodStructs_doFn - doReturnFn moqConverterer_MethodStructs_doReturnFn - }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqConverterer_MethodStructs_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 *moqConverterer_MethodStructs_resultsByParams - for n, res := range r.moq.resultsByParams_MethodStructs { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqConverterer_MethodStructs_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqConverterer_MethodStructs_paramsKey]*moqConverterer_MethodStructs_results{}, - } - r.moq.resultsByParams_MethodStructs = append(r.moq.resultsByParams_MethodStructs, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_MethodStructs) { - copy(r.moq.resultsByParams_MethodStructs[insertAt+1:], r.moq.resultsByParams_MethodStructs[insertAt:0]) - r.moq.resultsByParams_MethodStructs[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_MethodStructs(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqConverterer_MethodStructs_results{ - params: r.params, - results: nil, - index: 0, - repeat: &moq.RepeatVal{}, +func (r *moqConverterer_MethodStructs_recorder) doReturnResults(fn moqConverterer_MethodStructs_doReturnFn) *moqConverterer_MethodStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqConverterer_MethodStructs_params) *moqConverterer_MethodStructs_results { + structDecls, err := fn(params.fn) + return &moqConverterer_MethodStructs_results{ + structDecls: structDecls, + err: err, } - results.results[paramsKey] = r.results - } - - r.results.repeat.Increment(r.moq.scene.T) + }) + return r } -func (r *moqConverterer_MethodStructs_fnRecorder) repeat(repeaters ...moq.Repeater) *moqConverterer_MethodStructs_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqConverterer_MethodStructs_recorder) repeat(repeaters ...moq.Repeater) *moqConverterer_MethodStructs_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - structDecls []dst.Decl - err error - } - sequence uint32 - doFn moqConverterer_MethodStructs_doFn - doReturnFn moqConverterer_MethodStructs_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqConverterer) prettyParams_MethodStructs(params moqConverterer_MethodStructs_params) string { +func (*moqConverterer_MethodStructs_adaptor) PrettyParams(params moqConverterer_MethodStructs_params) string { return fmt.Sprintf("MethodStructs(%#v)", params.fn) } -func (m *moqConverterer) paramsKey_MethodStructs(params moqConverterer_MethodStructs_params, anyParams uint64) moqConverterer_MethodStructs_paramsKey { - m.scene.T.Helper() - var fnUsed generator.Func - var fnUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.MethodStructs.fn == moq.ParamIndexByValue { - fnUsed = params.fn - } else { - fnUsedHash = hash.DeepHash(params.fn) - } - } +func (a *moqConverterer_MethodStructs_adaptor) ParamsKey(params moqConverterer_MethodStructs_params, anyParams uint64) moqConverterer_MethodStructs_paramsKey { + a.moq.moq_MethodStructs.Scene.T.Helper() + fnUsed, fnUsedHash := impl.ParamKey( + params.fn, 1, a.moq.runtime.parameterIndexing.MethodStructs.fn, anyParams) return moqConverterer_MethodStructs_paramsKey{ params: struct{ fn generator.Func }{ fn: fnUsed, @@ -1914,407 +1172,179 @@ func (m *moqConverterer) paramsKey_MethodStructs(params moqConverterer_MethodStr } } -func (m *moqConverterer_recorder) NewFunc() *moqConverterer_NewFunc_fnRecorder { - return &moqConverterer_NewFunc_fnRecorder{ - params: moqConverterer_NewFunc_params{}, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, +func (m *moqConverterer_recorder) NewFunc() *moqConverterer_NewFunc_recorder { + return &moqConverterer_NewFunc_recorder{ + recorder: m.moq.moq_NewFunc.OnCall(moqConverterer_NewFunc_params{}), } } -func (r *moqConverterer_NewFunc_fnRecorder) any() *moqConverterer_NewFunc_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_NewFunc(r.params)) +func (r *moqConverterer_NewFunc_recorder) any() *moqConverterer_NewFunc_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqConverterer_NewFunc_anyParams{recorder: r} } -func (r *moqConverterer_NewFunc_fnRecorder) seq() *moqConverterer_NewFunc_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_NewFunc(r.params)) +func (r *moqConverterer_NewFunc_recorder) seq() *moqConverterer_NewFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqConverterer_NewFunc_fnRecorder) noSeq() *moqConverterer_NewFunc_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_NewFunc(r.params)) +func (r *moqConverterer_NewFunc_recorder) noSeq() *moqConverterer_NewFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqConverterer_NewFunc_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_NewFunc_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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_NewFunc_doFn - doReturnFn moqConverterer_NewFunc_doReturnFn - }{ - values: &struct { - funcDecl *dst.FuncDecl - err error - }{ - funcDecl: funcDecl, - err: err, - }, - sequence: sequence, +func (r *moqConverterer_NewFunc_recorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_NewFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqConverterer_NewFunc_results{ + funcDecl: funcDecl, + err: err, }) return r } -func (r *moqConverterer_NewFunc_fnRecorder) andDo(fn moqConverterer_NewFunc_doFn) *moqConverterer_NewFunc_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqConverterer_NewFunc_recorder) andDo(fn moqConverterer_NewFunc_doFn) *moqConverterer_NewFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqConverterer_NewFunc_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqConverterer_NewFunc_fnRecorder) doReturnResults(fn moqConverterer_NewFunc_doReturnFn) *moqConverterer_NewFunc_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 { - funcDecl *dst.FuncDecl - err error +func (r *moqConverterer_NewFunc_recorder) doReturnResults(fn moqConverterer_NewFunc_doReturnFn) *moqConverterer_NewFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqConverterer_NewFunc_params) *moqConverterer_NewFunc_results { + funcDecl, err := fn() + return &moqConverterer_NewFunc_results{ + funcDecl: funcDecl, + err: err, } - sequence uint32 - doFn moqConverterer_NewFunc_doFn - doReturnFn moqConverterer_NewFunc_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqConverterer_NewFunc_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 *moqConverterer_NewFunc_resultsByParams - for n, res := range r.moq.resultsByParams_NewFunc { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqConverterer_NewFunc_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqConverterer_NewFunc_paramsKey]*moqConverterer_NewFunc_results{}, - } - r.moq.resultsByParams_NewFunc = append(r.moq.resultsByParams_NewFunc, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_NewFunc) { - copy(r.moq.resultsByParams_NewFunc[insertAt+1:], r.moq.resultsByParams_NewFunc[insertAt:0]) - r.moq.resultsByParams_NewFunc[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_NewFunc(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqConverterer_NewFunc_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 *moqConverterer_NewFunc_fnRecorder) repeat(repeaters ...moq.Repeater) *moqConverterer_NewFunc_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqConverterer_NewFunc_recorder) repeat(repeaters ...moq.Repeater) *moqConverterer_NewFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_NewFunc_doFn - doReturnFn moqConverterer_NewFunc_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqConverterer) prettyParams_NewFunc(params moqConverterer_NewFunc_params) string { +func (*moqConverterer_NewFunc_adaptor) PrettyParams(params moqConverterer_NewFunc_params) string { return fmt.Sprintf("NewFunc()") } -func (m *moqConverterer) paramsKey_NewFunc(params moqConverterer_NewFunc_params, anyParams uint64) moqConverterer_NewFunc_paramsKey { - m.scene.T.Helper() +func (a *moqConverterer_NewFunc_adaptor) ParamsKey(params moqConverterer_NewFunc_params, anyParams uint64) moqConverterer_NewFunc_paramsKey { + a.moq.moq_NewFunc.Scene.T.Helper() return moqConverterer_NewFunc_paramsKey{ params: struct{}{}, hashes: struct{}{}, } } -func (m *moqConverterer_recorder) IsolationAccessor(suffix, fnName string) *moqConverterer_IsolationAccessor_fnRecorder { - return &moqConverterer_IsolationAccessor_fnRecorder{ - params: moqConverterer_IsolationAccessor_params{ +func (m *moqConverterer_recorder) IsolationAccessor(suffix, fnName string) *moqConverterer_IsolationAccessor_recorder { + return &moqConverterer_IsolationAccessor_recorder{ + recorder: m.moq.moq_IsolationAccessor.OnCall(moqConverterer_IsolationAccessor_params{ suffix: suffix, fnName: fnName, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqConverterer_IsolationAccessor_fnRecorder) any() *moqConverterer_IsolationAccessor_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_IsolationAccessor(r.params)) +func (r *moqConverterer_IsolationAccessor_recorder) any() *moqConverterer_IsolationAccessor_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqConverterer_IsolationAccessor_anyParams{recorder: r} } -func (a *moqConverterer_IsolationAccessor_anyParams) suffix() *moqConverterer_IsolationAccessor_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqConverterer_IsolationAccessor_anyParams) suffix() *moqConverterer_IsolationAccessor_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqConverterer_IsolationAccessor_anyParams) fnName() *moqConverterer_IsolationAccessor_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqConverterer_IsolationAccessor_anyParams) fnName() *moqConverterer_IsolationAccessor_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqConverterer_IsolationAccessor_fnRecorder) seq() *moqConverterer_IsolationAccessor_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_IsolationAccessor(r.params)) +func (r *moqConverterer_IsolationAccessor_recorder) seq() *moqConverterer_IsolationAccessor_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqConverterer_IsolationAccessor_fnRecorder) noSeq() *moqConverterer_IsolationAccessor_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_IsolationAccessor(r.params)) +func (r *moqConverterer_IsolationAccessor_recorder) noSeq() *moqConverterer_IsolationAccessor_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqConverterer_IsolationAccessor_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_IsolationAccessor_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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_IsolationAccessor_doFn - doReturnFn moqConverterer_IsolationAccessor_doReturnFn - }{ - values: &struct { - funcDecl *dst.FuncDecl - err error - }{ - funcDecl: funcDecl, - err: err, - }, - sequence: sequence, +func (r *moqConverterer_IsolationAccessor_recorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_IsolationAccessor_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqConverterer_IsolationAccessor_results{ + funcDecl: funcDecl, + err: err, }) return r } -func (r *moqConverterer_IsolationAccessor_fnRecorder) andDo(fn moqConverterer_IsolationAccessor_doFn) *moqConverterer_IsolationAccessor_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqConverterer_IsolationAccessor_recorder) andDo(fn moqConverterer_IsolationAccessor_doFn) *moqConverterer_IsolationAccessor_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqConverterer_IsolationAccessor_params) { + fn(params.suffix, params.fnName) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqConverterer_IsolationAccessor_fnRecorder) doReturnResults(fn moqConverterer_IsolationAccessor_doReturnFn) *moqConverterer_IsolationAccessor_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 { - funcDecl *dst.FuncDecl - err error +func (r *moqConverterer_IsolationAccessor_recorder) doReturnResults(fn moqConverterer_IsolationAccessor_doReturnFn) *moqConverterer_IsolationAccessor_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqConverterer_IsolationAccessor_params) *moqConverterer_IsolationAccessor_results { + funcDecl, err := fn(params.suffix, params.fnName) + return &moqConverterer_IsolationAccessor_results{ + funcDecl: funcDecl, + err: err, } - sequence uint32 - doFn moqConverterer_IsolationAccessor_doFn - doReturnFn moqConverterer_IsolationAccessor_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqConverterer_IsolationAccessor_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 *moqConverterer_IsolationAccessor_resultsByParams - for n, res := range r.moq.resultsByParams_IsolationAccessor { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqConverterer_IsolationAccessor_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqConverterer_IsolationAccessor_paramsKey]*moqConverterer_IsolationAccessor_results{}, - } - r.moq.resultsByParams_IsolationAccessor = append(r.moq.resultsByParams_IsolationAccessor, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_IsolationAccessor) { - copy(r.moq.resultsByParams_IsolationAccessor[insertAt+1:], r.moq.resultsByParams_IsolationAccessor[insertAt:0]) - r.moq.resultsByParams_IsolationAccessor[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_IsolationAccessor(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqConverterer_IsolationAccessor_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 *moqConverterer_IsolationAccessor_fnRecorder) repeat(repeaters ...moq.Repeater) *moqConverterer_IsolationAccessor_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqConverterer_IsolationAccessor_recorder) repeat(repeaters ...moq.Repeater) *moqConverterer_IsolationAccessor_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_IsolationAccessor_doFn - doReturnFn moqConverterer_IsolationAccessor_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqConverterer) prettyParams_IsolationAccessor(params moqConverterer_IsolationAccessor_params) string { +func (*moqConverterer_IsolationAccessor_adaptor) PrettyParams(params moqConverterer_IsolationAccessor_params) string { return fmt.Sprintf("IsolationAccessor(%#v, %#v)", params.suffix, params.fnName) } -func (m *moqConverterer) paramsKey_IsolationAccessor(params moqConverterer_IsolationAccessor_params, anyParams uint64) moqConverterer_IsolationAccessor_paramsKey { - m.scene.T.Helper() - var suffixUsed string - var suffixUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.IsolationAccessor.suffix == moq.ParamIndexByValue { - suffixUsed = params.suffix - } else { - suffixUsedHash = hash.DeepHash(params.suffix) - } - } - var fnNameUsed string - var fnNameUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.IsolationAccessor.fnName == moq.ParamIndexByValue { - fnNameUsed = params.fnName - } else { - fnNameUsedHash = hash.DeepHash(params.fnName) - } - } +func (a *moqConverterer_IsolationAccessor_adaptor) ParamsKey(params moqConverterer_IsolationAccessor_params, anyParams uint64) moqConverterer_IsolationAccessor_paramsKey { + a.moq.moq_IsolationAccessor.Scene.T.Helper() + suffixUsed, suffixUsedHash := impl.ParamKey( + params.suffix, 1, a.moq.runtime.parameterIndexing.IsolationAccessor.suffix, anyParams) + fnNameUsed, fnNameUsedHash := impl.ParamKey( + params.fnName, 2, a.moq.runtime.parameterIndexing.IsolationAccessor.fnName, anyParams) return moqConverterer_IsolationAccessor_paramsKey{ params: struct{ suffix, fnName string }{ suffix: suffixUsed, @@ -2327,204 +1357,90 @@ func (m *moqConverterer) paramsKey_IsolationAccessor(params moqConverterer_Isola } } -func (m *moqConverterer_recorder) FuncClosure(fn generator.Func) *moqConverterer_FuncClosure_fnRecorder { - return &moqConverterer_FuncClosure_fnRecorder{ - params: moqConverterer_FuncClosure_params{ +func (m *moqConverterer_recorder) FuncClosure(fn generator.Func) *moqConverterer_FuncClosure_recorder { + return &moqConverterer_FuncClosure_recorder{ + recorder: m.moq.moq_FuncClosure.OnCall(moqConverterer_FuncClosure_params{ fn: fn, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqConverterer_FuncClosure_fnRecorder) any() *moqConverterer_FuncClosure_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_FuncClosure(r.params)) +func (r *moqConverterer_FuncClosure_recorder) any() *moqConverterer_FuncClosure_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqConverterer_FuncClosure_anyParams{recorder: r} } -func (a *moqConverterer_FuncClosure_anyParams) fn() *moqConverterer_FuncClosure_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqConverterer_FuncClosure_anyParams) fn() *moqConverterer_FuncClosure_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqConverterer_FuncClosure_fnRecorder) seq() *moqConverterer_FuncClosure_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_FuncClosure(r.params)) +func (r *moqConverterer_FuncClosure_recorder) seq() *moqConverterer_FuncClosure_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqConverterer_FuncClosure_fnRecorder) noSeq() *moqConverterer_FuncClosure_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_FuncClosure(r.params)) +func (r *moqConverterer_FuncClosure_recorder) noSeq() *moqConverterer_FuncClosure_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqConverterer_FuncClosure_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_FuncClosure_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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_FuncClosure_doFn - doReturnFn moqConverterer_FuncClosure_doReturnFn - }{ - values: &struct { - funcDecl *dst.FuncDecl - err error - }{ - funcDecl: funcDecl, - err: err, - }, - sequence: sequence, +func (r *moqConverterer_FuncClosure_recorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_FuncClosure_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqConverterer_FuncClosure_results{ + funcDecl: funcDecl, + err: err, }) return r } -func (r *moqConverterer_FuncClosure_fnRecorder) andDo(fn moqConverterer_FuncClosure_doFn) *moqConverterer_FuncClosure_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqConverterer_FuncClosure_recorder) andDo(fn moqConverterer_FuncClosure_doFn) *moqConverterer_FuncClosure_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqConverterer_FuncClosure_params) { + fn(params.fn) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqConverterer_FuncClosure_fnRecorder) doReturnResults(fn moqConverterer_FuncClosure_doReturnFn) *moqConverterer_FuncClosure_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 { - funcDecl *dst.FuncDecl - err error +func (r *moqConverterer_FuncClosure_recorder) doReturnResults(fn moqConverterer_FuncClosure_doReturnFn) *moqConverterer_FuncClosure_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqConverterer_FuncClosure_params) *moqConverterer_FuncClosure_results { + funcDecl, err := fn(params.fn) + return &moqConverterer_FuncClosure_results{ + funcDecl: funcDecl, + err: err, } - sequence uint32 - doFn moqConverterer_FuncClosure_doFn - doReturnFn moqConverterer_FuncClosure_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqConverterer_FuncClosure_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 *moqConverterer_FuncClosure_resultsByParams - for n, res := range r.moq.resultsByParams_FuncClosure { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqConverterer_FuncClosure_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqConverterer_FuncClosure_paramsKey]*moqConverterer_FuncClosure_results{}, - } - r.moq.resultsByParams_FuncClosure = append(r.moq.resultsByParams_FuncClosure, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_FuncClosure) { - copy(r.moq.resultsByParams_FuncClosure[insertAt+1:], r.moq.resultsByParams_FuncClosure[insertAt:0]) - r.moq.resultsByParams_FuncClosure[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_FuncClosure(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqConverterer_FuncClosure_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 *moqConverterer_FuncClosure_fnRecorder) repeat(repeaters ...moq.Repeater) *moqConverterer_FuncClosure_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqConverterer_FuncClosure_recorder) repeat(repeaters ...moq.Repeater) *moqConverterer_FuncClosure_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_FuncClosure_doFn - doReturnFn moqConverterer_FuncClosure_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqConverterer) prettyParams_FuncClosure(params moqConverterer_FuncClosure_params) string { +func (*moqConverterer_FuncClosure_adaptor) PrettyParams(params moqConverterer_FuncClosure_params) string { return fmt.Sprintf("FuncClosure(%#v)", params.fn) } -func (m *moqConverterer) paramsKey_FuncClosure(params moqConverterer_FuncClosure_params, anyParams uint64) moqConverterer_FuncClosure_paramsKey { - m.scene.T.Helper() - var fnUsed generator.Func - var fnUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.FuncClosure.fn == moq.ParamIndexByValue { - fnUsed = params.fn - } else { - fnUsedHash = hash.DeepHash(params.fn) - } - } +func (a *moqConverterer_FuncClosure_adaptor) ParamsKey(params moqConverterer_FuncClosure_params, anyParams uint64) moqConverterer_FuncClosure_paramsKey { + a.moq.moq_FuncClosure.Scene.T.Helper() + fnUsed, fnUsedHash := impl.ParamKey( + params.fn, 1, a.moq.runtime.parameterIndexing.FuncClosure.fn, anyParams) return moqConverterer_FuncClosure_paramsKey{ params: struct{ fn generator.Func }{ fn: fnUsed, @@ -2535,204 +1451,90 @@ func (m *moqConverterer) paramsKey_FuncClosure(params moqConverterer_FuncClosure } } -func (m *moqConverterer_recorder) MockMethod(fn generator.Func) *moqConverterer_MockMethod_fnRecorder { - return &moqConverterer_MockMethod_fnRecorder{ - params: moqConverterer_MockMethod_params{ +func (m *moqConverterer_recorder) MockMethod(fn generator.Func) *moqConverterer_MockMethod_recorder { + return &moqConverterer_MockMethod_recorder{ + recorder: m.moq.moq_MockMethod.OnCall(moqConverterer_MockMethod_params{ fn: fn, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqConverterer_MockMethod_fnRecorder) any() *moqConverterer_MockMethod_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_MockMethod(r.params)) +func (r *moqConverterer_MockMethod_recorder) any() *moqConverterer_MockMethod_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqConverterer_MockMethod_anyParams{recorder: r} } -func (a *moqConverterer_MockMethod_anyParams) fn() *moqConverterer_MockMethod_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqConverterer_MockMethod_anyParams) fn() *moqConverterer_MockMethod_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqConverterer_MockMethod_fnRecorder) seq() *moqConverterer_MockMethod_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_MockMethod(r.params)) +func (r *moqConverterer_MockMethod_recorder) seq() *moqConverterer_MockMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqConverterer_MockMethod_fnRecorder) noSeq() *moqConverterer_MockMethod_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_MockMethod(r.params)) +func (r *moqConverterer_MockMethod_recorder) noSeq() *moqConverterer_MockMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqConverterer_MockMethod_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_MockMethod_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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_MockMethod_doFn - doReturnFn moqConverterer_MockMethod_doReturnFn - }{ - values: &struct { - funcDecl *dst.FuncDecl - err error - }{ - funcDecl: funcDecl, - err: err, - }, - sequence: sequence, +func (r *moqConverterer_MockMethod_recorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_MockMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqConverterer_MockMethod_results{ + funcDecl: funcDecl, + err: err, }) return r } -func (r *moqConverterer_MockMethod_fnRecorder) andDo(fn moqConverterer_MockMethod_doFn) *moqConverterer_MockMethod_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqConverterer_MockMethod_recorder) andDo(fn moqConverterer_MockMethod_doFn) *moqConverterer_MockMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqConverterer_MockMethod_params) { + fn(params.fn) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqConverterer_MockMethod_fnRecorder) doReturnResults(fn moqConverterer_MockMethod_doReturnFn) *moqConverterer_MockMethod_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 { - funcDecl *dst.FuncDecl - err error +func (r *moqConverterer_MockMethod_recorder) doReturnResults(fn moqConverterer_MockMethod_doReturnFn) *moqConverterer_MockMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqConverterer_MockMethod_params) *moqConverterer_MockMethod_results { + funcDecl, err := fn(params.fn) + return &moqConverterer_MockMethod_results{ + funcDecl: funcDecl, + err: err, } - sequence uint32 - doFn moqConverterer_MockMethod_doFn - doReturnFn moqConverterer_MockMethod_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqConverterer_MockMethod_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 *moqConverterer_MockMethod_resultsByParams - for n, res := range r.moq.resultsByParams_MockMethod { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqConverterer_MockMethod_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqConverterer_MockMethod_paramsKey]*moqConverterer_MockMethod_results{}, - } - r.moq.resultsByParams_MockMethod = append(r.moq.resultsByParams_MockMethod, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_MockMethod) { - copy(r.moq.resultsByParams_MockMethod[insertAt+1:], r.moq.resultsByParams_MockMethod[insertAt:0]) - r.moq.resultsByParams_MockMethod[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_MockMethod(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqConverterer_MockMethod_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 *moqConverterer_MockMethod_fnRecorder) repeat(repeaters ...moq.Repeater) *moqConverterer_MockMethod_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqConverterer_MockMethod_recorder) repeat(repeaters ...moq.Repeater) *moqConverterer_MockMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_MockMethod_doFn - doReturnFn moqConverterer_MockMethod_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqConverterer) prettyParams_MockMethod(params moqConverterer_MockMethod_params) string { +func (*moqConverterer_MockMethod_adaptor) PrettyParams(params moqConverterer_MockMethod_params) string { return fmt.Sprintf("MockMethod(%#v)", params.fn) } -func (m *moqConverterer) paramsKey_MockMethod(params moqConverterer_MockMethod_params, anyParams uint64) moqConverterer_MockMethod_paramsKey { - m.scene.T.Helper() - var fnUsed generator.Func - var fnUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.MockMethod.fn == moq.ParamIndexByValue { - fnUsed = params.fn - } else { - fnUsedHash = hash.DeepHash(params.fn) - } - } +func (a *moqConverterer_MockMethod_adaptor) ParamsKey(params moqConverterer_MockMethod_params, anyParams uint64) moqConverterer_MockMethod_paramsKey { + a.moq.moq_MockMethod.Scene.T.Helper() + fnUsed, fnUsedHash := impl.ParamKey( + params.fn, 1, a.moq.runtime.parameterIndexing.MockMethod.fn, anyParams) return moqConverterer_MockMethod_paramsKey{ params: struct{ fn generator.Func }{ fn: fnUsed, @@ -2743,204 +1545,90 @@ func (m *moqConverterer) paramsKey_MockMethod(params moqConverterer_MockMethod_p } } -func (m *moqConverterer_recorder) RecorderMethods(fn generator.Func) *moqConverterer_RecorderMethods_fnRecorder { - return &moqConverterer_RecorderMethods_fnRecorder{ - params: moqConverterer_RecorderMethods_params{ +func (m *moqConverterer_recorder) RecorderMethods(fn generator.Func) *moqConverterer_RecorderMethods_recorder { + return &moqConverterer_RecorderMethods_recorder{ + recorder: m.moq.moq_RecorderMethods.OnCall(moqConverterer_RecorderMethods_params{ fn: fn, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqConverterer_RecorderMethods_fnRecorder) any() *moqConverterer_RecorderMethods_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_RecorderMethods(r.params)) +func (r *moqConverterer_RecorderMethods_recorder) any() *moqConverterer_RecorderMethods_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqConverterer_RecorderMethods_anyParams{recorder: r} } -func (a *moqConverterer_RecorderMethods_anyParams) fn() *moqConverterer_RecorderMethods_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqConverterer_RecorderMethods_anyParams) fn() *moqConverterer_RecorderMethods_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqConverterer_RecorderMethods_fnRecorder) seq() *moqConverterer_RecorderMethods_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_RecorderMethods(r.params)) +func (r *moqConverterer_RecorderMethods_recorder) seq() *moqConverterer_RecorderMethods_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqConverterer_RecorderMethods_fnRecorder) noSeq() *moqConverterer_RecorderMethods_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_RecorderMethods(r.params)) +func (r *moqConverterer_RecorderMethods_recorder) noSeq() *moqConverterer_RecorderMethods_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqConverterer_RecorderMethods_fnRecorder) returnResults(funcDecls []dst.Decl, err error) *moqConverterer_RecorderMethods_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 { - funcDecls []dst.Decl - err error - } - sequence uint32 - doFn moqConverterer_RecorderMethods_doFn - doReturnFn moqConverterer_RecorderMethods_doReturnFn - }{ - values: &struct { - funcDecls []dst.Decl - err error - }{ - funcDecls: funcDecls, - err: err, - }, - sequence: sequence, +func (r *moqConverterer_RecorderMethods_recorder) returnResults(funcDecls []dst.Decl, err error) *moqConverterer_RecorderMethods_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqConverterer_RecorderMethods_results{ + funcDecls: funcDecls, + err: err, }) return r } -func (r *moqConverterer_RecorderMethods_fnRecorder) andDo(fn moqConverterer_RecorderMethods_doFn) *moqConverterer_RecorderMethods_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqConverterer_RecorderMethods_recorder) andDo(fn moqConverterer_RecorderMethods_doFn) *moqConverterer_RecorderMethods_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqConverterer_RecorderMethods_params) { + fn(params.fn) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqConverterer_RecorderMethods_fnRecorder) doReturnResults(fn moqConverterer_RecorderMethods_doReturnFn) *moqConverterer_RecorderMethods_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 { - funcDecls []dst.Decl - err error +func (r *moqConverterer_RecorderMethods_recorder) doReturnResults(fn moqConverterer_RecorderMethods_doReturnFn) *moqConverterer_RecorderMethods_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqConverterer_RecorderMethods_params) *moqConverterer_RecorderMethods_results { + funcDecls, err := fn(params.fn) + return &moqConverterer_RecorderMethods_results{ + funcDecls: funcDecls, + err: err, } - sequence uint32 - doFn moqConverterer_RecorderMethods_doFn - doReturnFn moqConverterer_RecorderMethods_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqConverterer_RecorderMethods_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 *moqConverterer_RecorderMethods_resultsByParams - for n, res := range r.moq.resultsByParams_RecorderMethods { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqConverterer_RecorderMethods_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqConverterer_RecorderMethods_paramsKey]*moqConverterer_RecorderMethods_results{}, - } - r.moq.resultsByParams_RecorderMethods = append(r.moq.resultsByParams_RecorderMethods, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_RecorderMethods) { - copy(r.moq.resultsByParams_RecorderMethods[insertAt+1:], r.moq.resultsByParams_RecorderMethods[insertAt:0]) - r.moq.resultsByParams_RecorderMethods[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_RecorderMethods(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqConverterer_RecorderMethods_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 *moqConverterer_RecorderMethods_fnRecorder) repeat(repeaters ...moq.Repeater) *moqConverterer_RecorderMethods_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqConverterer_RecorderMethods_recorder) repeat(repeaters ...moq.Repeater) *moqConverterer_RecorderMethods_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - funcDecls []dst.Decl - err error - } - sequence uint32 - doFn moqConverterer_RecorderMethods_doFn - doReturnFn moqConverterer_RecorderMethods_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqConverterer) prettyParams_RecorderMethods(params moqConverterer_RecorderMethods_params) string { +func (*moqConverterer_RecorderMethods_adaptor) PrettyParams(params moqConverterer_RecorderMethods_params) string { return fmt.Sprintf("RecorderMethods(%#v)", params.fn) } -func (m *moqConverterer) paramsKey_RecorderMethods(params moqConverterer_RecorderMethods_params, anyParams uint64) moqConverterer_RecorderMethods_paramsKey { - m.scene.T.Helper() - var fnUsed generator.Func - var fnUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.RecorderMethods.fn == moq.ParamIndexByValue { - fnUsed = params.fn - } else { - fnUsedHash = hash.DeepHash(params.fn) - } - } +func (a *moqConverterer_RecorderMethods_adaptor) ParamsKey(params moqConverterer_RecorderMethods_params, anyParams uint64) moqConverterer_RecorderMethods_paramsKey { + a.moq.moq_RecorderMethods.Scene.T.Helper() + fnUsed, fnUsedHash := impl.ParamKey( + params.fn, 1, a.moq.runtime.parameterIndexing.RecorderMethods.fn, anyParams) return moqConverterer_RecorderMethods_paramsKey{ params: struct{ fn generator.Func }{ fn: fnUsed, @@ -2951,376 +1639,162 @@ func (m *moqConverterer) paramsKey_RecorderMethods(params moqConverterer_Recorde } } -func (m *moqConverterer_recorder) ResetMethod() *moqConverterer_ResetMethod_fnRecorder { - return &moqConverterer_ResetMethod_fnRecorder{ - params: moqConverterer_ResetMethod_params{}, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, +func (m *moqConverterer_recorder) ResetMethod() *moqConverterer_ResetMethod_recorder { + return &moqConverterer_ResetMethod_recorder{ + recorder: m.moq.moq_ResetMethod.OnCall(moqConverterer_ResetMethod_params{}), } } -func (r *moqConverterer_ResetMethod_fnRecorder) any() *moqConverterer_ResetMethod_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_ResetMethod(r.params)) +func (r *moqConverterer_ResetMethod_recorder) any() *moqConverterer_ResetMethod_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqConverterer_ResetMethod_anyParams{recorder: r} } -func (r *moqConverterer_ResetMethod_fnRecorder) seq() *moqConverterer_ResetMethod_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_ResetMethod(r.params)) +func (r *moqConverterer_ResetMethod_recorder) seq() *moqConverterer_ResetMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqConverterer_ResetMethod_fnRecorder) noSeq() *moqConverterer_ResetMethod_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_ResetMethod(r.params)) +func (r *moqConverterer_ResetMethod_recorder) noSeq() *moqConverterer_ResetMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqConverterer_ResetMethod_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_ResetMethod_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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_ResetMethod_doFn - doReturnFn moqConverterer_ResetMethod_doReturnFn - }{ - values: &struct { - funcDecl *dst.FuncDecl - err error - }{ - funcDecl: funcDecl, - err: err, - }, - sequence: sequence, +func (r *moqConverterer_ResetMethod_recorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_ResetMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqConverterer_ResetMethod_results{ + funcDecl: funcDecl, + err: err, }) return r } -func (r *moqConverterer_ResetMethod_fnRecorder) andDo(fn moqConverterer_ResetMethod_doFn) *moqConverterer_ResetMethod_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqConverterer_ResetMethod_recorder) andDo(fn moqConverterer_ResetMethod_doFn) *moqConverterer_ResetMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqConverterer_ResetMethod_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqConverterer_ResetMethod_fnRecorder) doReturnResults(fn moqConverterer_ResetMethod_doReturnFn) *moqConverterer_ResetMethod_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 { - funcDecl *dst.FuncDecl - err error +func (r *moqConverterer_ResetMethod_recorder) doReturnResults(fn moqConverterer_ResetMethod_doReturnFn) *moqConverterer_ResetMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqConverterer_ResetMethod_params) *moqConverterer_ResetMethod_results { + funcDecl, err := fn() + return &moqConverterer_ResetMethod_results{ + funcDecl: funcDecl, + err: err, } - sequence uint32 - doFn moqConverterer_ResetMethod_doFn - doReturnFn moqConverterer_ResetMethod_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqConverterer_ResetMethod_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 *moqConverterer_ResetMethod_resultsByParams - for n, res := range r.moq.resultsByParams_ResetMethod { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqConverterer_ResetMethod_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqConverterer_ResetMethod_paramsKey]*moqConverterer_ResetMethod_results{}, - } - r.moq.resultsByParams_ResetMethod = append(r.moq.resultsByParams_ResetMethod, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_ResetMethod) { - copy(r.moq.resultsByParams_ResetMethod[insertAt+1:], r.moq.resultsByParams_ResetMethod[insertAt:0]) - r.moq.resultsByParams_ResetMethod[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_ResetMethod(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqConverterer_ResetMethod_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 *moqConverterer_ResetMethod_fnRecorder) repeat(repeaters ...moq.Repeater) *moqConverterer_ResetMethod_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqConverterer_ResetMethod_recorder) repeat(repeaters ...moq.Repeater) *moqConverterer_ResetMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_ResetMethod_doFn - doReturnFn moqConverterer_ResetMethod_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqConverterer) prettyParams_ResetMethod(params moqConverterer_ResetMethod_params) string { +func (*moqConverterer_ResetMethod_adaptor) PrettyParams(params moqConverterer_ResetMethod_params) string { return fmt.Sprintf("ResetMethod()") } -func (m *moqConverterer) paramsKey_ResetMethod(params moqConverterer_ResetMethod_params, anyParams uint64) moqConverterer_ResetMethod_paramsKey { - m.scene.T.Helper() +func (a *moqConverterer_ResetMethod_adaptor) ParamsKey(params moqConverterer_ResetMethod_params, anyParams uint64) moqConverterer_ResetMethod_paramsKey { + a.moq.moq_ResetMethod.Scene.T.Helper() return moqConverterer_ResetMethod_paramsKey{ params: struct{}{}, hashes: struct{}{}, } } -func (m *moqConverterer_recorder) AssertMethod() *moqConverterer_AssertMethod_fnRecorder { - return &moqConverterer_AssertMethod_fnRecorder{ - params: moqConverterer_AssertMethod_params{}, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, +func (m *moqConverterer_recorder) AssertMethod() *moqConverterer_AssertMethod_recorder { + return &moqConverterer_AssertMethod_recorder{ + recorder: m.moq.moq_AssertMethod.OnCall(moqConverterer_AssertMethod_params{}), } } -func (r *moqConverterer_AssertMethod_fnRecorder) any() *moqConverterer_AssertMethod_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_AssertMethod(r.params)) +func (r *moqConverterer_AssertMethod_recorder) any() *moqConverterer_AssertMethod_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqConverterer_AssertMethod_anyParams{recorder: r} } -func (r *moqConverterer_AssertMethod_fnRecorder) seq() *moqConverterer_AssertMethod_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_AssertMethod(r.params)) +func (r *moqConverterer_AssertMethod_recorder) seq() *moqConverterer_AssertMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqConverterer_AssertMethod_fnRecorder) noSeq() *moqConverterer_AssertMethod_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_AssertMethod(r.params)) +func (r *moqConverterer_AssertMethod_recorder) noSeq() *moqConverterer_AssertMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqConverterer_AssertMethod_fnRecorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_AssertMethod_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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_AssertMethod_doFn - doReturnFn moqConverterer_AssertMethod_doReturnFn - }{ - values: &struct { - funcDecl *dst.FuncDecl - err error - }{ - funcDecl: funcDecl, - err: err, - }, - sequence: sequence, +func (r *moqConverterer_AssertMethod_recorder) returnResults(funcDecl *dst.FuncDecl, err error) *moqConverterer_AssertMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqConverterer_AssertMethod_results{ + funcDecl: funcDecl, + err: err, }) return r } -func (r *moqConverterer_AssertMethod_fnRecorder) andDo(fn moqConverterer_AssertMethod_doFn) *moqConverterer_AssertMethod_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqConverterer_AssertMethod_recorder) andDo(fn moqConverterer_AssertMethod_doFn) *moqConverterer_AssertMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqConverterer_AssertMethod_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqConverterer_AssertMethod_fnRecorder) doReturnResults(fn moqConverterer_AssertMethod_doReturnFn) *moqConverterer_AssertMethod_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 { - funcDecl *dst.FuncDecl - err error +func (r *moqConverterer_AssertMethod_recorder) doReturnResults(fn moqConverterer_AssertMethod_doReturnFn) *moqConverterer_AssertMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqConverterer_AssertMethod_params) *moqConverterer_AssertMethod_results { + funcDecl, err := fn() + return &moqConverterer_AssertMethod_results{ + funcDecl: funcDecl, + err: err, } - sequence uint32 - doFn moqConverterer_AssertMethod_doFn - doReturnFn moqConverterer_AssertMethod_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqConverterer_AssertMethod_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 *moqConverterer_AssertMethod_resultsByParams - for n, res := range r.moq.resultsByParams_AssertMethod { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqConverterer_AssertMethod_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqConverterer_AssertMethod_paramsKey]*moqConverterer_AssertMethod_results{}, - } - r.moq.resultsByParams_AssertMethod = append(r.moq.resultsByParams_AssertMethod, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_AssertMethod) { - copy(r.moq.resultsByParams_AssertMethod[insertAt+1:], r.moq.resultsByParams_AssertMethod[insertAt:0]) - r.moq.resultsByParams_AssertMethod[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_AssertMethod(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqConverterer_AssertMethod_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 *moqConverterer_AssertMethod_fnRecorder) repeat(repeaters ...moq.Repeater) *moqConverterer_AssertMethod_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqConverterer_AssertMethod_recorder) repeat(repeaters ...moq.Repeater) *moqConverterer_AssertMethod_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - funcDecl *dst.FuncDecl - err error - } - sequence uint32 - doFn moqConverterer_AssertMethod_doFn - doReturnFn moqConverterer_AssertMethod_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqConverterer) prettyParams_AssertMethod(params moqConverterer_AssertMethod_params) string { +func (*moqConverterer_AssertMethod_adaptor) PrettyParams(params moqConverterer_AssertMethod_params) string { return fmt.Sprintf("AssertMethod()") } -func (m *moqConverterer) paramsKey_AssertMethod(params moqConverterer_AssertMethod_params, anyParams uint64) moqConverterer_AssertMethod_paramsKey { - m.scene.T.Helper() +func (a *moqConverterer_AssertMethod_adaptor) ParamsKey(params moqConverterer_AssertMethod_params, anyParams uint64) moqConverterer_AssertMethod_paramsKey { + a.moq.moq_AssertMethod.Scene.T.Helper() return moqConverterer_AssertMethod_paramsKey{ params: struct{}{}, hashes: struct{}{}, @@ -3329,99 +1803,29 @@ func (m *moqConverterer) paramsKey_AssertMethod(params moqConverterer_AssertMeth // Reset resets the state of the moq func (m *moqConverterer) Reset() { - m.resultsByParams_BaseDecls = nil - m.resultsByParams_IsolationStruct = nil - m.resultsByParams_MethodStructs = nil - m.resultsByParams_NewFunc = nil - m.resultsByParams_IsolationAccessor = nil - m.resultsByParams_FuncClosure = nil - m.resultsByParams_MockMethod = nil - m.resultsByParams_RecorderMethods = nil - m.resultsByParams_ResetMethod = nil - m.resultsByParams_AssertMethod = nil + m.moq_BaseDecls.Reset() + m.moq_MockStructs.Reset() + m.moq_MethodStructs.Reset() + m.moq_NewFunc.Reset() + m.moq_IsolationAccessor.Reset() + m.moq_FuncClosure.Reset() + m.moq_MockMethod.Reset() + m.moq_RecorderMethods.Reset() + m.moq_ResetMethod.Reset() + m.moq_AssertMethod.Reset() } // AssertExpectationsMet asserts that all expectations have been met func (m *moqConverterer) AssertExpectationsMet() { - m.scene.T.Helper() - for _, res := range m.resultsByParams_BaseDecls { - 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_BaseDecls(results.params)) - } - } - } - for _, res := range m.resultsByParams_IsolationStruct { - 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_IsolationStruct(results.params)) - } - } - } - for _, res := range m.resultsByParams_MethodStructs { - 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_MethodStructs(results.params)) - } - } - } - for _, res := range m.resultsByParams_NewFunc { - 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_NewFunc(results.params)) - } - } - } - for _, res := range m.resultsByParams_IsolationAccessor { - 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_IsolationAccessor(results.params)) - } - } - } - for _, res := range m.resultsByParams_FuncClosure { - 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_FuncClosure(results.params)) - } - } - } - for _, res := range m.resultsByParams_MockMethod { - 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_MockMethod(results.params)) - } - } - } - for _, res := range m.resultsByParams_RecorderMethods { - 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_RecorderMethods(results.params)) - } - } - } - for _, res := range m.resultsByParams_ResetMethod { - 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_ResetMethod(results.params)) - } - } - } - for _, res := range m.resultsByParams_AssertMethod { - 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_AssertMethod(results.params)) - } - } - } + m.moq_BaseDecls.Scene.T.Helper() + m.moq_BaseDecls.AssertExpectationsMet() + m.moq_MockStructs.AssertExpectationsMet() + m.moq_MethodStructs.AssertExpectationsMet() + m.moq_NewFunc.AssertExpectationsMet() + m.moq_IsolationAccessor.AssertExpectationsMet() + m.moq_FuncClosure.AssertExpectationsMet() + m.moq_MockMethod.AssertExpectationsMet() + m.moq_RecorderMethods.AssertExpectationsMet() + m.moq_ResetMethod.AssertExpectationsMet() + m.moq_AssertMethod.AssertExpectationsMet() } diff --git a/generator/moq_getwdfunc_test.go b/generator/moq_getwdfunc_test.go index 60b57a4..b67fbd4 100644 --- a/generator/moq_getwdfunc_test.go +++ b/generator/moq_getwdfunc_test.go @@ -4,28 +4,31 @@ package generator_test import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/cli/generator" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqGetwdFunc holds the state of a moq of the GetwdFunc type type moqGetwdFunc struct { - scene *moq.Scene - config moq.Config - moq *moqGetwdFunc_mock + moq *impl.Moq[ + *moqGetwdFunc_adaptor, + moqGetwdFunc_params, + moqGetwdFunc_paramsKey, + moqGetwdFunc_results, + ] - resultsByParams []moqGetwdFunc_resultsByParams + runtime moqGetwdFunc_runtime +} - runtime struct { - parameterIndexing struct{} - } +// moqGetwdFunc_runtime holds runtime configuration for the GetwdFunc type +type moqGetwdFunc_runtime struct { + parameterIndexing moqGetwdFunc_paramIndexing } -// moqGetwdFunc_mock isolates the mock interface of the GetwdFunc type -type moqGetwdFunc_mock struct { +// moqGetwdFunc_adaptor adapts moqGetwdFunc as needed by the runtime +type moqGetwdFunc_adaptor struct { moq *moqGetwdFunc } @@ -38,14 +41,16 @@ type moqGetwdFunc_paramsKey struct { hashes struct{} } -// moqGetwdFunc_resultsByParams contains the results for a given set of -// parameters for the GetwdFunc type -type moqGetwdFunc_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqGetwdFunc_paramsKey]*moqGetwdFunc_results +// moqGetwdFunc_results holds the results of the GetwdFunc type +type moqGetwdFunc_results struct { + result1 string + result2 error } +// moqGetwdFunc_paramIndexing holds the parameter indexing runtime +// configuration for the GetwdFunc type +type moqGetwdFunc_paramIndexing struct{} + // moqGetwdFunc_doFn defines the type of function needed when calling andDo for // the GetwdFunc type type moqGetwdFunc_doFn func() @@ -54,53 +59,36 @@ type moqGetwdFunc_doFn func() // doReturnResults for the GetwdFunc type type moqGetwdFunc_doReturnFn func() (string, error) -// moqGetwdFunc_results holds the results of the GetwdFunc type -type moqGetwdFunc_results struct { - params moqGetwdFunc_params - results []struct { - values *struct { - result1 string - result2 error - } - sequence uint32 - doFn moqGetwdFunc_doFn - doReturnFn moqGetwdFunc_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqGetwdFunc_fnRecorder routes recorded function calls to the moqGetwdFunc -// moq -type moqGetwdFunc_fnRecorder struct { - params moqGetwdFunc_params - anyParams uint64 - sequence bool - results *moqGetwdFunc_results - moq *moqGetwdFunc +// moqGetwdFunc_recorder routes recorded function calls to the moqGetwdFunc moq +type moqGetwdFunc_recorder struct { + recorder *impl.Recorder[ + *moqGetwdFunc_adaptor, + moqGetwdFunc_params, + moqGetwdFunc_paramsKey, + moqGetwdFunc_results, + ] } // moqGetwdFunc_anyParams isolates the any params functions of the GetwdFunc // type type moqGetwdFunc_anyParams struct { - recorder *moqGetwdFunc_fnRecorder + recorder *moqGetwdFunc_recorder } // newMoqGetwdFunc creates a new moq of the GetwdFunc type func newMoqGetwdFunc(scene *moq.Scene, config *moq.Config) *moqGetwdFunc { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqGetwdFunc_adaptor{} m := &moqGetwdFunc{ - scene: scene, - config: *config, - moq: &moqGetwdFunc_mock{}, + moq: impl.NewMoq[ + *moqGetwdFunc_adaptor, + moqGetwdFunc_params, + moqGetwdFunc_paramsKey, + moqGetwdFunc_results, + ](scene, adaptor1, config), - runtime: struct { - parameterIndexing struct{} - }{parameterIndexing: struct{}{}}, + runtime: moqGetwdFunc_runtime{parameterIndexing: moqGetwdFunc_paramIndexing{}}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -108,243 +96,95 @@ func newMoqGetwdFunc(scene *moq.Scene, config *moq.Config) *moqGetwdFunc { // mock returns the moq implementation of the GetwdFunc type func (m *moqGetwdFunc) mock() generator.GetwdFunc { - return func() (string, error) { m.scene.T.Helper(); moq := &moqGetwdFunc_mock{moq: m}; return moq.fn() } -} - -func (m *moqGetwdFunc_mock) fn() (result1 string, result2 error) { - m.moq.scene.T.Helper() - params := moqGetwdFunc_params{} - var results *moqGetwdFunc_results - 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 + return func() (string, error) { + m.moq.Scene.T.Helper() + params := moqGetwdFunc_params{} + + var result1 string + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - i = results.repeat.ResultCount - 1 + return result1, result2 } - - 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() - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn() - } - return } -func (m *moqGetwdFunc) onCall() *moqGetwdFunc_fnRecorder { - return &moqGetwdFunc_fnRecorder{ - params: moqGetwdFunc_params{}, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, +func (m *moqGetwdFunc) onCall() *moqGetwdFunc_recorder { + return &moqGetwdFunc_recorder{ + recorder: m.moq.OnCall(moqGetwdFunc_params{}), } } -func (r *moqGetwdFunc_fnRecorder) any() *moqGetwdFunc_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(r.params)) +func (r *moqGetwdFunc_recorder) any() *moqGetwdFunc_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqGetwdFunc_anyParams{recorder: r} } -func (r *moqGetwdFunc_fnRecorder) seq() *moqGetwdFunc_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(r.params)) +func (r *moqGetwdFunc_recorder) seq() *moqGetwdFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqGetwdFunc_fnRecorder) noSeq() *moqGetwdFunc_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(r.params)) +func (r *moqGetwdFunc_recorder) noSeq() *moqGetwdFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqGetwdFunc_fnRecorder) returnResults(result1 string, result2 error) *moqGetwdFunc_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 moqGetwdFunc_doFn - doReturnFn moqGetwdFunc_doReturnFn - }{ - values: &struct { - result1 string - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqGetwdFunc_recorder) returnResults(result1 string, result2 error) *moqGetwdFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqGetwdFunc_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqGetwdFunc_fnRecorder) andDo(fn moqGetwdFunc_doFn) *moqGetwdFunc_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqGetwdFunc_recorder) andDo(fn moqGetwdFunc_doFn) *moqGetwdFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqGetwdFunc_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqGetwdFunc_fnRecorder) doReturnResults(fn moqGetwdFunc_doReturnFn) *moqGetwdFunc_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 +func (r *moqGetwdFunc_recorder) doReturnResults(fn moqGetwdFunc_doReturnFn) *moqGetwdFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqGetwdFunc_params) *moqGetwdFunc_results { + result1, result2 := fn() + return &moqGetwdFunc_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqGetwdFunc_doFn - doReturnFn moqGetwdFunc_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqGetwdFunc_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 *moqGetwdFunc_resultsByParams - 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 = &moqGetwdFunc_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqGetwdFunc_paramsKey]*moqGetwdFunc_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqGetwdFunc_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 *moqGetwdFunc_fnRecorder) repeat(repeaters ...moq.Repeater) *moqGetwdFunc_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqGetwdFunc_recorder) repeat(repeaters ...moq.Repeater) *moqGetwdFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 moqGetwdFunc_doFn - doReturnFn moqGetwdFunc_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqGetwdFunc) prettyParams(params moqGetwdFunc_params) string { +func (*moqGetwdFunc_adaptor) PrettyParams(params moqGetwdFunc_params) string { return fmt.Sprintf("GetwdFunc()") } -func (m *moqGetwdFunc) paramsKey(params moqGetwdFunc_params, anyParams uint64) moqGetwdFunc_paramsKey { - m.scene.T.Helper() +func (a *moqGetwdFunc_adaptor) ParamsKey(params moqGetwdFunc_params, anyParams uint64) moqGetwdFunc_paramsKey { + a.moq.moq.Scene.T.Helper() return moqGetwdFunc_paramsKey{ params: struct{}{}, hashes: struct{}{}, @@ -352,17 +192,12 @@ func (m *moqGetwdFunc) paramsKey(params moqGetwdFunc_params, anyParams uint64) m } // Reset resets the state of the moq -func (m *moqGetwdFunc) Reset() { m.resultsByParams = nil } +func (m *moqGetwdFunc) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqGetwdFunc) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/generator/moq_newconverterfunc_test.go b/generator/moq_newconverterfunc_test.go index 3013481..c686bfa 100644 --- a/generator/moq_newconverterfunc_test.go +++ b/generator/moq_newconverterfunc_test.go @@ -4,33 +4,34 @@ package generator_test import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/cli/generator" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqNewConverterFunc holds the state of a moq of the NewConverterFunc type type moqNewConverterFunc struct { - scene *moq.Scene - config moq.Config - moq *moqNewConverterFunc_mock + moq *impl.Moq[ + *moqNewConverterFunc_adaptor, + moqNewConverterFunc_params, + moqNewConverterFunc_paramsKey, + moqNewConverterFunc_results, + ] - resultsByParams []moqNewConverterFunc_resultsByParams + runtime moqNewConverterFunc_runtime +} - runtime struct { - parameterIndexing struct { - typ moq.ParamIndexing - export moq.ParamIndexing - } - } +// moqNewConverterFunc_runtime holds runtime configuration for the +// NewConverterFunc type +type moqNewConverterFunc_runtime struct { + parameterIndexing moqNewConverterFunc_paramIndexing } -// moqNewConverterFunc_mock isolates the mock interface of the NewConverterFunc -// type -type moqNewConverterFunc_mock struct { +// moqNewConverterFunc_adaptor adapts moqNewConverterFunc as needed by the +// runtime +type moqNewConverterFunc_adaptor struct { moq *moqNewConverterFunc } @@ -50,12 +51,16 @@ type moqNewConverterFunc_paramsKey struct { } } -// moqNewConverterFunc_resultsByParams contains the results for a given set of -// parameters for the NewConverterFunc type -type moqNewConverterFunc_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqNewConverterFunc_paramsKey]*moqNewConverterFunc_results +// moqNewConverterFunc_results holds the results of the NewConverterFunc type +type moqNewConverterFunc_results struct { + result1 generator.Converterer +} + +// moqNewConverterFunc_paramIndexing holds the parameter indexing runtime +// configuration for the NewConverterFunc type +type moqNewConverterFunc_paramIndexing struct { + typ moq.ParamIndexing + export moq.ParamIndexing } // moqNewConverterFunc_doFn defines the type of function needed when calling @@ -66,61 +71,40 @@ type moqNewConverterFunc_doFn func(typ generator.Type, export bool) // calling doReturnResults for the NewConverterFunc type type moqNewConverterFunc_doReturnFn func(typ generator.Type, export bool) generator.Converterer -// moqNewConverterFunc_results holds the results of the NewConverterFunc type -type moqNewConverterFunc_results struct { - params moqNewConverterFunc_params - results []struct { - values *struct { - result1 generator.Converterer - } - sequence uint32 - doFn moqNewConverterFunc_doFn - doReturnFn moqNewConverterFunc_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqNewConverterFunc_fnRecorder routes recorded function calls to the +// moqNewConverterFunc_recorder routes recorded function calls to the // moqNewConverterFunc moq -type moqNewConverterFunc_fnRecorder struct { - params moqNewConverterFunc_params - anyParams uint64 - sequence bool - results *moqNewConverterFunc_results - moq *moqNewConverterFunc +type moqNewConverterFunc_recorder struct { + recorder *impl.Recorder[ + *moqNewConverterFunc_adaptor, + moqNewConverterFunc_params, + moqNewConverterFunc_paramsKey, + moqNewConverterFunc_results, + ] } // moqNewConverterFunc_anyParams isolates the any params functions of the // NewConverterFunc type type moqNewConverterFunc_anyParams struct { - recorder *moqNewConverterFunc_fnRecorder + recorder *moqNewConverterFunc_recorder } // newMoqNewConverterFunc creates a new moq of the NewConverterFunc type func newMoqNewConverterFunc(scene *moq.Scene, config *moq.Config) *moqNewConverterFunc { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqNewConverterFunc_adaptor{} m := &moqNewConverterFunc{ - scene: scene, - config: *config, - moq: &moqNewConverterFunc_mock{}, - - runtime: struct { - parameterIndexing struct { - typ moq.ParamIndexing - export moq.ParamIndexing - } - }{parameterIndexing: struct { - typ moq.ParamIndexing - export moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqNewConverterFunc_adaptor, + moqNewConverterFunc_params, + moqNewConverterFunc_paramsKey, + moqNewConverterFunc_results, + ](scene, adaptor1, config), + + runtime: moqNewConverterFunc_runtime{parameterIndexing: moqNewConverterFunc_paramIndexing{ typ: moq.ParamIndexByHash, export: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -129,272 +113,110 @@ func newMoqNewConverterFunc(scene *moq.Scene, config *moq.Config) *moqNewConvert // mock returns the moq implementation of the NewConverterFunc type func (m *moqNewConverterFunc) mock() generator.NewConverterFunc { return func(typ generator.Type, export bool) generator.Converterer { - m.scene.T.Helper() - moq := &moqNewConverterFunc_mock{moq: m} - return moq.fn(typ, export) - } -} - -func (m *moqNewConverterFunc_mock) fn(typ generator.Type, export bool) (result1 generator.Converterer) { - m.moq.scene.T.Helper() - params := moqNewConverterFunc_params{ - typ: typ, - export: export, - } - var results *moqNewConverterFunc_results - 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)) + m.moq.Scene.T.Helper() + params := moqNewConverterFunc_params{ + typ: typ, + export: export, } - 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 + var result1 generator.Converterer + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } - i = results.repeat.ResultCount - 1 + return result1 } - - 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(typ, export) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(typ, export) - } - return } -func (m *moqNewConverterFunc) onCall(typ generator.Type, export bool) *moqNewConverterFunc_fnRecorder { - return &moqNewConverterFunc_fnRecorder{ - params: moqNewConverterFunc_params{ +func (m *moqNewConverterFunc) onCall(typ generator.Type, export bool) *moqNewConverterFunc_recorder { + return &moqNewConverterFunc_recorder{ + recorder: m.moq.OnCall(moqNewConverterFunc_params{ typ: typ, export: export, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqNewConverterFunc_fnRecorder) any() *moqNewConverterFunc_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(r.params)) +func (r *moqNewConverterFunc_recorder) any() *moqNewConverterFunc_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqNewConverterFunc_anyParams{recorder: r} } -func (a *moqNewConverterFunc_anyParams) typ() *moqNewConverterFunc_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqNewConverterFunc_anyParams) typ() *moqNewConverterFunc_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqNewConverterFunc_anyParams) export() *moqNewConverterFunc_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqNewConverterFunc_anyParams) export() *moqNewConverterFunc_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqNewConverterFunc_fnRecorder) seq() *moqNewConverterFunc_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(r.params)) +func (r *moqNewConverterFunc_recorder) seq() *moqNewConverterFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqNewConverterFunc_fnRecorder) noSeq() *moqNewConverterFunc_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(r.params)) +func (r *moqNewConverterFunc_recorder) noSeq() *moqNewConverterFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqNewConverterFunc_fnRecorder) returnResults(result1 generator.Converterer) *moqNewConverterFunc_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 generator.Converterer - } - sequence uint32 - doFn moqNewConverterFunc_doFn - doReturnFn moqNewConverterFunc_doReturnFn - }{ - values: &struct { - result1 generator.Converterer - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqNewConverterFunc_recorder) returnResults(result1 generator.Converterer) *moqNewConverterFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqNewConverterFunc_results{ + result1: result1, }) return r } -func (r *moqNewConverterFunc_fnRecorder) andDo(fn moqNewConverterFunc_doFn) *moqNewConverterFunc_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqNewConverterFunc_recorder) andDo(fn moqNewConverterFunc_doFn) *moqNewConverterFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqNewConverterFunc_params) { + fn(params.typ, params.export) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqNewConverterFunc_fnRecorder) doReturnResults(fn moqNewConverterFunc_doReturnFn) *moqNewConverterFunc_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 generator.Converterer +func (r *moqNewConverterFunc_recorder) doReturnResults(fn moqNewConverterFunc_doReturnFn) *moqNewConverterFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqNewConverterFunc_params) *moqNewConverterFunc_results { + result1 := fn(params.typ, params.export) + return &moqNewConverterFunc_results{ + result1: result1, } - sequence uint32 - doFn moqNewConverterFunc_doFn - doReturnFn moqNewConverterFunc_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqNewConverterFunc_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 *moqNewConverterFunc_resultsByParams - 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 = &moqNewConverterFunc_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqNewConverterFunc_paramsKey]*moqNewConverterFunc_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqNewConverterFunc_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 *moqNewConverterFunc_fnRecorder) repeat(repeaters ...moq.Repeater) *moqNewConverterFunc_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqNewConverterFunc_recorder) repeat(repeaters ...moq.Repeater) *moqNewConverterFunc_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 generator.Converterer - } - sequence uint32 - doFn moqNewConverterFunc_doFn - doReturnFn moqNewConverterFunc_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqNewConverterFunc) prettyParams(params moqNewConverterFunc_params) string { +func (*moqNewConverterFunc_adaptor) PrettyParams(params moqNewConverterFunc_params) string { return fmt.Sprintf("NewConverterFunc(%#v, %#v)", params.typ, params.export) } -func (m *moqNewConverterFunc) paramsKey(params moqNewConverterFunc_params, anyParams uint64) moqNewConverterFunc_paramsKey { - m.scene.T.Helper() - var typUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.typ == moq.ParamIndexByValue { - m.scene.T.Fatalf("The typ parameter can't be indexed by value") - } - typUsedHash = hash.DeepHash(params.typ) - } - var exportUsed bool - var exportUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.export == moq.ParamIndexByValue { - exportUsed = params.export - } else { - exportUsedHash = hash.DeepHash(params.export) - } - } +func (a *moqNewConverterFunc_adaptor) ParamsKey(params moqNewConverterFunc_params, anyParams uint64) moqNewConverterFunc_paramsKey { + a.moq.moq.Scene.T.Helper() + typUsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.typ, "typ", 1, a.moq.runtime.parameterIndexing.typ, anyParams) + exportUsed, exportUsedHash := impl.ParamKey( + params.export, 2, a.moq.runtime.parameterIndexing.export, anyParams) return moqNewConverterFunc_paramsKey{ params: struct{ export bool }{ export: exportUsed, @@ -410,17 +232,12 @@ func (m *moqNewConverterFunc) paramsKey(params moqNewConverterFunc_params, anyPa } // Reset resets the state of the moq -func (m *moqNewConverterFunc) Reset() { m.resultsByParams = nil } +func (m *moqNewConverterFunc) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqNewConverterFunc) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/generator/moq_testinterface_test.go b/generator/moq_testinterface_test.go index eef2fac..9283a81 100644 --- a/generator/moq_testinterface_test.go +++ b/generator/moq_testinterface_test.go @@ -4,9 +4,8 @@ package generator_test import ( "fmt" - "math/bits" - "sync/atomic" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -16,17 +15,16 @@ var _ testInterface = (*moqTestInterface_mock)(nil) // moqTestInterface holds the state of a moq of the testInterface type type moqTestInterface struct { - scene *moq.Scene - config moq.Config - moq *moqTestInterface_mock + moq *moqTestInterface_mock - resultsByParams_something []moqTestInterface_something_resultsByParams + moq_something *impl.Moq[ + *moqTestInterface_something_adaptor, + moqTestInterface_something_params, + moqTestInterface_something_paramsKey, + moqTestInterface_something_results, + ] - runtime struct { - parameterIndexing struct { - something struct{} - } - } + runtime moqTestInterface_runtime } // moqTestInterface_mock isolates the mock interface of the testInterface type @@ -40,6 +38,20 @@ type moqTestInterface_recorder struct { moq *moqTestInterface } +// moqTestInterface_runtime holds runtime configuration for the testInterface +// type +type moqTestInterface_runtime struct { + parameterIndexing struct { + something moqTestInterface_something_paramIndexing + } +} + +// moqTestInterface_something_adaptor adapts moqTestInterface as needed by the +// runtime +type moqTestInterface_something_adaptor struct { + moq *moqTestInterface +} + // moqTestInterface_something_params holds the params of the testInterface type type moqTestInterface_something_params struct{} @@ -50,13 +62,13 @@ type moqTestInterface_something_paramsKey struct { hashes struct{} } -// moqTestInterface_something_resultsByParams contains the results for a given -// set of parameters for the testInterface type -type moqTestInterface_something_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTestInterface_something_paramsKey]*moqTestInterface_something_results -} +// moqTestInterface_something_results holds the results of the testInterface +// type +type moqTestInterface_something_results struct{} + +// moqTestInterface_something_paramIndexing holds the parameter indexing +// runtime configuration for the testInterface type +type moqTestInterface_something_paramIndexing struct{} // moqTestInterface_something_doFn defines the type of function needed when // calling andDo for the testInterface type @@ -66,58 +78,46 @@ type moqTestInterface_something_doFn func() // when calling doReturnResults for the testInterface type type moqTestInterface_something_doReturnFn func() -// moqTestInterface_something_results holds the results of the testInterface -// type -type moqTestInterface_something_results struct { - params moqTestInterface_something_params - results []struct { - values *struct{} - sequence uint32 - doFn moqTestInterface_something_doFn - doReturnFn moqTestInterface_something_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTestInterface_something_fnRecorder routes recorded function calls to the +// moqTestInterface_something_recorder routes recorded function calls to the // moqTestInterface moq -type moqTestInterface_something_fnRecorder struct { - params moqTestInterface_something_params - anyParams uint64 - sequence bool - results *moqTestInterface_something_results - moq *moqTestInterface +type moqTestInterface_something_recorder struct { + recorder *impl.Recorder[ + *moqTestInterface_something_adaptor, + moqTestInterface_something_params, + moqTestInterface_something_paramsKey, + moqTestInterface_something_results, + ] } // moqTestInterface_something_anyParams isolates the any params functions of // the testInterface type type moqTestInterface_something_anyParams struct { - recorder *moqTestInterface_something_fnRecorder + recorder *moqTestInterface_something_recorder } // newMoqtestInterface creates a new moq of the testInterface type func newMoqtestInterface(scene *moq.Scene, config *moq.Config) *moqTestInterface { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqTestInterface_something_adaptor{} m := &moqTestInterface{ - scene: scene, - config: *config, - moq: &moqTestInterface_mock{}, - - runtime: struct { - parameterIndexing struct { - something struct{} - } - }{parameterIndexing: struct { - something struct{} + moq: &moqTestInterface_mock{}, + + moq_something: impl.NewMoq[ + *moqTestInterface_something_adaptor, + moqTestInterface_something_params, + moqTestInterface_something_paramsKey, + moqTestInterface_something_results, + ](scene, adaptor1, config), + + runtime: moqTestInterface_runtime{parameterIndexing: struct { + something moqTestInterface_something_paramIndexing }{ - something: struct{}{}, + something: moqTestInterface_something_paramIndexing{}, }}, } m.moq.moq = m + adaptor1.moq = m + scene.AddMoq(m) return m } @@ -126,51 +126,10 @@ func newMoqtestInterface(scene *moq.Scene, config *moq.Config) *moqTestInterface func (m *moqTestInterface) mock() *moqTestInterface_mock { return m.moq } func (m *moqTestInterface_mock) something() { - m.moq.scene.T.Helper() + m.moq.moq_something.Scene.T.Helper() params := moqTestInterface_something_params{} - var results *moqTestInterface_something_results - for _, resultsByParams := range m.moq.resultsByParams_something { - paramsKey := m.moq.paramsKey_something(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_something(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_something(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_something(params)) - } - } - - if result.doFn != nil { - result.doFn() - } - - if result.doReturnFn != nil { - result.doReturnFn() - } - return + m.moq.moq_something.Function(params) } // onCall returns the recorder implementation of the testInterface type @@ -180,173 +139,75 @@ func (m *moqTestInterface) onCall() *moqTestInterface_recorder { } } -func (m *moqTestInterface_recorder) something() *moqTestInterface_something_fnRecorder { - return &moqTestInterface_something_fnRecorder{ - params: moqTestInterface_something_params{}, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, +func (m *moqTestInterface_recorder) something() *moqTestInterface_something_recorder { + return &moqTestInterface_something_recorder{ + recorder: m.moq.moq_something.OnCall(moqTestInterface_something_params{}), } } -func (r *moqTestInterface_something_fnRecorder) any() *moqTestInterface_something_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_something(r.params)) +func (r *moqTestInterface_something_recorder) any() *moqTestInterface_something_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTestInterface_something_anyParams{recorder: r} } -func (r *moqTestInterface_something_fnRecorder) seq() *moqTestInterface_something_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_something(r.params)) +func (r *moqTestInterface_something_recorder) seq() *moqTestInterface_something_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTestInterface_something_fnRecorder) noSeq() *moqTestInterface_something_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_something(r.params)) +func (r *moqTestInterface_something_recorder) noSeq() *moqTestInterface_something_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTestInterface_something_fnRecorder) returnResults() *moqTestInterface_something_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 moqTestInterface_something_doFn - doReturnFn moqTestInterface_something_doReturnFn - }{ - values: &struct{}{}, - sequence: sequence, - }) +func (r *moqTestInterface_something_recorder) returnResults() *moqTestInterface_something_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTestInterface_something_results{}) return r } -func (r *moqTestInterface_something_fnRecorder) andDo(fn moqTestInterface_something_doFn) *moqTestInterface_something_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTestInterface_something_recorder) andDo(fn moqTestInterface_something_doFn) *moqTestInterface_something_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTestInterface_something_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTestInterface_something_fnRecorder) doReturnResults(fn moqTestInterface_something_doReturnFn) *moqTestInterface_something_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 moqTestInterface_something_doFn - doReturnFn moqTestInterface_something_doReturnFn - }{sequence: sequence, doReturnFn: fn}) +func (r *moqTestInterface_something_recorder) doReturnResults(fn moqTestInterface_something_doReturnFn) *moqTestInterface_something_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTestInterface_something_params) *moqTestInterface_something_results { + fn() + return &moqTestInterface_something_results{} + }) return r } -func (r *moqTestInterface_something_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 *moqTestInterface_something_resultsByParams - for n, res := range r.moq.resultsByParams_something { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqTestInterface_something_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTestInterface_something_paramsKey]*moqTestInterface_something_results{}, - } - r.moq.resultsByParams_something = append(r.moq.resultsByParams_something, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_something) { - copy(r.moq.resultsByParams_something[insertAt+1:], r.moq.resultsByParams_something[insertAt:0]) - r.moq.resultsByParams_something[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_something(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTestInterface_something_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 *moqTestInterface_something_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTestInterface_something_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqTestInterface_something_recorder) repeat(repeaters ...moq.Repeater) *moqTestInterface_something_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 moqTestInterface_something_doFn - doReturnFn moqTestInterface_something_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqTestInterface) prettyParams_something(params moqTestInterface_something_params) string { +func (*moqTestInterface_something_adaptor) PrettyParams(params moqTestInterface_something_params) string { return fmt.Sprintf("something()") } -func (m *moqTestInterface) paramsKey_something(params moqTestInterface_something_params, anyParams uint64) moqTestInterface_something_paramsKey { - m.scene.T.Helper() +func (a *moqTestInterface_something_adaptor) ParamsKey(params moqTestInterface_something_params, anyParams uint64) moqTestInterface_something_paramsKey { + a.moq.moq_something.Scene.T.Helper() return moqTestInterface_something_paramsKey{ params: struct{}{}, hashes: struct{}{}, @@ -354,17 +215,12 @@ func (m *moqTestInterface) paramsKey_something(params moqTestInterface_something } // Reset resets the state of the moq -func (m *moqTestInterface) Reset() { m.resultsByParams_something = nil } +func (m *moqTestInterface) Reset() { + m.moq_something.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqTestInterface) AssertExpectationsMet() { - m.scene.T.Helper() - for _, res := range m.resultsByParams_something { - 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_something(results.params)) - } - } - } + m.moq_something.Scene.T.Helper() + m.moq_something.AssertExpectationsMet() } diff --git a/generator/moq_typecache_test.go b/generator/moq_typecache_test.go index 24852e6..44facaf 100644 --- a/generator/moq_typecache_test.go +++ b/generator/moq_typecache_test.go @@ -4,13 +4,12 @@ package generator_test import ( "fmt" - "math/bits" - "sync/atomic" "github.com/dave/dst" "moqueries.org/cli/ast" "moqueries.org/cli/generator" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -20,38 +19,37 @@ var _ generator.TypeCache = (*moqTypeCache_mock)(nil) // moqTypeCache holds the state of a moq of the TypeCache type type moqTypeCache struct { - scene *moq.Scene - config moq.Config - moq *moqTypeCache_mock - - resultsByParams_Type []moqTypeCache_Type_resultsByParams - resultsByParams_IsComparable []moqTypeCache_IsComparable_resultsByParams - resultsByParams_IsDefaultComparable []moqTypeCache_IsDefaultComparable_resultsByParams - resultsByParams_FindPackage []moqTypeCache_FindPackage_resultsByParams - - runtime struct { - parameterIndexing struct { - Type struct { - id moq.ParamIndexing - contextPkg moq.ParamIndexing - testImport moq.ParamIndexing - } - IsComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - IsDefaultComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - FindPackage struct { - dir moq.ParamIndexing - } - } - } - // moqTypeCache_mock isolates the mock interface of the TypeCache type -} - + moq *moqTypeCache_mock + + moq_Type *impl.Moq[ + *moqTypeCache_Type_adaptor, + moqTypeCache_Type_params, + moqTypeCache_Type_paramsKey, + moqTypeCache_Type_results, + ] + moq_IsComparable *impl.Moq[ + *moqTypeCache_IsComparable_adaptor, + moqTypeCache_IsComparable_params, + moqTypeCache_IsComparable_paramsKey, + moqTypeCache_IsComparable_results, + ] + moq_IsDefaultComparable *impl.Moq[ + *moqTypeCache_IsDefaultComparable_adaptor, + moqTypeCache_IsDefaultComparable_params, + moqTypeCache_IsDefaultComparable_paramsKey, + moqTypeCache_IsDefaultComparable_results, + ] + moq_FindPackage *impl.Moq[ + *moqTypeCache_FindPackage_adaptor, + moqTypeCache_FindPackage_params, + moqTypeCache_FindPackage_paramsKey, + moqTypeCache_FindPackage_results, + ] + + runtime moqTypeCache_runtime +} + +// moqTypeCache_mock isolates the mock interface of the TypeCache type type moqTypeCache_mock struct { moq *moqTypeCache } @@ -61,6 +59,21 @@ type moqTypeCache_recorder struct { moq *moqTypeCache } +// moqTypeCache_runtime holds runtime configuration for the TypeCache type +type moqTypeCache_runtime struct { + parameterIndexing struct { + Type moqTypeCache_Type_paramIndexing + IsComparable moqTypeCache_IsComparable_paramIndexing + IsDefaultComparable moqTypeCache_IsDefaultComparable_paramIndexing + FindPackage moqTypeCache_FindPackage_paramIndexing + } +} + +// moqTypeCache_Type_adaptor adapts moqTypeCache as needed by the runtime +type moqTypeCache_Type_adaptor struct { + moq *moqTypeCache +} + // moqTypeCache_Type_params holds the params of the TypeCache type type moqTypeCache_Type_params struct { id dst.Ident @@ -81,12 +94,18 @@ type moqTypeCache_Type_paramsKey struct { } } -// moqTypeCache_Type_resultsByParams contains the results for a given set of -// parameters for the TypeCache type -type moqTypeCache_Type_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTypeCache_Type_paramsKey]*moqTypeCache_Type_results +// moqTypeCache_Type_results holds the results of the TypeCache type +type moqTypeCache_Type_results struct { + result1 ast.TypeInfo + result2 error +} + +// moqTypeCache_Type_paramIndexing holds the parameter indexing runtime +// configuration for the TypeCache type +type moqTypeCache_Type_paramIndexing struct { + id moq.ParamIndexing + contextPkg moq.ParamIndexing + testImport moq.ParamIndexing } // moqTypeCache_Type_doFn defines the type of function needed when calling @@ -97,36 +116,27 @@ type moqTypeCache_Type_doFn func(id dst.Ident, contextPkg string, testImport boo // calling doReturnResults for the TypeCache type type moqTypeCache_Type_doReturnFn func(id dst.Ident, contextPkg string, testImport bool) (ast.TypeInfo, error) -// moqTypeCache_Type_results holds the results of the TypeCache type -type moqTypeCache_Type_results struct { - params moqTypeCache_Type_params - results []struct { - values *struct { - result1 ast.TypeInfo - result2 error - } - sequence uint32 - doFn moqTypeCache_Type_doFn - doReturnFn moqTypeCache_Type_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTypeCache_Type_fnRecorder routes recorded function calls to the +// moqTypeCache_Type_recorder routes recorded function calls to the // moqTypeCache moq -type moqTypeCache_Type_fnRecorder struct { - params moqTypeCache_Type_params - anyParams uint64 - sequence bool - results *moqTypeCache_Type_results - moq *moqTypeCache +type moqTypeCache_Type_recorder struct { + recorder *impl.Recorder[ + *moqTypeCache_Type_adaptor, + moqTypeCache_Type_params, + moqTypeCache_Type_paramsKey, + moqTypeCache_Type_results, + ] } // moqTypeCache_Type_anyParams isolates the any params functions of the // TypeCache type type moqTypeCache_Type_anyParams struct { - recorder *moqTypeCache_Type_fnRecorder + recorder *moqTypeCache_Type_recorder +} + +// moqTypeCache_IsComparable_adaptor adapts moqTypeCache as needed by the +// runtime +type moqTypeCache_IsComparable_adaptor struct { + moq *moqTypeCache } // moqTypeCache_IsComparable_params holds the params of the TypeCache type @@ -148,12 +158,17 @@ type moqTypeCache_IsComparable_paramsKey struct { } } -// moqTypeCache_IsComparable_resultsByParams contains the results for a given -// set of parameters for the TypeCache type -type moqTypeCache_IsComparable_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTypeCache_IsComparable_paramsKey]*moqTypeCache_IsComparable_results +// moqTypeCache_IsComparable_results holds the results of the TypeCache type +type moqTypeCache_IsComparable_results struct { + result1 bool + result2 error +} + +// moqTypeCache_IsComparable_paramIndexing holds the parameter indexing runtime +// configuration for the TypeCache type +type moqTypeCache_IsComparable_paramIndexing struct { + expr moq.ParamIndexing + parentType moq.ParamIndexing } // moqTypeCache_IsComparable_doFn defines the type of function needed when @@ -164,36 +179,27 @@ type moqTypeCache_IsComparable_doFn func(expr dst.Expr, parentType ast.TypeInfo) // when calling doReturnResults for the TypeCache type 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 { - params moqTypeCache_IsComparable_params - results []struct { - values *struct { - result1 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsComparable_doFn - doReturnFn moqTypeCache_IsComparable_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTypeCache_IsComparable_fnRecorder routes recorded function calls to the +// moqTypeCache_IsComparable_recorder routes recorded function calls to the // moqTypeCache moq -type moqTypeCache_IsComparable_fnRecorder struct { - params moqTypeCache_IsComparable_params - anyParams uint64 - sequence bool - results *moqTypeCache_IsComparable_results - moq *moqTypeCache +type moqTypeCache_IsComparable_recorder struct { + recorder *impl.Recorder[ + *moqTypeCache_IsComparable_adaptor, + moqTypeCache_IsComparable_params, + moqTypeCache_IsComparable_paramsKey, + moqTypeCache_IsComparable_results, + ] } // moqTypeCache_IsComparable_anyParams isolates the any params functions of the // TypeCache type type moqTypeCache_IsComparable_anyParams struct { - recorder *moqTypeCache_IsComparable_fnRecorder + recorder *moqTypeCache_IsComparable_recorder +} + +// moqTypeCache_IsDefaultComparable_adaptor adapts moqTypeCache as needed by +// the runtime +type moqTypeCache_IsDefaultComparable_adaptor struct { + moq *moqTypeCache } // moqTypeCache_IsDefaultComparable_params holds the params of the TypeCache @@ -216,12 +222,18 @@ type moqTypeCache_IsDefaultComparable_paramsKey struct { } } -// moqTypeCache_IsDefaultComparable_resultsByParams contains the results for a -// given set of parameters for the TypeCache type -type moqTypeCache_IsDefaultComparable_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTypeCache_IsDefaultComparable_paramsKey]*moqTypeCache_IsDefaultComparable_results +// moqTypeCache_IsDefaultComparable_results holds the results of the TypeCache +// type +type moqTypeCache_IsDefaultComparable_results struct { + result1 bool + result2 error +} + +// moqTypeCache_IsDefaultComparable_paramIndexing holds the parameter indexing +// runtime configuration for the TypeCache type +type moqTypeCache_IsDefaultComparable_paramIndexing struct { + expr moq.ParamIndexing + parentType moq.ParamIndexing } // moqTypeCache_IsDefaultComparable_doFn defines the type of function needed @@ -232,37 +244,27 @@ type moqTypeCache_IsDefaultComparable_doFn func(expr dst.Expr, parentType ast.Ty // needed when calling doReturnResults for the TypeCache type type moqTypeCache_IsDefaultComparable_doReturnFn func(expr dst.Expr, parentType ast.TypeInfo) (bool, error) -// moqTypeCache_IsDefaultComparable_results holds the results of the TypeCache -// type -type moqTypeCache_IsDefaultComparable_results struct { - params moqTypeCache_IsDefaultComparable_params - results []struct { - values *struct { - result1 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsDefaultComparable_doFn - doReturnFn moqTypeCache_IsDefaultComparable_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTypeCache_IsDefaultComparable_fnRecorder routes recorded function calls -// to the moqTypeCache moq -type moqTypeCache_IsDefaultComparable_fnRecorder struct { - params moqTypeCache_IsDefaultComparable_params - anyParams uint64 - sequence bool - results *moqTypeCache_IsDefaultComparable_results - moq *moqTypeCache +// moqTypeCache_IsDefaultComparable_recorder routes recorded function calls to +// the moqTypeCache moq +type moqTypeCache_IsDefaultComparable_recorder struct { + recorder *impl.Recorder[ + *moqTypeCache_IsDefaultComparable_adaptor, + moqTypeCache_IsDefaultComparable_params, + moqTypeCache_IsDefaultComparable_paramsKey, + moqTypeCache_IsDefaultComparable_results, + ] } // moqTypeCache_IsDefaultComparable_anyParams isolates the any params functions // of the TypeCache type type moqTypeCache_IsDefaultComparable_anyParams struct { - recorder *moqTypeCache_IsDefaultComparable_fnRecorder + recorder *moqTypeCache_IsDefaultComparable_recorder +} + +// moqTypeCache_FindPackage_adaptor adapts moqTypeCache as needed by the +// runtime +type moqTypeCache_FindPackage_adaptor struct { + moq *moqTypeCache } // moqTypeCache_FindPackage_params holds the params of the TypeCache type @@ -275,12 +277,16 @@ type moqTypeCache_FindPackage_paramsKey struct { hashes struct{ dir hash.Hash } } -// moqTypeCache_FindPackage_resultsByParams contains the results for a given -// set of parameters for the TypeCache type -type moqTypeCache_FindPackage_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTypeCache_FindPackage_paramsKey]*moqTypeCache_FindPackage_results +// moqTypeCache_FindPackage_results holds the results of the TypeCache type +type moqTypeCache_FindPackage_results struct { + result1 string + result2 error +} + +// moqTypeCache_FindPackage_paramIndexing holds the parameter indexing runtime +// configuration for the TypeCache type +type moqTypeCache_FindPackage_paramIndexing struct { + dir moq.ParamIndexing } // moqTypeCache_FindPackage_doFn defines the type of function needed when @@ -291,117 +297,88 @@ type moqTypeCache_FindPackage_doFn func(dir string) // calling doReturnResults for the TypeCache type type moqTypeCache_FindPackage_doReturnFn func(dir string) (string, error) -// moqTypeCache_FindPackage_results holds the results of the TypeCache type -type moqTypeCache_FindPackage_results struct { - params moqTypeCache_FindPackage_params - results []struct { - values *struct { - result1 string - result2 error - } - sequence uint32 - doFn moqTypeCache_FindPackage_doFn - doReturnFn moqTypeCache_FindPackage_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTypeCache_FindPackage_fnRecorder routes recorded function calls to the +// moqTypeCache_FindPackage_recorder routes recorded function calls to the // moqTypeCache moq -type moqTypeCache_FindPackage_fnRecorder struct { - params moqTypeCache_FindPackage_params - anyParams uint64 - sequence bool - results *moqTypeCache_FindPackage_results - moq *moqTypeCache +type moqTypeCache_FindPackage_recorder struct { + recorder *impl.Recorder[ + *moqTypeCache_FindPackage_adaptor, + moqTypeCache_FindPackage_params, + moqTypeCache_FindPackage_paramsKey, + moqTypeCache_FindPackage_results, + ] } // moqTypeCache_FindPackage_anyParams isolates the any params functions of the // TypeCache type type moqTypeCache_FindPackage_anyParams struct { - recorder *moqTypeCache_FindPackage_fnRecorder + recorder *moqTypeCache_FindPackage_recorder } // newMoqTypeCache creates a new moq of the TypeCache type func newMoqTypeCache(scene *moq.Scene, config *moq.Config) *moqTypeCache { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqTypeCache_Type_adaptor{} + adaptor2 := &moqTypeCache_IsComparable_adaptor{} + adaptor3 := &moqTypeCache_IsDefaultComparable_adaptor{} + adaptor4 := &moqTypeCache_FindPackage_adaptor{} m := &moqTypeCache{ - scene: scene, - config: *config, - moq: &moqTypeCache_mock{}, - - runtime: struct { - parameterIndexing struct { - Type struct { - id moq.ParamIndexing - contextPkg moq.ParamIndexing - testImport moq.ParamIndexing - } - IsComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - IsDefaultComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - FindPackage struct { - dir moq.ParamIndexing - } - } - }{parameterIndexing: struct { - Type struct { - id moq.ParamIndexing - contextPkg moq.ParamIndexing - testImport moq.ParamIndexing - } - IsComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - IsDefaultComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - FindPackage struct { - dir moq.ParamIndexing - } + moq: &moqTypeCache_mock{}, + + moq_Type: impl.NewMoq[ + *moqTypeCache_Type_adaptor, + moqTypeCache_Type_params, + moqTypeCache_Type_paramsKey, + moqTypeCache_Type_results, + ](scene, adaptor1, config), + moq_IsComparable: impl.NewMoq[ + *moqTypeCache_IsComparable_adaptor, + moqTypeCache_IsComparable_params, + moqTypeCache_IsComparable_paramsKey, + moqTypeCache_IsComparable_results, + ](scene, adaptor2, config), + moq_IsDefaultComparable: impl.NewMoq[ + *moqTypeCache_IsDefaultComparable_adaptor, + moqTypeCache_IsDefaultComparable_params, + moqTypeCache_IsDefaultComparable_paramsKey, + moqTypeCache_IsDefaultComparable_results, + ](scene, adaptor3, config), + moq_FindPackage: impl.NewMoq[ + *moqTypeCache_FindPackage_adaptor, + moqTypeCache_FindPackage_params, + moqTypeCache_FindPackage_paramsKey, + moqTypeCache_FindPackage_results, + ](scene, adaptor4, config), + + runtime: moqTypeCache_runtime{parameterIndexing: struct { + Type moqTypeCache_Type_paramIndexing + IsComparable moqTypeCache_IsComparable_paramIndexing + IsDefaultComparable moqTypeCache_IsDefaultComparable_paramIndexing + FindPackage moqTypeCache_FindPackage_paramIndexing }{ - Type: struct { - id moq.ParamIndexing - contextPkg moq.ParamIndexing - testImport moq.ParamIndexing - }{ + Type: moqTypeCache_Type_paramIndexing{ id: moq.ParamIndexByHash, contextPkg: moq.ParamIndexByValue, testImport: moq.ParamIndexByValue, }, - IsComparable: struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - }{ + IsComparable: moqTypeCache_IsComparable_paramIndexing{ expr: moq.ParamIndexByHash, parentType: moq.ParamIndexByHash, }, - IsDefaultComparable: struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - }{ + IsDefaultComparable: moqTypeCache_IsDefaultComparable_paramIndexing{ expr: moq.ParamIndexByHash, parentType: moq.ParamIndexByHash, }, - FindPackage: struct { - dir moq.ParamIndexing - }{ + FindPackage: moqTypeCache_FindPackage_paramIndexing{ dir: moq.ParamIndexByValue, }, }}, } m.moq.moq = m + adaptor1.moq = m + adaptor2.moq = m + adaptor3.moq = m + adaptor4.moq = m + scene.AddMoq(m) return m } @@ -409,224 +386,68 @@ func newMoqTypeCache(scene *moq.Scene, config *moq.Config) *moqTypeCache { // mock returns the mock implementation of the TypeCache type func (m *moqTypeCache) mock() *moqTypeCache_mock { return m.moq } -func (m *moqTypeCache_mock) Type(id dst.Ident, contextPkg string, testImport bool) (result1 ast.TypeInfo, result2 error) { - m.moq.scene.T.Helper() +func (m *moqTypeCache_mock) Type(id dst.Ident, contextPkg string, testImport bool) (ast.TypeInfo, error) { + m.moq.moq_Type.Scene.T.Helper() params := moqTypeCache_Type_params{ id: id, contextPkg: contextPkg, testImport: testImport, } - var results *moqTypeCache_Type_results - for _, resultsByParams := range m.moq.resultsByParams_Type { - paramsKey := m.moq.paramsKey_Type(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_Type(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_Type(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_Type(params)) - } - } - - if result.doFn != nil { - result.doFn(id, contextPkg, testImport) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(id, contextPkg, testImport) + var result1 ast.TypeInfo + var result2 error + if result := m.moq.moq_Type.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - return + return result1, result2 } -func (m *moqTypeCache_mock) IsComparable(expr dst.Expr, parentType ast.TypeInfo) (result1 bool, result2 error) { - m.moq.scene.T.Helper() +func (m *moqTypeCache_mock) IsComparable(expr dst.Expr, parentType ast.TypeInfo) (bool, error) { + m.moq.moq_IsComparable.Scene.T.Helper() params := moqTypeCache_IsComparable_params{ expr: expr, parentType: parentType, } - var results *moqTypeCache_IsComparable_results - for _, resultsByParams := range m.moq.resultsByParams_IsComparable { - paramsKey := m.moq.paramsKey_IsComparable(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_IsComparable(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_IsComparable(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_IsComparable(params)) - } - } - if result.doFn != nil { - result.doFn(expr, parentType) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(expr, parentType) + var result1 bool + var result2 error + if result := m.moq.moq_IsComparable.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - return + return result1, result2 } -func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) (result1 bool, result2 error) { - m.moq.scene.T.Helper() +func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) (bool, error) { + m.moq.moq_IsDefaultComparable.Scene.T.Helper() params := moqTypeCache_IsDefaultComparable_params{ expr: expr, parentType: parentType, } - var results *moqTypeCache_IsDefaultComparable_results - for _, resultsByParams := range m.moq.resultsByParams_IsDefaultComparable { - paramsKey := m.moq.paramsKey_IsDefaultComparable(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_IsDefaultComparable(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_IsDefaultComparable(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_IsDefaultComparable(params)) - } - } - - if result.doFn != nil { - result.doFn(expr, parentType) - } - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 + var result1 bool + var result2 error + if result := m.moq.moq_IsDefaultComparable.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(expr, parentType) - } - return + return result1, result2 } -func (m *moqTypeCache_mock) FindPackage(dir string) (result1 string, result2 error) { - m.moq.scene.T.Helper() +func (m *moqTypeCache_mock) FindPackage(dir string) (string, error) { + m.moq.moq_FindPackage.Scene.T.Helper() params := moqTypeCache_FindPackage_params{ dir: dir, } - var results *moqTypeCache_FindPackage_results - for _, resultsByParams := range m.moq.resultsByParams_FindPackage { - paramsKey := m.moq.paramsKey_FindPackage(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_FindPackage(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_FindPackage(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_FindPackage(params)) - } + var result1 string + var result2 error + if result := m.moq.moq_FindPackage.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - - if result.doFn != nil { - result.doFn(dir) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(dir) - } - return + return result1, result2 } // onCall returns the recorder implementation of the TypeCache type @@ -636,232 +457,106 @@ func (m *moqTypeCache) onCall() *moqTypeCache_recorder { } } -func (m *moqTypeCache_recorder) Type(id dst.Ident, contextPkg string, testImport bool) *moqTypeCache_Type_fnRecorder { - return &moqTypeCache_Type_fnRecorder{ - params: moqTypeCache_Type_params{ +func (m *moqTypeCache_recorder) Type(id dst.Ident, contextPkg string, testImport bool) *moqTypeCache_Type_recorder { + return &moqTypeCache_Type_recorder{ + recorder: m.moq.moq_Type.OnCall(moqTypeCache_Type_params{ id: id, contextPkg: contextPkg, testImport: testImport, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqTypeCache_Type_fnRecorder) any() *moqTypeCache_Type_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_Type(r.params)) +func (r *moqTypeCache_Type_recorder) any() *moqTypeCache_Type_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTypeCache_Type_anyParams{recorder: r} } -func (a *moqTypeCache_Type_anyParams) id() *moqTypeCache_Type_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqTypeCache_Type_anyParams) id() *moqTypeCache_Type_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqTypeCache_Type_anyParams) contextPkg() *moqTypeCache_Type_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqTypeCache_Type_anyParams) contextPkg() *moqTypeCache_Type_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (a *moqTypeCache_Type_anyParams) testImport() *moqTypeCache_Type_fnRecorder { - a.recorder.anyParams |= 1 << 2 +func (a *moqTypeCache_Type_anyParams) testImport() *moqTypeCache_Type_recorder { + a.recorder.recorder.AnyParam(3) return a.recorder } -func (r *moqTypeCache_Type_fnRecorder) seq() *moqTypeCache_Type_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_Type(r.params)) +func (r *moqTypeCache_Type_recorder) seq() *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTypeCache_Type_fnRecorder) noSeq() *moqTypeCache_Type_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_Type(r.params)) +func (r *moqTypeCache_Type_recorder) noSeq() *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTypeCache_Type_fnRecorder) returnResults(result1 ast.TypeInfo, result2 error) *moqTypeCache_Type_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 ast.TypeInfo - result2 error - } - sequence uint32 - doFn moqTypeCache_Type_doFn - doReturnFn moqTypeCache_Type_doReturnFn - }{ - values: &struct { - result1 ast.TypeInfo - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqTypeCache_Type_recorder) returnResults(result1 ast.TypeInfo, result2 error) *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTypeCache_Type_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqTypeCache_Type_fnRecorder) andDo(fn moqTypeCache_Type_doFn) *moqTypeCache_Type_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTypeCache_Type_recorder) andDo(fn moqTypeCache_Type_doFn) *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTypeCache_Type_params) { + fn(params.id, params.contextPkg, params.testImport) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTypeCache_Type_fnRecorder) doReturnResults(fn moqTypeCache_Type_doReturnFn) *moqTypeCache_Type_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 ast.TypeInfo - result2 error +func (r *moqTypeCache_Type_recorder) doReturnResults(fn moqTypeCache_Type_doReturnFn) *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTypeCache_Type_params) *moqTypeCache_Type_results { + result1, result2 := fn(params.id, params.contextPkg, params.testImport) + return &moqTypeCache_Type_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqTypeCache_Type_doFn - doReturnFn moqTypeCache_Type_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqTypeCache_Type_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 *moqTypeCache_Type_resultsByParams - for n, res := range r.moq.resultsByParams_Type { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqTypeCache_Type_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTypeCache_Type_paramsKey]*moqTypeCache_Type_results{}, - } - r.moq.resultsByParams_Type = append(r.moq.resultsByParams_Type, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Type) { - copy(r.moq.resultsByParams_Type[insertAt+1:], r.moq.resultsByParams_Type[insertAt:0]) - r.moq.resultsByParams_Type[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Type(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTypeCache_Type_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 *moqTypeCache_Type_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_Type_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqTypeCache_Type_recorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 ast.TypeInfo - result2 error - } - sequence uint32 - doFn moqTypeCache_Type_doFn - doReturnFn moqTypeCache_Type_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqTypeCache) prettyParams_Type(params moqTypeCache_Type_params) string { +func (*moqTypeCache_Type_adaptor) PrettyParams(params moqTypeCache_Type_params) string { return fmt.Sprintf("Type(%#v, %#v, %#v)", params.id, params.contextPkg, params.testImport) } -func (m *moqTypeCache) paramsKey_Type(params moqTypeCache_Type_params, anyParams uint64) moqTypeCache_Type_paramsKey { - m.scene.T.Helper() - var idUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Type.id == moq.ParamIndexByValue { - m.scene.T.Fatalf("The id parameter of the Type function can't be indexed by value") - } - idUsedHash = hash.DeepHash(params.id) - } - var contextPkgUsed string - var contextPkgUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.Type.contextPkg == moq.ParamIndexByValue { - contextPkgUsed = params.contextPkg - } else { - contextPkgUsedHash = hash.DeepHash(params.contextPkg) - } - } - var testImportUsed bool - var testImportUsedHash hash.Hash - if anyParams&(1<<2) == 0 { - if m.runtime.parameterIndexing.Type.testImport == moq.ParamIndexByValue { - testImportUsed = params.testImport - } else { - testImportUsedHash = hash.DeepHash(params.testImport) - } - } +func (a *moqTypeCache_Type_adaptor) ParamsKey(params moqTypeCache_Type_params, anyParams uint64) moqTypeCache_Type_paramsKey { + a.moq.moq_Type.Scene.T.Helper() + idUsedHash := impl.HashOnlyParamKey(a.moq.moq_Type.Scene.T, + params.id, "id", 1, a.moq.runtime.parameterIndexing.Type.id, anyParams) + contextPkgUsed, contextPkgUsedHash := impl.ParamKey( + params.contextPkg, 2, a.moq.runtime.parameterIndexing.Type.contextPkg, anyParams) + testImportUsed, testImportUsedHash := impl.ParamKey( + params.testImport, 3, a.moq.runtime.parameterIndexing.Type.testImport, anyParams) return moqTypeCache_Type_paramsKey{ params: struct { contextPkg string @@ -882,219 +577,98 @@ func (m *moqTypeCache) paramsKey_Type(params moqTypeCache_Type_params, anyParams } } -func (m *moqTypeCache_recorder) IsComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsComparable_fnRecorder { - return &moqTypeCache_IsComparable_fnRecorder{ - params: moqTypeCache_IsComparable_params{ +func (m *moqTypeCache_recorder) IsComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsComparable_recorder { + return &moqTypeCache_IsComparable_recorder{ + recorder: m.moq.moq_IsComparable.OnCall(moqTypeCache_IsComparable_params{ expr: expr, parentType: parentType, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqTypeCache_IsComparable_fnRecorder) any() *moqTypeCache_IsComparable_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_IsComparable(r.params)) +func (r *moqTypeCache_IsComparable_recorder) any() *moqTypeCache_IsComparable_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTypeCache_IsComparable_anyParams{recorder: r} } -func (a *moqTypeCache_IsComparable_anyParams) expr() *moqTypeCache_IsComparable_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqTypeCache_IsComparable_anyParams) expr() *moqTypeCache_IsComparable_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqTypeCache_IsComparable_anyParams) parentType() *moqTypeCache_IsComparable_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqTypeCache_IsComparable_anyParams) parentType() *moqTypeCache_IsComparable_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqTypeCache_IsComparable_fnRecorder) seq() *moqTypeCache_IsComparable_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_IsComparable(r.params)) +func (r *moqTypeCache_IsComparable_recorder) seq() *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTypeCache_IsComparable_fnRecorder) noSeq() *moqTypeCache_IsComparable_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_IsComparable(r.params)) +func (r *moqTypeCache_IsComparable_recorder) noSeq() *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTypeCache_IsComparable_fnRecorder) returnResults(result1 bool, result2 error) *moqTypeCache_IsComparable_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 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsComparable_doFn - doReturnFn moqTypeCache_IsComparable_doReturnFn - }{ - values: &struct { - result1 bool - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqTypeCache_IsComparable_recorder) returnResults(result1 bool, result2 error) *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTypeCache_IsComparable_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqTypeCache_IsComparable_fnRecorder) andDo(fn moqTypeCache_IsComparable_doFn) *moqTypeCache_IsComparable_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTypeCache_IsComparable_recorder) andDo(fn moqTypeCache_IsComparable_doFn) *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTypeCache_IsComparable_params) { + fn(params.expr, params.parentType) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTypeCache_IsComparable_fnRecorder) doReturnResults(fn moqTypeCache_IsComparable_doReturnFn) *moqTypeCache_IsComparable_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 bool - result2 error +func (r *moqTypeCache_IsComparable_recorder) doReturnResults(fn moqTypeCache_IsComparable_doReturnFn) *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTypeCache_IsComparable_params) *moqTypeCache_IsComparable_results { + result1, result2 := fn(params.expr, params.parentType) + return &moqTypeCache_IsComparable_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqTypeCache_IsComparable_doFn - doReturnFn moqTypeCache_IsComparable_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqTypeCache_IsComparable_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 *moqTypeCache_IsComparable_resultsByParams - for n, res := range r.moq.resultsByParams_IsComparable { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqTypeCache_IsComparable_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTypeCache_IsComparable_paramsKey]*moqTypeCache_IsComparable_results{}, - } - r.moq.resultsByParams_IsComparable = append(r.moq.resultsByParams_IsComparable, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_IsComparable) { - copy(r.moq.resultsByParams_IsComparable[insertAt+1:], r.moq.resultsByParams_IsComparable[insertAt:0]) - r.moq.resultsByParams_IsComparable[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_IsComparable(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTypeCache_IsComparable_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 *moqTypeCache_IsComparable_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_IsComparable_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqTypeCache_IsComparable_recorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsComparable_doFn - doReturnFn moqTypeCache_IsComparable_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqTypeCache) prettyParams_IsComparable(params moqTypeCache_IsComparable_params) string { +func (*moqTypeCache_IsComparable_adaptor) PrettyParams(params moqTypeCache_IsComparable_params) string { return fmt.Sprintf("IsComparable(%#v, %#v)", params.expr, params.parentType) } -func (m *moqTypeCache) paramsKey_IsComparable(params moqTypeCache_IsComparable_params, anyParams uint64) moqTypeCache_IsComparable_paramsKey { - m.scene.T.Helper() - var exprUsed dst.Expr - var exprUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.IsComparable.expr == moq.ParamIndexByValue { - exprUsed = params.expr - } else { - 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) - } - } +func (a *moqTypeCache_IsComparable_adaptor) ParamsKey(params moqTypeCache_IsComparable_params, anyParams uint64) moqTypeCache_IsComparable_paramsKey { + a.moq.moq_IsComparable.Scene.T.Helper() + exprUsed, exprUsedHash := impl.ParamKey( + params.expr, 1, a.moq.runtime.parameterIndexing.IsComparable.expr, anyParams) + parentTypeUsed, parentTypeUsedHash := impl.ParamKey( + params.parentType, 2, a.moq.runtime.parameterIndexing.IsComparable.parentType, anyParams) return moqTypeCache_IsComparable_paramsKey{ params: struct { expr dst.Expr @@ -1113,219 +687,98 @@ func (m *moqTypeCache) paramsKey_IsComparable(params moqTypeCache_IsComparable_p } } -func (m *moqTypeCache_recorder) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsDefaultComparable_fnRecorder { - return &moqTypeCache_IsDefaultComparable_fnRecorder{ - params: moqTypeCache_IsDefaultComparable_params{ +func (m *moqTypeCache_recorder) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsDefaultComparable_recorder { + return &moqTypeCache_IsDefaultComparable_recorder{ + recorder: m.moq.moq_IsDefaultComparable.OnCall(moqTypeCache_IsDefaultComparable_params{ expr: expr, parentType: parentType, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) any() *moqTypeCache_IsDefaultComparable_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_IsDefaultComparable(r.params)) +func (r *moqTypeCache_IsDefaultComparable_recorder) any() *moqTypeCache_IsDefaultComparable_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTypeCache_IsDefaultComparable_anyParams{recorder: r} } -func (a *moqTypeCache_IsDefaultComparable_anyParams) expr() *moqTypeCache_IsDefaultComparable_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqTypeCache_IsDefaultComparable_anyParams) expr() *moqTypeCache_IsDefaultComparable_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqTypeCache_IsDefaultComparable_anyParams) parentType() *moqTypeCache_IsDefaultComparable_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqTypeCache_IsDefaultComparable_anyParams) parentType() *moqTypeCache_IsDefaultComparable_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) seq() *moqTypeCache_IsDefaultComparable_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_IsDefaultComparable(r.params)) +func (r *moqTypeCache_IsDefaultComparable_recorder) seq() *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) noSeq() *moqTypeCache_IsDefaultComparable_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_IsDefaultComparable(r.params)) +func (r *moqTypeCache_IsDefaultComparable_recorder) noSeq() *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) returnResults(result1 bool, result2 error) *moqTypeCache_IsDefaultComparable_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 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsDefaultComparable_doFn - doReturnFn moqTypeCache_IsDefaultComparable_doReturnFn - }{ - values: &struct { - result1 bool - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqTypeCache_IsDefaultComparable_recorder) returnResults(result1 bool, result2 error) *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTypeCache_IsDefaultComparable_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) andDo(fn moqTypeCache_IsDefaultComparable_doFn) *moqTypeCache_IsDefaultComparable_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTypeCache_IsDefaultComparable_recorder) andDo(fn moqTypeCache_IsDefaultComparable_doFn) *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTypeCache_IsDefaultComparable_params) { + fn(params.expr, params.parentType) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) doReturnResults(fn moqTypeCache_IsDefaultComparable_doReturnFn) *moqTypeCache_IsDefaultComparable_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 bool - result2 error +func (r *moqTypeCache_IsDefaultComparable_recorder) doReturnResults(fn moqTypeCache_IsDefaultComparable_doReturnFn) *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTypeCache_IsDefaultComparable_params) *moqTypeCache_IsDefaultComparable_results { + result1, result2 := fn(params.expr, params.parentType) + return &moqTypeCache_IsDefaultComparable_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqTypeCache_IsDefaultComparable_doFn - doReturnFn moqTypeCache_IsDefaultComparable_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqTypeCache_IsDefaultComparable_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 *moqTypeCache_IsDefaultComparable_resultsByParams - for n, res := range r.moq.resultsByParams_IsDefaultComparable { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqTypeCache_IsDefaultComparable_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTypeCache_IsDefaultComparable_paramsKey]*moqTypeCache_IsDefaultComparable_results{}, - } - r.moq.resultsByParams_IsDefaultComparable = append(r.moq.resultsByParams_IsDefaultComparable, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_IsDefaultComparable) { - copy(r.moq.resultsByParams_IsDefaultComparable[insertAt+1:], r.moq.resultsByParams_IsDefaultComparable[insertAt:0]) - r.moq.resultsByParams_IsDefaultComparable[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_IsDefaultComparable(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTypeCache_IsDefaultComparable_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 *moqTypeCache_IsDefaultComparable_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_IsDefaultComparable_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqTypeCache_IsDefaultComparable_recorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsDefaultComparable_doFn - doReturnFn moqTypeCache_IsDefaultComparable_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqTypeCache) prettyParams_IsDefaultComparable(params moqTypeCache_IsDefaultComparable_params) string { +func (*moqTypeCache_IsDefaultComparable_adaptor) PrettyParams(params moqTypeCache_IsDefaultComparable_params) string { return fmt.Sprintf("IsDefaultComparable(%#v, %#v)", params.expr, params.parentType) } -func (m *moqTypeCache) paramsKey_IsDefaultComparable(params moqTypeCache_IsDefaultComparable_params, anyParams uint64) moqTypeCache_IsDefaultComparable_paramsKey { - m.scene.T.Helper() - var exprUsed dst.Expr - var exprUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.IsDefaultComparable.expr == moq.ParamIndexByValue { - exprUsed = params.expr - } else { - 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) - } - } +func (a *moqTypeCache_IsDefaultComparable_adaptor) ParamsKey(params moqTypeCache_IsDefaultComparable_params, anyParams uint64) moqTypeCache_IsDefaultComparable_paramsKey { + a.moq.moq_IsDefaultComparable.Scene.T.Helper() + exprUsed, exprUsedHash := impl.ParamKey( + params.expr, 1, a.moq.runtime.parameterIndexing.IsDefaultComparable.expr, anyParams) + parentTypeUsed, parentTypeUsedHash := impl.ParamKey( + params.parentType, 2, a.moq.runtime.parameterIndexing.IsDefaultComparable.parentType, anyParams) return moqTypeCache_IsDefaultComparable_paramsKey{ params: struct { expr dst.Expr @@ -1344,204 +797,90 @@ func (m *moqTypeCache) paramsKey_IsDefaultComparable(params moqTypeCache_IsDefau } } -func (m *moqTypeCache_recorder) FindPackage(dir string) *moqTypeCache_FindPackage_fnRecorder { - return &moqTypeCache_FindPackage_fnRecorder{ - params: moqTypeCache_FindPackage_params{ +func (m *moqTypeCache_recorder) FindPackage(dir string) *moqTypeCache_FindPackage_recorder { + return &moqTypeCache_FindPackage_recorder{ + recorder: m.moq.moq_FindPackage.OnCall(moqTypeCache_FindPackage_params{ dir: dir, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqTypeCache_FindPackage_fnRecorder) any() *moqTypeCache_FindPackage_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_FindPackage(r.params)) +func (r *moqTypeCache_FindPackage_recorder) any() *moqTypeCache_FindPackage_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTypeCache_FindPackage_anyParams{recorder: r} } -func (a *moqTypeCache_FindPackage_anyParams) dir() *moqTypeCache_FindPackage_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqTypeCache_FindPackage_anyParams) dir() *moqTypeCache_FindPackage_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqTypeCache_FindPackage_fnRecorder) seq() *moqTypeCache_FindPackage_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_FindPackage(r.params)) +func (r *moqTypeCache_FindPackage_recorder) seq() *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTypeCache_FindPackage_fnRecorder) noSeq() *moqTypeCache_FindPackage_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_FindPackage(r.params)) +func (r *moqTypeCache_FindPackage_recorder) noSeq() *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTypeCache_FindPackage_fnRecorder) returnResults(result1 string, result2 error) *moqTypeCache_FindPackage_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 moqTypeCache_FindPackage_doFn - doReturnFn moqTypeCache_FindPackage_doReturnFn - }{ - values: &struct { - result1 string - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqTypeCache_FindPackage_recorder) returnResults(result1 string, result2 error) *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTypeCache_FindPackage_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqTypeCache_FindPackage_fnRecorder) andDo(fn moqTypeCache_FindPackage_doFn) *moqTypeCache_FindPackage_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTypeCache_FindPackage_recorder) andDo(fn moqTypeCache_FindPackage_doFn) *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTypeCache_FindPackage_params) { + fn(params.dir) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTypeCache_FindPackage_fnRecorder) doReturnResults(fn moqTypeCache_FindPackage_doReturnFn) *moqTypeCache_FindPackage_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 +func (r *moqTypeCache_FindPackage_recorder) doReturnResults(fn moqTypeCache_FindPackage_doReturnFn) *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTypeCache_FindPackage_params) *moqTypeCache_FindPackage_results { + result1, result2 := fn(params.dir) + return &moqTypeCache_FindPackage_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqTypeCache_FindPackage_doFn - doReturnFn moqTypeCache_FindPackage_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqTypeCache_FindPackage_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 *moqTypeCache_FindPackage_resultsByParams - for n, res := range r.moq.resultsByParams_FindPackage { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqTypeCache_FindPackage_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTypeCache_FindPackage_paramsKey]*moqTypeCache_FindPackage_results{}, - } - r.moq.resultsByParams_FindPackage = append(r.moq.resultsByParams_FindPackage, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_FindPackage) { - copy(r.moq.resultsByParams_FindPackage[insertAt+1:], r.moq.resultsByParams_FindPackage[insertAt:0]) - r.moq.resultsByParams_FindPackage[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_FindPackage(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTypeCache_FindPackage_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 *moqTypeCache_FindPackage_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_FindPackage_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqTypeCache_FindPackage_recorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 moqTypeCache_FindPackage_doFn - doReturnFn moqTypeCache_FindPackage_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqTypeCache) prettyParams_FindPackage(params moqTypeCache_FindPackage_params) string { +func (*moqTypeCache_FindPackage_adaptor) PrettyParams(params moqTypeCache_FindPackage_params) string { return fmt.Sprintf("FindPackage(%#v)", params.dir) } -func (m *moqTypeCache) paramsKey_FindPackage(params moqTypeCache_FindPackage_params, anyParams uint64) moqTypeCache_FindPackage_paramsKey { - m.scene.T.Helper() - var dirUsed string - var dirUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.FindPackage.dir == moq.ParamIndexByValue { - dirUsed = params.dir - } else { - dirUsedHash = hash.DeepHash(params.dir) - } - } +func (a *moqTypeCache_FindPackage_adaptor) ParamsKey(params moqTypeCache_FindPackage_params, anyParams uint64) moqTypeCache_FindPackage_paramsKey { + a.moq.moq_FindPackage.Scene.T.Helper() + dirUsed, dirUsedHash := impl.ParamKey( + params.dir, 1, a.moq.runtime.parameterIndexing.FindPackage.dir, anyParams) return moqTypeCache_FindPackage_paramsKey{ params: struct{ dir string }{ dir: dirUsed, @@ -1554,45 +893,17 @@ func (m *moqTypeCache) paramsKey_FindPackage(params moqTypeCache_FindPackage_par // Reset resets the state of the moq func (m *moqTypeCache) Reset() { - m.resultsByParams_Type = nil - m.resultsByParams_IsComparable = nil - m.resultsByParams_IsDefaultComparable = nil - m.resultsByParams_FindPackage = nil + m.moq_Type.Reset() + m.moq_IsComparable.Reset() + m.moq_IsDefaultComparable.Reset() + m.moq_FindPackage.Reset() } // AssertExpectationsMet asserts that all expectations have been met func (m *moqTypeCache) AssertExpectationsMet() { - m.scene.T.Helper() - for _, res := range m.resultsByParams_Type { - 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_Type(results.params)) - } - } - } - for _, res := range m.resultsByParams_IsComparable { - 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_IsComparable(results.params)) - } - } - } - for _, res := range m.resultsByParams_IsDefaultComparable { - 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_IsDefaultComparable(results.params)) - } - } - } - for _, res := range m.resultsByParams_FindPackage { - 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_FindPackage(results.params)) - } - } - } + m.moq_Type.Scene.T.Helper() + m.moq_Type.AssertExpectationsMet() + m.moq_IsComparable.AssertExpectationsMet() + m.moq_IsDefaultComparable.AssertExpectationsMet() + m.moq_FindPackage.AssertExpectationsMet() } diff --git a/generator/moqgen.go b/generator/moqgen.go index eb1298f..0f3c858 100644 --- a/generator/moqgen.go +++ b/generator/moqgen.go @@ -52,7 +52,7 @@ 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, err error) - IsolationStruct(suffix string) (structDecl *dst.GenDecl, err error) + MockStructs() (structDecls []dst.Decl, err error) MethodStructs(fn Func) (structDecls []dst.Decl, err error) NewFunc() (funcDecl *dst.FuncDecl, err error) IsolationAccessor(suffix, fnName string) (funcDecl *dst.FuncDecl, err error) @@ -488,21 +488,11 @@ func (g *MoqGenerator) structs(converter Converterer, typ Type) ([]dst.Decl, err if err != nil { return nil, err } - mockIsolStruct, err := converter.IsolationStruct(mockIdent) + mockStructs, err := converter.MockStructs() 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 { - recIsolStruct, err := converter.IsolationStruct(recorderIdent) - if err != nil { - return nil, err - } - decls = append(decls, recIsolStruct) - } + decls = append(decls, mockStructs...) for _, fn := range typ.Funcs { structs, err := converter.MethodStructs(fn) @@ -561,12 +551,6 @@ func (g *MoqGenerator) methods( } decls = append(decls, fnClos) - meth, err := converter.MockMethod(funcs[0]) - if err != nil { - return nil, err - } - decls = append(decls, meth) - meths, err := converter.RecorderMethods(funcs[0]) if err != nil { return nil, err diff --git a/generator/moqgen_test.go b/generator/moqgen_test.go index 315036e..ac48fa2 100644 --- a/generator/moqgen_test.go +++ b/generator/moqgen_test.go @@ -559,9 +559,7 @@ func TestMoqGenerator(t *testing.T) { 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, nil) - converter1Moq.onCall().IsolationStruct("recorder"). + converter1Moq.onCall().MockStructs(). returnResults(nil, nil) converter1Moq.onCall().MethodStructs(ifaceFuncs[0]). returnResults(nil, nil) @@ -602,9 +600,7 @@ func TestMoqGenerator(t *testing.T) { OutPkgPath: tc.outPkgPath, }, tc.request.Export).returnResults(converter2Moq.mock()) converter2Moq.onCall().BaseDecls().returnResults(nil, nil) - converter2Moq.onCall().IsolationStruct("mock"). - returnResults(nil, nil) - converter2Moq.onCall().IsolationStruct("recorder"). + converter2Moq.onCall().MockStructs(). returnResults(nil, nil) converter2Moq.onCall().MethodStructs(iface2Funcs[0]). returnResults(nil, nil) @@ -739,9 +735,7 @@ func TestMoqGenerator(t *testing.T) { 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, nil) - converter1Moq.onCall().IsolationStruct("recorder"). + converter1Moq.onCall().MockStructs(). returnResults(nil, nil) converter1Moq.onCall().MethodStructs(ifaceFuncs[0]). returnResults(nil, nil) @@ -884,7 +878,7 @@ func TestMoqGenerator(t *testing.T) { "func type params": ast.FnType(fl).Obj, "func type results": ast.FnType(nil).Results(fl).Obj, "interface type": &dst.InterfaceType{Methods: fl}, - "star expr": ast.Star(ast.Id("string")), + "star expr": ast.Star(ast.Id("string")).Obj, "struct type": ast.Struct(ast.Field(ast.Id("string")).Obj), "map key": ast.MapType(ast.Id("string")).Value(ast.Id("int")).Obj, "map value": ast.MapType(ast.Id("int")).Value(ast.Id("string")).Obj, @@ -957,7 +951,7 @@ func TestMoqGenerator(t *testing.T) { "ellipsis w/ literal": ast.Ellipsis(ast.LitInt(48)), "func type w/ literal": ast.FnType(weirdFL).Obj, "interface type w/ literal": &dst.InterfaceType{Methods: weirdFL}, - "star expr w/ literal": ast.Star(ast.LitInt(91)), + "star expr w/ literal": ast.Star(ast.LitInt(91)).Obj, "struct type w/ literal": ast.Struct(ast.Field(ast.LitInt(65)).Obj), "map type w/ literal": ast.MapType(ast.LitInt(38)).Value(ast.Id("string")).Obj, } @@ -1155,9 +1149,7 @@ func TestMoqGenerator(t *testing.T) { OutPkgPath: "thispkg_test", }, false).returnResults(converter1Moq.mock()) converter1Moq.onCall().BaseDecls().returnResults(nil, nil) - converter1Moq.onCall().IsolationStruct("mock"). - returnResults(nil, nil) - converter1Moq.onCall().IsolationStruct("recorder"). + converter1Moq.onCall().MockStructs(). returnResults(nil, nil) converter1Moq.onCall().MethodStructs(ifaceFuncs[0]). returnResults(nil, nil) @@ -1280,7 +1272,7 @@ func TestMoqGenerator(t *testing.T) { }) t.Run("returns a converter error", func(t *testing.T) { - for n := 1; n < 20; n++ { + for n := 1; n < 19; n++ { t.Run(fmt.Sprintf("%d calls", n), func(t *testing.T) { // ASSEMBLE beforeEach(t) @@ -1325,11 +1317,7 @@ func TestMoqGenerator(t *testing.T) { }}, retError()) } if !done() { - converter1Moq.onCall().IsolationStruct("mock"). - returnResults(nil, retError()) - } - if !done() { - converter1Moq.onCall().IsolationStruct("recorder"). + converter1Moq.onCall().MockStructs(). returnResults(nil, retError()) } if !done() { @@ -1388,7 +1376,7 @@ func TestMoqGenerator(t *testing.T) { }}, retError()) } if !done() { - converter2Moq.onCall().IsolationStruct("mock"). + converter2Moq.onCall().MockStructs(). returnResults(nil, retError()) } if !done() { @@ -1403,10 +1391,6 @@ func TestMoqGenerator(t *testing.T) { converter2Moq.onCall().FuncClosure(fnFuncs[0]). returnResults(nil, retError()) } - if !done() { - converter2Moq.onCall().MockMethod(fnFuncs[0]). - returnResults(nil, retError()) - } if !done() { converter2Moq.onCall().RecorderMethods(fnFuncs[0]). returnResults(nil, retError()) @@ -1419,6 +1403,9 @@ func TestMoqGenerator(t *testing.T) { converter2Moq.onCall().AssertMethod(). returnResults(nil, retError()) } + if !done() { + t.Fatalf("got !done(), want to be done! (reduce max n at top of test)") + } req := generator.GenerateRequest{ Types: []string{"PublicInterface", "PublicFn"}, @@ -1477,9 +1464,7 @@ func TestMoqGenerator(t *testing.T) { OutPkgPath: "thispkg_test", }, false).returnResults(converter1Moq.mock()) converter1Moq.onCall().BaseDecls().returnResults(nil, nil) - converter1Moq.onCall().IsolationStruct("mock"). - returnResults(nil, nil) - converter1Moq.onCall().IsolationStruct("recorder"). + converter1Moq.onCall().MockStructs(). returnResults(nil, nil) converter1Moq.onCall().MethodStructs(iface1Funcs[0]). returnResults(nil, nil) @@ -1508,9 +1493,7 @@ func TestMoqGenerator(t *testing.T) { OutPkgPath: "thispkg_test", }, false).returnResults(converter2Moq.mock()) converter2Moq.onCall().BaseDecls().returnResults(nil, nil) - converter2Moq.onCall().IsolationStruct("mock"). - returnResults(nil, nil) - converter2Moq.onCall().IsolationStruct("recorder"). + converter2Moq.onCall().MockStructs(). returnResults(nil, nil) converter2Moq.onCall().NewFunc(). returnResults(nil, nil) @@ -1713,7 +1696,7 @@ func TestMoqGenerator(t *testing.T) { converter1Moq.onCall().BaseDecls().returnResults([]dst.Decl{&dst.GenDecl{ Specs: []dst.Spec{&dst.TypeSpec{Name: dst.NewIdent("pub-decl")}}, }}, nil) - converter1Moq.onCall().IsolationStruct("mock"). + converter1Moq.onCall().MockStructs(). returnResults(nil, nil) converter1Moq.onCall().MethodStructs(fnFuncs[0]). returnResults(nil, nil) @@ -1721,8 +1704,6 @@ func TestMoqGenerator(t *testing.T) { returnResults(nil, nil) converter1Moq.onCall().FuncClosure(fnFuncs[0]). returnResults(nil, nil) - converter1Moq.onCall().MockMethod(fnFuncs[0]). - returnResults(nil, nil) converter1Moq.onCall().RecorderMethods(fnFuncs[0]). returnResults(nil, nil) converter1Moq.onCall().ResetMethod(). diff --git a/generator/testmoqs/exported/moq_exported_testmoqs.go b/generator/testmoqs/exported/moq_exported_testmoqs.go index f7a6b0e..530a372 100644 --- a/generator/testmoqs/exported/moq_exported_testmoqs.go +++ b/generator/testmoqs/exported/moq_exported_testmoqs.go @@ -5,34 +5,34 @@ package exported import ( "fmt" "io" - "math/bits" - "sync/atomic" "unsafe" "moqueries.org/cli/generator/testmoqs" "moqueries.org/cli/generator/testmoqs/other" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // MoqUsualFn holds the state of a moq of the UsualFn type type MoqUsualFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqUsualFn_mock + Moq *impl.Moq[ + *MoqUsualFn_adaptor, + MoqUsualFn_params, + MoqUsualFn_paramsKey, + MoqUsualFn_results, + ] - ResultsByParams []MoqUsualFn_resultsByParams + Runtime MoqUsualFn_runtime +} - Runtime struct { - ParameterIndexing struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - } +// MoqUsualFn_runtime holds runtime configuration for the UsualFn type +type MoqUsualFn_runtime struct { + ParameterIndexing MoqUsualFn_paramIndexing } -// MoqUsualFn_mock isolates the mock interface of the UsualFn type -type MoqUsualFn_mock struct { +// MoqUsualFn_adaptor adapts MoqUsualFn as needed by the runtime +type MoqUsualFn_adaptor struct { Moq *MoqUsualFn } @@ -54,12 +54,17 @@ type MoqUsualFn_paramsKey struct { } } -// MoqUsualFn_resultsByParams contains the results for a given set of -// parameters for the UsualFn type -type MoqUsualFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsualFn_paramsKey]*MoqUsualFn_results +// MoqUsualFn_results holds the results of the UsualFn type +type MoqUsualFn_results struct { + SResult string + Err error +} + +// MoqUsualFn_paramIndexing holds the parameter indexing runtime configuration +// for the UsualFn type +type MoqUsualFn_paramIndexing struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing } // MoqUsualFn_doFn defines the type of function needed when calling AndDo for @@ -70,60 +75,38 @@ type MoqUsualFn_doFn func(sParam string, bParam bool) // DoReturnResults for the UsualFn type type MoqUsualFn_doReturnFn func(sParam string, bParam bool) (sResult string, err error) -// MoqUsualFn_results holds the results of the UsualFn type -type MoqUsualFn_results struct { - Params MoqUsualFn_params - Results []struct { - Values *struct { - SResult string - Err error - } - Sequence uint32 - DoFn MoqUsualFn_doFn - DoReturnFn MoqUsualFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsualFn_fnRecorder routes recorded function calls to the MoqUsualFn moq -type MoqUsualFn_fnRecorder struct { - Params MoqUsualFn_params - AnyParams uint64 - Sequence bool - Results *MoqUsualFn_results - Moq *MoqUsualFn +// MoqUsualFn_recorder routes recorded function calls to the MoqUsualFn moq +type MoqUsualFn_recorder struct { + Recorder *impl.Recorder[ + *MoqUsualFn_adaptor, + MoqUsualFn_params, + MoqUsualFn_paramsKey, + MoqUsualFn_results, + ] } // MoqUsualFn_anyParams isolates the any params functions of the UsualFn type type MoqUsualFn_anyParams struct { - Recorder *MoqUsualFn_fnRecorder + Recorder *MoqUsualFn_recorder } // NewMoqUsualFn creates a new moq of the UsualFn type func NewMoqUsualFn(scene *moq.Scene, config *moq.Config) *MoqUsualFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqUsualFn_adaptor{} m := &MoqUsualFn{ - Scene: scene, - Config: *config, - Moq: &MoqUsualFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - }{ParameterIndexing: struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqUsualFn_adaptor, + MoqUsualFn_params, + MoqUsualFn_paramsKey, + MoqUsualFn_results, + ](scene, adaptor1, config), + + Runtime: MoqUsualFn_runtime{ParameterIndexing: MoqUsualFn_paramIndexing{ SParam: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -131,281 +114,115 @@ func NewMoqUsualFn(scene *moq.Scene, config *moq.Config) *MoqUsualFn { // Mock returns the moq implementation of the UsualFn type func (m *MoqUsualFn) Mock() testmoqs.UsualFn { - return func(sParam string, bParam bool) (_ string, _ error) { - m.Scene.T.Helper() - moq := &MoqUsualFn_mock{Moq: m} - return moq.Fn(sParam, bParam) - } -} - -func (m *MoqUsualFn_mock) Fn(sParam string, bParam bool) (sResult string, err error) { - m.Moq.Scene.T.Helper() - params := MoqUsualFn_params{ - SParam: sParam, - BParam: bParam, - } - var results *MoqUsualFn_results - 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 + return func(sParam string, bParam bool) (string, error) { + m.Moq.Scene.T.Helper() + params := MoqUsualFn_params{ + SParam: sParam, + BParam: bParam, } - 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)) + var result1 string + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } + return result1, result2 } - - 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 *MoqUsualFn) OnCall(sParam string, bParam bool) *MoqUsualFn_fnRecorder { - return &MoqUsualFn_fnRecorder{ - Params: MoqUsualFn_params{ +func (m *MoqUsualFn) OnCall(sParam string, bParam bool) *MoqUsualFn_recorder { + return &MoqUsualFn_recorder{ + Recorder: m.Moq.OnCall(MoqUsualFn_params{ SParam: sParam, BParam: bParam, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqUsualFn_fnRecorder) Any() *MoqUsualFn_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(r.Params)) +func (r *MoqUsualFn_recorder) Any() *MoqUsualFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsualFn_anyParams{Recorder: r} } -func (a *MoqUsualFn_anyParams) SParam() *MoqUsualFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsualFn_anyParams) SParam() *MoqUsualFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqUsualFn_anyParams) BParam() *MoqUsualFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqUsualFn_anyParams) BParam() *MoqUsualFn_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (r *MoqUsualFn_fnRecorder) Seq() *MoqUsualFn_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(r.Params)) +func (r *MoqUsualFn_recorder) Seq() *MoqUsualFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqUsualFn_fnRecorder) NoSeq() *MoqUsualFn_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(r.Params)) +func (r *MoqUsualFn_recorder) NoSeq() *MoqUsualFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUsualFn_fnRecorder) ReturnResults(sResult string, err error) *MoqUsualFn_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 MoqUsualFn_doFn - DoReturnFn MoqUsualFn_doReturnFn - }{ - Values: &struct { - SResult string - Err error - }{ - SResult: sResult, - Err: err, - }, - Sequence: sequence, +func (r *MoqUsualFn_recorder) ReturnResults(sResult string, err error) *MoqUsualFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsualFn_results{ + SResult: sResult, + Err: err, }) return r } -func (r *MoqUsualFn_fnRecorder) AndDo(fn MoqUsualFn_doFn) *MoqUsualFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqUsualFn_recorder) AndDo(fn MoqUsualFn_doFn) *MoqUsualFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsualFn_params) { + fn(params.SParam, params.BParam) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqUsualFn_fnRecorder) DoReturnResults(fn MoqUsualFn_doReturnFn) *MoqUsualFn_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 +func (r *MoqUsualFn_recorder) DoReturnResults(fn MoqUsualFn_doReturnFn) *MoqUsualFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsualFn_params) *MoqUsualFn_results { + sResult, err := fn(params.SParam, params.BParam) + return &MoqUsualFn_results{ + SResult: sResult, + Err: err, } - Sequence uint32 - DoFn MoqUsualFn_doFn - DoReturnFn MoqUsualFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqUsualFn_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 *MoqUsualFn_resultsByParams - 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 = &MoqUsualFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsualFn_paramsKey]*MoqUsualFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsualFn_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 *MoqUsualFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsualFn_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 MoqUsualFn_doFn - DoReturnFn MoqUsualFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqUsualFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsualFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqUsualFn) PrettyParams(params MoqUsualFn_params) string { +func (*MoqUsualFn_adaptor) PrettyParams(params MoqUsualFn_params) string { return fmt.Sprintf("UsualFn(%#v, %#v)", params.SParam, params.BParam) } -func (m *MoqUsualFn) ParamsKey(params MoqUsualFn_params, anyParams uint64) MoqUsualFn_paramsKey { - m.Scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.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.BParam == moq.ParamIndexByValue { - bParamUsed = params.BParam - } else { - bParamUsedHash = hash.DeepHash(params.BParam) - } - } +func (a *MoqUsualFn_adaptor) ParamsKey(params MoqUsualFn_params, anyParams uint64) MoqUsualFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.SParam, 1, a.Moq.Runtime.ParameterIndexing.SParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 2, a.Moq.Runtime.ParameterIndexing.BParam, anyParams) return MoqUsualFn_paramsKey{ Params: struct { SParam string @@ -425,39 +242,35 @@ func (m *MoqUsualFn) ParamsKey(params MoqUsualFn_params, anyParams uint64) MoqUs } // Reset resets the state of the moq -func (m *MoqUsualFn) Reset() { m.ResultsByParams = nil } +func (m *MoqUsualFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqUsualFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqNoNamesFn holds the state of a moq of the NoNamesFn type type MoqNoNamesFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqNoNamesFn_mock + Moq *impl.Moq[ + *MoqNoNamesFn_adaptor, + MoqNoNamesFn_params, + MoqNoNamesFn_paramsKey, + MoqNoNamesFn_results, + ] - ResultsByParams []MoqNoNamesFn_resultsByParams + Runtime MoqNoNamesFn_runtime +} - Runtime struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - } +// MoqNoNamesFn_runtime holds runtime configuration for the NoNamesFn type +type MoqNoNamesFn_runtime struct { + ParameterIndexing MoqNoNamesFn_paramIndexing } -// MoqNoNamesFn_mock isolates the mock interface of the NoNamesFn type -type MoqNoNamesFn_mock struct { +// MoqNoNamesFn_adaptor adapts MoqNoNamesFn as needed by the runtime +type MoqNoNamesFn_adaptor struct { Moq *MoqNoNamesFn } @@ -479,12 +292,17 @@ type MoqNoNamesFn_paramsKey struct { } } -// MoqNoNamesFn_resultsByParams contains the results for a given set of -// parameters for the NoNamesFn type -type MoqNoNamesFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqNoNamesFn_paramsKey]*MoqNoNamesFn_results +// MoqNoNamesFn_results holds the results of the NoNamesFn type +type MoqNoNamesFn_results struct { + Result1 string + Result2 error +} + +// MoqNoNamesFn_paramIndexing holds the parameter indexing runtime +// configuration for the NoNamesFn type +type MoqNoNamesFn_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqNoNamesFn_doFn defines the type of function needed when calling AndDo for @@ -495,62 +313,39 @@ type MoqNoNamesFn_doFn func(string, bool) // DoReturnResults for the NoNamesFn type type MoqNoNamesFn_doReturnFn func(string, bool) (string, error) -// MoqNoNamesFn_results holds the results of the NoNamesFn type -type MoqNoNamesFn_results struct { - Params MoqNoNamesFn_params - Results []struct { - Values *struct { - Result1 string - Result2 error - } - Sequence uint32 - DoFn MoqNoNamesFn_doFn - DoReturnFn MoqNoNamesFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqNoNamesFn_fnRecorder routes recorded function calls to the MoqNoNamesFn -// moq -type MoqNoNamesFn_fnRecorder struct { - Params MoqNoNamesFn_params - AnyParams uint64 - Sequence bool - Results *MoqNoNamesFn_results - Moq *MoqNoNamesFn +// MoqNoNamesFn_recorder routes recorded function calls to the MoqNoNamesFn moq +type MoqNoNamesFn_recorder struct { + Recorder *impl.Recorder[ + *MoqNoNamesFn_adaptor, + MoqNoNamesFn_params, + MoqNoNamesFn_paramsKey, + MoqNoNamesFn_results, + ] } // MoqNoNamesFn_anyParams isolates the any params functions of the NoNamesFn // type type MoqNoNamesFn_anyParams struct { - Recorder *MoqNoNamesFn_fnRecorder + Recorder *MoqNoNamesFn_recorder } // NewMoqNoNamesFn creates a new moq of the NoNamesFn type func NewMoqNoNamesFn(scene *moq.Scene, config *moq.Config) *MoqNoNamesFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqNoNamesFn_adaptor{} m := &MoqNoNamesFn{ - Scene: scene, - Config: *config, - Moq: &MoqNoNamesFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - }{ParameterIndexing: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqNoNamesFn_adaptor, + MoqNoNamesFn_params, + MoqNoNamesFn_paramsKey, + MoqNoNamesFn_results, + ](scene, adaptor1, config), + + Runtime: MoqNoNamesFn_runtime{ParameterIndexing: MoqNoNamesFn_paramIndexing{ Param1: moq.ParamIndexByValue, Param2: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -559,280 +354,114 @@ func NewMoqNoNamesFn(scene *moq.Scene, config *moq.Config) *MoqNoNamesFn { // Mock returns the moq implementation of the NoNamesFn type func (m *MoqNoNamesFn) Mock() testmoqs.NoNamesFn { return func(param1 string, param2 bool) (string, error) { - m.Scene.T.Helper() - moq := &MoqNoNamesFn_mock{Moq: m} - return moq.Fn(param1, param2) - } -} - -func (m *MoqNoNamesFn_mock) Fn(param1 string, param2 bool) (result1 string, result2 error) { - m.Moq.Scene.T.Helper() - params := MoqNoNamesFn_params{ - Param1: param1, - Param2: param2, - } - var results *MoqNoNamesFn_results - 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 + m.Moq.Scene.T.Helper() + params := MoqNoNamesFn_params{ + Param1: param1, + Param2: param2, } - 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)) + var result1 string + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } + return result1, result2 } - - 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 *MoqNoNamesFn) OnCall(param1 string, param2 bool) *MoqNoNamesFn_fnRecorder { - return &MoqNoNamesFn_fnRecorder{ - Params: MoqNoNamesFn_params{ +func (m *MoqNoNamesFn) OnCall(param1 string, param2 bool) *MoqNoNamesFn_recorder { + return &MoqNoNamesFn_recorder{ + Recorder: m.Moq.OnCall(MoqNoNamesFn_params{ Param1: param1, Param2: param2, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqNoNamesFn_fnRecorder) Any() *MoqNoNamesFn_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(r.Params)) +func (r *MoqNoNamesFn_recorder) Any() *MoqNoNamesFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqNoNamesFn_anyParams{Recorder: r} } -func (a *MoqNoNamesFn_anyParams) Param1() *MoqNoNamesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqNoNamesFn_anyParams) Param1() *MoqNoNamesFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqNoNamesFn_anyParams) Param2() *MoqNoNamesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqNoNamesFn_anyParams) Param2() *MoqNoNamesFn_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (r *MoqNoNamesFn_fnRecorder) Seq() *MoqNoNamesFn_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(r.Params)) +func (r *MoqNoNamesFn_recorder) Seq() *MoqNoNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqNoNamesFn_fnRecorder) NoSeq() *MoqNoNamesFn_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(r.Params)) +func (r *MoqNoNamesFn_recorder) NoSeq() *MoqNoNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqNoNamesFn_fnRecorder) ReturnResults(result1 string, result2 error) *MoqNoNamesFn_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 MoqNoNamesFn_doFn - DoReturnFn MoqNoNamesFn_doReturnFn - }{ - Values: &struct { - Result1 string - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqNoNamesFn_recorder) ReturnResults(result1 string, result2 error) *MoqNoNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqNoNamesFn_results{ + Result1: result1, + Result2: result2, }) return r } -func (r *MoqNoNamesFn_fnRecorder) AndDo(fn MoqNoNamesFn_doFn) *MoqNoNamesFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqNoNamesFn_recorder) AndDo(fn MoqNoNamesFn_doFn) *MoqNoNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqNoNamesFn_params) { + fn(params.Param1, params.Param2) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqNoNamesFn_fnRecorder) DoReturnResults(fn MoqNoNamesFn_doReturnFn) *MoqNoNamesFn_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 +func (r *MoqNoNamesFn_recorder) DoReturnResults(fn MoqNoNamesFn_doReturnFn) *MoqNoNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqNoNamesFn_params) *MoqNoNamesFn_results { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqNoNamesFn_results{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqNoNamesFn_doFn - DoReturnFn MoqNoNamesFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqNoNamesFn_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 *MoqNoNamesFn_resultsByParams - 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 = &MoqNoNamesFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqNoNamesFn_paramsKey]*MoqNoNamesFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqNoNamesFn_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 *MoqNoNamesFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqNoNamesFn_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 MoqNoNamesFn_doFn - DoReturnFn MoqNoNamesFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqNoNamesFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqNoNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqNoNamesFn) PrettyParams(params MoqNoNamesFn_params) string { +func (*MoqNoNamesFn_adaptor) PrettyParams(params MoqNoNamesFn_params) string { return fmt.Sprintf("NoNamesFn(%#v, %#v)", params.Param1, params.Param2) } -func (m *MoqNoNamesFn) ParamsKey(params MoqNoNamesFn_params, anyParams uint64) MoqNoNamesFn_paramsKey { - 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) - } - } - 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) - } - } +func (a *MoqNoNamesFn_adaptor) ParamsKey(params MoqNoNamesFn_params, anyParams uint64) MoqNoNamesFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.Param2, anyParams) return MoqNoNamesFn_paramsKey{ Params: struct { Param1 string @@ -852,39 +481,35 @@ func (m *MoqNoNamesFn) ParamsKey(params MoqNoNamesFn_params, anyParams uint64) M } // Reset resets the state of the moq -func (m *MoqNoNamesFn) Reset() { m.ResultsByParams = nil } +func (m *MoqNoNamesFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqNoNamesFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqNoResultsFn holds the state of a moq of the NoResultsFn type type MoqNoResultsFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqNoResultsFn_mock + Moq *impl.Moq[ + *MoqNoResultsFn_adaptor, + MoqNoResultsFn_params, + MoqNoResultsFn_paramsKey, + MoqNoResultsFn_results, + ] - ResultsByParams []MoqNoResultsFn_resultsByParams + Runtime MoqNoResultsFn_runtime +} - Runtime struct { - ParameterIndexing struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - } +// MoqNoResultsFn_runtime holds runtime configuration for the NoResultsFn type +type MoqNoResultsFn_runtime struct { + ParameterIndexing MoqNoResultsFn_paramIndexing } -// MoqNoResultsFn_mock isolates the mock interface of the NoResultsFn type -type MoqNoResultsFn_mock struct { +// MoqNoResultsFn_adaptor adapts MoqNoResultsFn as needed by the runtime +type MoqNoResultsFn_adaptor struct { Moq *MoqNoResultsFn } @@ -906,12 +531,14 @@ type MoqNoResultsFn_paramsKey struct { } } -// MoqNoResultsFn_resultsByParams contains the results for a given set of -// parameters for the NoResultsFn type -type MoqNoResultsFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqNoResultsFn_paramsKey]*MoqNoResultsFn_results +// MoqNoResultsFn_results holds the results of the NoResultsFn type +type MoqNoResultsFn_results struct{} + +// MoqNoResultsFn_paramIndexing holds the parameter indexing runtime +// configuration for the NoResultsFn type +type MoqNoResultsFn_paramIndexing struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing } // MoqNoResultsFn_doFn defines the type of function needed when calling AndDo @@ -922,59 +549,40 @@ type MoqNoResultsFn_doFn func(sParam string, bParam bool) // DoReturnResults for the NoResultsFn type type MoqNoResultsFn_doReturnFn func(sParam string, bParam bool) -// MoqNoResultsFn_results holds the results of the NoResultsFn type -type MoqNoResultsFn_results struct { - Params MoqNoResultsFn_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqNoResultsFn_doFn - DoReturnFn MoqNoResultsFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqNoResultsFn_fnRecorder routes recorded function calls to the -// MoqNoResultsFn moq -type MoqNoResultsFn_fnRecorder struct { - Params MoqNoResultsFn_params - AnyParams uint64 - Sequence bool - Results *MoqNoResultsFn_results - Moq *MoqNoResultsFn +// MoqNoResultsFn_recorder routes recorded function calls to the MoqNoResultsFn +// moq +type MoqNoResultsFn_recorder struct { + Recorder *impl.Recorder[ + *MoqNoResultsFn_adaptor, + MoqNoResultsFn_params, + MoqNoResultsFn_paramsKey, + MoqNoResultsFn_results, + ] } // MoqNoResultsFn_anyParams isolates the any params functions of the // NoResultsFn type type MoqNoResultsFn_anyParams struct { - Recorder *MoqNoResultsFn_fnRecorder + Recorder *MoqNoResultsFn_recorder } // NewMoqNoResultsFn creates a new moq of the NoResultsFn type func NewMoqNoResultsFn(scene *moq.Scene, config *moq.Config) *MoqNoResultsFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqNoResultsFn_adaptor{} m := &MoqNoResultsFn{ - Scene: scene, - Config: *config, - Moq: &MoqNoResultsFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - }{ParameterIndexing: struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqNoResultsFn_adaptor, + MoqNoResultsFn_params, + MoqNoResultsFn_paramsKey, + MoqNoResultsFn_results, + ](scene, adaptor1, config), + + Runtime: MoqNoResultsFn_runtime{ParameterIndexing: MoqNoResultsFn_paramIndexing{ SParam: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -983,261 +591,102 @@ func NewMoqNoResultsFn(scene *moq.Scene, config *moq.Config) *MoqNoResultsFn { // Mock returns the moq implementation of the NoResultsFn type func (m *MoqNoResultsFn) Mock() testmoqs.NoResultsFn { return func(sParam string, bParam bool) { - m.Scene.T.Helper() - moq := &MoqNoResultsFn_mock{Moq: m} - moq.Fn(sParam, bParam) - } -} - -func (m *MoqNoResultsFn_mock) Fn(sParam string, bParam bool) { - m.Moq.Scene.T.Helper() - params := MoqNoResultsFn_params{ - SParam: sParam, - BParam: bParam, - } - var results *MoqNoResultsFn_results - 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)) + m.Moq.Scene.T.Helper() + params := MoqNoResultsFn_params{ + SParam: sParam, + BParam: bParam, } - } - if result.DoFn != nil { - result.DoFn(sParam, bParam) + m.Moq.Function(params) } - - if result.DoReturnFn != nil { - result.DoReturnFn(sParam, bParam) - } - return } -func (m *MoqNoResultsFn) OnCall(sParam string, bParam bool) *MoqNoResultsFn_fnRecorder { - return &MoqNoResultsFn_fnRecorder{ - Params: MoqNoResultsFn_params{ +func (m *MoqNoResultsFn) OnCall(sParam string, bParam bool) *MoqNoResultsFn_recorder { + return &MoqNoResultsFn_recorder{ + Recorder: m.Moq.OnCall(MoqNoResultsFn_params{ SParam: sParam, BParam: bParam, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqNoResultsFn_fnRecorder) Any() *MoqNoResultsFn_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(r.Params)) +func (r *MoqNoResultsFn_recorder) Any() *MoqNoResultsFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqNoResultsFn_anyParams{Recorder: r} } -func (a *MoqNoResultsFn_anyParams) SParam() *MoqNoResultsFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqNoResultsFn_anyParams) SParam() *MoqNoResultsFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqNoResultsFn_anyParams) BParam() *MoqNoResultsFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqNoResultsFn_anyParams) BParam() *MoqNoResultsFn_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (r *MoqNoResultsFn_fnRecorder) Seq() *MoqNoResultsFn_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(r.Params)) +func (r *MoqNoResultsFn_recorder) Seq() *MoqNoResultsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqNoResultsFn_fnRecorder) NoSeq() *MoqNoResultsFn_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(r.Params)) +func (r *MoqNoResultsFn_recorder) NoSeq() *MoqNoResultsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqNoResultsFn_fnRecorder) ReturnResults() *MoqNoResultsFn_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 MoqNoResultsFn_doFn - DoReturnFn MoqNoResultsFn_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqNoResultsFn_recorder) ReturnResults() *MoqNoResultsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqNoResultsFn_results{}) return r } -func (r *MoqNoResultsFn_fnRecorder) AndDo(fn MoqNoResultsFn_doFn) *MoqNoResultsFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqNoResultsFn_recorder) AndDo(fn MoqNoResultsFn_doFn) *MoqNoResultsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqNoResultsFn_params) { + fn(params.SParam, params.BParam) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqNoResultsFn_fnRecorder) DoReturnResults(fn MoqNoResultsFn_doReturnFn) *MoqNoResultsFn_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 MoqNoResultsFn_doFn - DoReturnFn MoqNoResultsFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqNoResultsFn_recorder) DoReturnResults(fn MoqNoResultsFn_doReturnFn) *MoqNoResultsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqNoResultsFn_params) *MoqNoResultsFn_results { + fn(params.SParam, params.BParam) + return &MoqNoResultsFn_results{} + }) return r } -func (r *MoqNoResultsFn_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 *MoqNoResultsFn_resultsByParams - 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 = &MoqNoResultsFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqNoResultsFn_paramsKey]*MoqNoResultsFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqNoResultsFn_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 *MoqNoResultsFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqNoResultsFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqNoResultsFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqNoResultsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 MoqNoResultsFn_doFn - DoReturnFn MoqNoResultsFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqNoResultsFn) PrettyParams(params MoqNoResultsFn_params) string { +func (*MoqNoResultsFn_adaptor) PrettyParams(params MoqNoResultsFn_params) string { return fmt.Sprintf("NoResultsFn(%#v, %#v)", params.SParam, params.BParam) } -func (m *MoqNoResultsFn) ParamsKey(params MoqNoResultsFn_params, anyParams uint64) MoqNoResultsFn_paramsKey { - m.Scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.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.BParam == moq.ParamIndexByValue { - bParamUsed = params.BParam - } else { - bParamUsedHash = hash.DeepHash(params.BParam) - } - } +func (a *MoqNoResultsFn_adaptor) ParamsKey(params MoqNoResultsFn_params, anyParams uint64) MoqNoResultsFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.SParam, 1, a.Moq.Runtime.ParameterIndexing.SParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 2, a.Moq.Runtime.ParameterIndexing.BParam, anyParams) return MoqNoResultsFn_paramsKey{ Params: struct { SParam string @@ -1257,36 +706,35 @@ func (m *MoqNoResultsFn) ParamsKey(params MoqNoResultsFn_params, anyParams uint6 } // Reset resets the state of the moq -func (m *MoqNoResultsFn) Reset() { m.ResultsByParams = nil } +func (m *MoqNoResultsFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqNoResultsFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqNoParamsFn holds the state of a moq of the NoParamsFn type type MoqNoParamsFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqNoParamsFn_mock + Moq *impl.Moq[ + *MoqNoParamsFn_adaptor, + MoqNoParamsFn_params, + MoqNoParamsFn_paramsKey, + MoqNoParamsFn_results, + ] - ResultsByParams []MoqNoParamsFn_resultsByParams + Runtime MoqNoParamsFn_runtime +} - Runtime struct { - ParameterIndexing struct{} - } +// MoqNoParamsFn_runtime holds runtime configuration for the NoParamsFn type +type MoqNoParamsFn_runtime struct { + ParameterIndexing MoqNoParamsFn_paramIndexing } -// MoqNoParamsFn_mock isolates the mock interface of the NoParamsFn type -type MoqNoParamsFn_mock struct { +// MoqNoParamsFn_adaptor adapts MoqNoParamsFn as needed by the runtime +type MoqNoParamsFn_adaptor struct { Moq *MoqNoParamsFn } @@ -1299,14 +747,16 @@ type MoqNoParamsFn_paramsKey struct { Hashes struct{} } -// MoqNoParamsFn_resultsByParams contains the results for a given set of -// parameters for the NoParamsFn type -type MoqNoParamsFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqNoParamsFn_paramsKey]*MoqNoParamsFn_results +// MoqNoParamsFn_results holds the results of the NoParamsFn type +type MoqNoParamsFn_results struct { + SResult string + Err error } +// MoqNoParamsFn_paramIndexing holds the parameter indexing runtime +// configuration for the NoParamsFn type +type MoqNoParamsFn_paramIndexing struct{} + // MoqNoParamsFn_doFn defines the type of function needed when calling AndDo // for the NoParamsFn type type MoqNoParamsFn_doFn func() @@ -1315,53 +765,37 @@ type MoqNoParamsFn_doFn func() // DoReturnResults for the NoParamsFn type type MoqNoParamsFn_doReturnFn func() (sResult string, err error) -// MoqNoParamsFn_results holds the results of the NoParamsFn type -type MoqNoParamsFn_results struct { - Params MoqNoParamsFn_params - Results []struct { - Values *struct { - SResult string - Err error - } - Sequence uint32 - DoFn MoqNoParamsFn_doFn - DoReturnFn MoqNoParamsFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqNoParamsFn_fnRecorder routes recorded function calls to the MoqNoParamsFn +// MoqNoParamsFn_recorder routes recorded function calls to the MoqNoParamsFn // moq -type MoqNoParamsFn_fnRecorder struct { - Params MoqNoParamsFn_params - AnyParams uint64 - Sequence bool - Results *MoqNoParamsFn_results - Moq *MoqNoParamsFn +type MoqNoParamsFn_recorder struct { + Recorder *impl.Recorder[ + *MoqNoParamsFn_adaptor, + MoqNoParamsFn_params, + MoqNoParamsFn_paramsKey, + MoqNoParamsFn_results, + ] } // MoqNoParamsFn_anyParams isolates the any params functions of the NoParamsFn // type type MoqNoParamsFn_anyParams struct { - Recorder *MoqNoParamsFn_fnRecorder + Recorder *MoqNoParamsFn_recorder } // NewMoqNoParamsFn creates a new moq of the NoParamsFn type func NewMoqNoParamsFn(scene *moq.Scene, config *moq.Config) *MoqNoParamsFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqNoParamsFn_adaptor{} m := &MoqNoParamsFn{ - Scene: scene, - Config: *config, - Moq: &MoqNoParamsFn_mock{}, + Moq: impl.NewMoq[ + *MoqNoParamsFn_adaptor, + MoqNoParamsFn_params, + MoqNoParamsFn_paramsKey, + MoqNoParamsFn_results, + ](scene, adaptor1, config), - Runtime: struct { - ParameterIndexing struct{} - }{ParameterIndexing: struct{}{}}, + Runtime: MoqNoParamsFn_runtime{ParameterIndexing: MoqNoParamsFn_paramIndexing{}}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -1369,280 +803,131 @@ func NewMoqNoParamsFn(scene *moq.Scene, config *moq.Config) *MoqNoParamsFn { // Mock returns the moq implementation of the NoParamsFn type func (m *MoqNoParamsFn) Mock() testmoqs.NoParamsFn { - return func() (_ string, _ error) { m.Scene.T.Helper(); moq := &MoqNoParamsFn_mock{Moq: m}; return moq.Fn() } -} - -func (m *MoqNoParamsFn_mock) Fn() (sResult string, err error) { - m.Moq.Scene.T.Helper() - params := MoqNoParamsFn_params{} - var results *MoqNoParamsFn_results - 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 - } + return func() (string, error) { + m.Moq.Scene.T.Helper() + params := MoqNoParamsFn_params{} - 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 + var result1 string + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } - 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() - } - - if result.Values != nil { - sResult = result.Values.SResult - err = result.Values.Err - } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn() + return result1, result2 } - return } -func (m *MoqNoParamsFn) OnCall() *MoqNoParamsFn_fnRecorder { - return &MoqNoParamsFn_fnRecorder{ - Params: MoqNoParamsFn_params{}, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, +func (m *MoqNoParamsFn) OnCall() *MoqNoParamsFn_recorder { + return &MoqNoParamsFn_recorder{ + Recorder: m.Moq.OnCall(MoqNoParamsFn_params{}), } } -func (r *MoqNoParamsFn_fnRecorder) Any() *MoqNoParamsFn_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(r.Params)) +func (r *MoqNoParamsFn_recorder) Any() *MoqNoParamsFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqNoParamsFn_anyParams{Recorder: r} } -func (r *MoqNoParamsFn_fnRecorder) Seq() *MoqNoParamsFn_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(r.Params)) +func (r *MoqNoParamsFn_recorder) Seq() *MoqNoParamsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqNoParamsFn_fnRecorder) NoSeq() *MoqNoParamsFn_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(r.Params)) +func (r *MoqNoParamsFn_recorder) NoSeq() *MoqNoParamsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqNoParamsFn_fnRecorder) ReturnResults(sResult string, err error) *MoqNoParamsFn_fnRecorder { - r.Moq.Scene.T.Helper() - r.FindResults() +func (r *MoqNoParamsFn_recorder) ReturnResults(sResult string, err error) *MoqNoParamsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqNoParamsFn_results{ + SResult: sResult, + Err: err, + }) + return r +} - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() +func (r *MoqNoParamsFn_recorder) AndDo(fn MoqNoParamsFn_doFn) *MoqNoParamsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqNoParamsFn_params) { + fn() + }, true) { + return nil } + return r +} - r.Results.Results = append(r.Results.Results, struct { - Values *struct { - SResult string - Err error - } - Sequence uint32 - DoFn MoqNoParamsFn_doFn - DoReturnFn MoqNoParamsFn_doReturnFn - }{ - Values: &struct { - SResult string - Err error - }{ +func (r *MoqNoParamsFn_recorder) DoReturnResults(fn MoqNoParamsFn_doReturnFn) *MoqNoParamsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqNoParamsFn_params) *MoqNoParamsFn_results { + sResult, err := fn() + return &MoqNoParamsFn_results{ SResult: sResult, Err: err, - }, - Sequence: sequence, + } }) return r } -func (r *MoqNoParamsFn_fnRecorder) AndDo(fn MoqNoParamsFn_doFn) *MoqNoParamsFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqNoParamsFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqNoParamsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqNoParamsFn_fnRecorder) DoReturnResults(fn MoqNoParamsFn_doReturnFn) *MoqNoParamsFn_fnRecorder { - r.Moq.Scene.T.Helper() - r.FindResults() +func (*MoqNoParamsFn_adaptor) PrettyParams(params MoqNoParamsFn_params) string { + return fmt.Sprintf("NoParamsFn()") +} - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() +func (a *MoqNoParamsFn_adaptor) ParamsKey(params MoqNoParamsFn_params, anyParams uint64) MoqNoParamsFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + return MoqNoParamsFn_paramsKey{ + Params: struct{}{}, + Hashes: struct{}{}, } - - r.Results.Results = append(r.Results.Results, struct { - Values *struct { - SResult string - Err error - } - Sequence uint32 - DoFn MoqNoParamsFn_doFn - DoReturnFn MoqNoParamsFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) - return r -} - -func (r *MoqNoParamsFn_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 *MoqNoParamsFn_resultsByParams - 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 = &MoqNoParamsFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqNoParamsFn_paramsKey]*MoqNoParamsFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqNoParamsFn_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 *MoqNoParamsFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqNoParamsFn_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 MoqNoParamsFn_doFn - DoReturnFn MoqNoParamsFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } - return r -} - -func (m *MoqNoParamsFn) PrettyParams(params MoqNoParamsFn_params) string { - return fmt.Sprintf("NoParamsFn()") -} - -func (m *MoqNoParamsFn) ParamsKey(params MoqNoParamsFn_params, anyParams uint64) MoqNoParamsFn_paramsKey { - m.Scene.T.Helper() - return MoqNoParamsFn_paramsKey{ - Params: struct{}{}, - Hashes: struct{}{}, - } -} +} // Reset resets the state of the moq -func (m *MoqNoParamsFn) Reset() { m.ResultsByParams = nil } +func (m *MoqNoParamsFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqNoParamsFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqNothingFn holds the state of a moq of the NothingFn type type MoqNothingFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqNothingFn_mock + Moq *impl.Moq[ + *MoqNothingFn_adaptor, + MoqNothingFn_params, + MoqNothingFn_paramsKey, + MoqNothingFn_results, + ] - ResultsByParams []MoqNothingFn_resultsByParams + Runtime MoqNothingFn_runtime +} - Runtime struct { - ParameterIndexing struct{} - } +// MoqNothingFn_runtime holds runtime configuration for the NothingFn type +type MoqNothingFn_runtime struct { + ParameterIndexing MoqNothingFn_paramIndexing } -// MoqNothingFn_mock isolates the mock interface of the NothingFn type -type MoqNothingFn_mock struct { +// MoqNothingFn_adaptor adapts MoqNothingFn as needed by the runtime +type MoqNothingFn_adaptor struct { Moq *MoqNothingFn } @@ -1655,13 +940,12 @@ type MoqNothingFn_paramsKey struct { Hashes struct{} } -// MoqNothingFn_resultsByParams contains the results for a given set of -// parameters for the NothingFn type -type MoqNothingFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqNothingFn_paramsKey]*MoqNothingFn_results -} +// MoqNothingFn_results holds the results of the NothingFn type +type MoqNothingFn_results struct{} + +// MoqNothingFn_paramIndexing holds the parameter indexing runtime +// configuration for the NothingFn type +type MoqNothingFn_paramIndexing struct{} // MoqNothingFn_doFn defines the type of function needed when calling AndDo for // the NothingFn type @@ -1671,50 +955,36 @@ type MoqNothingFn_doFn func() // DoReturnResults for the NothingFn type type MoqNothingFn_doReturnFn func() -// MoqNothingFn_results holds the results of the NothingFn type -type MoqNothingFn_results struct { - Params MoqNothingFn_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqNothingFn_doFn - DoReturnFn MoqNothingFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqNothingFn_fnRecorder routes recorded function calls to the MoqNothingFn -// moq -type MoqNothingFn_fnRecorder struct { - Params MoqNothingFn_params - AnyParams uint64 - Sequence bool - Results *MoqNothingFn_results - Moq *MoqNothingFn +// MoqNothingFn_recorder routes recorded function calls to the MoqNothingFn moq +type MoqNothingFn_recorder struct { + Recorder *impl.Recorder[ + *MoqNothingFn_adaptor, + MoqNothingFn_params, + MoqNothingFn_paramsKey, + MoqNothingFn_results, + ] } // MoqNothingFn_anyParams isolates the any params functions of the NothingFn // type type MoqNothingFn_anyParams struct { - Recorder *MoqNothingFn_fnRecorder + Recorder *MoqNothingFn_recorder } // NewMoqNothingFn creates a new moq of the NothingFn type func NewMoqNothingFn(scene *moq.Scene, config *moq.Config) *MoqNothingFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqNothingFn_adaptor{} m := &MoqNothingFn{ - Scene: scene, - Config: *config, - Moq: &MoqNothingFn_mock{}, + Moq: impl.NewMoq[ + *MoqNothingFn_adaptor, + MoqNothingFn_params, + MoqNothingFn_paramsKey, + MoqNothingFn_results, + ](scene, adaptor1, config), - Runtime: struct { - ParameterIndexing struct{} - }{ParameterIndexing: struct{}{}}, + Runtime: MoqNothingFn_runtime{ParameterIndexing: MoqNothingFn_paramIndexing{}}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -1722,224 +992,83 @@ func NewMoqNothingFn(scene *moq.Scene, config *moq.Config) *MoqNothingFn { // Mock returns the moq implementation of the NothingFn type func (m *MoqNothingFn) Mock() testmoqs.NothingFn { - return func() { m.Scene.T.Helper(); moq := &MoqNothingFn_mock{Moq: m}; moq.Fn() } -} - -func (m *MoqNothingFn_mock) Fn() { - m.Moq.Scene.T.Helper() - params := MoqNothingFn_params{} - var results *MoqNothingFn_results - 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() - } + return func() { + m.Moq.Scene.T.Helper() + params := MoqNothingFn_params{} - if result.DoReturnFn != nil { - result.DoReturnFn() + m.Moq.Function(params) } - return } -func (m *MoqNothingFn) OnCall() *MoqNothingFn_fnRecorder { - return &MoqNothingFn_fnRecorder{ - Params: MoqNothingFn_params{}, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, +func (m *MoqNothingFn) OnCall() *MoqNothingFn_recorder { + return &MoqNothingFn_recorder{ + Recorder: m.Moq.OnCall(MoqNothingFn_params{}), } } -func (r *MoqNothingFn_fnRecorder) Any() *MoqNothingFn_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(r.Params)) +func (r *MoqNothingFn_recorder) Any() *MoqNothingFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqNothingFn_anyParams{Recorder: r} } -func (r *MoqNothingFn_fnRecorder) Seq() *MoqNothingFn_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(r.Params)) +func (r *MoqNothingFn_recorder) Seq() *MoqNothingFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqNothingFn_fnRecorder) NoSeq() *MoqNothingFn_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(r.Params)) +func (r *MoqNothingFn_recorder) NoSeq() *MoqNothingFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqNothingFn_fnRecorder) ReturnResults() *MoqNothingFn_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 MoqNothingFn_doFn - DoReturnFn MoqNothingFn_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqNothingFn_recorder) ReturnResults() *MoqNothingFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqNothingFn_results{}) return r } -func (r *MoqNothingFn_fnRecorder) AndDo(fn MoqNothingFn_doFn) *MoqNothingFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqNothingFn_recorder) AndDo(fn MoqNothingFn_doFn) *MoqNothingFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqNothingFn_params) { + fn() + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqNothingFn_fnRecorder) DoReturnResults(fn MoqNothingFn_doReturnFn) *MoqNothingFn_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 MoqNothingFn_doFn - DoReturnFn MoqNothingFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqNothingFn_recorder) DoReturnResults(fn MoqNothingFn_doReturnFn) *MoqNothingFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqNothingFn_params) *MoqNothingFn_results { + fn() + return &MoqNothingFn_results{} + }) return r } -func (r *MoqNothingFn_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 *MoqNothingFn_resultsByParams - 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 = &MoqNothingFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqNothingFn_paramsKey]*MoqNothingFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqNothingFn_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 *MoqNothingFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqNothingFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqNothingFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqNothingFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 MoqNothingFn_doFn - DoReturnFn MoqNothingFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqNothingFn) PrettyParams(params MoqNothingFn_params) string { +func (*MoqNothingFn_adaptor) PrettyParams(params MoqNothingFn_params) string { return fmt.Sprintf("NothingFn()") } -func (m *MoqNothingFn) ParamsKey(params MoqNothingFn_params, anyParams uint64) MoqNothingFn_paramsKey { - m.Scene.T.Helper() +func (a *MoqNothingFn_adaptor) ParamsKey(params MoqNothingFn_params, anyParams uint64) MoqNothingFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() return MoqNothingFn_paramsKey{ Params: struct{}{}, Hashes: struct{}{}, @@ -1947,39 +1076,35 @@ func (m *MoqNothingFn) ParamsKey(params MoqNothingFn_params, anyParams uint64) M } // Reset resets the state of the moq -func (m *MoqNothingFn) Reset() { m.ResultsByParams = nil } +func (m *MoqNothingFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqNothingFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqVariadicFn holds the state of a moq of the VariadicFn type type MoqVariadicFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqVariadicFn_mock + Moq *impl.Moq[ + *MoqVariadicFn_adaptor, + MoqVariadicFn_params, + MoqVariadicFn_paramsKey, + MoqVariadicFn_results, + ] - ResultsByParams []MoqVariadicFn_resultsByParams + Runtime MoqVariadicFn_runtime +} - Runtime struct { - ParameterIndexing struct { - Other moq.ParamIndexing - Args moq.ParamIndexing - } - } +// MoqVariadicFn_runtime holds runtime configuration for the VariadicFn type +type MoqVariadicFn_runtime struct { + ParameterIndexing MoqVariadicFn_paramIndexing } -// MoqVariadicFn_mock isolates the mock interface of the VariadicFn type -type MoqVariadicFn_mock struct { +// MoqVariadicFn_adaptor adapts MoqVariadicFn as needed by the runtime +type MoqVariadicFn_adaptor struct { Moq *MoqVariadicFn } @@ -1998,12 +1123,17 @@ type MoqVariadicFn_paramsKey struct { } } -// MoqVariadicFn_resultsByParams contains the results for a given set of -// parameters for the VariadicFn type -type MoqVariadicFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqVariadicFn_paramsKey]*MoqVariadicFn_results +// MoqVariadicFn_results holds the results of the VariadicFn type +type MoqVariadicFn_results struct { + SResult string + Err error +} + +// MoqVariadicFn_paramIndexing holds the parameter indexing runtime +// configuration for the VariadicFn type +type MoqVariadicFn_paramIndexing struct { + Other moq.ParamIndexing + Args moq.ParamIndexing } // MoqVariadicFn_doFn defines the type of function needed when calling AndDo @@ -2014,62 +1144,40 @@ type MoqVariadicFn_doFn func(other bool, args ...string) // DoReturnResults for the VariadicFn type type MoqVariadicFn_doReturnFn func(other bool, args ...string) (sResult string, err error) -// MoqVariadicFn_results holds the results of the VariadicFn type -type MoqVariadicFn_results struct { - Params MoqVariadicFn_params - Results []struct { - Values *struct { - SResult string - Err error - } - Sequence uint32 - DoFn MoqVariadicFn_doFn - DoReturnFn MoqVariadicFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqVariadicFn_fnRecorder routes recorded function calls to the MoqVariadicFn +// MoqVariadicFn_recorder routes recorded function calls to the MoqVariadicFn // moq -type MoqVariadicFn_fnRecorder struct { - Params MoqVariadicFn_params - AnyParams uint64 - Sequence bool - Results *MoqVariadicFn_results - Moq *MoqVariadicFn +type MoqVariadicFn_recorder struct { + Recorder *impl.Recorder[ + *MoqVariadicFn_adaptor, + MoqVariadicFn_params, + MoqVariadicFn_paramsKey, + MoqVariadicFn_results, + ] } // MoqVariadicFn_anyParams isolates the any params functions of the VariadicFn // type type MoqVariadicFn_anyParams struct { - Recorder *MoqVariadicFn_fnRecorder + Recorder *MoqVariadicFn_recorder } // NewMoqVariadicFn creates a new moq of the VariadicFn type func NewMoqVariadicFn(scene *moq.Scene, config *moq.Config) *MoqVariadicFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqVariadicFn_adaptor{} m := &MoqVariadicFn{ - Scene: scene, - Config: *config, - Moq: &MoqVariadicFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - Other moq.ParamIndexing - Args moq.ParamIndexing - } - }{ParameterIndexing: struct { - Other moq.ParamIndexing - Args moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqVariadicFn_adaptor, + MoqVariadicFn_params, + MoqVariadicFn_paramsKey, + MoqVariadicFn_results, + ](scene, adaptor1, config), + + Runtime: MoqVariadicFn_runtime{ParameterIndexing: MoqVariadicFn_paramIndexing{ Other: moq.ParamIndexByValue, Args: moq.ParamIndexByHash, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -2077,279 +1185,115 @@ func NewMoqVariadicFn(scene *moq.Scene, config *moq.Config) *MoqVariadicFn { // Mock returns the moq implementation of the VariadicFn type func (m *MoqVariadicFn) Mock() testmoqs.VariadicFn { - return func(other bool, args ...string) (_ string, _ error) { - m.Scene.T.Helper() - moq := &MoqVariadicFn_mock{Moq: m} - return moq.Fn(other, args...) - } -} - -func (m *MoqVariadicFn_mock) Fn(other bool, args ...string) (sResult string, err error) { - m.Moq.Scene.T.Helper() - params := MoqVariadicFn_params{ - Other: other, - Args: args, - } - var results *MoqVariadicFn_results - 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 + return func(other bool, args ...string) (string, error) { + m.Moq.Scene.T.Helper() + params := MoqVariadicFn_params{ + Other: other, + Args: args, } - 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)) + var result1 string + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } + return result1, result2 } - - 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 *MoqVariadicFn) OnCall(other bool, args ...string) *MoqVariadicFn_fnRecorder { - return &MoqVariadicFn_fnRecorder{ - Params: MoqVariadicFn_params{ +func (m *MoqVariadicFn) OnCall(other bool, args ...string) *MoqVariadicFn_recorder { + return &MoqVariadicFn_recorder{ + Recorder: m.Moq.OnCall(MoqVariadicFn_params{ Other: other, Args: args, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqVariadicFn_fnRecorder) Any() *MoqVariadicFn_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(r.Params)) +func (r *MoqVariadicFn_recorder) Any() *MoqVariadicFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqVariadicFn_anyParams{Recorder: r} } -func (a *MoqVariadicFn_anyParams) Other() *MoqVariadicFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqVariadicFn_anyParams) Other() *MoqVariadicFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqVariadicFn_anyParams) Args() *MoqVariadicFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqVariadicFn_anyParams) Args() *MoqVariadicFn_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (r *MoqVariadicFn_fnRecorder) Seq() *MoqVariadicFn_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(r.Params)) +func (r *MoqVariadicFn_recorder) Seq() *MoqVariadicFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqVariadicFn_fnRecorder) NoSeq() *MoqVariadicFn_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(r.Params)) +func (r *MoqVariadicFn_recorder) NoSeq() *MoqVariadicFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqVariadicFn_fnRecorder) ReturnResults(sResult string, err error) *MoqVariadicFn_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 MoqVariadicFn_doFn - DoReturnFn MoqVariadicFn_doReturnFn - }{ - Values: &struct { - SResult string - Err error - }{ - SResult: sResult, - Err: err, - }, - Sequence: sequence, +func (r *MoqVariadicFn_recorder) ReturnResults(sResult string, err error) *MoqVariadicFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqVariadicFn_results{ + SResult: sResult, + Err: err, }) return r } -func (r *MoqVariadicFn_fnRecorder) AndDo(fn MoqVariadicFn_doFn) *MoqVariadicFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqVariadicFn_recorder) AndDo(fn MoqVariadicFn_doFn) *MoqVariadicFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqVariadicFn_params) { + fn(params.Other, params.Args...) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqVariadicFn_fnRecorder) DoReturnResults(fn MoqVariadicFn_doReturnFn) *MoqVariadicFn_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 +func (r *MoqVariadicFn_recorder) DoReturnResults(fn MoqVariadicFn_doReturnFn) *MoqVariadicFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqVariadicFn_params) *MoqVariadicFn_results { + sResult, err := fn(params.Other, params.Args...) + return &MoqVariadicFn_results{ + SResult: sResult, + Err: err, } - Sequence uint32 - DoFn MoqVariadicFn_doFn - DoReturnFn MoqVariadicFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqVariadicFn_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 *MoqVariadicFn_resultsByParams - 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 = &MoqVariadicFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqVariadicFn_paramsKey]*MoqVariadicFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqVariadicFn_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 *MoqVariadicFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqVariadicFn_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 MoqVariadicFn_doFn - DoReturnFn MoqVariadicFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqVariadicFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqVariadicFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqVariadicFn) PrettyParams(params MoqVariadicFn_params) string { +func (*MoqVariadicFn_adaptor) PrettyParams(params MoqVariadicFn_params) string { return fmt.Sprintf("VariadicFn(%#v, %#v)", params.Other, params.Args) } -func (m *MoqVariadicFn) ParamsKey(params MoqVariadicFn_params, anyParams uint64) MoqVariadicFn_paramsKey { - m.Scene.T.Helper() - var otherUsed bool - var otherUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.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.Args == moq.ParamIndexByValue { - m.Scene.T.Fatalf("The args parameter can't be indexed by value") - } - argsUsedHash = hash.DeepHash(params.Args) - } +func (a *MoqVariadicFn_adaptor) ParamsKey(params MoqVariadicFn_params, anyParams uint64) MoqVariadicFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + otherUsed, otherUsedHash := impl.ParamKey( + params.Other, 1, a.Moq.Runtime.ParameterIndexing.Other, anyParams) + argsUsedHash := impl.HashOnlyParamKey(a.Moq.Moq.Scene.T, + params.Args, "args", 2, a.Moq.Runtime.ParameterIndexing.Args, anyParams) return MoqVariadicFn_paramsKey{ Params: struct{ Other bool }{ Other: otherUsed, @@ -2365,40 +1309,36 @@ func (m *MoqVariadicFn) ParamsKey(params MoqVariadicFn_params, anyParams uint64) } // Reset resets the state of the moq -func (m *MoqVariadicFn) Reset() { m.ResultsByParams = nil } +func (m *MoqVariadicFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqVariadicFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqRepeatedIdsFn holds the state of a moq of the RepeatedIdsFn type type MoqRepeatedIdsFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqRepeatedIdsFn_mock + Moq *impl.Moq[ + *MoqRepeatedIdsFn_adaptor, + MoqRepeatedIdsFn_params, + MoqRepeatedIdsFn_paramsKey, + MoqRepeatedIdsFn_results, + ] - ResultsByParams []MoqRepeatedIdsFn_resultsByParams + Runtime MoqRepeatedIdsFn_runtime +} - Runtime struct { - ParameterIndexing struct { - SParam1 moq.ParamIndexing - SParam2 moq.ParamIndexing - BParam moq.ParamIndexing - } - } +// MoqRepeatedIdsFn_runtime holds runtime configuration for the RepeatedIdsFn +// type +type MoqRepeatedIdsFn_runtime struct { + ParameterIndexing MoqRepeatedIdsFn_paramIndexing } -// MoqRepeatedIdsFn_mock isolates the mock interface of the RepeatedIdsFn type -type MoqRepeatedIdsFn_mock struct { +// MoqRepeatedIdsFn_adaptor adapts MoqRepeatedIdsFn as needed by the runtime +type MoqRepeatedIdsFn_adaptor struct { Moq *MoqRepeatedIdsFn } @@ -2421,12 +1361,17 @@ type MoqRepeatedIdsFn_paramsKey struct { } } -// MoqRepeatedIdsFn_resultsByParams contains the results for a given set of -// parameters for the RepeatedIdsFn type -type MoqRepeatedIdsFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqRepeatedIdsFn_paramsKey]*MoqRepeatedIdsFn_results +// MoqRepeatedIdsFn_results holds the results of the RepeatedIdsFn type +type MoqRepeatedIdsFn_results struct { + SResult1, SResult2 string + Err error +} + +// MoqRepeatedIdsFn_paramIndexing holds the parameter indexing runtime +// configuration for the RepeatedIdsFn type +type MoqRepeatedIdsFn_paramIndexing struct { + SParam1, SParam2 moq.ParamIndexing + BParam moq.ParamIndexing } // MoqRepeatedIdsFn_doFn defines the type of function needed when calling AndDo @@ -2437,65 +1382,41 @@ type MoqRepeatedIdsFn_doFn func(sParam1, sParam2 string, bParam bool) // DoReturnResults for the RepeatedIdsFn type type MoqRepeatedIdsFn_doReturnFn func(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) -// MoqRepeatedIdsFn_results holds the results of the RepeatedIdsFn type -type MoqRepeatedIdsFn_results struct { - Params MoqRepeatedIdsFn_params - Results []struct { - Values *struct { - SResult1, SResult2 string - Err error - } - Sequence uint32 - DoFn MoqRepeatedIdsFn_doFn - DoReturnFn MoqRepeatedIdsFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqRepeatedIdsFn_fnRecorder routes recorded function calls to the +// MoqRepeatedIdsFn_recorder routes recorded function calls to the // MoqRepeatedIdsFn moq -type MoqRepeatedIdsFn_fnRecorder struct { - Params MoqRepeatedIdsFn_params - AnyParams uint64 - Sequence bool - Results *MoqRepeatedIdsFn_results - Moq *MoqRepeatedIdsFn +type MoqRepeatedIdsFn_recorder struct { + Recorder *impl.Recorder[ + *MoqRepeatedIdsFn_adaptor, + MoqRepeatedIdsFn_params, + MoqRepeatedIdsFn_paramsKey, + MoqRepeatedIdsFn_results, + ] } // MoqRepeatedIdsFn_anyParams isolates the any params functions of the // RepeatedIdsFn type type MoqRepeatedIdsFn_anyParams struct { - Recorder *MoqRepeatedIdsFn_fnRecorder + Recorder *MoqRepeatedIdsFn_recorder } // NewMoqRepeatedIdsFn creates a new moq of the RepeatedIdsFn type func NewMoqRepeatedIdsFn(scene *moq.Scene, config *moq.Config) *MoqRepeatedIdsFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqRepeatedIdsFn_adaptor{} m := &MoqRepeatedIdsFn{ - Scene: scene, - Config: *config, - Moq: &MoqRepeatedIdsFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - SParam1 moq.ParamIndexing - SParam2 moq.ParamIndexing - BParam moq.ParamIndexing - } - }{ParameterIndexing: struct { - SParam1 moq.ParamIndexing - SParam2 moq.ParamIndexing - BParam moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqRepeatedIdsFn_adaptor, + MoqRepeatedIdsFn_params, + MoqRepeatedIdsFn_paramsKey, + MoqRepeatedIdsFn_results, + ](scene, adaptor1, config), + + Runtime: MoqRepeatedIdsFn_runtime{ParameterIndexing: MoqRepeatedIdsFn_paramIndexing{ SParam1: moq.ParamIndexByValue, SParam2: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -2503,299 +1424,128 @@ func NewMoqRepeatedIdsFn(scene *moq.Scene, config *moq.Config) *MoqRepeatedIdsFn // Mock returns the moq implementation of the RepeatedIdsFn type func (m *MoqRepeatedIdsFn) Mock() testmoqs.RepeatedIdsFn { - return func(sParam1, sParam2 string, bParam bool) (_, _ string, _ error) { - m.Scene.T.Helper() - moq := &MoqRepeatedIdsFn_mock{Moq: m} - return moq.Fn(sParam1, sParam2, bParam) - } -} - -func (m *MoqRepeatedIdsFn_mock) Fn(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) { - m.Moq.Scene.T.Helper() - params := MoqRepeatedIdsFn_params{ - SParam1: sParam1, - SParam2: sParam2, - BParam: bParam, - } - var results *MoqRepeatedIdsFn_results - 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 + return func(sParam1, sParam2 string, bParam bool) (string, string, error) { + m.Moq.Scene.T.Helper() + params := MoqRepeatedIdsFn_params{ + SParam1: sParam1, + SParam2: sParam2, + BParam: bParam, } - 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)) + var result1 string + var result2 string + var result3 error + if result := m.Moq.Function(params); result != nil { + result1 = result.SResult1 + result2 = result.SResult2 + result3 = result.Err } + return result1, result2, result3 } - - 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 *MoqRepeatedIdsFn) OnCall(sParam1, sParam2 string, bParam bool) *MoqRepeatedIdsFn_fnRecorder { - return &MoqRepeatedIdsFn_fnRecorder{ - Params: MoqRepeatedIdsFn_params{ +func (m *MoqRepeatedIdsFn) OnCall(sParam1, sParam2 string, bParam bool) *MoqRepeatedIdsFn_recorder { + return &MoqRepeatedIdsFn_recorder{ + Recorder: m.Moq.OnCall(MoqRepeatedIdsFn_params{ SParam1: sParam1, SParam2: sParam2, BParam: bParam, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqRepeatedIdsFn_fnRecorder) Any() *MoqRepeatedIdsFn_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(r.Params)) +func (r *MoqRepeatedIdsFn_recorder) Any() *MoqRepeatedIdsFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqRepeatedIdsFn_anyParams{Recorder: r} } -func (a *MoqRepeatedIdsFn_anyParams) SParam1() *MoqRepeatedIdsFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqRepeatedIdsFn_anyParams) SParam1() *MoqRepeatedIdsFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqRepeatedIdsFn_anyParams) SParam2() *MoqRepeatedIdsFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqRepeatedIdsFn_anyParams) SParam2() *MoqRepeatedIdsFn_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (a *MoqRepeatedIdsFn_anyParams) BParam() *MoqRepeatedIdsFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 2 +func (a *MoqRepeatedIdsFn_anyParams) BParam() *MoqRepeatedIdsFn_recorder { + a.Recorder.Recorder.AnyParam(3) return a.Recorder } -func (r *MoqRepeatedIdsFn_fnRecorder) Seq() *MoqRepeatedIdsFn_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(r.Params)) +func (r *MoqRepeatedIdsFn_recorder) Seq() *MoqRepeatedIdsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqRepeatedIdsFn_fnRecorder) NoSeq() *MoqRepeatedIdsFn_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(r.Params)) +func (r *MoqRepeatedIdsFn_recorder) NoSeq() *MoqRepeatedIdsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqRepeatedIdsFn_fnRecorder) ReturnResults(sResult1, sResult2 string, err error) *MoqRepeatedIdsFn_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 MoqRepeatedIdsFn_doFn - DoReturnFn MoqRepeatedIdsFn_doReturnFn - }{ - Values: &struct { - SResult1, SResult2 string - Err error - }{ - SResult1: sResult1, - SResult2: sResult2, - Err: err, - }, - Sequence: sequence, +func (r *MoqRepeatedIdsFn_recorder) ReturnResults(sResult1, sResult2 string, err error) *MoqRepeatedIdsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqRepeatedIdsFn_results{ + SResult1: sResult1, + SResult2: sResult2, + Err: err, }) return r } -func (r *MoqRepeatedIdsFn_fnRecorder) AndDo(fn MoqRepeatedIdsFn_doFn) *MoqRepeatedIdsFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqRepeatedIdsFn_recorder) AndDo(fn MoqRepeatedIdsFn_doFn) *MoqRepeatedIdsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqRepeatedIdsFn_params) { + fn(params.SParam1, params.SParam2, params.BParam) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqRepeatedIdsFn_fnRecorder) DoReturnResults(fn MoqRepeatedIdsFn_doReturnFn) *MoqRepeatedIdsFn_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 +func (r *MoqRepeatedIdsFn_recorder) DoReturnResults(fn MoqRepeatedIdsFn_doReturnFn) *MoqRepeatedIdsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqRepeatedIdsFn_params) *MoqRepeatedIdsFn_results { + sResult1, sResult2, err := fn(params.SParam1, params.SParam2, params.BParam) + return &MoqRepeatedIdsFn_results{ + SResult1: sResult1, + SResult2: sResult2, + Err: err, } - Sequence uint32 - DoFn MoqRepeatedIdsFn_doFn - DoReturnFn MoqRepeatedIdsFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqRepeatedIdsFn_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 *MoqRepeatedIdsFn_resultsByParams - 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 = &MoqRepeatedIdsFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqRepeatedIdsFn_paramsKey]*MoqRepeatedIdsFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqRepeatedIdsFn_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 *MoqRepeatedIdsFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqRepeatedIdsFn_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 MoqRepeatedIdsFn_doFn - DoReturnFn MoqRepeatedIdsFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqRepeatedIdsFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqRepeatedIdsFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqRepeatedIdsFn) PrettyParams(params MoqRepeatedIdsFn_params) string { +func (*MoqRepeatedIdsFn_adaptor) PrettyParams(params MoqRepeatedIdsFn_params) string { return fmt.Sprintf("RepeatedIdsFn(%#v, %#v, %#v)", params.SParam1, params.SParam2, params.BParam) } -func (m *MoqRepeatedIdsFn) ParamsKey(params MoqRepeatedIdsFn_params, anyParams uint64) MoqRepeatedIdsFn_paramsKey { - m.Scene.T.Helper() - var sParam1Used string - var sParam1UsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.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.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.BParam == moq.ParamIndexByValue { - bParamUsed = params.BParam - } else { - bParamUsedHash = hash.DeepHash(params.BParam) - } - } +func (a *MoqRepeatedIdsFn_adaptor) ParamsKey(params MoqRepeatedIdsFn_params, anyParams uint64) MoqRepeatedIdsFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + sParam1Used, sParam1UsedHash := impl.ParamKey( + params.SParam1, 1, a.Moq.Runtime.ParameterIndexing.SParam1, anyParams) + sParam2Used, sParam2UsedHash := impl.ParamKey( + params.SParam2, 2, a.Moq.Runtime.ParameterIndexing.SParam2, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 3, a.Moq.Runtime.ParameterIndexing.BParam, anyParams) return MoqRepeatedIdsFn_paramsKey{ Params: struct { SParam1, SParam2 string @@ -2817,39 +1567,35 @@ func (m *MoqRepeatedIdsFn) ParamsKey(params MoqRepeatedIdsFn_params, anyParams u } // Reset resets the state of the moq -func (m *MoqRepeatedIdsFn) Reset() { m.ResultsByParams = nil } +func (m *MoqRepeatedIdsFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqRepeatedIdsFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqTimesFn holds the state of a moq of the TimesFn type type MoqTimesFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqTimesFn_mock + Moq *impl.Moq[ + *MoqTimesFn_adaptor, + MoqTimesFn_params, + MoqTimesFn_paramsKey, + MoqTimesFn_results, + ] - ResultsByParams []MoqTimesFn_resultsByParams + Runtime MoqTimesFn_runtime +} - Runtime struct { - ParameterIndexing struct { - Times moq.ParamIndexing - BParam moq.ParamIndexing - } - } +// MoqTimesFn_runtime holds runtime configuration for the TimesFn type +type MoqTimesFn_runtime struct { + ParameterIndexing MoqTimesFn_paramIndexing } -// MoqTimesFn_mock isolates the mock interface of the TimesFn type -type MoqTimesFn_mock struct { +// MoqTimesFn_adaptor adapts MoqTimesFn as needed by the runtime +type MoqTimesFn_adaptor struct { Moq *MoqTimesFn } @@ -2871,12 +1617,17 @@ type MoqTimesFn_paramsKey struct { } } -// MoqTimesFn_resultsByParams contains the results for a given set of -// parameters for the TimesFn type -type MoqTimesFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqTimesFn_paramsKey]*MoqTimesFn_results +// MoqTimesFn_results holds the results of the TimesFn type +type MoqTimesFn_results struct { + SResult string + Err error +} + +// MoqTimesFn_paramIndexing holds the parameter indexing runtime configuration +// for the TimesFn type +type MoqTimesFn_paramIndexing struct { + Times moq.ParamIndexing + BParam moq.ParamIndexing } // MoqTimesFn_doFn defines the type of function needed when calling AndDo for @@ -2887,60 +1638,38 @@ type MoqTimesFn_doFn func(times string, bParam bool) // DoReturnResults for the TimesFn type type MoqTimesFn_doReturnFn func(times string, bParam bool) (sResult string, err error) -// MoqTimesFn_results holds the results of the TimesFn type -type MoqTimesFn_results struct { - Params MoqTimesFn_params - Results []struct { - Values *struct { - SResult string - Err error - } - Sequence uint32 - DoFn MoqTimesFn_doFn - DoReturnFn MoqTimesFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqTimesFn_fnRecorder routes recorded function calls to the MoqTimesFn moq -type MoqTimesFn_fnRecorder struct { - Params MoqTimesFn_params - AnyParams uint64 - Sequence bool - Results *MoqTimesFn_results - Moq *MoqTimesFn +// MoqTimesFn_recorder routes recorded function calls to the MoqTimesFn moq +type MoqTimesFn_recorder struct { + Recorder *impl.Recorder[ + *MoqTimesFn_adaptor, + MoqTimesFn_params, + MoqTimesFn_paramsKey, + MoqTimesFn_results, + ] } // MoqTimesFn_anyParams isolates the any params functions of the TimesFn type type MoqTimesFn_anyParams struct { - Recorder *MoqTimesFn_fnRecorder + Recorder *MoqTimesFn_recorder } // NewMoqTimesFn creates a new moq of the TimesFn type func NewMoqTimesFn(scene *moq.Scene, config *moq.Config) *MoqTimesFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqTimesFn_adaptor{} m := &MoqTimesFn{ - Scene: scene, - Config: *config, - Moq: &MoqTimesFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - Times moq.ParamIndexing - BParam moq.ParamIndexing - } - }{ParameterIndexing: struct { - Times moq.ParamIndexing - BParam moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqTimesFn_adaptor, + MoqTimesFn_params, + MoqTimesFn_paramsKey, + MoqTimesFn_results, + ](scene, adaptor1, config), + + Runtime: MoqTimesFn_runtime{ParameterIndexing: MoqTimesFn_paramIndexing{ Times: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -2948,281 +1677,115 @@ func NewMoqTimesFn(scene *moq.Scene, config *moq.Config) *MoqTimesFn { // Mock returns the moq implementation of the TimesFn type func (m *MoqTimesFn) Mock() testmoqs.TimesFn { - return func(times string, bParam bool) (_ string, _ error) { - m.Scene.T.Helper() - moq := &MoqTimesFn_mock{Moq: m} - return moq.Fn(times, bParam) - } -} - -func (m *MoqTimesFn_mock) Fn(times string, bParam bool) (sResult string, err error) { - m.Moq.Scene.T.Helper() - params := MoqTimesFn_params{ - Times: times, - BParam: bParam, - } - var results *MoqTimesFn_results - 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 + return func(times string, bParam bool) (string, error) { + m.Moq.Scene.T.Helper() + params := MoqTimesFn_params{ + Times: times, + BParam: bParam, } - 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)) + var result1 string + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } + return result1, result2 } - - if result.DoFn != nil { - result.DoFn(times, bParam) - } - - if result.Values != nil { - sResult = result.Values.SResult - err = result.Values.Err - } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn(times, bParam) - } - return } -func (m *MoqTimesFn) OnCall(times string, bParam bool) *MoqTimesFn_fnRecorder { - return &MoqTimesFn_fnRecorder{ - Params: MoqTimesFn_params{ +func (m *MoqTimesFn) OnCall(times string, bParam bool) *MoqTimesFn_recorder { + return &MoqTimesFn_recorder{ + Recorder: m.Moq.OnCall(MoqTimesFn_params{ Times: times, BParam: bParam, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqTimesFn_fnRecorder) Any() *MoqTimesFn_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(r.Params)) +func (r *MoqTimesFn_recorder) Any() *MoqTimesFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqTimesFn_anyParams{Recorder: r} } -func (a *MoqTimesFn_anyParams) Times() *MoqTimesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqTimesFn_anyParams) Times() *MoqTimesFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqTimesFn_anyParams) BParam() *MoqTimesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqTimesFn_anyParams) BParam() *MoqTimesFn_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (r *MoqTimesFn_fnRecorder) Seq() *MoqTimesFn_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(r.Params)) +func (r *MoqTimesFn_recorder) Seq() *MoqTimesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqTimesFn_fnRecorder) NoSeq() *MoqTimesFn_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(r.Params)) +func (r *MoqTimesFn_recorder) NoSeq() *MoqTimesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqTimesFn_fnRecorder) ReturnResults(sResult string, err error) *MoqTimesFn_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 MoqTimesFn_doFn - DoReturnFn MoqTimesFn_doReturnFn - }{ - Values: &struct { - SResult string - Err error - }{ - SResult: sResult, - Err: err, - }, - Sequence: sequence, +func (r *MoqTimesFn_recorder) ReturnResults(sResult string, err error) *MoqTimesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqTimesFn_results{ + SResult: sResult, + Err: err, }) return r } -func (r *MoqTimesFn_fnRecorder) AndDo(fn MoqTimesFn_doFn) *MoqTimesFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqTimesFn_recorder) AndDo(fn MoqTimesFn_doFn) *MoqTimesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqTimesFn_params) { + fn(params.Times, params.BParam) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqTimesFn_fnRecorder) DoReturnResults(fn MoqTimesFn_doReturnFn) *MoqTimesFn_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 +func (r *MoqTimesFn_recorder) DoReturnResults(fn MoqTimesFn_doReturnFn) *MoqTimesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqTimesFn_params) *MoqTimesFn_results { + sResult, err := fn(params.Times, params.BParam) + return &MoqTimesFn_results{ + SResult: sResult, + Err: err, } - Sequence uint32 - DoFn MoqTimesFn_doFn - DoReturnFn MoqTimesFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqTimesFn_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 *MoqTimesFn_resultsByParams - 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 = &MoqTimesFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqTimesFn_paramsKey]*MoqTimesFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqTimesFn_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 *MoqTimesFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqTimesFn_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 MoqTimesFn_doFn - DoReturnFn MoqTimesFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqTimesFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqTimesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqTimesFn) PrettyParams(params MoqTimesFn_params) string { +func (*MoqTimesFn_adaptor) PrettyParams(params MoqTimesFn_params) string { return fmt.Sprintf("TimesFn(%#v, %#v)", params.Times, params.BParam) } -func (m *MoqTimesFn) ParamsKey(params MoqTimesFn_params, anyParams uint64) MoqTimesFn_paramsKey { - m.Scene.T.Helper() - var timesUsed string - var timesUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.Times == moq.ParamIndexByValue { - timesUsed = params.Times - } else { - timesUsedHash = hash.DeepHash(params.Times) - } - } - var bParamUsed bool - var bParamUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.Runtime.ParameterIndexing.BParam == moq.ParamIndexByValue { - bParamUsed = params.BParam - } else { - bParamUsedHash = hash.DeepHash(params.BParam) - } - } +func (a *MoqTimesFn_adaptor) ParamsKey(params MoqTimesFn_params, anyParams uint64) MoqTimesFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + timesUsed, timesUsedHash := impl.ParamKey( + params.Times, 1, a.Moq.Runtime.ParameterIndexing.Times, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 2, a.Moq.Runtime.ParameterIndexing.BParam, anyParams) return MoqTimesFn_paramsKey{ Params: struct { Times string @@ -3242,48 +1805,38 @@ func (m *MoqTimesFn) ParamsKey(params MoqTimesFn_params, anyParams uint64) MoqTi } // Reset resets the state of the moq -func (m *MoqTimesFn) Reset() { m.ResultsByParams = nil } +func (m *MoqTimesFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqTimesFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqDifficultParamNamesFn holds the state of a moq of the // DifficultParamNamesFn type type MoqDifficultParamNamesFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqDifficultParamNamesFn_mock - - ResultsByParams []MoqDifficultParamNamesFn_resultsByParams - - Runtime struct { - ParameterIndexing 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 - } - } + Moq *impl.Moq[ + *MoqDifficultParamNamesFn_adaptor, + MoqDifficultParamNamesFn_params, + MoqDifficultParamNamesFn_paramsKey, + MoqDifficultParamNamesFn_results, + ] + + Runtime MoqDifficultParamNamesFn_runtime } -// MoqDifficultParamNamesFn_mock isolates the mock interface of the +// MoqDifficultParamNamesFn_runtime holds runtime configuration for the // DifficultParamNamesFn type -type MoqDifficultParamNamesFn_mock struct { +type MoqDifficultParamNamesFn_runtime struct { + ParameterIndexing MoqDifficultParamNamesFn_paramIndexing +} + +// MoqDifficultParamNamesFn_adaptor adapts MoqDifficultParamNamesFn as needed +// by the runtime +type MoqDifficultParamNamesFn_adaptor struct { Moq *MoqDifficultParamNamesFn } @@ -3313,12 +1866,17 @@ type MoqDifficultParamNamesFn_paramsKey struct { } } -// MoqDifficultParamNamesFn_resultsByParams contains the results for a given -// set of parameters for the DifficultParamNamesFn type -type MoqDifficultParamNamesFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqDifficultParamNamesFn_paramsKey]*MoqDifficultParamNamesFn_results +// MoqDifficultParamNamesFn_results holds the results of the +// DifficultParamNamesFn type +type MoqDifficultParamNamesFn_results struct{} + +// MoqDifficultParamNamesFn_paramIndexing holds the parameter indexing runtime +// configuration for the DifficultParamNamesFn type +type MoqDifficultParamNamesFn_paramIndexing struct { + Param1, Param2 moq.ParamIndexing + Param3 moq.ParamIndexing + Param, Param5, Param6 moq.ParamIndexing + Param7, Param8, Param9 moq.ParamIndexing } // MoqDifficultParamNamesFn_doFn defines the type of function needed when @@ -3329,70 +1887,36 @@ type MoqDifficultParamNamesFn_doFn func(m, r bool, sequence string, param, param // calling DoReturnResults for the DifficultParamNamesFn type type MoqDifficultParamNamesFn_doReturnFn func(m, r bool, sequence string, param, params, i int, result, results, _ float32) -// MoqDifficultParamNamesFn_results holds the results of the -// DifficultParamNamesFn type -type MoqDifficultParamNamesFn_results struct { - Params MoqDifficultParamNamesFn_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqDifficultParamNamesFn_doFn - DoReturnFn MoqDifficultParamNamesFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqDifficultParamNamesFn_fnRecorder routes recorded function calls to the +// MoqDifficultParamNamesFn_recorder routes recorded function calls to the // MoqDifficultParamNamesFn moq -type MoqDifficultParamNamesFn_fnRecorder struct { - Params MoqDifficultParamNamesFn_params - AnyParams uint64 - Sequence bool - Results *MoqDifficultParamNamesFn_results - Moq *MoqDifficultParamNamesFn +type MoqDifficultParamNamesFn_recorder struct { + Recorder *impl.Recorder[ + *MoqDifficultParamNamesFn_adaptor, + MoqDifficultParamNamesFn_params, + MoqDifficultParamNamesFn_paramsKey, + MoqDifficultParamNamesFn_results, + ] } // MoqDifficultParamNamesFn_anyParams isolates the any params functions of the // DifficultParamNamesFn type type MoqDifficultParamNamesFn_anyParams struct { - Recorder *MoqDifficultParamNamesFn_fnRecorder + Recorder *MoqDifficultParamNamesFn_recorder } // NewMoqDifficultParamNamesFn creates a new moq of the DifficultParamNamesFn // type func NewMoqDifficultParamNamesFn(scene *moq.Scene, config *moq.Config) *MoqDifficultParamNamesFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqDifficultParamNamesFn_adaptor{} m := &MoqDifficultParamNamesFn{ - Scene: scene, - Config: *config, - Moq: &MoqDifficultParamNamesFn_mock{}, - - Runtime: struct { - ParameterIndexing 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 - } - }{ParameterIndexing: 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 - }{ + Moq: impl.NewMoq[ + *MoqDifficultParamNamesFn_adaptor, + MoqDifficultParamNamesFn_params, + MoqDifficultParamNamesFn_paramsKey, + MoqDifficultParamNamesFn_results, + ](scene, adaptor1, config), + + Runtime: MoqDifficultParamNamesFn_runtime{ParameterIndexing: MoqDifficultParamNamesFn_paramIndexing{ Param1: moq.ParamIndexByValue, Param2: moq.ParamIndexByValue, Param3: moq.ParamIndexByValue, @@ -3404,7 +1928,7 @@ func NewMoqDifficultParamNamesFn(scene *moq.Scene, config *moq.Config) *MoqDiffi Param9: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -3413,73 +1937,26 @@ func NewMoqDifficultParamNamesFn(scene *moq.Scene, config *moq.Config) *MoqDiffi // Mock returns the moq implementation of the DifficultParamNamesFn type func (m *MoqDifficultParamNamesFn) Mock() testmoqs.DifficultParamNamesFn { return func(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) { - m.Scene.T.Helper() - moq := &MoqDifficultParamNamesFn_mock{Moq: m} - moq.Fn(param1, param2, param3, param, param5, param6, param7, param8, param9) - } -} - -func (m *MoqDifficultParamNamesFn_mock) Fn(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) { - m.Moq.Scene.T.Helper() - params := MoqDifficultParamNamesFn_params{ - Param1: param1, - Param2: param2, - Param3: param3, - Param: param, - Param5: param5, - Param6: param6, - Param7: param7, - Param8: param8, - Param9: param9, - } - var results *MoqDifficultParamNamesFn_results - 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)) + m.Moq.Scene.T.Helper() + params := MoqDifficultParamNamesFn_params{ + Param1: param1, + Param2: param2, + Param3: param3, + Param: param, + Param5: param5, + Param6: param6, + Param7: param7, + Param8: param8, + Param9: param9, } - } - if result.DoFn != nil { - result.DoFn(param1, param2, param3, param, param5, param6, param7, param8, param9) + m.Moq.Function(params) } - - if result.DoReturnFn != nil { - result.DoReturnFn(param1, param2, param3, param, param5, param6, param7, param8, param9) - } - return } -func (m *MoqDifficultParamNamesFn) OnCall(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) *MoqDifficultParamNamesFn_fnRecorder { - return &MoqDifficultParamNamesFn_fnRecorder{ - Params: MoqDifficultParamNamesFn_params{ +func (m *MoqDifficultParamNamesFn) OnCall(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) *MoqDifficultParamNamesFn_recorder { + return &MoqDifficultParamNamesFn_recorder{ + Recorder: m.Moq.OnCall(MoqDifficultParamNamesFn_params{ Param1: param1, Param2: param2, Param3: param3, @@ -3489,297 +1966,136 @@ func (m *MoqDifficultParamNamesFn) OnCall(param1, param2 bool, param3 string, pa Param7: param7, Param8: param8, Param9: param9, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqDifficultParamNamesFn_fnRecorder) Any() *MoqDifficultParamNamesFn_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(r.Params)) +func (r *MoqDifficultParamNamesFn_recorder) Any() *MoqDifficultParamNamesFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqDifficultParamNamesFn_anyParams{Recorder: r} } -func (a *MoqDifficultParamNamesFn_anyParams) Param1() *MoqDifficultParamNamesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqDifficultParamNamesFn_anyParams) Param1() *MoqDifficultParamNamesFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqDifficultParamNamesFn_anyParams) Param2() *MoqDifficultParamNamesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqDifficultParamNamesFn_anyParams) Param2() *MoqDifficultParamNamesFn_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (a *MoqDifficultParamNamesFn_anyParams) Param3() *MoqDifficultParamNamesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 2 +func (a *MoqDifficultParamNamesFn_anyParams) Param3() *MoqDifficultParamNamesFn_recorder { + a.Recorder.Recorder.AnyParam(3) return a.Recorder } -func (a *MoqDifficultParamNamesFn_anyParams) Param() *MoqDifficultParamNamesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 3 +func (a *MoqDifficultParamNamesFn_anyParams) Param() *MoqDifficultParamNamesFn_recorder { + a.Recorder.Recorder.AnyParam(4) return a.Recorder } -func (a *MoqDifficultParamNamesFn_anyParams) Param5() *MoqDifficultParamNamesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 4 +func (a *MoqDifficultParamNamesFn_anyParams) Param5() *MoqDifficultParamNamesFn_recorder { + a.Recorder.Recorder.AnyParam(5) return a.Recorder } -func (a *MoqDifficultParamNamesFn_anyParams) Param6() *MoqDifficultParamNamesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 5 +func (a *MoqDifficultParamNamesFn_anyParams) Param6() *MoqDifficultParamNamesFn_recorder { + a.Recorder.Recorder.AnyParam(6) return a.Recorder } -func (a *MoqDifficultParamNamesFn_anyParams) Param7() *MoqDifficultParamNamesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 6 +func (a *MoqDifficultParamNamesFn_anyParams) Param7() *MoqDifficultParamNamesFn_recorder { + a.Recorder.Recorder.AnyParam(7) return a.Recorder } -func (a *MoqDifficultParamNamesFn_anyParams) Param8() *MoqDifficultParamNamesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 7 +func (a *MoqDifficultParamNamesFn_anyParams) Param8() *MoqDifficultParamNamesFn_recorder { + a.Recorder.Recorder.AnyParam(8) return a.Recorder } -func (a *MoqDifficultParamNamesFn_anyParams) Param9() *MoqDifficultParamNamesFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 8 +func (a *MoqDifficultParamNamesFn_anyParams) Param9() *MoqDifficultParamNamesFn_recorder { + a.Recorder.Recorder.AnyParam(9) return a.Recorder } -func (r *MoqDifficultParamNamesFn_fnRecorder) Seq() *MoqDifficultParamNamesFn_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(r.Params)) +func (r *MoqDifficultParamNamesFn_recorder) Seq() *MoqDifficultParamNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqDifficultParamNamesFn_fnRecorder) NoSeq() *MoqDifficultParamNamesFn_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(r.Params)) +func (r *MoqDifficultParamNamesFn_recorder) NoSeq() *MoqDifficultParamNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqDifficultParamNamesFn_fnRecorder) ReturnResults() *MoqDifficultParamNamesFn_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 MoqDifficultParamNamesFn_doFn - DoReturnFn MoqDifficultParamNamesFn_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqDifficultParamNamesFn_recorder) ReturnResults() *MoqDifficultParamNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqDifficultParamNamesFn_results{}) return r } -func (r *MoqDifficultParamNamesFn_fnRecorder) AndDo(fn MoqDifficultParamNamesFn_doFn) *MoqDifficultParamNamesFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqDifficultParamNamesFn_recorder) AndDo(fn MoqDifficultParamNamesFn_doFn) *MoqDifficultParamNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqDifficultParamNamesFn_params) { + fn(params.Param1, params.Param2, params.Param3, params.Param, params.Param5, params.Param6, params.Param7, params.Param8, params.Param9) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqDifficultParamNamesFn_fnRecorder) DoReturnResults(fn MoqDifficultParamNamesFn_doReturnFn) *MoqDifficultParamNamesFn_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 MoqDifficultParamNamesFn_doFn - DoReturnFn MoqDifficultParamNamesFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqDifficultParamNamesFn_recorder) DoReturnResults(fn MoqDifficultParamNamesFn_doReturnFn) *MoqDifficultParamNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqDifficultParamNamesFn_params) *MoqDifficultParamNamesFn_results { + fn(params.Param1, params.Param2, params.Param3, params.Param, params.Param5, params.Param6, params.Param7, params.Param8, params.Param9) + return &MoqDifficultParamNamesFn_results{} + }) return r } -func (r *MoqDifficultParamNamesFn_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 *MoqDifficultParamNamesFn_resultsByParams - 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 = &MoqDifficultParamNamesFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqDifficultParamNamesFn_paramsKey]*MoqDifficultParamNamesFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqDifficultParamNamesFn_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 *MoqDifficultParamNamesFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqDifficultParamNamesFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqDifficultParamNamesFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqDifficultParamNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 MoqDifficultParamNamesFn_doFn - DoReturnFn MoqDifficultParamNamesFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqDifficultParamNamesFn) PrettyParams(params MoqDifficultParamNamesFn_params) string { +func (*MoqDifficultParamNamesFn_adaptor) PrettyParams(params MoqDifficultParamNamesFn_params) string { return fmt.Sprintf("DifficultParamNamesFn(%#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 *MoqDifficultParamNamesFn) ParamsKey(params MoqDifficultParamNamesFn_params, anyParams uint64) MoqDifficultParamNamesFn_paramsKey { - m.Scene.T.Helper() - var param1Used bool - 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) - } - } - 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) - } - } - var param3Used string - var param3UsedHash hash.Hash - if anyParams&(1<<2) == 0 { - if m.Runtime.ParameterIndexing.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.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.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.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.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.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.Param9 == moq.ParamIndexByValue { - param9Used = params.Param9 - } else { - param9UsedHash = hash.DeepHash(params.Param9) - } - } +func (a *MoqDifficultParamNamesFn_adaptor) ParamsKey(params MoqDifficultParamNamesFn_params, anyParams uint64) MoqDifficultParamNamesFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.Param2, anyParams) + param3Used, param3UsedHash := impl.ParamKey( + params.Param3, 3, a.Moq.Runtime.ParameterIndexing.Param3, anyParams) + paramUsed, paramUsedHash := impl.ParamKey( + params.Param, 4, a.Moq.Runtime.ParameterIndexing.Param, anyParams) + param5Used, param5UsedHash := impl.ParamKey( + params.Param5, 5, a.Moq.Runtime.ParameterIndexing.Param5, anyParams) + param6Used, param6UsedHash := impl.ParamKey( + params.Param6, 6, a.Moq.Runtime.ParameterIndexing.Param6, anyParams) + param7Used, param7UsedHash := impl.ParamKey( + params.Param7, 7, a.Moq.Runtime.ParameterIndexing.Param7, anyParams) + param8Used, param8UsedHash := impl.ParamKey( + params.Param8, 8, a.Moq.Runtime.ParameterIndexing.Param8, anyParams) + param9Used, param9UsedHash := impl.ParamKey( + params.Param9, 9, a.Moq.Runtime.ParameterIndexing.Param9, anyParams) return MoqDifficultParamNamesFn_paramsKey{ Params: struct { Param1, Param2 bool @@ -3817,38 +2133,38 @@ func (m *MoqDifficultParamNamesFn) ParamsKey(params MoqDifficultParamNamesFn_par } // Reset resets the state of the moq -func (m *MoqDifficultParamNamesFn) Reset() { m.ResultsByParams = nil } +func (m *MoqDifficultParamNamesFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqDifficultParamNamesFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqDifficultResultNamesFn holds the state of a moq of the // DifficultResultNamesFn type type MoqDifficultResultNamesFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqDifficultResultNamesFn_mock + Moq *impl.Moq[ + *MoqDifficultResultNamesFn_adaptor, + MoqDifficultResultNamesFn_params, + MoqDifficultResultNamesFn_paramsKey, + MoqDifficultResultNamesFn_results, + ] - ResultsByParams []MoqDifficultResultNamesFn_resultsByParams - - Runtime struct { - ParameterIndexing struct{} - } + Runtime MoqDifficultResultNamesFn_runtime } -// MoqDifficultResultNamesFn_mock isolates the mock interface of the +// MoqDifficultResultNamesFn_runtime holds runtime configuration for the // DifficultResultNamesFn type -type MoqDifficultResultNamesFn_mock struct { +type MoqDifficultResultNamesFn_runtime struct { + ParameterIndexing MoqDifficultResultNamesFn_paramIndexing +} + +// MoqDifficultResultNamesFn_adaptor adapts MoqDifficultResultNamesFn as needed +// by the runtime +type MoqDifficultResultNamesFn_adaptor struct { Moq *MoqDifficultResultNamesFn } @@ -3863,14 +2179,19 @@ type MoqDifficultResultNamesFn_paramsKey struct { Hashes struct{} } -// MoqDifficultResultNamesFn_resultsByParams contains the results for a given -// set of parameters for the DifficultResultNamesFn type -type MoqDifficultResultNamesFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqDifficultResultNamesFn_paramsKey]*MoqDifficultResultNamesFn_results +// MoqDifficultResultNamesFn_results holds the results of the +// DifficultResultNamesFn type +type MoqDifficultResultNamesFn_results struct { + Result1, Result2 string + Result3 error + Param, Result5, Result6 int + Result7, Result8, Result9 float32 } +// MoqDifficultResultNamesFn_paramIndexing holds the parameter indexing runtime +// configuration for the DifficultResultNamesFn type +type MoqDifficultResultNamesFn_paramIndexing struct{} + // MoqDifficultResultNamesFn_doFn defines the type of function needed when // calling AndDo for the DifficultResultNamesFn type type MoqDifficultResultNamesFn_doFn func() @@ -3879,57 +2200,38 @@ type MoqDifficultResultNamesFn_doFn func() // when calling DoReturnResults for the DifficultResultNamesFn type type MoqDifficultResultNamesFn_doReturnFn func() (m, r string, sequence error, param, params, i int, result, results, _ float32) -// MoqDifficultResultNamesFn_results holds the results of the -// DifficultResultNamesFn type -type MoqDifficultResultNamesFn_results struct { - Params MoqDifficultResultNamesFn_params - Results []struct { - Values *struct { - Result1, Result2 string - Result3 error - Param, Result5, Result6 int - Result7, Result8, Result9 float32 - } - Sequence uint32 - DoFn MoqDifficultResultNamesFn_doFn - DoReturnFn MoqDifficultResultNamesFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqDifficultResultNamesFn_fnRecorder routes recorded function calls to the +// MoqDifficultResultNamesFn_recorder routes recorded function calls to the // MoqDifficultResultNamesFn moq -type MoqDifficultResultNamesFn_fnRecorder struct { - Params MoqDifficultResultNamesFn_params - AnyParams uint64 - Sequence bool - Results *MoqDifficultResultNamesFn_results - Moq *MoqDifficultResultNamesFn +type MoqDifficultResultNamesFn_recorder struct { + Recorder *impl.Recorder[ + *MoqDifficultResultNamesFn_adaptor, + MoqDifficultResultNamesFn_params, + MoqDifficultResultNamesFn_paramsKey, + MoqDifficultResultNamesFn_results, + ] } // MoqDifficultResultNamesFn_anyParams isolates the any params functions of the // DifficultResultNamesFn type type MoqDifficultResultNamesFn_anyParams struct { - Recorder *MoqDifficultResultNamesFn_fnRecorder + Recorder *MoqDifficultResultNamesFn_recorder } // NewMoqDifficultResultNamesFn creates a new moq of the DifficultResultNamesFn // type func NewMoqDifficultResultNamesFn(scene *moq.Scene, config *moq.Config) *MoqDifficultResultNamesFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqDifficultResultNamesFn_adaptor{} m := &MoqDifficultResultNamesFn{ - Scene: scene, - Config: *config, - Moq: &MoqDifficultResultNamesFn_mock{}, + Moq: impl.NewMoq[ + *MoqDifficultResultNamesFn_adaptor, + MoqDifficultResultNamesFn_params, + MoqDifficultResultNamesFn_paramsKey, + MoqDifficultResultNamesFn_results, + ](scene, adaptor1, config), - Runtime: struct { - ParameterIndexing struct{} - }{ParameterIndexing: struct{}{}}, + Runtime: MoqDifficultResultNamesFn_runtime{ParameterIndexing: MoqDifficultResultNamesFn_paramIndexing{}}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -3937,135 +2239,95 @@ func NewMoqDifficultResultNamesFn(scene *moq.Scene, config *moq.Config) *MoqDiff // Mock returns the moq implementation of the DifficultResultNamesFn type func (m *MoqDifficultResultNamesFn) Mock() testmoqs.DifficultResultNamesFn { - return func() (_, _ string, _ error, _, _, _ int, _, _, _ float32) { - m.Scene.T.Helper() - moq := &MoqDifficultResultNamesFn_mock{Moq: m} - return moq.Fn() - } -} - -func (m *MoqDifficultResultNamesFn_mock) Fn() (result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) { - m.Moq.Scene.T.Helper() - params := MoqDifficultResultNamesFn_params{} - var results *MoqDifficultResultNamesFn_results - 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 - } + return func() (string, string, error, int, int, int, float32, float32, float32) { + m.Moq.Scene.T.Helper() + params := MoqDifficultResultNamesFn_params{} - 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)) + var result1 string + var result2 string + var result3 error + var result4 int + var result5 int + var result6 int + var result7 float32 + var result8 float32 + var result9 float32 + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 + result3 = result.Result3 + result4 = result.Param + result5 = result.Result5 + result6 = result.Result6 + result7 = result.Result7 + result8 = result.Result8 + result9 = result.Result9 } + return result1, result2, result3, result4, result5, result6, result7, result8, result9 } - - 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 *MoqDifficultResultNamesFn) OnCall() *MoqDifficultResultNamesFn_fnRecorder { - return &MoqDifficultResultNamesFn_fnRecorder{ - Params: MoqDifficultResultNamesFn_params{}, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, +func (m *MoqDifficultResultNamesFn) OnCall() *MoqDifficultResultNamesFn_recorder { + return &MoqDifficultResultNamesFn_recorder{ + Recorder: m.Moq.OnCall(MoqDifficultResultNamesFn_params{}), } } -func (r *MoqDifficultResultNamesFn_fnRecorder) Any() *MoqDifficultResultNamesFn_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(r.Params)) +func (r *MoqDifficultResultNamesFn_recorder) Any() *MoqDifficultResultNamesFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqDifficultResultNamesFn_anyParams{Recorder: r} } -func (r *MoqDifficultResultNamesFn_fnRecorder) Seq() *MoqDifficultResultNamesFn_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(r.Params)) +func (r *MoqDifficultResultNamesFn_recorder) Seq() *MoqDifficultResultNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqDifficultResultNamesFn_fnRecorder) NoSeq() *MoqDifficultResultNamesFn_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(r.Params)) +func (r *MoqDifficultResultNamesFn_recorder) NoSeq() *MoqDifficultResultNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqDifficultResultNamesFn_fnRecorder) ReturnResults(result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) *MoqDifficultResultNamesFn_fnRecorder { - r.Moq.Scene.T.Helper() - r.FindResults() +func (r *MoqDifficultResultNamesFn_recorder) ReturnResults(result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) *MoqDifficultResultNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqDifficultResultNamesFn_results{ + Result1: result1, + Result2: result2, + Result3: result3, + Param: param, + Result5: result5, + Result6: result6, + Result7: result7, + Result8: result8, + Result9: result9, + }) + return r +} - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() +func (r *MoqDifficultResultNamesFn_recorder) AndDo(fn MoqDifficultResultNamesFn_doFn) *MoqDifficultResultNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqDifficultResultNamesFn_params) { + fn() + }, true) { + return nil } + return r +} - 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 MoqDifficultResultNamesFn_doFn - DoReturnFn MoqDifficultResultNamesFn_doReturnFn - }{ - Values: &struct { - Result1, Result2 string - Result3 error - Param, Result5, Result6 int - Result7, Result8, Result9 float32 - }{ +func (r *MoqDifficultResultNamesFn_recorder) DoReturnResults(fn MoqDifficultResultNamesFn_doReturnFn) *MoqDifficultResultNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqDifficultResultNamesFn_params) *MoqDifficultResultNamesFn_results { + result1, result2, result3, param, result5, result6, result7, result8, result9 := fn() + return &MoqDifficultResultNamesFn_results{ Result1: result1, Result2: result2, Result3: result3, @@ -4075,131 +2337,25 @@ func (r *MoqDifficultResultNamesFn_fnRecorder) ReturnResults(result1, result2 st Result7: result7, Result8: result8, Result9: result9, - }, - Sequence: sequence, + } }) return r } -func (r *MoqDifficultResultNamesFn_fnRecorder) AndDo(fn MoqDifficultResultNamesFn_doFn) *MoqDifficultResultNamesFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqDifficultResultNamesFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqDifficultResultNamesFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn - return r -} - -func (r *MoqDifficultResultNamesFn_fnRecorder) DoReturnResults(fn MoqDifficultResultNamesFn_doReturnFn) *MoqDifficultResultNamesFn_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 MoqDifficultResultNamesFn_doFn - DoReturnFn MoqDifficultResultNamesFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) - return r -} - -func (r *MoqDifficultResultNamesFn_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 *MoqDifficultResultNamesFn_resultsByParams - 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 = &MoqDifficultResultNamesFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqDifficultResultNamesFn_paramsKey]*MoqDifficultResultNamesFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqDifficultResultNamesFn_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 *MoqDifficultResultNamesFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqDifficultResultNamesFn_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 MoqDifficultResultNamesFn_doFn - DoReturnFn MoqDifficultResultNamesFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqDifficultResultNamesFn) PrettyParams(params MoqDifficultResultNamesFn_params) string { +func (*MoqDifficultResultNamesFn_adaptor) PrettyParams(params MoqDifficultResultNamesFn_params) string { return fmt.Sprintf("DifficultResultNamesFn()") } -func (m *MoqDifficultResultNamesFn) ParamsKey(params MoqDifficultResultNamesFn_params, anyParams uint64) MoqDifficultResultNamesFn_paramsKey { - m.Scene.T.Helper() +func (a *MoqDifficultResultNamesFn_adaptor) ParamsKey(params MoqDifficultResultNamesFn_params, anyParams uint64) MoqDifficultResultNamesFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() return MoqDifficultResultNamesFn_paramsKey{ Params: struct{}{}, Hashes: struct{}{}, @@ -4207,38 +2363,36 @@ func (m *MoqDifficultResultNamesFn) ParamsKey(params MoqDifficultResultNamesFn_p } // Reset resets the state of the moq -func (m *MoqDifficultResultNamesFn) Reset() { m.ResultsByParams = nil } +func (m *MoqDifficultResultNamesFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqDifficultResultNamesFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqPassByArrayFn holds the state of a moq of the PassByArrayFn type type MoqPassByArrayFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqPassByArrayFn_mock + Moq *impl.Moq[ + *MoqPassByArrayFn_adaptor, + MoqPassByArrayFn_params, + MoqPassByArrayFn_paramsKey, + MoqPassByArrayFn_results, + ] - ResultsByParams []MoqPassByArrayFn_resultsByParams + Runtime MoqPassByArrayFn_runtime +} - Runtime struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - } +// MoqPassByArrayFn_runtime holds runtime configuration for the PassByArrayFn +// type +type MoqPassByArrayFn_runtime struct { + ParameterIndexing MoqPassByArrayFn_paramIndexing } -// MoqPassByArrayFn_mock isolates the mock interface of the PassByArrayFn type -type MoqPassByArrayFn_mock struct { +// MoqPassByArrayFn_adaptor adapts MoqPassByArrayFn as needed by the runtime +type MoqPassByArrayFn_adaptor struct { Moq *MoqPassByArrayFn } @@ -4252,12 +2406,15 @@ type MoqPassByArrayFn_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqPassByArrayFn_resultsByParams contains the results for a given set of -// parameters for the PassByArrayFn type -type MoqPassByArrayFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqPassByArrayFn_paramsKey]*MoqPassByArrayFn_results +// MoqPassByArrayFn_results holds the results of the PassByArrayFn type +type MoqPassByArrayFn_results struct { + Result1 [3]testmoqs.Results +} + +// MoqPassByArrayFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByArrayFn type +type MoqPassByArrayFn_paramIndexing struct { + P moq.ParamIndexing } // MoqPassByArrayFn_doFn defines the type of function needed when calling AndDo @@ -4268,58 +2425,39 @@ type MoqPassByArrayFn_doFn func(p [3]testmoqs.Params) // DoReturnResults for the PassByArrayFn type type MoqPassByArrayFn_doReturnFn func(p [3]testmoqs.Params) [3]testmoqs.Results -// MoqPassByArrayFn_results holds the results of the PassByArrayFn type -type MoqPassByArrayFn_results struct { - Params MoqPassByArrayFn_params - Results []struct { - Values *struct { - Result1 [3]testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByArrayFn_doFn - DoReturnFn MoqPassByArrayFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqPassByArrayFn_fnRecorder routes recorded function calls to the +// MoqPassByArrayFn_recorder routes recorded function calls to the // MoqPassByArrayFn moq -type MoqPassByArrayFn_fnRecorder struct { - Params MoqPassByArrayFn_params - AnyParams uint64 - Sequence bool - Results *MoqPassByArrayFn_results - Moq *MoqPassByArrayFn +type MoqPassByArrayFn_recorder struct { + Recorder *impl.Recorder[ + *MoqPassByArrayFn_adaptor, + MoqPassByArrayFn_params, + MoqPassByArrayFn_paramsKey, + MoqPassByArrayFn_results, + ] } // MoqPassByArrayFn_anyParams isolates the any params functions of the // PassByArrayFn type type MoqPassByArrayFn_anyParams struct { - Recorder *MoqPassByArrayFn_fnRecorder + Recorder *MoqPassByArrayFn_recorder } // NewMoqPassByArrayFn creates a new moq of the PassByArrayFn type func NewMoqPassByArrayFn(scene *moq.Scene, config *moq.Config) *MoqPassByArrayFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqPassByArrayFn_adaptor{} m := &MoqPassByArrayFn{ - Scene: scene, - Config: *config, - Moq: &MoqPassByArrayFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - }{ParameterIndexing: struct { - P moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqPassByArrayFn_adaptor, + MoqPassByArrayFn_params, + MoqPassByArrayFn_paramsKey, + MoqPassByArrayFn_results, + ](scene, adaptor1, config), + + Runtime: MoqPassByArrayFn_runtime{ParameterIndexing: MoqPassByArrayFn_paramIndexing{ P: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -4328,258 +2466,101 @@ func NewMoqPassByArrayFn(scene *moq.Scene, config *moq.Config) *MoqPassByArrayFn // Mock returns the moq implementation of the PassByArrayFn type func (m *MoqPassByArrayFn) Mock() testmoqs.PassByArrayFn { return func(p [3]testmoqs.Params) [3]testmoqs.Results { - m.Scene.T.Helper() - moq := &MoqPassByArrayFn_mock{Moq: m} - return moq.Fn(p) - } -} - -func (m *MoqPassByArrayFn_mock) Fn(p [3]testmoqs.Params) (result1 [3]testmoqs.Results) { - m.Moq.Scene.T.Helper() - params := MoqPassByArrayFn_params{ - P: p, - } - var results *MoqPassByArrayFn_results - 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)) + m.Moq.Scene.T.Helper() + params := MoqPassByArrayFn_params{ + P: p, } - 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 + var result1 [3]testmoqs.Results + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 } - i = results.Repeat.ResultCount - 1 + return result1 } +} - 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)) - } +func (m *MoqPassByArrayFn) OnCall(p [3]testmoqs.Params) *MoqPassByArrayFn_recorder { + return &MoqPassByArrayFn_recorder{ + Recorder: m.Moq.OnCall(MoqPassByArrayFn_params{ + P: p, + }), } +} - if result.DoFn != nil { - result.DoFn(p) - } - - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) - } - return -} - -func (m *MoqPassByArrayFn) OnCall(p [3]testmoqs.Params) *MoqPassByArrayFn_fnRecorder { - return &MoqPassByArrayFn_fnRecorder{ - Params: MoqPassByArrayFn_params{ - P: p, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, - } -} - -func (r *MoqPassByArrayFn_fnRecorder) Any() *MoqPassByArrayFn_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(r.Params)) - return nil +func (r *MoqPassByArrayFn_recorder) Any() *MoqPassByArrayFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { + return nil } return &MoqPassByArrayFn_anyParams{Recorder: r} } -func (a *MoqPassByArrayFn_anyParams) P() *MoqPassByArrayFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPassByArrayFn_anyParams) P() *MoqPassByArrayFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqPassByArrayFn_fnRecorder) Seq() *MoqPassByArrayFn_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(r.Params)) +func (r *MoqPassByArrayFn_recorder) Seq() *MoqPassByArrayFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqPassByArrayFn_fnRecorder) NoSeq() *MoqPassByArrayFn_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(r.Params)) +func (r *MoqPassByArrayFn_recorder) NoSeq() *MoqPassByArrayFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPassByArrayFn_fnRecorder) ReturnResults(result1 [3]testmoqs.Results) *MoqPassByArrayFn_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 [3]testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByArrayFn_doFn - DoReturnFn MoqPassByArrayFn_doReturnFn - }{ - Values: &struct { - Result1 [3]testmoqs.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqPassByArrayFn_recorder) ReturnResults(result1 [3]testmoqs.Results) *MoqPassByArrayFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPassByArrayFn_results{ + Result1: result1, }) return r } -func (r *MoqPassByArrayFn_fnRecorder) AndDo(fn MoqPassByArrayFn_doFn) *MoqPassByArrayFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqPassByArrayFn_recorder) AndDo(fn MoqPassByArrayFn_doFn) *MoqPassByArrayFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPassByArrayFn_params) { + fn(params.P) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPassByArrayFn_fnRecorder) DoReturnResults(fn MoqPassByArrayFn_doReturnFn) *MoqPassByArrayFn_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 [3]testmoqs.Results +func (r *MoqPassByArrayFn_recorder) DoReturnResults(fn MoqPassByArrayFn_doReturnFn) *MoqPassByArrayFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPassByArrayFn_params) *MoqPassByArrayFn_results { + result1 := fn(params.P) + return &MoqPassByArrayFn_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqPassByArrayFn_doFn - DoReturnFn MoqPassByArrayFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPassByArrayFn_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 *MoqPassByArrayFn_resultsByParams - 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 = &MoqPassByArrayFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPassByArrayFn_paramsKey]*MoqPassByArrayFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqPassByArrayFn_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 *MoqPassByArrayFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqPassByArrayFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqPassByArrayFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqPassByArrayFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 [3]testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByArrayFn_doFn - DoReturnFn MoqPassByArrayFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqPassByArrayFn) PrettyParams(params MoqPassByArrayFn_params) string { +func (*MoqPassByArrayFn_adaptor) PrettyParams(params MoqPassByArrayFn_params) string { return fmt.Sprintf("PassByArrayFn(%#v)", params.P) } -func (m *MoqPassByArrayFn) ParamsKey(params MoqPassByArrayFn_params, anyParams uint64) MoqPassByArrayFn_paramsKey { - m.Scene.T.Helper() - var pUsed [3]testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.P == moq.ParamIndexByValue { - pUsed = params.P - } else { - pUsedHash = hash.DeepHash(params.P) - } - } +func (a *MoqPassByArrayFn_adaptor) ParamsKey(params MoqPassByArrayFn_params, anyParams uint64) MoqPassByArrayFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.P, 1, a.Moq.Runtime.ParameterIndexing.P, anyParams) return MoqPassByArrayFn_paramsKey{ Params: struct{ P [3]testmoqs.Params }{ P: pUsed, @@ -4591,38 +2572,36 @@ func (m *MoqPassByArrayFn) ParamsKey(params MoqPassByArrayFn_params, anyParams u } // Reset resets the state of the moq -func (m *MoqPassByArrayFn) Reset() { m.ResultsByParams = nil } +func (m *MoqPassByArrayFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqPassByArrayFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqPassByChanFn holds the state of a moq of the PassByChanFn type type MoqPassByChanFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqPassByChanFn_mock + Moq *impl.Moq[ + *MoqPassByChanFn_adaptor, + MoqPassByChanFn_params, + MoqPassByChanFn_paramsKey, + MoqPassByChanFn_results, + ] - ResultsByParams []MoqPassByChanFn_resultsByParams + Runtime MoqPassByChanFn_runtime +} - Runtime struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - } +// MoqPassByChanFn_runtime holds runtime configuration for the PassByChanFn +// type +type MoqPassByChanFn_runtime struct { + ParameterIndexing MoqPassByChanFn_paramIndexing } -// MoqPassByChanFn_mock isolates the mock interface of the PassByChanFn type -type MoqPassByChanFn_mock struct { +// MoqPassByChanFn_adaptor adapts MoqPassByChanFn as needed by the runtime +type MoqPassByChanFn_adaptor struct { Moq *MoqPassByChanFn } @@ -4635,12 +2614,15 @@ type MoqPassByChanFn_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqPassByChanFn_resultsByParams contains the results for a given set of -// parameters for the PassByChanFn type -type MoqPassByChanFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqPassByChanFn_paramsKey]*MoqPassByChanFn_results +// MoqPassByChanFn_results holds the results of the PassByChanFn type +type MoqPassByChanFn_results struct { + Result1 chan testmoqs.Results +} + +// MoqPassByChanFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByChanFn type +type MoqPassByChanFn_paramIndexing struct { + P moq.ParamIndexing } // MoqPassByChanFn_doFn defines the type of function needed when calling AndDo @@ -4651,58 +2633,39 @@ type MoqPassByChanFn_doFn func(p chan testmoqs.Params) // DoReturnResults for the PassByChanFn type type MoqPassByChanFn_doReturnFn func(p chan testmoqs.Params) chan testmoqs.Results -// MoqPassByChanFn_results holds the results of the PassByChanFn type -type MoqPassByChanFn_results struct { - Params MoqPassByChanFn_params - Results []struct { - Values *struct { - Result1 chan testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByChanFn_doFn - DoReturnFn MoqPassByChanFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqPassByChanFn_fnRecorder routes recorded function calls to the +// MoqPassByChanFn_recorder routes recorded function calls to the // MoqPassByChanFn moq -type MoqPassByChanFn_fnRecorder struct { - Params MoqPassByChanFn_params - AnyParams uint64 - Sequence bool - Results *MoqPassByChanFn_results - Moq *MoqPassByChanFn +type MoqPassByChanFn_recorder struct { + Recorder *impl.Recorder[ + *MoqPassByChanFn_adaptor, + MoqPassByChanFn_params, + MoqPassByChanFn_paramsKey, + MoqPassByChanFn_results, + ] } // MoqPassByChanFn_anyParams isolates the any params functions of the // PassByChanFn type type MoqPassByChanFn_anyParams struct { - Recorder *MoqPassByChanFn_fnRecorder + Recorder *MoqPassByChanFn_recorder } // NewMoqPassByChanFn creates a new moq of the PassByChanFn type func NewMoqPassByChanFn(scene *moq.Scene, config *moq.Config) *MoqPassByChanFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqPassByChanFn_adaptor{} m := &MoqPassByChanFn{ - Scene: scene, - Config: *config, - Moq: &MoqPassByChanFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - }{ParameterIndexing: struct { - P moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqPassByChanFn_adaptor, + MoqPassByChanFn_params, + MoqPassByChanFn_paramsKey, + MoqPassByChanFn_results, + ](scene, adaptor1, config), + + Runtime: MoqPassByChanFn_runtime{ParameterIndexing: MoqPassByChanFn_paramIndexing{ P: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -4711,258 +2674,101 @@ func NewMoqPassByChanFn(scene *moq.Scene, config *moq.Config) *MoqPassByChanFn { // Mock returns the moq implementation of the PassByChanFn type func (m *MoqPassByChanFn) Mock() testmoqs.PassByChanFn { return func(p chan testmoqs.Params) chan testmoqs.Results { - m.Scene.T.Helper() - moq := &MoqPassByChanFn_mock{Moq: m} - return moq.Fn(p) - } -} - -func (m *MoqPassByChanFn_mock) Fn(p chan testmoqs.Params) (result1 chan testmoqs.Results) { - m.Moq.Scene.T.Helper() - params := MoqPassByChanFn_params{ - P: p, - } - var results *MoqPassByChanFn_results - 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 + m.Moq.Scene.T.Helper() + params := MoqPassByChanFn_params{ + P: p, } - 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)) + var result1 chan testmoqs.Results + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 } + return result1 } - - if result.DoFn != nil { - result.DoFn(p) - } - - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) - } - return } -func (m *MoqPassByChanFn) OnCall(p chan testmoqs.Params) *MoqPassByChanFn_fnRecorder { - return &MoqPassByChanFn_fnRecorder{ - Params: MoqPassByChanFn_params{ +func (m *MoqPassByChanFn) OnCall(p chan testmoqs.Params) *MoqPassByChanFn_recorder { + return &MoqPassByChanFn_recorder{ + Recorder: m.Moq.OnCall(MoqPassByChanFn_params{ P: p, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqPassByChanFn_fnRecorder) Any() *MoqPassByChanFn_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(r.Params)) +func (r *MoqPassByChanFn_recorder) Any() *MoqPassByChanFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPassByChanFn_anyParams{Recorder: r} } -func (a *MoqPassByChanFn_anyParams) P() *MoqPassByChanFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPassByChanFn_anyParams) P() *MoqPassByChanFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqPassByChanFn_fnRecorder) Seq() *MoqPassByChanFn_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(r.Params)) +func (r *MoqPassByChanFn_recorder) Seq() *MoqPassByChanFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqPassByChanFn_fnRecorder) NoSeq() *MoqPassByChanFn_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(r.Params)) +func (r *MoqPassByChanFn_recorder) NoSeq() *MoqPassByChanFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPassByChanFn_fnRecorder) ReturnResults(result1 chan testmoqs.Results) *MoqPassByChanFn_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 chan testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByChanFn_doFn - DoReturnFn MoqPassByChanFn_doReturnFn - }{ - Values: &struct { - Result1 chan testmoqs.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqPassByChanFn_recorder) ReturnResults(result1 chan testmoqs.Results) *MoqPassByChanFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPassByChanFn_results{ + Result1: result1, }) return r } -func (r *MoqPassByChanFn_fnRecorder) AndDo(fn MoqPassByChanFn_doFn) *MoqPassByChanFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqPassByChanFn_recorder) AndDo(fn MoqPassByChanFn_doFn) *MoqPassByChanFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPassByChanFn_params) { + fn(params.P) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPassByChanFn_fnRecorder) DoReturnResults(fn MoqPassByChanFn_doReturnFn) *MoqPassByChanFn_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 chan testmoqs.Results +func (r *MoqPassByChanFn_recorder) DoReturnResults(fn MoqPassByChanFn_doReturnFn) *MoqPassByChanFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPassByChanFn_params) *MoqPassByChanFn_results { + result1 := fn(params.P) + return &MoqPassByChanFn_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqPassByChanFn_doFn - DoReturnFn MoqPassByChanFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPassByChanFn_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 *MoqPassByChanFn_resultsByParams - 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 = &MoqPassByChanFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPassByChanFn_paramsKey]*MoqPassByChanFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqPassByChanFn_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 *MoqPassByChanFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqPassByChanFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqPassByChanFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqPassByChanFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 chan testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByChanFn_doFn - DoReturnFn MoqPassByChanFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqPassByChanFn) PrettyParams(params MoqPassByChanFn_params) string { +func (*MoqPassByChanFn_adaptor) PrettyParams(params MoqPassByChanFn_params) string { return fmt.Sprintf("PassByChanFn(%#v)", params.P) } -func (m *MoqPassByChanFn) ParamsKey(params MoqPassByChanFn_params, anyParams uint64) MoqPassByChanFn_paramsKey { - m.Scene.T.Helper() - var pUsed chan testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.P == moq.ParamIndexByValue { - pUsed = params.P - } else { - pUsedHash = hash.DeepHash(params.P) - } - } +func (a *MoqPassByChanFn_adaptor) ParamsKey(params MoqPassByChanFn_params, anyParams uint64) MoqPassByChanFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.P, 1, a.Moq.Runtime.ParameterIndexing.P, anyParams) return MoqPassByChanFn_paramsKey{ Params: struct{ P chan testmoqs.Params }{ P: pUsed, @@ -4974,39 +2780,37 @@ func (m *MoqPassByChanFn) ParamsKey(params MoqPassByChanFn_params, anyParams uin } // Reset resets the state of the moq -func (m *MoqPassByChanFn) Reset() { m.ResultsByParams = nil } +func (m *MoqPassByChanFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqPassByChanFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqPassByEllipsisFn holds the state of a moq of the PassByEllipsisFn type type MoqPassByEllipsisFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqPassByEllipsisFn_mock + Moq *impl.Moq[ + *MoqPassByEllipsisFn_adaptor, + MoqPassByEllipsisFn_params, + MoqPassByEllipsisFn_paramsKey, + MoqPassByEllipsisFn_results, + ] - ResultsByParams []MoqPassByEllipsisFn_resultsByParams + Runtime MoqPassByEllipsisFn_runtime +} - Runtime struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - } +// MoqPassByEllipsisFn_runtime holds runtime configuration for the +// PassByEllipsisFn type +type MoqPassByEllipsisFn_runtime struct { + ParameterIndexing MoqPassByEllipsisFn_paramIndexing } -// MoqPassByEllipsisFn_mock isolates the mock interface of the PassByEllipsisFn -// type -type MoqPassByEllipsisFn_mock struct { +// MoqPassByEllipsisFn_adaptor adapts MoqPassByEllipsisFn as needed by the +// runtime +type MoqPassByEllipsisFn_adaptor struct { Moq *MoqPassByEllipsisFn } @@ -5020,12 +2824,16 @@ type MoqPassByEllipsisFn_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqPassByEllipsisFn_resultsByParams contains the results for a given set of -// parameters for the PassByEllipsisFn type -type MoqPassByEllipsisFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqPassByEllipsisFn_paramsKey]*MoqPassByEllipsisFn_results +// MoqPassByEllipsisFn_results holds the results of the PassByEllipsisFn type +type MoqPassByEllipsisFn_results struct { + Result1 string + Result2 error +} + +// MoqPassByEllipsisFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByEllipsisFn type +type MoqPassByEllipsisFn_paramIndexing struct { + P moq.ParamIndexing } // MoqPassByEllipsisFn_doFn defines the type of function needed when calling @@ -5036,59 +2844,39 @@ type MoqPassByEllipsisFn_doFn func(p ...testmoqs.Params) // calling DoReturnResults for the PassByEllipsisFn type type MoqPassByEllipsisFn_doReturnFn func(p ...testmoqs.Params) (string, error) -// MoqPassByEllipsisFn_results holds the results of the PassByEllipsisFn type -type MoqPassByEllipsisFn_results struct { - Params MoqPassByEllipsisFn_params - Results []struct { - Values *struct { - Result1 string - Result2 error - } - Sequence uint32 - DoFn MoqPassByEllipsisFn_doFn - DoReturnFn MoqPassByEllipsisFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqPassByEllipsisFn_fnRecorder routes recorded function calls to the +// MoqPassByEllipsisFn_recorder routes recorded function calls to the // MoqPassByEllipsisFn moq -type MoqPassByEllipsisFn_fnRecorder struct { - Params MoqPassByEllipsisFn_params - AnyParams uint64 - Sequence bool - Results *MoqPassByEllipsisFn_results - Moq *MoqPassByEllipsisFn +type MoqPassByEllipsisFn_recorder struct { + Recorder *impl.Recorder[ + *MoqPassByEllipsisFn_adaptor, + MoqPassByEllipsisFn_params, + MoqPassByEllipsisFn_paramsKey, + MoqPassByEllipsisFn_results, + ] } // MoqPassByEllipsisFn_anyParams isolates the any params functions of the // PassByEllipsisFn type type MoqPassByEllipsisFn_anyParams struct { - Recorder *MoqPassByEllipsisFn_fnRecorder + Recorder *MoqPassByEllipsisFn_recorder } // NewMoqPassByEllipsisFn creates a new moq of the PassByEllipsisFn type func NewMoqPassByEllipsisFn(scene *moq.Scene, config *moq.Config) *MoqPassByEllipsisFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqPassByEllipsisFn_adaptor{} m := &MoqPassByEllipsisFn{ - Scene: scene, - Config: *config, - Moq: &MoqPassByEllipsisFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - }{ParameterIndexing: struct { - P moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqPassByEllipsisFn_adaptor, + MoqPassByEllipsisFn_params, + MoqPassByEllipsisFn_paramsKey, + MoqPassByEllipsisFn_results, + ](scene, adaptor1, config), + + Runtime: MoqPassByEllipsisFn_runtime{ParameterIndexing: MoqPassByEllipsisFn_paramIndexing{ P: moq.ParamIndexByHash, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -5097,262 +2885,105 @@ func NewMoqPassByEllipsisFn(scene *moq.Scene, config *moq.Config) *MoqPassByElli // Mock returns the moq implementation of the PassByEllipsisFn type func (m *MoqPassByEllipsisFn) Mock() testmoqs.PassByEllipsisFn { return func(p ...testmoqs.Params) (string, error) { - m.Scene.T.Helper() - moq := &MoqPassByEllipsisFn_mock{Moq: m} - return moq.Fn(p...) - } -} - -func (m *MoqPassByEllipsisFn_mock) Fn(p ...testmoqs.Params) (result1 string, result2 error) { - m.Moq.Scene.T.Helper() - params := MoqPassByEllipsisFn_params{ - P: p, - } - var results *MoqPassByEllipsisFn_results - 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 + m.Moq.Scene.T.Helper() + params := MoqPassByEllipsisFn_params{ + P: p, } - 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)) + var result1 string + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } + return result1, result2 } - - if result.DoFn != nil { - result.DoFn(p...) - } - - if result.Values != nil { - result1 = result.Values.Result1 - result2 = result.Values.Result2 - } - if result.DoReturnFn != nil { - result1, result2 = result.DoReturnFn(p...) - } - return } -func (m *MoqPassByEllipsisFn) OnCall(p ...testmoqs.Params) *MoqPassByEllipsisFn_fnRecorder { - return &MoqPassByEllipsisFn_fnRecorder{ - Params: MoqPassByEllipsisFn_params{ +func (m *MoqPassByEllipsisFn) OnCall(p ...testmoqs.Params) *MoqPassByEllipsisFn_recorder { + return &MoqPassByEllipsisFn_recorder{ + Recorder: m.Moq.OnCall(MoqPassByEllipsisFn_params{ P: p, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqPassByEllipsisFn_fnRecorder) Any() *MoqPassByEllipsisFn_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(r.Params)) +func (r *MoqPassByEllipsisFn_recorder) Any() *MoqPassByEllipsisFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPassByEllipsisFn_anyParams{Recorder: r} } -func (a *MoqPassByEllipsisFn_anyParams) P() *MoqPassByEllipsisFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPassByEllipsisFn_anyParams) P() *MoqPassByEllipsisFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqPassByEllipsisFn_fnRecorder) Seq() *MoqPassByEllipsisFn_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(r.Params)) +func (r *MoqPassByEllipsisFn_recorder) Seq() *MoqPassByEllipsisFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqPassByEllipsisFn_fnRecorder) NoSeq() *MoqPassByEllipsisFn_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(r.Params)) +func (r *MoqPassByEllipsisFn_recorder) NoSeq() *MoqPassByEllipsisFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPassByEllipsisFn_fnRecorder) ReturnResults(result1 string, result2 error) *MoqPassByEllipsisFn_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 MoqPassByEllipsisFn_doFn - DoReturnFn MoqPassByEllipsisFn_doReturnFn - }{ - Values: &struct { - Result1 string - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqPassByEllipsisFn_recorder) ReturnResults(result1 string, result2 error) *MoqPassByEllipsisFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPassByEllipsisFn_results{ + Result1: result1, + Result2: result2, }) return r } -func (r *MoqPassByEllipsisFn_fnRecorder) AndDo(fn MoqPassByEllipsisFn_doFn) *MoqPassByEllipsisFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqPassByEllipsisFn_recorder) AndDo(fn MoqPassByEllipsisFn_doFn) *MoqPassByEllipsisFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPassByEllipsisFn_params) { + fn(params.P...) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPassByEllipsisFn_fnRecorder) DoReturnResults(fn MoqPassByEllipsisFn_doReturnFn) *MoqPassByEllipsisFn_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 +func (r *MoqPassByEllipsisFn_recorder) DoReturnResults(fn MoqPassByEllipsisFn_doReturnFn) *MoqPassByEllipsisFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPassByEllipsisFn_params) *MoqPassByEllipsisFn_results { + result1, result2 := fn(params.P...) + return &MoqPassByEllipsisFn_results{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqPassByEllipsisFn_doFn - DoReturnFn MoqPassByEllipsisFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPassByEllipsisFn_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 *MoqPassByEllipsisFn_resultsByParams - 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 = &MoqPassByEllipsisFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPassByEllipsisFn_paramsKey]*MoqPassByEllipsisFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqPassByEllipsisFn_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 *MoqPassByEllipsisFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqPassByEllipsisFn_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 MoqPassByEllipsisFn_doFn - DoReturnFn MoqPassByEllipsisFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqPassByEllipsisFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqPassByEllipsisFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqPassByEllipsisFn) PrettyParams(params MoqPassByEllipsisFn_params) string { +func (*MoqPassByEllipsisFn_adaptor) PrettyParams(params MoqPassByEllipsisFn_params) string { return fmt.Sprintf("PassByEllipsisFn(%#v)", params.P) } -func (m *MoqPassByEllipsisFn) ParamsKey(params MoqPassByEllipsisFn_params, anyParams uint64) MoqPassByEllipsisFn_paramsKey { - m.Scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.P == moq.ParamIndexByValue { - m.Scene.T.Fatalf("The p parameter can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.P) - } +func (a *MoqPassByEllipsisFn_adaptor) ParamsKey(params MoqPassByEllipsisFn_params, anyParams uint64) MoqPassByEllipsisFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.Moq.Moq.Scene.T, + params.P, "p", 1, a.Moq.Runtime.ParameterIndexing.P, anyParams) return MoqPassByEllipsisFn_paramsKey{ Params: struct{}{}, Hashes: struct{ P hash.Hash }{ @@ -5362,38 +2993,35 @@ func (m *MoqPassByEllipsisFn) ParamsKey(params MoqPassByEllipsisFn_params, anyPa } // Reset resets the state of the moq -func (m *MoqPassByEllipsisFn) Reset() { m.ResultsByParams = nil } +func (m *MoqPassByEllipsisFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqPassByEllipsisFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqPassByMapFn holds the state of a moq of the PassByMapFn type type MoqPassByMapFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqPassByMapFn_mock + Moq *impl.Moq[ + *MoqPassByMapFn_adaptor, + MoqPassByMapFn_params, + MoqPassByMapFn_paramsKey, + MoqPassByMapFn_results, + ] - ResultsByParams []MoqPassByMapFn_resultsByParams + Runtime MoqPassByMapFn_runtime +} - Runtime struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - } +// MoqPassByMapFn_runtime holds runtime configuration for the PassByMapFn type +type MoqPassByMapFn_runtime struct { + ParameterIndexing MoqPassByMapFn_paramIndexing } -// MoqPassByMapFn_mock isolates the mock interface of the PassByMapFn type -type MoqPassByMapFn_mock struct { +// MoqPassByMapFn_adaptor adapts MoqPassByMapFn as needed by the runtime +type MoqPassByMapFn_adaptor struct { Moq *MoqPassByMapFn } @@ -5406,12 +3034,15 @@ type MoqPassByMapFn_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqPassByMapFn_resultsByParams contains the results for a given set of -// parameters for the PassByMapFn type -type MoqPassByMapFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqPassByMapFn_paramsKey]*MoqPassByMapFn_results +// MoqPassByMapFn_results holds the results of the PassByMapFn type +type MoqPassByMapFn_results struct { + Result1 map[string]testmoqs.Results +} + +// MoqPassByMapFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByMapFn type +type MoqPassByMapFn_paramIndexing struct { + P moq.ParamIndexing } // MoqPassByMapFn_doFn defines the type of function needed when calling AndDo @@ -5422,58 +3053,39 @@ type MoqPassByMapFn_doFn func(p map[string]testmoqs.Params) // DoReturnResults for the PassByMapFn type type MoqPassByMapFn_doReturnFn func(p map[string]testmoqs.Params) map[string]testmoqs.Results -// MoqPassByMapFn_results holds the results of the PassByMapFn type -type MoqPassByMapFn_results struct { - Params MoqPassByMapFn_params - Results []struct { - Values *struct { - Result1 map[string]testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByMapFn_doFn - DoReturnFn MoqPassByMapFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqPassByMapFn_fnRecorder routes recorded function calls to the -// MoqPassByMapFn moq -type MoqPassByMapFn_fnRecorder struct { - Params MoqPassByMapFn_params - AnyParams uint64 - Sequence bool - Results *MoqPassByMapFn_results - Moq *MoqPassByMapFn +// MoqPassByMapFn_recorder routes recorded function calls to the MoqPassByMapFn +// moq +type MoqPassByMapFn_recorder struct { + Recorder *impl.Recorder[ + *MoqPassByMapFn_adaptor, + MoqPassByMapFn_params, + MoqPassByMapFn_paramsKey, + MoqPassByMapFn_results, + ] } // MoqPassByMapFn_anyParams isolates the any params functions of the // PassByMapFn type type MoqPassByMapFn_anyParams struct { - Recorder *MoqPassByMapFn_fnRecorder + Recorder *MoqPassByMapFn_recorder } // NewMoqPassByMapFn creates a new moq of the PassByMapFn type func NewMoqPassByMapFn(scene *moq.Scene, config *moq.Config) *MoqPassByMapFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqPassByMapFn_adaptor{} m := &MoqPassByMapFn{ - Scene: scene, - Config: *config, - Moq: &MoqPassByMapFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - }{ParameterIndexing: struct { - P moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqPassByMapFn_adaptor, + MoqPassByMapFn_params, + MoqPassByMapFn_paramsKey, + MoqPassByMapFn_results, + ](scene, adaptor1, config), + + Runtime: MoqPassByMapFn_runtime{ParameterIndexing: MoqPassByMapFn_paramIndexing{ P: moq.ParamIndexByHash, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -5482,256 +3094,101 @@ func NewMoqPassByMapFn(scene *moq.Scene, config *moq.Config) *MoqPassByMapFn { // Mock returns the moq implementation of the PassByMapFn type func (m *MoqPassByMapFn) Mock() testmoqs.PassByMapFn { return func(p map[string]testmoqs.Params) map[string]testmoqs.Results { - m.Scene.T.Helper() - moq := &MoqPassByMapFn_mock{Moq: m} - return moq.Fn(p) - } -} - -func (m *MoqPassByMapFn_mock) Fn(p map[string]testmoqs.Params) (result1 map[string]testmoqs.Results) { - m.Moq.Scene.T.Helper() - params := MoqPassByMapFn_params{ - P: p, - } - var results *MoqPassByMapFn_results - 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 + m.Moq.Scene.T.Helper() + params := MoqPassByMapFn_params{ + P: p, } - 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)) + var result1 map[string]testmoqs.Results + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 } + return result1 } - - if result.DoFn != nil { - result.DoFn(p) - } - - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) - } - return } -func (m *MoqPassByMapFn) OnCall(p map[string]testmoqs.Params) *MoqPassByMapFn_fnRecorder { - return &MoqPassByMapFn_fnRecorder{ - Params: MoqPassByMapFn_params{ +func (m *MoqPassByMapFn) OnCall(p map[string]testmoqs.Params) *MoqPassByMapFn_recorder { + return &MoqPassByMapFn_recorder{ + Recorder: m.Moq.OnCall(MoqPassByMapFn_params{ P: p, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqPassByMapFn_fnRecorder) Any() *MoqPassByMapFn_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(r.Params)) +func (r *MoqPassByMapFn_recorder) Any() *MoqPassByMapFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPassByMapFn_anyParams{Recorder: r} } -func (a *MoqPassByMapFn_anyParams) P() *MoqPassByMapFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPassByMapFn_anyParams) P() *MoqPassByMapFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqPassByMapFn_fnRecorder) Seq() *MoqPassByMapFn_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(r.Params)) +func (r *MoqPassByMapFn_recorder) Seq() *MoqPassByMapFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqPassByMapFn_fnRecorder) NoSeq() *MoqPassByMapFn_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(r.Params)) +func (r *MoqPassByMapFn_recorder) NoSeq() *MoqPassByMapFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPassByMapFn_fnRecorder) ReturnResults(result1 map[string]testmoqs.Results) *MoqPassByMapFn_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 map[string]testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByMapFn_doFn - DoReturnFn MoqPassByMapFn_doReturnFn - }{ - Values: &struct { - Result1 map[string]testmoqs.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqPassByMapFn_recorder) ReturnResults(result1 map[string]testmoqs.Results) *MoqPassByMapFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPassByMapFn_results{ + Result1: result1, }) return r } -func (r *MoqPassByMapFn_fnRecorder) AndDo(fn MoqPassByMapFn_doFn) *MoqPassByMapFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqPassByMapFn_recorder) AndDo(fn MoqPassByMapFn_doFn) *MoqPassByMapFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPassByMapFn_params) { + fn(params.P) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPassByMapFn_fnRecorder) DoReturnResults(fn MoqPassByMapFn_doReturnFn) *MoqPassByMapFn_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 map[string]testmoqs.Results +func (r *MoqPassByMapFn_recorder) DoReturnResults(fn MoqPassByMapFn_doReturnFn) *MoqPassByMapFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPassByMapFn_params) *MoqPassByMapFn_results { + result1 := fn(params.P) + return &MoqPassByMapFn_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqPassByMapFn_doFn - DoReturnFn MoqPassByMapFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPassByMapFn_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 *MoqPassByMapFn_resultsByParams - 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 = &MoqPassByMapFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPassByMapFn_paramsKey]*MoqPassByMapFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqPassByMapFn_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 *MoqPassByMapFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqPassByMapFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqPassByMapFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqPassByMapFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 map[string]testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByMapFn_doFn - DoReturnFn MoqPassByMapFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqPassByMapFn) PrettyParams(params MoqPassByMapFn_params) string { +func (*MoqPassByMapFn_adaptor) PrettyParams(params MoqPassByMapFn_params) string { return fmt.Sprintf("PassByMapFn(%#v)", params.P) } -func (m *MoqPassByMapFn) ParamsKey(params MoqPassByMapFn_params, anyParams uint64) MoqPassByMapFn_paramsKey { - m.Scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.P == moq.ParamIndexByValue { - m.Scene.T.Fatalf("The p parameter can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.P) - } +func (a *MoqPassByMapFn_adaptor) ParamsKey(params MoqPassByMapFn_params, anyParams uint64) MoqPassByMapFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.Moq.Moq.Scene.T, + params.P, "p", 1, a.Moq.Runtime.ParameterIndexing.P, anyParams) return MoqPassByMapFn_paramsKey{ Params: struct{}{}, Hashes: struct{ P hash.Hash }{ @@ -5741,39 +3198,37 @@ func (m *MoqPassByMapFn) ParamsKey(params MoqPassByMapFn_params, anyParams uint6 } // Reset resets the state of the moq -func (m *MoqPassByMapFn) Reset() { m.ResultsByParams = nil } +func (m *MoqPassByMapFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqPassByMapFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqPassByReferenceFn holds the state of a moq of the PassByReferenceFn type type MoqPassByReferenceFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqPassByReferenceFn_mock - - ResultsByParams []MoqPassByReferenceFn_resultsByParams + Moq *impl.Moq[ + *MoqPassByReferenceFn_adaptor, + MoqPassByReferenceFn_params, + MoqPassByReferenceFn_paramsKey, + MoqPassByReferenceFn_results, + ] - Runtime struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - } + Runtime MoqPassByReferenceFn_runtime } -// MoqPassByReferenceFn_mock isolates the mock interface of the +// MoqPassByReferenceFn_runtime holds runtime configuration for the // PassByReferenceFn type -type MoqPassByReferenceFn_mock struct { +type MoqPassByReferenceFn_runtime struct { + ParameterIndexing MoqPassByReferenceFn_paramIndexing +} + +// MoqPassByReferenceFn_adaptor adapts MoqPassByReferenceFn as needed by the +// runtime +type MoqPassByReferenceFn_adaptor struct { Moq *MoqPassByReferenceFn } @@ -5787,12 +3242,15 @@ type MoqPassByReferenceFn_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqPassByReferenceFn_resultsByParams contains the results for a given set of -// parameters for the PassByReferenceFn type -type MoqPassByReferenceFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqPassByReferenceFn_paramsKey]*MoqPassByReferenceFn_results +// MoqPassByReferenceFn_results holds the results of the PassByReferenceFn type +type MoqPassByReferenceFn_results struct { + Result1 *testmoqs.Results +} + +// MoqPassByReferenceFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByReferenceFn type +type MoqPassByReferenceFn_paramIndexing struct { + P moq.ParamIndexing } // MoqPassByReferenceFn_doFn defines the type of function needed when calling @@ -5803,58 +3261,39 @@ type MoqPassByReferenceFn_doFn func(p *testmoqs.Params) // calling DoReturnResults for the PassByReferenceFn type type MoqPassByReferenceFn_doReturnFn func(p *testmoqs.Params) *testmoqs.Results -// MoqPassByReferenceFn_results holds the results of the PassByReferenceFn type -type MoqPassByReferenceFn_results struct { - Params MoqPassByReferenceFn_params - Results []struct { - Values *struct { - Result1 *testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByReferenceFn_doFn - DoReturnFn MoqPassByReferenceFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqPassByReferenceFn_fnRecorder routes recorded function calls to the +// MoqPassByReferenceFn_recorder routes recorded function calls to the // MoqPassByReferenceFn moq -type MoqPassByReferenceFn_fnRecorder struct { - Params MoqPassByReferenceFn_params - AnyParams uint64 - Sequence bool - Results *MoqPassByReferenceFn_results - Moq *MoqPassByReferenceFn +type MoqPassByReferenceFn_recorder struct { + Recorder *impl.Recorder[ + *MoqPassByReferenceFn_adaptor, + MoqPassByReferenceFn_params, + MoqPassByReferenceFn_paramsKey, + MoqPassByReferenceFn_results, + ] } // MoqPassByReferenceFn_anyParams isolates the any params functions of the // PassByReferenceFn type type MoqPassByReferenceFn_anyParams struct { - Recorder *MoqPassByReferenceFn_fnRecorder + Recorder *MoqPassByReferenceFn_recorder } // NewMoqPassByReferenceFn creates a new moq of the PassByReferenceFn type func NewMoqPassByReferenceFn(scene *moq.Scene, config *moq.Config) *MoqPassByReferenceFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqPassByReferenceFn_adaptor{} m := &MoqPassByReferenceFn{ - Scene: scene, - Config: *config, - Moq: &MoqPassByReferenceFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - }{ParameterIndexing: struct { - P moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqPassByReferenceFn_adaptor, + MoqPassByReferenceFn_params, + MoqPassByReferenceFn_paramsKey, + MoqPassByReferenceFn_results, + ](scene, adaptor1, config), + + Runtime: MoqPassByReferenceFn_runtime{ParameterIndexing: MoqPassByReferenceFn_paramIndexing{ P: moq.ParamIndexByHash, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -5863,258 +3302,101 @@ func NewMoqPassByReferenceFn(scene *moq.Scene, config *moq.Config) *MoqPassByRef // Mock returns the moq implementation of the PassByReferenceFn type func (m *MoqPassByReferenceFn) Mock() testmoqs.PassByReferenceFn { return func(p *testmoqs.Params) *testmoqs.Results { - m.Scene.T.Helper() - moq := &MoqPassByReferenceFn_mock{Moq: m} - return moq.Fn(p) - } -} - -func (m *MoqPassByReferenceFn_mock) Fn(p *testmoqs.Params) (result1 *testmoqs.Results) { - m.Moq.Scene.T.Helper() - params := MoqPassByReferenceFn_params{ - P: p, - } - var results *MoqPassByReferenceFn_results - 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 + m.Moq.Scene.T.Helper() + params := MoqPassByReferenceFn_params{ + P: p, } - 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)) + var result1 *testmoqs.Results + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 } + return result1 } - - if result.DoFn != nil { - result.DoFn(p) - } - - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) - } - return } -func (m *MoqPassByReferenceFn) OnCall(p *testmoqs.Params) *MoqPassByReferenceFn_fnRecorder { - return &MoqPassByReferenceFn_fnRecorder{ - Params: MoqPassByReferenceFn_params{ +func (m *MoqPassByReferenceFn) OnCall(p *testmoqs.Params) *MoqPassByReferenceFn_recorder { + return &MoqPassByReferenceFn_recorder{ + Recorder: m.Moq.OnCall(MoqPassByReferenceFn_params{ P: p, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqPassByReferenceFn_fnRecorder) Any() *MoqPassByReferenceFn_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(r.Params)) +func (r *MoqPassByReferenceFn_recorder) Any() *MoqPassByReferenceFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPassByReferenceFn_anyParams{Recorder: r} } -func (a *MoqPassByReferenceFn_anyParams) P() *MoqPassByReferenceFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPassByReferenceFn_anyParams) P() *MoqPassByReferenceFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqPassByReferenceFn_fnRecorder) Seq() *MoqPassByReferenceFn_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(r.Params)) +func (r *MoqPassByReferenceFn_recorder) Seq() *MoqPassByReferenceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqPassByReferenceFn_fnRecorder) NoSeq() *MoqPassByReferenceFn_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(r.Params)) +func (r *MoqPassByReferenceFn_recorder) NoSeq() *MoqPassByReferenceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPassByReferenceFn_fnRecorder) ReturnResults(result1 *testmoqs.Results) *MoqPassByReferenceFn_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 *testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByReferenceFn_doFn - DoReturnFn MoqPassByReferenceFn_doReturnFn - }{ - Values: &struct { - Result1 *testmoqs.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqPassByReferenceFn_recorder) ReturnResults(result1 *testmoqs.Results) *MoqPassByReferenceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPassByReferenceFn_results{ + Result1: result1, }) return r } -func (r *MoqPassByReferenceFn_fnRecorder) AndDo(fn MoqPassByReferenceFn_doFn) *MoqPassByReferenceFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqPassByReferenceFn_recorder) AndDo(fn MoqPassByReferenceFn_doFn) *MoqPassByReferenceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPassByReferenceFn_params) { + fn(params.P) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPassByReferenceFn_fnRecorder) DoReturnResults(fn MoqPassByReferenceFn_doReturnFn) *MoqPassByReferenceFn_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 *testmoqs.Results +func (r *MoqPassByReferenceFn_recorder) DoReturnResults(fn MoqPassByReferenceFn_doReturnFn) *MoqPassByReferenceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPassByReferenceFn_params) *MoqPassByReferenceFn_results { + result1 := fn(params.P) + return &MoqPassByReferenceFn_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqPassByReferenceFn_doFn - DoReturnFn MoqPassByReferenceFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPassByReferenceFn_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 *MoqPassByReferenceFn_resultsByParams - 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 = &MoqPassByReferenceFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPassByReferenceFn_paramsKey]*MoqPassByReferenceFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqPassByReferenceFn_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 *MoqPassByReferenceFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqPassByReferenceFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqPassByReferenceFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqPassByReferenceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 *testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByReferenceFn_doFn - DoReturnFn MoqPassByReferenceFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqPassByReferenceFn) PrettyParams(params MoqPassByReferenceFn_params) string { +func (*MoqPassByReferenceFn_adaptor) PrettyParams(params MoqPassByReferenceFn_params) string { return fmt.Sprintf("PassByReferenceFn(%#v)", params.P) } -func (m *MoqPassByReferenceFn) ParamsKey(params MoqPassByReferenceFn_params, anyParams uint64) MoqPassByReferenceFn_paramsKey { - m.Scene.T.Helper() - var pUsed *testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.P == moq.ParamIndexByValue { - pUsed = params.P - } else { - pUsedHash = hash.DeepHash(params.P) - } - } +func (a *MoqPassByReferenceFn_adaptor) ParamsKey(params MoqPassByReferenceFn_params, anyParams uint64) MoqPassByReferenceFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.P, 1, a.Moq.Runtime.ParameterIndexing.P, anyParams) return MoqPassByReferenceFn_paramsKey{ Params: struct{ P *testmoqs.Params }{ P: pUsed, @@ -6126,38 +3408,36 @@ func (m *MoqPassByReferenceFn) ParamsKey(params MoqPassByReferenceFn_params, any } // Reset resets the state of the moq -func (m *MoqPassByReferenceFn) Reset() { m.ResultsByParams = nil } +func (m *MoqPassByReferenceFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqPassByReferenceFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqPassBySliceFn holds the state of a moq of the PassBySliceFn type type MoqPassBySliceFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqPassBySliceFn_mock + Moq *impl.Moq[ + *MoqPassBySliceFn_adaptor, + MoqPassBySliceFn_params, + MoqPassBySliceFn_paramsKey, + MoqPassBySliceFn_results, + ] - ResultsByParams []MoqPassBySliceFn_resultsByParams + Runtime MoqPassBySliceFn_runtime +} - Runtime struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - } +// MoqPassBySliceFn_runtime holds runtime configuration for the PassBySliceFn +// type +type MoqPassBySliceFn_runtime struct { + ParameterIndexing MoqPassBySliceFn_paramIndexing } -// MoqPassBySliceFn_mock isolates the mock interface of the PassBySliceFn type -type MoqPassBySliceFn_mock struct { +// MoqPassBySliceFn_adaptor adapts MoqPassBySliceFn as needed by the runtime +type MoqPassBySliceFn_adaptor struct { Moq *MoqPassBySliceFn } @@ -6171,12 +3451,15 @@ type MoqPassBySliceFn_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqPassBySliceFn_resultsByParams contains the results for a given set of -// parameters for the PassBySliceFn type -type MoqPassBySliceFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqPassBySliceFn_paramsKey]*MoqPassBySliceFn_results +// MoqPassBySliceFn_results holds the results of the PassBySliceFn type +type MoqPassBySliceFn_results struct { + Result1 []testmoqs.Results +} + +// MoqPassBySliceFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassBySliceFn type +type MoqPassBySliceFn_paramIndexing struct { + P moq.ParamIndexing } // MoqPassBySliceFn_doFn defines the type of function needed when calling AndDo @@ -6187,58 +3470,39 @@ type MoqPassBySliceFn_doFn func(p []testmoqs.Params) // DoReturnResults for the PassBySliceFn type type MoqPassBySliceFn_doReturnFn func(p []testmoqs.Params) []testmoqs.Results -// MoqPassBySliceFn_results holds the results of the PassBySliceFn type -type MoqPassBySliceFn_results struct { - Params MoqPassBySliceFn_params - Results []struct { - Values *struct { - Result1 []testmoqs.Results - } - Sequence uint32 - DoFn MoqPassBySliceFn_doFn - DoReturnFn MoqPassBySliceFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqPassBySliceFn_fnRecorder routes recorded function calls to the +// MoqPassBySliceFn_recorder routes recorded function calls to the // MoqPassBySliceFn moq -type MoqPassBySliceFn_fnRecorder struct { - Params MoqPassBySliceFn_params - AnyParams uint64 - Sequence bool - Results *MoqPassBySliceFn_results - Moq *MoqPassBySliceFn +type MoqPassBySliceFn_recorder struct { + Recorder *impl.Recorder[ + *MoqPassBySliceFn_adaptor, + MoqPassBySliceFn_params, + MoqPassBySliceFn_paramsKey, + MoqPassBySliceFn_results, + ] } // MoqPassBySliceFn_anyParams isolates the any params functions of the // PassBySliceFn type type MoqPassBySliceFn_anyParams struct { - Recorder *MoqPassBySliceFn_fnRecorder + Recorder *MoqPassBySliceFn_recorder } // NewMoqPassBySliceFn creates a new moq of the PassBySliceFn type func NewMoqPassBySliceFn(scene *moq.Scene, config *moq.Config) *MoqPassBySliceFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqPassBySliceFn_adaptor{} m := &MoqPassBySliceFn{ - Scene: scene, - Config: *config, - Moq: &MoqPassBySliceFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - }{ParameterIndexing: struct { - P moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqPassBySliceFn_adaptor, + MoqPassBySliceFn_params, + MoqPassBySliceFn_paramsKey, + MoqPassBySliceFn_results, + ](scene, adaptor1, config), + + Runtime: MoqPassBySliceFn_runtime{ParameterIndexing: MoqPassBySliceFn_paramIndexing{ P: moq.ParamIndexByHash, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -6247,256 +3511,101 @@ func NewMoqPassBySliceFn(scene *moq.Scene, config *moq.Config) *MoqPassBySliceFn // Mock returns the moq implementation of the PassBySliceFn type func (m *MoqPassBySliceFn) Mock() testmoqs.PassBySliceFn { return func(p []testmoqs.Params) []testmoqs.Results { - m.Scene.T.Helper() - moq := &MoqPassBySliceFn_mock{Moq: m} - return moq.Fn(p) - } -} - -func (m *MoqPassBySliceFn_mock) Fn(p []testmoqs.Params) (result1 []testmoqs.Results) { - m.Moq.Scene.T.Helper() - params := MoqPassBySliceFn_params{ - P: p, - } - var results *MoqPassBySliceFn_results - 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 + m.Moq.Scene.T.Helper() + params := MoqPassBySliceFn_params{ + P: p, } - 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)) + var result1 []testmoqs.Results + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 } + return result1 } - - if result.DoFn != nil { - result.DoFn(p) - } - - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) - } - return } -func (m *MoqPassBySliceFn) OnCall(p []testmoqs.Params) *MoqPassBySliceFn_fnRecorder { - return &MoqPassBySliceFn_fnRecorder{ - Params: MoqPassBySliceFn_params{ +func (m *MoqPassBySliceFn) OnCall(p []testmoqs.Params) *MoqPassBySliceFn_recorder { + return &MoqPassBySliceFn_recorder{ + Recorder: m.Moq.OnCall(MoqPassBySliceFn_params{ P: p, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqPassBySliceFn_fnRecorder) Any() *MoqPassBySliceFn_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(r.Params)) +func (r *MoqPassBySliceFn_recorder) Any() *MoqPassBySliceFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPassBySliceFn_anyParams{Recorder: r} } -func (a *MoqPassBySliceFn_anyParams) P() *MoqPassBySliceFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPassBySliceFn_anyParams) P() *MoqPassBySliceFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqPassBySliceFn_fnRecorder) Seq() *MoqPassBySliceFn_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(r.Params)) +func (r *MoqPassBySliceFn_recorder) Seq() *MoqPassBySliceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqPassBySliceFn_fnRecorder) NoSeq() *MoqPassBySliceFn_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(r.Params)) +func (r *MoqPassBySliceFn_recorder) NoSeq() *MoqPassBySliceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPassBySliceFn_fnRecorder) ReturnResults(result1 []testmoqs.Results) *MoqPassBySliceFn_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 []testmoqs.Results - } - Sequence uint32 - DoFn MoqPassBySliceFn_doFn - DoReturnFn MoqPassBySliceFn_doReturnFn - }{ - Values: &struct { - Result1 []testmoqs.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqPassBySliceFn_recorder) ReturnResults(result1 []testmoqs.Results) *MoqPassBySliceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPassBySliceFn_results{ + Result1: result1, }) return r } -func (r *MoqPassBySliceFn_fnRecorder) AndDo(fn MoqPassBySliceFn_doFn) *MoqPassBySliceFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqPassBySliceFn_recorder) AndDo(fn MoqPassBySliceFn_doFn) *MoqPassBySliceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPassBySliceFn_params) { + fn(params.P) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPassBySliceFn_fnRecorder) DoReturnResults(fn MoqPassBySliceFn_doReturnFn) *MoqPassBySliceFn_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 []testmoqs.Results +func (r *MoqPassBySliceFn_recorder) DoReturnResults(fn MoqPassBySliceFn_doReturnFn) *MoqPassBySliceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPassBySliceFn_params) *MoqPassBySliceFn_results { + result1 := fn(params.P) + return &MoqPassBySliceFn_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqPassBySliceFn_doFn - DoReturnFn MoqPassBySliceFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPassBySliceFn_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 *MoqPassBySliceFn_resultsByParams - 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 = &MoqPassBySliceFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPassBySliceFn_paramsKey]*MoqPassBySliceFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqPassBySliceFn_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 *MoqPassBySliceFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqPassBySliceFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqPassBySliceFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqPassBySliceFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 []testmoqs.Results - } - Sequence uint32 - DoFn MoqPassBySliceFn_doFn - DoReturnFn MoqPassBySliceFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqPassBySliceFn) PrettyParams(params MoqPassBySliceFn_params) string { +func (*MoqPassBySliceFn_adaptor) PrettyParams(params MoqPassBySliceFn_params) string { return fmt.Sprintf("PassBySliceFn(%#v)", params.P) } -func (m *MoqPassBySliceFn) ParamsKey(params MoqPassBySliceFn_params, anyParams uint64) MoqPassBySliceFn_paramsKey { - m.Scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.P == moq.ParamIndexByValue { - m.Scene.T.Fatalf("The p parameter can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.P) - } +func (a *MoqPassBySliceFn_adaptor) ParamsKey(params MoqPassBySliceFn_params, anyParams uint64) MoqPassBySliceFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.Moq.Moq.Scene.T, + params.P, "p", 1, a.Moq.Runtime.ParameterIndexing.P, anyParams) return MoqPassBySliceFn_paramsKey{ Params: struct{}{}, Hashes: struct{ P hash.Hash }{ @@ -6506,38 +3615,36 @@ func (m *MoqPassBySliceFn) ParamsKey(params MoqPassBySliceFn_params, anyParams u } // Reset resets the state of the moq -func (m *MoqPassBySliceFn) Reset() { m.ResultsByParams = nil } +func (m *MoqPassBySliceFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqPassBySliceFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqPassByValueFn holds the state of a moq of the PassByValueFn type type MoqPassByValueFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqPassByValueFn_mock + Moq *impl.Moq[ + *MoqPassByValueFn_adaptor, + MoqPassByValueFn_params, + MoqPassByValueFn_paramsKey, + MoqPassByValueFn_results, + ] - ResultsByParams []MoqPassByValueFn_resultsByParams + Runtime MoqPassByValueFn_runtime +} - Runtime struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - } +// MoqPassByValueFn_runtime holds runtime configuration for the PassByValueFn +// type +type MoqPassByValueFn_runtime struct { + ParameterIndexing MoqPassByValueFn_paramIndexing } -// MoqPassByValueFn_mock isolates the mock interface of the PassByValueFn type -type MoqPassByValueFn_mock struct { +// MoqPassByValueFn_adaptor adapts MoqPassByValueFn as needed by the runtime +type MoqPassByValueFn_adaptor struct { Moq *MoqPassByValueFn } @@ -6551,12 +3658,15 @@ type MoqPassByValueFn_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqPassByValueFn_resultsByParams contains the results for a given set of -// parameters for the PassByValueFn type -type MoqPassByValueFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqPassByValueFn_paramsKey]*MoqPassByValueFn_results +// MoqPassByValueFn_results holds the results of the PassByValueFn type +type MoqPassByValueFn_results struct { + Result1 testmoqs.Results +} + +// MoqPassByValueFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByValueFn type +type MoqPassByValueFn_paramIndexing struct { + P moq.ParamIndexing } // MoqPassByValueFn_doFn defines the type of function needed when calling AndDo @@ -6567,58 +3677,39 @@ type MoqPassByValueFn_doFn func(p testmoqs.Params) // DoReturnResults for the PassByValueFn type type MoqPassByValueFn_doReturnFn func(p testmoqs.Params) testmoqs.Results -// MoqPassByValueFn_results holds the results of the PassByValueFn type -type MoqPassByValueFn_results struct { - Params MoqPassByValueFn_params - Results []struct { - Values *struct { - Result1 testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByValueFn_doFn - DoReturnFn MoqPassByValueFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqPassByValueFn_fnRecorder routes recorded function calls to the +// MoqPassByValueFn_recorder routes recorded function calls to the // MoqPassByValueFn moq -type MoqPassByValueFn_fnRecorder struct { - Params MoqPassByValueFn_params - AnyParams uint64 - Sequence bool - Results *MoqPassByValueFn_results - Moq *MoqPassByValueFn +type MoqPassByValueFn_recorder struct { + Recorder *impl.Recorder[ + *MoqPassByValueFn_adaptor, + MoqPassByValueFn_params, + MoqPassByValueFn_paramsKey, + MoqPassByValueFn_results, + ] } // MoqPassByValueFn_anyParams isolates the any params functions of the // PassByValueFn type type MoqPassByValueFn_anyParams struct { - Recorder *MoqPassByValueFn_fnRecorder + Recorder *MoqPassByValueFn_recorder } // NewMoqPassByValueFn creates a new moq of the PassByValueFn type func NewMoqPassByValueFn(scene *moq.Scene, config *moq.Config) *MoqPassByValueFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqPassByValueFn_adaptor{} m := &MoqPassByValueFn{ - Scene: scene, - Config: *config, - Moq: &MoqPassByValueFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - P moq.ParamIndexing - } - }{ParameterIndexing: struct { - P moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqPassByValueFn_adaptor, + MoqPassByValueFn_params, + MoqPassByValueFn_paramsKey, + MoqPassByValueFn_results, + ](scene, adaptor1, config), + + Runtime: MoqPassByValueFn_runtime{ParameterIndexing: MoqPassByValueFn_paramIndexing{ P: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -6627,258 +3718,101 @@ func NewMoqPassByValueFn(scene *moq.Scene, config *moq.Config) *MoqPassByValueFn // Mock returns the moq implementation of the PassByValueFn type func (m *MoqPassByValueFn) Mock() testmoqs.PassByValueFn { return func(p testmoqs.Params) testmoqs.Results { - m.Scene.T.Helper() - moq := &MoqPassByValueFn_mock{Moq: m} - return moq.Fn(p) - } -} - -func (m *MoqPassByValueFn_mock) Fn(p testmoqs.Params) (result1 testmoqs.Results) { - m.Moq.Scene.T.Helper() - params := MoqPassByValueFn_params{ - P: p, - } - var results *MoqPassByValueFn_results - 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 + m.Moq.Scene.T.Helper() + params := MoqPassByValueFn_params{ + P: p, } - 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)) + var result1 testmoqs.Results + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 } + return result1 } - - if result.DoFn != nil { - result.DoFn(p) - } - - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) - } - return } -func (m *MoqPassByValueFn) OnCall(p testmoqs.Params) *MoqPassByValueFn_fnRecorder { - return &MoqPassByValueFn_fnRecorder{ - Params: MoqPassByValueFn_params{ +func (m *MoqPassByValueFn) OnCall(p testmoqs.Params) *MoqPassByValueFn_recorder { + return &MoqPassByValueFn_recorder{ + Recorder: m.Moq.OnCall(MoqPassByValueFn_params{ P: p, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqPassByValueFn_fnRecorder) Any() *MoqPassByValueFn_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(r.Params)) +func (r *MoqPassByValueFn_recorder) Any() *MoqPassByValueFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPassByValueFn_anyParams{Recorder: r} } -func (a *MoqPassByValueFn_anyParams) P() *MoqPassByValueFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPassByValueFn_anyParams) P() *MoqPassByValueFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqPassByValueFn_fnRecorder) Seq() *MoqPassByValueFn_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(r.Params)) +func (r *MoqPassByValueFn_recorder) Seq() *MoqPassByValueFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqPassByValueFn_fnRecorder) NoSeq() *MoqPassByValueFn_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(r.Params)) +func (r *MoqPassByValueFn_recorder) NoSeq() *MoqPassByValueFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPassByValueFn_fnRecorder) ReturnResults(result1 testmoqs.Results) *MoqPassByValueFn_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 testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByValueFn_doFn - DoReturnFn MoqPassByValueFn_doReturnFn - }{ - Values: &struct { - Result1 testmoqs.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqPassByValueFn_recorder) ReturnResults(result1 testmoqs.Results) *MoqPassByValueFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPassByValueFn_results{ + Result1: result1, }) return r } -func (r *MoqPassByValueFn_fnRecorder) AndDo(fn MoqPassByValueFn_doFn) *MoqPassByValueFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqPassByValueFn_recorder) AndDo(fn MoqPassByValueFn_doFn) *MoqPassByValueFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPassByValueFn_params) { + fn(params.P) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPassByValueFn_fnRecorder) DoReturnResults(fn MoqPassByValueFn_doReturnFn) *MoqPassByValueFn_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 testmoqs.Results +func (r *MoqPassByValueFn_recorder) DoReturnResults(fn MoqPassByValueFn_doReturnFn) *MoqPassByValueFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPassByValueFn_params) *MoqPassByValueFn_results { + result1 := fn(params.P) + return &MoqPassByValueFn_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqPassByValueFn_doFn - DoReturnFn MoqPassByValueFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPassByValueFn_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 *MoqPassByValueFn_resultsByParams - 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 = &MoqPassByValueFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPassByValueFn_paramsKey]*MoqPassByValueFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqPassByValueFn_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 *MoqPassByValueFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqPassByValueFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqPassByValueFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqPassByValueFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 testmoqs.Results - } - Sequence uint32 - DoFn MoqPassByValueFn_doFn - DoReturnFn MoqPassByValueFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqPassByValueFn) PrettyParams(params MoqPassByValueFn_params) string { +func (*MoqPassByValueFn_adaptor) PrettyParams(params MoqPassByValueFn_params) string { return fmt.Sprintf("PassByValueFn(%#v)", params.P) } -func (m *MoqPassByValueFn) ParamsKey(params MoqPassByValueFn_params, anyParams uint64) MoqPassByValueFn_paramsKey { - m.Scene.T.Helper() - var pUsed testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.P == moq.ParamIndexByValue { - pUsed = params.P - } else { - pUsedHash = hash.DeepHash(params.P) - } - } +func (a *MoqPassByValueFn_adaptor) ParamsKey(params MoqPassByValueFn_params, anyParams uint64) MoqPassByValueFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.P, 1, a.Moq.Runtime.ParameterIndexing.P, anyParams) return MoqPassByValueFn_paramsKey{ Params: struct{ P testmoqs.Params }{ P: pUsed, @@ -6890,39 +3824,37 @@ func (m *MoqPassByValueFn) ParamsKey(params MoqPassByValueFn_params, anyParams u } // Reset resets the state of the moq -func (m *MoqPassByValueFn) Reset() { m.ResultsByParams = nil } +func (m *MoqPassByValueFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqPassByValueFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqInterfaceParamFn holds the state of a moq of the InterfaceParamFn type type MoqInterfaceParamFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqInterfaceParamFn_mock + Moq *impl.Moq[ + *MoqInterfaceParamFn_adaptor, + MoqInterfaceParamFn_params, + MoqInterfaceParamFn_paramsKey, + MoqInterfaceParamFn_results, + ] - ResultsByParams []MoqInterfaceParamFn_resultsByParams + Runtime MoqInterfaceParamFn_runtime +} - Runtime struct { - ParameterIndexing struct { - W moq.ParamIndexing - } - } +// MoqInterfaceParamFn_runtime holds runtime configuration for the +// InterfaceParamFn type +type MoqInterfaceParamFn_runtime struct { + ParameterIndexing MoqInterfaceParamFn_paramIndexing } -// MoqInterfaceParamFn_mock isolates the mock interface of the InterfaceParamFn -// type -type MoqInterfaceParamFn_mock struct { +// MoqInterfaceParamFn_adaptor adapts MoqInterfaceParamFn as needed by the +// runtime +type MoqInterfaceParamFn_adaptor struct { Moq *MoqInterfaceParamFn } @@ -6936,12 +3868,16 @@ type MoqInterfaceParamFn_paramsKey struct { Hashes struct{ W hash.Hash } } -// MoqInterfaceParamFn_resultsByParams contains the results for a given set of -// parameters for the InterfaceParamFn type -type MoqInterfaceParamFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqInterfaceParamFn_paramsKey]*MoqInterfaceParamFn_results +// MoqInterfaceParamFn_results holds the results of the InterfaceParamFn type +type MoqInterfaceParamFn_results struct { + SResult string + Err error +} + +// MoqInterfaceParamFn_paramIndexing holds the parameter indexing runtime +// configuration for the InterfaceParamFn type +type MoqInterfaceParamFn_paramIndexing struct { + W moq.ParamIndexing } // MoqInterfaceParamFn_doFn defines the type of function needed when calling @@ -6952,59 +3888,39 @@ type MoqInterfaceParamFn_doFn func(w io.Writer) // calling DoReturnResults for the InterfaceParamFn type type MoqInterfaceParamFn_doReturnFn func(w io.Writer) (sResult string, err error) -// MoqInterfaceParamFn_results holds the results of the InterfaceParamFn type -type MoqInterfaceParamFn_results struct { - Params MoqInterfaceParamFn_params - Results []struct { - Values *struct { - SResult string - Err error - } - Sequence uint32 - DoFn MoqInterfaceParamFn_doFn - DoReturnFn MoqInterfaceParamFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqInterfaceParamFn_fnRecorder routes recorded function calls to the +// MoqInterfaceParamFn_recorder routes recorded function calls to the // MoqInterfaceParamFn moq -type MoqInterfaceParamFn_fnRecorder struct { - Params MoqInterfaceParamFn_params - AnyParams uint64 - Sequence bool - Results *MoqInterfaceParamFn_results - Moq *MoqInterfaceParamFn +type MoqInterfaceParamFn_recorder struct { + Recorder *impl.Recorder[ + *MoqInterfaceParamFn_adaptor, + MoqInterfaceParamFn_params, + MoqInterfaceParamFn_paramsKey, + MoqInterfaceParamFn_results, + ] } // MoqInterfaceParamFn_anyParams isolates the any params functions of the // InterfaceParamFn type type MoqInterfaceParamFn_anyParams struct { - Recorder *MoqInterfaceParamFn_fnRecorder + Recorder *MoqInterfaceParamFn_recorder } // NewMoqInterfaceParamFn creates a new moq of the InterfaceParamFn type func NewMoqInterfaceParamFn(scene *moq.Scene, config *moq.Config) *MoqInterfaceParamFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqInterfaceParamFn_adaptor{} m := &MoqInterfaceParamFn{ - Scene: scene, - Config: *config, - Moq: &MoqInterfaceParamFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - W moq.ParamIndexing - } - }{ParameterIndexing: struct { - W moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqInterfaceParamFn_adaptor, + MoqInterfaceParamFn_params, + MoqInterfaceParamFn_paramsKey, + MoqInterfaceParamFn_results, + ](scene, adaptor1, config), + + Runtime: MoqInterfaceParamFn_runtime{ParameterIndexing: MoqInterfaceParamFn_paramIndexing{ W: moq.ParamIndexByHash, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -7012,265 +3928,106 @@ func NewMoqInterfaceParamFn(scene *moq.Scene, config *moq.Config) *MoqInterfaceP // Mock returns the moq implementation of the InterfaceParamFn type func (m *MoqInterfaceParamFn) Mock() testmoqs.InterfaceParamFn { - return func(w io.Writer) (_ string, _ error) { - m.Scene.T.Helper() - moq := &MoqInterfaceParamFn_mock{Moq: m} - return moq.Fn(w) - } -} - -func (m *MoqInterfaceParamFn_mock) Fn(w io.Writer) (sResult string, err error) { - m.Moq.Scene.T.Helper() - params := MoqInterfaceParamFn_params{ - W: w, - } - var results *MoqInterfaceParamFn_results - 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 + return func(w io.Writer) (string, error) { + m.Moq.Scene.T.Helper() + params := MoqInterfaceParamFn_params{ + W: w, } - 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)) + var result1 string + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } + return result1, result2 } - - 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 *MoqInterfaceParamFn) OnCall(w io.Writer) *MoqInterfaceParamFn_fnRecorder { - return &MoqInterfaceParamFn_fnRecorder{ - Params: MoqInterfaceParamFn_params{ +func (m *MoqInterfaceParamFn) OnCall(w io.Writer) *MoqInterfaceParamFn_recorder { + return &MoqInterfaceParamFn_recorder{ + Recorder: m.Moq.OnCall(MoqInterfaceParamFn_params{ W: w, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqInterfaceParamFn_fnRecorder) Any() *MoqInterfaceParamFn_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(r.Params)) +func (r *MoqInterfaceParamFn_recorder) Any() *MoqInterfaceParamFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqInterfaceParamFn_anyParams{Recorder: r} } -func (a *MoqInterfaceParamFn_anyParams) W() *MoqInterfaceParamFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqInterfaceParamFn_anyParams) W() *MoqInterfaceParamFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqInterfaceParamFn_fnRecorder) Seq() *MoqInterfaceParamFn_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(r.Params)) +func (r *MoqInterfaceParamFn_recorder) Seq() *MoqInterfaceParamFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqInterfaceParamFn_fnRecorder) NoSeq() *MoqInterfaceParamFn_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(r.Params)) +func (r *MoqInterfaceParamFn_recorder) NoSeq() *MoqInterfaceParamFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqInterfaceParamFn_fnRecorder) ReturnResults(sResult string, err error) *MoqInterfaceParamFn_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 MoqInterfaceParamFn_doFn - DoReturnFn MoqInterfaceParamFn_doReturnFn - }{ - Values: &struct { - SResult string - Err error - }{ - SResult: sResult, - Err: err, - }, - Sequence: sequence, +func (r *MoqInterfaceParamFn_recorder) ReturnResults(sResult string, err error) *MoqInterfaceParamFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqInterfaceParamFn_results{ + SResult: sResult, + Err: err, }) return r } -func (r *MoqInterfaceParamFn_fnRecorder) AndDo(fn MoqInterfaceParamFn_doFn) *MoqInterfaceParamFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqInterfaceParamFn_recorder) AndDo(fn MoqInterfaceParamFn_doFn) *MoqInterfaceParamFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqInterfaceParamFn_params) { + fn(params.W) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqInterfaceParamFn_fnRecorder) DoReturnResults(fn MoqInterfaceParamFn_doReturnFn) *MoqInterfaceParamFn_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 +func (r *MoqInterfaceParamFn_recorder) DoReturnResults(fn MoqInterfaceParamFn_doReturnFn) *MoqInterfaceParamFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqInterfaceParamFn_params) *MoqInterfaceParamFn_results { + sResult, err := fn(params.W) + return &MoqInterfaceParamFn_results{ + SResult: sResult, + Err: err, } - Sequence uint32 - DoFn MoqInterfaceParamFn_doFn - DoReturnFn MoqInterfaceParamFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqInterfaceParamFn_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 *MoqInterfaceParamFn_resultsByParams - 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 = &MoqInterfaceParamFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqInterfaceParamFn_paramsKey]*MoqInterfaceParamFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqInterfaceParamFn_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 *MoqInterfaceParamFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqInterfaceParamFn_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 MoqInterfaceParamFn_doFn - DoReturnFn MoqInterfaceParamFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqInterfaceParamFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqInterfaceParamFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqInterfaceParamFn) PrettyParams(params MoqInterfaceParamFn_params) string { +func (*MoqInterfaceParamFn_adaptor) PrettyParams(params MoqInterfaceParamFn_params) string { return fmt.Sprintf("InterfaceParamFn(%#v)", params.W) } -func (m *MoqInterfaceParamFn) ParamsKey(params MoqInterfaceParamFn_params, anyParams uint64) MoqInterfaceParamFn_paramsKey { - m.Scene.T.Helper() - var wUsed io.Writer - var wUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.W == moq.ParamIndexByValue { - wUsed = params.W - } else { - wUsedHash = hash.DeepHash(params.W) - } - } +func (a *MoqInterfaceParamFn_adaptor) ParamsKey(params MoqInterfaceParamFn_params, anyParams uint64) MoqInterfaceParamFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + wUsed, wUsedHash := impl.ParamKey( + params.W, 1, a.Moq.Runtime.ParameterIndexing.W, anyParams) return MoqInterfaceParamFn_paramsKey{ Params: struct{ W io.Writer }{ W: wUsed, @@ -7282,40 +4039,37 @@ func (m *MoqInterfaceParamFn) ParamsKey(params MoqInterfaceParamFn_params, anyPa } // Reset resets the state of the moq -func (m *MoqInterfaceParamFn) Reset() { m.ResultsByParams = nil } +func (m *MoqInterfaceParamFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqInterfaceParamFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqInterfaceResultFn holds the state of a moq of the InterfaceResultFn type type MoqInterfaceResultFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqInterfaceResultFn_mock - - ResultsByParams []MoqInterfaceResultFn_resultsByParams + Moq *impl.Moq[ + *MoqInterfaceResultFn_adaptor, + MoqInterfaceResultFn_params, + MoqInterfaceResultFn_paramsKey, + MoqInterfaceResultFn_results, + ] - Runtime struct { - ParameterIndexing struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - } + Runtime MoqInterfaceResultFn_runtime } -// MoqInterfaceResultFn_mock isolates the mock interface of the +// MoqInterfaceResultFn_runtime holds runtime configuration for the // InterfaceResultFn type -type MoqInterfaceResultFn_mock struct { +type MoqInterfaceResultFn_runtime struct { + ParameterIndexing MoqInterfaceResultFn_paramIndexing +} + +// MoqInterfaceResultFn_adaptor adapts MoqInterfaceResultFn as needed by the +// runtime +type MoqInterfaceResultFn_adaptor struct { Moq *MoqInterfaceResultFn } @@ -7338,12 +4092,14 @@ type MoqInterfaceResultFn_paramsKey struct { } } -// MoqInterfaceResultFn_resultsByParams contains the results for a given set of -// parameters for the InterfaceResultFn type -type MoqInterfaceResultFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqInterfaceResultFn_paramsKey]*MoqInterfaceResultFn_results +// MoqInterfaceResultFn_results holds the results of the InterfaceResultFn type +type MoqInterfaceResultFn_results struct{ Result1 io.Reader } + +// MoqInterfaceResultFn_paramIndexing holds the parameter indexing runtime +// configuration for the InterfaceResultFn type +type MoqInterfaceResultFn_paramIndexing struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing } // MoqInterfaceResultFn_doFn defines the type of function needed when calling @@ -7354,59 +4110,40 @@ type MoqInterfaceResultFn_doFn func(sParam string, bParam bool) // calling DoReturnResults for the InterfaceResultFn type type MoqInterfaceResultFn_doReturnFn func(sParam string, bParam bool) (r io.Reader) -// MoqInterfaceResultFn_results holds the results of the InterfaceResultFn type -type MoqInterfaceResultFn_results struct { - Params MoqInterfaceResultFn_params - Results []struct { - Values *struct{ Result1 io.Reader } - Sequence uint32 - DoFn MoqInterfaceResultFn_doFn - DoReturnFn MoqInterfaceResultFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqInterfaceResultFn_fnRecorder routes recorded function calls to the +// MoqInterfaceResultFn_recorder routes recorded function calls to the // MoqInterfaceResultFn moq -type MoqInterfaceResultFn_fnRecorder struct { - Params MoqInterfaceResultFn_params - AnyParams uint64 - Sequence bool - Results *MoqInterfaceResultFn_results - Moq *MoqInterfaceResultFn +type MoqInterfaceResultFn_recorder struct { + Recorder *impl.Recorder[ + *MoqInterfaceResultFn_adaptor, + MoqInterfaceResultFn_params, + MoqInterfaceResultFn_paramsKey, + MoqInterfaceResultFn_results, + ] } // MoqInterfaceResultFn_anyParams isolates the any params functions of the // InterfaceResultFn type type MoqInterfaceResultFn_anyParams struct { - Recorder *MoqInterfaceResultFn_fnRecorder + Recorder *MoqInterfaceResultFn_recorder } // NewMoqInterfaceResultFn creates a new moq of the InterfaceResultFn type func NewMoqInterfaceResultFn(scene *moq.Scene, config *moq.Config) *MoqInterfaceResultFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqInterfaceResultFn_adaptor{} m := &MoqInterfaceResultFn{ - Scene: scene, - Config: *config, - Moq: &MoqInterfaceResultFn_mock{}, - - Runtime: struct { - ParameterIndexing struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - }{ParameterIndexing: struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqInterfaceResultFn_adaptor, + MoqInterfaceResultFn_params, + MoqInterfaceResultFn_paramsKey, + MoqInterfaceResultFn_results, + ](scene, adaptor1, config), + + Runtime: MoqInterfaceResultFn_runtime{ParameterIndexing: MoqInterfaceResultFn_paramIndexing{ SParam: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -7414,267 +4151,111 @@ func NewMoqInterfaceResultFn(scene *moq.Scene, config *moq.Config) *MoqInterface // Mock returns the moq implementation of the InterfaceResultFn type func (m *MoqInterfaceResultFn) Mock() testmoqs.InterfaceResultFn { - return func(sParam string, bParam bool) (_ io.Reader) { - m.Scene.T.Helper() - moq := &MoqInterfaceResultFn_mock{Moq: m} - return moq.Fn(sParam, bParam) - } -} - -func (m *MoqInterfaceResultFn_mock) Fn(sParam string, bParam bool) (result1 io.Reader) { - m.Moq.Scene.T.Helper() - params := MoqInterfaceResultFn_params{ - SParam: sParam, - BParam: bParam, - } - var results *MoqInterfaceResultFn_results - 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 + return func(sParam string, bParam bool) io.Reader { + m.Moq.Scene.T.Helper() + params := MoqInterfaceResultFn_params{ + SParam: sParam, + BParam: bParam, } - 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)) + var result1 io.Reader + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 } + return result1 } - - 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 *MoqInterfaceResultFn) OnCall(sParam string, bParam bool) *MoqInterfaceResultFn_fnRecorder { - return &MoqInterfaceResultFn_fnRecorder{ - Params: MoqInterfaceResultFn_params{ +func (m *MoqInterfaceResultFn) OnCall(sParam string, bParam bool) *MoqInterfaceResultFn_recorder { + return &MoqInterfaceResultFn_recorder{ + Recorder: m.Moq.OnCall(MoqInterfaceResultFn_params{ SParam: sParam, BParam: bParam, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqInterfaceResultFn_fnRecorder) Any() *MoqInterfaceResultFn_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(r.Params)) +func (r *MoqInterfaceResultFn_recorder) Any() *MoqInterfaceResultFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqInterfaceResultFn_anyParams{Recorder: r} } -func (a *MoqInterfaceResultFn_anyParams) SParam() *MoqInterfaceResultFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqInterfaceResultFn_anyParams) SParam() *MoqInterfaceResultFn_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqInterfaceResultFn_anyParams) BParam() *MoqInterfaceResultFn_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqInterfaceResultFn_anyParams) BParam() *MoqInterfaceResultFn_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (r *MoqInterfaceResultFn_fnRecorder) Seq() *MoqInterfaceResultFn_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(r.Params)) +func (r *MoqInterfaceResultFn_recorder) Seq() *MoqInterfaceResultFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqInterfaceResultFn_fnRecorder) NoSeq() *MoqInterfaceResultFn_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(r.Params)) +func (r *MoqInterfaceResultFn_recorder) NoSeq() *MoqInterfaceResultFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqInterfaceResultFn_fnRecorder) ReturnResults(result1 io.Reader) *MoqInterfaceResultFn_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 io.Reader } - Sequence uint32 - DoFn MoqInterfaceResultFn_doFn - DoReturnFn MoqInterfaceResultFn_doReturnFn - }{ - Values: &struct{ Result1 io.Reader }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqInterfaceResultFn_recorder) ReturnResults(result1 io.Reader) *MoqInterfaceResultFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqInterfaceResultFn_results{ + Result1: result1, }) return r } -func (r *MoqInterfaceResultFn_fnRecorder) AndDo(fn MoqInterfaceResultFn_doFn) *MoqInterfaceResultFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqInterfaceResultFn_recorder) AndDo(fn MoqInterfaceResultFn_doFn) *MoqInterfaceResultFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqInterfaceResultFn_params) { + fn(params.SParam, params.BParam) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn - return r -} - -func (r *MoqInterfaceResultFn_fnRecorder) DoReturnResults(fn MoqInterfaceResultFn_doReturnFn) *MoqInterfaceResultFn_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 io.Reader } - Sequence uint32 - DoFn MoqInterfaceResultFn_doFn - DoReturnFn MoqInterfaceResultFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqInterfaceResultFn_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 *MoqInterfaceResultFn_resultsByParams - 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 = &MoqInterfaceResultFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqInterfaceResultFn_paramsKey]*MoqInterfaceResultFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqInterfaceResultFn_results{ - Params: r.Params, - Results: nil, - Index: 0, - Repeat: &moq.RepeatVal{}, +func (r *MoqInterfaceResultFn_recorder) DoReturnResults(fn MoqInterfaceResultFn_doReturnFn) *MoqInterfaceResultFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqInterfaceResultFn_params) *MoqInterfaceResultFn_results { + result1 := fn(params.SParam, params.BParam) + return &MoqInterfaceResultFn_results{ + Result1: result1, } - results.Results[paramsKey] = r.Results - } - - r.Results.Repeat.Increment(r.Moq.Scene.T) + }) + return r } -func (r *MoqInterfaceResultFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqInterfaceResultFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqInterfaceResultFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqInterfaceResultFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 io.Reader } - Sequence uint32 - DoFn MoqInterfaceResultFn_doFn - DoReturnFn MoqInterfaceResultFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqInterfaceResultFn) PrettyParams(params MoqInterfaceResultFn_params) string { +func (*MoqInterfaceResultFn_adaptor) PrettyParams(params MoqInterfaceResultFn_params) string { return fmt.Sprintf("InterfaceResultFn(%#v, %#v)", params.SParam, params.BParam) } -func (m *MoqInterfaceResultFn) ParamsKey(params MoqInterfaceResultFn_params, anyParams uint64) MoqInterfaceResultFn_paramsKey { - m.Scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.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.BParam == moq.ParamIndexByValue { - bParamUsed = params.BParam - } else { - bParamUsedHash = hash.DeepHash(params.BParam) - } - } +func (a *MoqInterfaceResultFn_adaptor) ParamsKey(params MoqInterfaceResultFn_params, anyParams uint64) MoqInterfaceResultFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.SParam, 1, a.Moq.Runtime.ParameterIndexing.SParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 2, a.Moq.Runtime.ParameterIndexing.BParam, anyParams) return MoqInterfaceResultFn_paramsKey{ Params: struct { SParam string @@ -7694,40 +4275,36 @@ func (m *MoqInterfaceResultFn) ParamsKey(params MoqInterfaceResultFn_params, any } // Reset resets the state of the moq -func (m *MoqInterfaceResultFn) Reset() { m.ResultsByParams = nil } +func (m *MoqInterfaceResultFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqInterfaceResultFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // MoqGenericParamsFn holds the state of a moq of the GenericParamsFn type type MoqGenericParamsFn[S, B any] struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqGenericParamsFn_mock[S, B] + Moq *impl.Moq[ + *MoqGenericParamsFn_adaptor[S, B], + MoqGenericParamsFn_params[S, B], + MoqGenericParamsFn_paramsKey[S, B], + MoqGenericParamsFn_results[S, B]] - ResultsByParams []MoqGenericParamsFn_resultsByParams[S, B] + Runtime MoqGenericParamsFn_runtime +} - Runtime struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - } +// MoqGenericParamsFn_runtime holds runtime configuration for the +// GenericParamsFn type +type MoqGenericParamsFn_runtime struct { + ParameterIndexing MoqGenericParamsFn_paramIndexing } -// MoqGenericParamsFn_mock isolates the mock interface of the GenericParamsFn -// type -type MoqGenericParamsFn_mock[S, B any] struct { +// MoqGenericParamsFn_adaptor adapts MoqGenericParamsFn as needed by the +// runtime +type MoqGenericParamsFn_adaptor[S, B any] struct { Moq *MoqGenericParamsFn[S, B] } @@ -7747,12 +4324,17 @@ type MoqGenericParamsFn_paramsKey[S, B any] 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[MoqGenericParamsFn_paramsKey[S, B]]*MoqGenericParamsFn_results[S, B] +// MoqGenericParamsFn_results holds the results of the GenericParamsFn type +type MoqGenericParamsFn_results[S, B any] struct { + Result1 string + Result2 error +} + +// MoqGenericParamsFn_paramIndexing holds the parameter indexing runtime +// configuration for the GenericParamsFn type +type MoqGenericParamsFn_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqGenericParamsFn_doFn defines the type of function needed when calling @@ -7763,62 +4345,38 @@ type MoqGenericParamsFn_doFn[S, B any] func(S, B) // calling DoReturnResults for the GenericParamsFn type type MoqGenericParamsFn_doReturnFn[S, B any] func(S, B) (string, error) -// 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 { - Result1 string - Result2 error - } - Sequence uint32 - DoFn MoqGenericParamsFn_doFn[S, B] - DoReturnFn MoqGenericParamsFn_doReturnFn[S, B] - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqGenericParamsFn_fnRecorder routes recorded function calls to the +// MoqGenericParamsFn_recorder 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 *MoqGenericParamsFn_results[S, B] - Moq *MoqGenericParamsFn[S, B] +type MoqGenericParamsFn_recorder[S, B any] struct { + Recorder *impl.Recorder[ + *MoqGenericParamsFn_adaptor[S, B], + MoqGenericParamsFn_params[S, B], + MoqGenericParamsFn_paramsKey[S, B], + MoqGenericParamsFn_results[S, B]] } // MoqGenericParamsFn_anyParams isolates the any params functions of the // GenericParamsFn type type MoqGenericParamsFn_anyParams[S, B any] struct { - Recorder *MoqGenericParamsFn_fnRecorder[S, B] + Recorder *MoqGenericParamsFn_recorder[S, B] } // 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{} - } + adaptor1 := &MoqGenericParamsFn_adaptor[S, B]{} 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 - }{ + Moq: impl.NewMoq[ + *MoqGenericParamsFn_adaptor[S, B], + MoqGenericParamsFn_params[S, B], + MoqGenericParamsFn_paramsKey[S, B], + MoqGenericParamsFn_results[S, B]](scene, adaptor1, config), + + Runtime: MoqGenericParamsFn_runtime{ParameterIndexing: MoqGenericParamsFn_paramIndexing{ Param1: moq.ParamIndexByHash, Param2: moq.ParamIndexByHash, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -7827,276 +4385,114 @@ func NewMoqGenericParamsFn[S, B any](scene *moq.Scene, config *moq.Config) *MoqG // 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) - } -} - -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 - } - - 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 + m.Moq.Scene.T.Helper() + params := MoqGenericParamsFn_params[S, B]{ + Param1: param1, + Param2: param2, } - 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)) + var result1 string + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } + return result1, result2 } - - 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 *MoqGenericParamsFn[S, B]) OnCall(param1 S, param2 B) *MoqGenericParamsFn_fnRecorder[S, B] { - return &MoqGenericParamsFn_fnRecorder[S, B]{ - Params: MoqGenericParamsFn_params[S, B]{ +func (m *MoqGenericParamsFn[S, B]) OnCall(param1 S, param2 B) *MoqGenericParamsFn_recorder[S, B] { + return &MoqGenericParamsFn_recorder[S, B]{ + Recorder: m.Moq.OnCall(MoqGenericParamsFn_params[S, B]{ Param1: param1, Param2: param2, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -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)) +func (r *MoqGenericParamsFn_recorder[S, B]) Any() *MoqGenericParamsFn_anyParams[S, B] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqGenericParamsFn_anyParams[S, B]{Recorder: r} } -func (a *MoqGenericParamsFn_anyParams[S, B]) Param1() *MoqGenericParamsFn_fnRecorder[S, B] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqGenericParamsFn_anyParams[S, B]) Param1() *MoqGenericParamsFn_recorder[S, B] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqGenericParamsFn_anyParams[S, B]) Param2() *MoqGenericParamsFn_fnRecorder[S, B] { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqGenericParamsFn_anyParams[S, B]) Param2() *MoqGenericParamsFn_recorder[S, B] { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -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)) +func (r *MoqGenericParamsFn_recorder[S, B]) Seq() *MoqGenericParamsFn_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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)) +func (r *MoqGenericParamsFn_recorder[S, B]) NoSeq() *MoqGenericParamsFn_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqGenericParamsFn_fnRecorder[S, B]) ReturnResults(result1 string, result2 error) *MoqGenericParamsFn_fnRecorder[S, B] { - 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 MoqGenericParamsFn_doFn[S, B] - DoReturnFn MoqGenericParamsFn_doReturnFn[S, B] - }{ - Values: &struct { - Result1 string - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqGenericParamsFn_recorder[S, B]) ReturnResults(result1 string, result2 error) *MoqGenericParamsFn_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqGenericParamsFn_results[S, B]{ + Result1: result1, + Result2: result2, }) return r } -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") +func (r *MoqGenericParamsFn_recorder[S, B]) AndDo(fn MoqGenericParamsFn_doFn[S, B]) *MoqGenericParamsFn_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqGenericParamsFn_params[S, B]) { + fn(params.Param1, params.Param2) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqGenericParamsFn_fnRecorder[S, B]) DoReturnResults(fn MoqGenericParamsFn_doReturnFn[S, B]) *MoqGenericParamsFn_fnRecorder[S, B] { - 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 +func (r *MoqGenericParamsFn_recorder[S, B]) DoReturnResults(fn MoqGenericParamsFn_doReturnFn[S, B]) *MoqGenericParamsFn_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqGenericParamsFn_params[S, B]) *MoqGenericParamsFn_results[S, B] { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqGenericParamsFn_results[S, B]{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqGenericParamsFn_doFn[S, B] - DoReturnFn MoqGenericParamsFn_doReturnFn[S, B] - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -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 - } - - 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 - } - } - - paramsKey := r.Moq.ParamsKey(r.Params, r.AnyParams) - - 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 - } - - r.Results.Repeat.Increment(r.Moq.Scene.T) -} - -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 - } - 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) +func (r *MoqGenericParamsFn_recorder[S, B]) Repeat(repeaters ...moq.Repeater) *MoqGenericParamsFn_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqGenericParamsFn[S, B]) PrettyParams(params MoqGenericParamsFn_params[S, B]) string { +func (*MoqGenericParamsFn_adaptor[S, B]) PrettyParams(params MoqGenericParamsFn_params[S, B]) string { return fmt.Sprintf("GenericParamsFn(%#v, %#v)", params.Param1, params.Param2) } -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) - } +func (a *MoqGenericParamsFn_adaptor[S, B]) ParamsKey(params MoqGenericParamsFn_params[S, B], anyParams uint64) MoqGenericParamsFn_paramsKey[S, B] { + a.Moq.Moq.Scene.T.Helper() + param1UsedHash := impl.HashOnlyParamKey(a.Moq.Moq.Scene.T, + params.Param1, "param1", 1, a.Moq.Runtime.ParameterIndexing.Param1, anyParams) + param2UsedHash := impl.HashOnlyParamKey(a.Moq.Moq.Scene.T, + params.Param2, "param2", 2, a.Moq.Runtime.ParameterIndexing.Param2, anyParams) return MoqGenericParamsFn_paramsKey[S, B]{ Params: struct{}{}, Hashes: struct { @@ -8110,41 +4506,37 @@ func (m *MoqGenericParamsFn[S, B]) ParamsKey(params MoqGenericParamsFn_params[S, } // Reset resets the state of the moq -func (m *MoqGenericParamsFn[S, B]) Reset() { m.ResultsByParams = nil } +func (m *MoqGenericParamsFn[S, B]) Reset() { + m.Moq.Reset() +} // 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // 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] - - ResultsByParams []MoqPartialGenericParamsFn_resultsByParams[S] + Moq *impl.Moq[ + *MoqPartialGenericParamsFn_adaptor[S], + MoqPartialGenericParamsFn_params[S], + MoqPartialGenericParamsFn_paramsKey[S], + MoqPartialGenericParamsFn_results[S]] - Runtime struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - } + Runtime MoqPartialGenericParamsFn_runtime } -// MoqPartialGenericParamsFn_mock isolates the mock interface of the +// MoqPartialGenericParamsFn_runtime holds runtime configuration for the // PartialGenericParamsFn type -type MoqPartialGenericParamsFn_mock[S any] struct { +type MoqPartialGenericParamsFn_runtime struct { + ParameterIndexing MoqPartialGenericParamsFn_paramIndexing +} + +// MoqPartialGenericParamsFn_adaptor adapts MoqPartialGenericParamsFn as needed +// by the runtime +type MoqPartialGenericParamsFn_adaptor[S any] struct { Moq *MoqPartialGenericParamsFn[S] } @@ -8165,12 +4557,18 @@ type MoqPartialGenericParamsFn_paramsKey[S any] 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[MoqPartialGenericParamsFn_paramsKey[S]]*MoqPartialGenericParamsFn_results[S] +// MoqPartialGenericParamsFn_results holds the results of the +// PartialGenericParamsFn type +type MoqPartialGenericParamsFn_results[S any] struct { + Result1 string + Result2 error +} + +// MoqPartialGenericParamsFn_paramIndexing holds the parameter indexing runtime +// configuration for the PartialGenericParamsFn type +type MoqPartialGenericParamsFn_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqPartialGenericParamsFn_doFn defines the type of function needed when @@ -8181,64 +4579,39 @@ type MoqPartialGenericParamsFn_doFn[S any] func(S, bool) // when calling DoReturnResults for the PartialGenericParamsFn type type MoqPartialGenericParamsFn_doReturnFn[S any] func(S, bool) (string, error) -// MoqPartialGenericParamsFn_results holds the results of the -// PartialGenericParamsFn type -type MoqPartialGenericParamsFn_results[S any] struct { - Params MoqPartialGenericParamsFn_params[S] - Results []struct { - Values *struct { - Result1 string - Result2 error - } - Sequence uint32 - DoFn MoqPartialGenericParamsFn_doFn[S] - DoReturnFn MoqPartialGenericParamsFn_doReturnFn[S] - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqPartialGenericParamsFn_fnRecorder routes recorded function calls to the +// MoqPartialGenericParamsFn_recorder routes recorded function calls to the // MoqPartialGenericParamsFn moq -type MoqPartialGenericParamsFn_fnRecorder[S any] struct { - Params MoqPartialGenericParamsFn_params[S] - AnyParams uint64 - Sequence bool - Results *MoqPartialGenericParamsFn_results[S] - Moq *MoqPartialGenericParamsFn[S] +type MoqPartialGenericParamsFn_recorder[S any] struct { + Recorder *impl.Recorder[ + *MoqPartialGenericParamsFn_adaptor[S], + MoqPartialGenericParamsFn_params[S], + MoqPartialGenericParamsFn_paramsKey[S], + MoqPartialGenericParamsFn_results[S]] } // MoqPartialGenericParamsFn_anyParams isolates the any params functions of the // PartialGenericParamsFn type type MoqPartialGenericParamsFn_anyParams[S any] struct { - Recorder *MoqPartialGenericParamsFn_fnRecorder[S] + Recorder *MoqPartialGenericParamsFn_recorder[S] } // 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{} - } + adaptor1 := &MoqPartialGenericParamsFn_adaptor[S]{} 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 - }{ + Moq: impl.NewMoq[ + *MoqPartialGenericParamsFn_adaptor[S], + MoqPartialGenericParamsFn_params[S], + MoqPartialGenericParamsFn_paramsKey[S], + MoqPartialGenericParamsFn_results[S]](scene, adaptor1, config), + + Runtime: MoqPartialGenericParamsFn_runtime{ParameterIndexing: MoqPartialGenericParamsFn_paramIndexing{ Param1: moq.ParamIndexByHash, Param2: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -8247,278 +4620,114 @@ func NewMoqPartialGenericParamsFn[S any](scene *moq.Scene, config *moq.Config) * // 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) - } -} - -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 - } - - 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 + m.Moq.Scene.T.Helper() + params := MoqPartialGenericParamsFn_params[S]{ + Param1: param1, + Param2: param2, } - 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)) + var result1 string + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } + return result1, result2 } - - 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 *MoqPartialGenericParamsFn[S]) OnCall(param1 S, param2 bool) *MoqPartialGenericParamsFn_fnRecorder[S] { - return &MoqPartialGenericParamsFn_fnRecorder[S]{ - Params: MoqPartialGenericParamsFn_params[S]{ +func (m *MoqPartialGenericParamsFn[S]) OnCall(param1 S, param2 bool) *MoqPartialGenericParamsFn_recorder[S] { + return &MoqPartialGenericParamsFn_recorder[S]{ + Recorder: m.Moq.OnCall(MoqPartialGenericParamsFn_params[S]{ Param1: param1, Param2: param2, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -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)) +func (r *MoqPartialGenericParamsFn_recorder[S]) Any() *MoqPartialGenericParamsFn_anyParams[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPartialGenericParamsFn_anyParams[S]{Recorder: r} } -func (a *MoqPartialGenericParamsFn_anyParams[S]) Param1() *MoqPartialGenericParamsFn_fnRecorder[S] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPartialGenericParamsFn_anyParams[S]) Param1() *MoqPartialGenericParamsFn_recorder[S] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqPartialGenericParamsFn_anyParams[S]) Param2() *MoqPartialGenericParamsFn_fnRecorder[S] { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqPartialGenericParamsFn_anyParams[S]) Param2() *MoqPartialGenericParamsFn_recorder[S] { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -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)) +func (r *MoqPartialGenericParamsFn_recorder[S]) Seq() *MoqPartialGenericParamsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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)) +func (r *MoqPartialGenericParamsFn_recorder[S]) NoSeq() *MoqPartialGenericParamsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPartialGenericParamsFn_fnRecorder[S]) ReturnResults(result1 string, result2 error) *MoqPartialGenericParamsFn_fnRecorder[S] { - 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 MoqPartialGenericParamsFn_doFn[S] - DoReturnFn MoqPartialGenericParamsFn_doReturnFn[S] - }{ - Values: &struct { - Result1 string - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqPartialGenericParamsFn_recorder[S]) ReturnResults(result1 string, result2 error) *MoqPartialGenericParamsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPartialGenericParamsFn_results[S]{ + Result1: result1, + Result2: result2, }) return r } -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") +func (r *MoqPartialGenericParamsFn_recorder[S]) AndDo(fn MoqPartialGenericParamsFn_doFn[S]) *MoqPartialGenericParamsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPartialGenericParamsFn_params[S]) { + fn(params.Param1, params.Param2) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPartialGenericParamsFn_fnRecorder[S]) DoReturnResults(fn MoqPartialGenericParamsFn_doReturnFn[S]) *MoqPartialGenericParamsFn_fnRecorder[S] { - 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 +func (r *MoqPartialGenericParamsFn_recorder[S]) DoReturnResults(fn MoqPartialGenericParamsFn_doReturnFn[S]) *MoqPartialGenericParamsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPartialGenericParamsFn_params[S]) *MoqPartialGenericParamsFn_results[S] { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqPartialGenericParamsFn_results[S]{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqPartialGenericParamsFn_doFn[S] - DoReturnFn MoqPartialGenericParamsFn_doReturnFn[S] - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPartialGenericParamsFn_fnRecorder[S]) 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 *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 - } - } - - paramsKey := r.Moq.ParamsKey(r.Params, r.AnyParams) - - 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{}, - } - results.Results[paramsKey] = r.Results - } - - r.Results.Repeat.Increment(r.Moq.Scene.T) -} - -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(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqPartialGenericParamsFn_recorder[S]) Repeat(repeaters ...moq.Repeater) *MoqPartialGenericParamsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqPartialGenericParamsFn[S]) PrettyParams(params MoqPartialGenericParamsFn_params[S]) string { +func (*MoqPartialGenericParamsFn_adaptor[S]) PrettyParams(params MoqPartialGenericParamsFn_params[S]) string { return fmt.Sprintf("PartialGenericParamsFn(%#v, %#v)", params.Param1, params.Param2) } -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) - } - 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) - } - } +func (a *MoqPartialGenericParamsFn_adaptor[S]) ParamsKey(params MoqPartialGenericParamsFn_params[S], anyParams uint64) MoqPartialGenericParamsFn_paramsKey[S] { + a.Moq.Moq.Scene.T.Helper() + param1UsedHash := impl.HashOnlyParamKey(a.Moq.Moq.Scene.T, + params.Param1, "param1", 1, a.Moq.Runtime.ParameterIndexing.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.Param2, anyParams) return MoqPartialGenericParamsFn_paramsKey[S]{ Params: struct{ Param2 bool }{ Param2: param2Used, @@ -8534,40 +4743,36 @@ func (m *MoqPartialGenericParamsFn[S]) ParamsKey(params MoqPartialGenericParamsF } // Reset resets the state of the moq -func (m *MoqPartialGenericParamsFn[S]) Reset() { m.ResultsByParams = nil } +func (m *MoqPartialGenericParamsFn[S]) Reset() { + m.Moq.Reset() +} // 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // 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] - - ResultsByParams []MoqGenericResultsFn_resultsByParams[S, E] + Moq *impl.Moq[ + *MoqGenericResultsFn_adaptor[S, E], + MoqGenericResultsFn_params[S, E], + MoqGenericResultsFn_paramsKey[S, E], + MoqGenericResultsFn_results[S, E]] - Runtime struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - } + Runtime MoqGenericResultsFn_runtime } -// MoqGenericResultsFn_mock isolates the mock interface of the GenericResultsFn -// type -type MoqGenericResultsFn_mock[S ~string, E error] struct { +// MoqGenericResultsFn_runtime holds runtime configuration for the +// GenericResultsFn type +type MoqGenericResultsFn_runtime struct { + ParameterIndexing MoqGenericResultsFn_paramIndexing +} + +// MoqGenericResultsFn_adaptor adapts MoqGenericResultsFn as needed by the +// runtime +type MoqGenericResultsFn_adaptor[S ~string, E error] struct { Moq *MoqGenericResultsFn[S, E] } @@ -8590,12 +4795,17 @@ type MoqGenericResultsFn_paramsKey[S ~string, E error] 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[MoqGenericResultsFn_paramsKey[S, E]]*MoqGenericResultsFn_results[S, E] +// MoqGenericResultsFn_results holds the results of the GenericResultsFn type +type MoqGenericResultsFn_results[S ~string, E error] struct { + Result1 S + Result2 E +} + +// MoqGenericResultsFn_paramIndexing holds the parameter indexing runtime +// configuration for the GenericResultsFn type +type MoqGenericResultsFn_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqGenericResultsFn_doFn defines the type of function needed when calling @@ -8606,62 +4816,38 @@ type MoqGenericResultsFn_doFn[S ~string, E error] func(string, bool) // calling DoReturnResults for the GenericResultsFn type type MoqGenericResultsFn_doReturnFn[S ~string, E error] func(string, bool) (S, E) -// 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 { - Result1 S - Result2 E - } - Sequence uint32 - DoFn MoqGenericResultsFn_doFn[S, E] - DoReturnFn MoqGenericResultsFn_doReturnFn[S, E] - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqGenericResultsFn_fnRecorder routes recorded function calls to the +// MoqGenericResultsFn_recorder 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 *MoqGenericResultsFn_results[S, E] - Moq *MoqGenericResultsFn[S, E] +type MoqGenericResultsFn_recorder[S ~string, E error] struct { + Recorder *impl.Recorder[ + *MoqGenericResultsFn_adaptor[S, E], + MoqGenericResultsFn_params[S, E], + MoqGenericResultsFn_paramsKey[S, E], + MoqGenericResultsFn_results[S, E]] } // MoqGenericResultsFn_anyParams isolates the any params functions of the // GenericResultsFn type type MoqGenericResultsFn_anyParams[S ~string, E error] struct { - Recorder *MoqGenericResultsFn_fnRecorder[S, E] + Recorder *MoqGenericResultsFn_recorder[S, E] } // 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{} - } + adaptor1 := &MoqGenericResultsFn_adaptor[S, E]{} m := &MoqGenericResultsFn[S, E]{ - Scene: scene, - Config: *config, - Moq: &MoqGenericResultsFn_mock[S, E]{}, - - Runtime: struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - }{ParameterIndexing: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqGenericResultsFn_adaptor[S, E], + MoqGenericResultsFn_params[S, E], + MoqGenericResultsFn_paramsKey[S, E], + MoqGenericResultsFn_results[S, E]](scene, adaptor1, config), + + Runtime: MoqGenericResultsFn_runtime{ParameterIndexing: MoqGenericResultsFn_paramIndexing{ Param1: moq.ParamIndexByValue, Param2: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -8670,280 +4856,114 @@ func NewMoqGenericResultsFn[S ~string, E error](scene *moq.Scene, config *moq.Co // 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) - } -} - -func (m *MoqGenericResultsFn_mock[S, E]) Fn(param1 string, param2 bool) (result1 S, result2 E) { - m.Moq.Scene.T.Helper() - params := MoqGenericResultsFn_params[S, E]{ - Param1: param1, - Param2: param2, - } - 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 { - 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 + m.Moq.Scene.T.Helper() + params := MoqGenericResultsFn_params[S, E]{ + Param1: param1, + Param2: param2, } - 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)) + var result1 S + var result2 E + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } + return result1, result2 } - - 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 *MoqGenericResultsFn[S, E]) OnCall(param1 string, param2 bool) *MoqGenericResultsFn_fnRecorder[S, E] { - return &MoqGenericResultsFn_fnRecorder[S, E]{ - Params: MoqGenericResultsFn_params[S, E]{ +func (m *MoqGenericResultsFn[S, E]) OnCall(param1 string, param2 bool) *MoqGenericResultsFn_recorder[S, E] { + return &MoqGenericResultsFn_recorder[S, E]{ + Recorder: m.Moq.OnCall(MoqGenericResultsFn_params[S, E]{ Param1: param1, Param2: param2, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -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)) +func (r *MoqGenericResultsFn_recorder[S, E]) Any() *MoqGenericResultsFn_anyParams[S, E] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqGenericResultsFn_anyParams[S, E]{Recorder: r} } -func (a *MoqGenericResultsFn_anyParams[S, E]) Param1() *MoqGenericResultsFn_fnRecorder[S, E] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqGenericResultsFn_anyParams[S, E]) Param1() *MoqGenericResultsFn_recorder[S, E] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqGenericResultsFn_anyParams[S, E]) Param2() *MoqGenericResultsFn_fnRecorder[S, E] { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqGenericResultsFn_anyParams[S, E]) Param2() *MoqGenericResultsFn_recorder[S, E] { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -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)) +func (r *MoqGenericResultsFn_recorder[S, E]) Seq() *MoqGenericResultsFn_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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)) +func (r *MoqGenericResultsFn_recorder[S, E]) NoSeq() *MoqGenericResultsFn_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqGenericResultsFn_fnRecorder[S, E]) ReturnResults(result1 S, result2 E) *MoqGenericResultsFn_fnRecorder[S, E] { - 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 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, +func (r *MoqGenericResultsFn_recorder[S, E]) ReturnResults(result1 S, result2 E) *MoqGenericResultsFn_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqGenericResultsFn_results[S, E]{ + Result1: result1, + Result2: result2, }) return r } -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") +func (r *MoqGenericResultsFn_recorder[S, E]) AndDo(fn MoqGenericResultsFn_doFn[S, E]) *MoqGenericResultsFn_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqGenericResultsFn_params[S, E]) { + fn(params.Param1, params.Param2) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqGenericResultsFn_fnRecorder[S, E]) DoReturnResults(fn MoqGenericResultsFn_doReturnFn[S, E]) *MoqGenericResultsFn_fnRecorder[S, E] { - 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 S - Result2 E +func (r *MoqGenericResultsFn_recorder[S, E]) DoReturnResults(fn MoqGenericResultsFn_doReturnFn[S, E]) *MoqGenericResultsFn_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqGenericResultsFn_params[S, E]) *MoqGenericResultsFn_results[S, E] { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqGenericResultsFn_results[S, E]{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqGenericResultsFn_doFn[S, E] - DoReturnFn MoqGenericResultsFn_doReturnFn[S, E] - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -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 - } - - 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 { - results = &MoqGenericResultsFn_resultsByParams[S, E]{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqGenericResultsFn_paramsKey[S, E]]*MoqGenericResultsFn_results[S, E]{}, - } - 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(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 - } - - r.Results.Repeat.Increment(r.Moq.Scene.T) -} - -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 - } - 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) +func (r *MoqGenericResultsFn_recorder[S, E]) Repeat(repeaters ...moq.Repeater) *MoqGenericResultsFn_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqGenericResultsFn[S, E]) PrettyParams(params MoqGenericResultsFn_params[S, E]) string { +func (*MoqGenericResultsFn_adaptor[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) - } - } - 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) - } - } +func (a *MoqGenericResultsFn_adaptor[S, E]) ParamsKey(params MoqGenericResultsFn_params[S, E], anyParams uint64) MoqGenericResultsFn_paramsKey[S, E] { + a.Moq.Moq.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.Param2, anyParams) return MoqGenericResultsFn_paramsKey[S, E]{ Params: struct { Param1 string @@ -8963,41 +4983,37 @@ func (m *MoqGenericResultsFn[S, E]) ParamsKey(params MoqGenericResultsFn_params[ } // Reset resets the state of the moq -func (m *MoqGenericResultsFn[S, E]) Reset() { m.ResultsByParams = nil } +func (m *MoqGenericResultsFn[S, E]) Reset() { + m.Moq.Reset() +} // 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // 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] + Moq *impl.Moq[ + *MoqPartialGenericResultsFn_adaptor[S], + MoqPartialGenericResultsFn_params[S], + MoqPartialGenericResultsFn_paramsKey[S], + MoqPartialGenericResultsFn_results[S]] - ResultsByParams []MoqPartialGenericResultsFn_resultsByParams[S] - - Runtime struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - } + Runtime MoqPartialGenericResultsFn_runtime } -// MoqPartialGenericResultsFn_mock isolates the mock interface of the +// MoqPartialGenericResultsFn_runtime holds runtime configuration for the // PartialGenericResultsFn type -type MoqPartialGenericResultsFn_mock[S ~string] struct { +type MoqPartialGenericResultsFn_runtime struct { + ParameterIndexing MoqPartialGenericResultsFn_paramIndexing +} + +// MoqPartialGenericResultsFn_adaptor adapts MoqPartialGenericResultsFn as +// needed by the runtime +type MoqPartialGenericResultsFn_adaptor[S ~string] struct { Moq *MoqPartialGenericResultsFn[S] } @@ -9021,12 +5037,18 @@ type MoqPartialGenericResultsFn_paramsKey[S ~string] struct { } } -// 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] +// MoqPartialGenericResultsFn_results holds the results of the +// PartialGenericResultsFn type +type MoqPartialGenericResultsFn_results[S ~string] struct { + Result1 S + Result2 error +} + +// MoqPartialGenericResultsFn_paramIndexing holds the parameter indexing +// runtime configuration for the PartialGenericResultsFn type +type MoqPartialGenericResultsFn_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqPartialGenericResultsFn_doFn defines the type of function needed when @@ -9037,64 +5059,39 @@ type MoqPartialGenericResultsFn_doFn[S ~string] func(string, bool) // 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 -} - -// MoqPartialGenericResultsFn_fnRecorder routes recorded function calls to the +// MoqPartialGenericResultsFn_recorder 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] +type MoqPartialGenericResultsFn_recorder[S ~string] struct { + Recorder *impl.Recorder[ + *MoqPartialGenericResultsFn_adaptor[S], + MoqPartialGenericResultsFn_params[S], + MoqPartialGenericResultsFn_paramsKey[S], + MoqPartialGenericResultsFn_results[S]] } // MoqPartialGenericResultsFn_anyParams isolates the any params functions of // the PartialGenericResultsFn type type MoqPartialGenericResultsFn_anyParams[S ~string] struct { - Recorder *MoqPartialGenericResultsFn_fnRecorder[S] + Recorder *MoqPartialGenericResultsFn_recorder[S] } // 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{} - } + adaptor1 := &MoqPartialGenericResultsFn_adaptor[S]{} m := &MoqPartialGenericResultsFn[S]{ - Scene: scene, - Config: *config, - Moq: &MoqPartialGenericResultsFn_mock[S]{}, - - Runtime: struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - }{ParameterIndexing: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqPartialGenericResultsFn_adaptor[S], + MoqPartialGenericResultsFn_params[S], + MoqPartialGenericResultsFn_paramsKey[S], + MoqPartialGenericResultsFn_results[S]](scene, adaptor1, config), + + Runtime: MoqPartialGenericResultsFn_runtime{ParameterIndexing: MoqPartialGenericResultsFn_paramIndexing{ Param1: moq.ParamIndexByValue, Param2: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -9103,280 +5100,114 @@ func NewMoqPartialGenericResultsFn[S ~string](scene *moq.Scene, config *moq.Conf // 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) - } -} - -func (m *MoqPartialGenericResultsFn_mock[S]) Fn(param1 string, param2 bool) (result1 S, result2 error) { - m.Moq.Scene.T.Helper() - 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 { - 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 + m.Moq.Scene.T.Helper() + params := MoqPartialGenericResultsFn_params[S]{ + Param1: param1, + Param2: param2, } - 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)) + var result1 S + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } + return result1, result2 } - - 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 *MoqPartialGenericResultsFn[S]) OnCall(param1 string, param2 bool) *MoqPartialGenericResultsFn_fnRecorder[S] { - return &MoqPartialGenericResultsFn_fnRecorder[S]{ - Params: MoqPartialGenericResultsFn_params[S]{ +func (m *MoqPartialGenericResultsFn[S]) OnCall(param1 string, param2 bool) *MoqPartialGenericResultsFn_recorder[S] { + return &MoqPartialGenericResultsFn_recorder[S]{ + Recorder: m.Moq.OnCall(MoqPartialGenericResultsFn_params[S]{ Param1: param1, Param2: param2, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -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(r.Params)) +func (r *MoqPartialGenericResultsFn_recorder[S]) Any() *MoqPartialGenericResultsFn_anyParams[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPartialGenericResultsFn_anyParams[S]{Recorder: r} } -func (a *MoqPartialGenericResultsFn_anyParams[S]) Param1() *MoqPartialGenericResultsFn_fnRecorder[S] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPartialGenericResultsFn_anyParams[S]) Param1() *MoqPartialGenericResultsFn_recorder[S] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqPartialGenericResultsFn_anyParams[S]) Param2() *MoqPartialGenericResultsFn_fnRecorder[S] { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqPartialGenericResultsFn_anyParams[S]) Param2() *MoqPartialGenericResultsFn_recorder[S] { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -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(r.Params)) +func (r *MoqPartialGenericResultsFn_recorder[S]) Seq() *MoqPartialGenericResultsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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(r.Params)) +func (r *MoqPartialGenericResultsFn_recorder[S]) NoSeq() *MoqPartialGenericResultsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPartialGenericResultsFn_fnRecorder[S]) ReturnResults(result1 S, result2 error) *MoqPartialGenericResultsFn_fnRecorder[S] { - 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 S - Result2 error - } - Sequence uint32 - DoFn MoqPartialGenericResultsFn_doFn[S] - DoReturnFn MoqPartialGenericResultsFn_doReturnFn[S] - }{ - Values: &struct { - Result1 S - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqPartialGenericResultsFn_recorder[S]) ReturnResults(result1 S, result2 error) *MoqPartialGenericResultsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPartialGenericResultsFn_results[S]{ + Result1: result1, + Result2: result2, }) return r } -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") +func (r *MoqPartialGenericResultsFn_recorder[S]) AndDo(fn MoqPartialGenericResultsFn_doFn[S]) *MoqPartialGenericResultsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPartialGenericResultsFn_params[S]) { + fn(params.Param1, params.Param2) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPartialGenericResultsFn_fnRecorder[S]) DoReturnResults(fn MoqPartialGenericResultsFn_doReturnFn[S]) *MoqPartialGenericResultsFn_fnRecorder[S] { - 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 S - Result2 error +func (r *MoqPartialGenericResultsFn_recorder[S]) DoReturnResults(fn MoqPartialGenericResultsFn_doReturnFn[S]) *MoqPartialGenericResultsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPartialGenericResultsFn_params[S]) *MoqPartialGenericResultsFn_results[S] { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqPartialGenericResultsFn_results[S]{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqPartialGenericResultsFn_doFn[S] - DoReturnFn MoqPartialGenericResultsFn_doReturnFn[S] - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPartialGenericResultsFn_fnRecorder[S]) 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 *MoqPartialGenericResultsFn_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 = &MoqPartialGenericResultsFn_resultsByParams[S]{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPartialGenericResultsFn_paramsKey[S]]*MoqPartialGenericResultsFn_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 - } - } - - paramsKey := r.Moq.ParamsKey(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqPartialGenericResultsFn_results[S]{ - 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 *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") - 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 S - Result2 error - } - Sequence uint32 - DoFn MoqPartialGenericResultsFn_doFn[S] - DoReturnFn MoqPartialGenericResultsFn_doReturnFn[S] - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqPartialGenericResultsFn_recorder[S]) Repeat(repeaters ...moq.Repeater) *MoqPartialGenericResultsFn_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqPartialGenericResultsFn[S]) PrettyParams(params MoqPartialGenericResultsFn_params[S]) string { +func (*MoqPartialGenericResultsFn_adaptor[S]) PrettyParams(params MoqPartialGenericResultsFn_params[S]) string { return fmt.Sprintf("PartialGenericResultsFn(%#v, %#v)", params.Param1, params.Param2) } -func (m *MoqPartialGenericResultsFn[S]) ParamsKey(params MoqPartialGenericResultsFn_params[S], anyParams uint64) MoqPartialGenericResultsFn_paramsKey[S] { - 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) - } - } - 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) - } - } +func (a *MoqPartialGenericResultsFn_adaptor[S]) ParamsKey(params MoqPartialGenericResultsFn_params[S], anyParams uint64) MoqPartialGenericResultsFn_paramsKey[S] { + a.Moq.Moq.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.Param2, anyParams) return MoqPartialGenericResultsFn_paramsKey[S]{ Params: struct { Param1 string @@ -9396,40 +5227,37 @@ func (m *MoqPartialGenericResultsFn[S]) ParamsKey(params MoqPartialGenericResult } // Reset resets the state of the moq -func (m *MoqPartialGenericResultsFn[S]) Reset() { m.ResultsByParams = nil } +func (m *MoqPartialGenericResultsFn[S]) Reset() { + m.Moq.Reset() +} // 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // 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] + Moq *impl.Moq[ + *MoqGenericInterfaceParamFn_adaptor[W], + MoqGenericInterfaceParamFn_params[W], + MoqGenericInterfaceParamFn_paramsKey[W], + MoqGenericInterfaceParamFn_results[W]] - Runtime struct { - ParameterIndexing struct { - W moq.ParamIndexing - } - } + Runtime MoqGenericInterfaceParamFn_runtime } -// MoqGenericInterfaceParamFn_mock isolates the mock interface of the +// MoqGenericInterfaceParamFn_runtime holds runtime configuration for the // GenericInterfaceParamFn type -type MoqGenericInterfaceParamFn_mock[W testmoqs.MyWriter] struct { +type MoqGenericInterfaceParamFn_runtime struct { + ParameterIndexing MoqGenericInterfaceParamFn_paramIndexing +} + +// MoqGenericInterfaceParamFn_adaptor adapts MoqGenericInterfaceParamFn as +// needed by the runtime +type MoqGenericInterfaceParamFn_adaptor[W testmoqs.MyWriter] struct { Moq *MoqGenericInterfaceParamFn[W] } @@ -9444,12 +5272,17 @@ type MoqGenericInterfaceParamFn_paramsKey[W testmoqs.MyWriter] 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_results holds the results of the +// GenericInterfaceParamFn type +type MoqGenericInterfaceParamFn_results[W testmoqs.MyWriter] struct { + SResult string + Err error +} + +// MoqGenericInterfaceParamFn_paramIndexing holds the parameter indexing +// runtime configuration for the GenericInterfaceParamFn type +type MoqGenericInterfaceParamFn_paramIndexing struct { + W moq.ParamIndexing } // MoqGenericInterfaceParamFn_doFn defines the type of function needed when @@ -9460,61 +5293,38 @@ type MoqGenericInterfaceParamFn_doFn[W testmoqs.MyWriter] func(w W) // 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_recorder 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] +type MoqGenericInterfaceParamFn_recorder[W testmoqs.MyWriter] struct { + Recorder *impl.Recorder[ + *MoqGenericInterfaceParamFn_adaptor[W], + MoqGenericInterfaceParamFn_params[W], + MoqGenericInterfaceParamFn_paramsKey[W], + MoqGenericInterfaceParamFn_results[W]] } // MoqGenericInterfaceParamFn_anyParams isolates the any params functions of // the GenericInterfaceParamFn type type MoqGenericInterfaceParamFn_anyParams[W testmoqs.MyWriter] struct { - Recorder *MoqGenericInterfaceParamFn_fnRecorder[W] + Recorder *MoqGenericInterfaceParamFn_recorder[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{} - } + adaptor1 := &MoqGenericInterfaceParamFn_adaptor[W]{} m := &MoqGenericInterfaceParamFn[W]{ - Scene: scene, - Config: *config, - Moq: &MoqGenericInterfaceParamFn_mock[W]{}, - - Runtime: struct { - ParameterIndexing struct { - W moq.ParamIndexing - } - }{ParameterIndexing: struct { - W moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqGenericInterfaceParamFn_adaptor[W], + MoqGenericInterfaceParamFn_params[W], + MoqGenericInterfaceParamFn_paramsKey[W], + MoqGenericInterfaceParamFn_results[W]](scene, adaptor1, config), + + Runtime: MoqGenericInterfaceParamFn_runtime{ParameterIndexing: MoqGenericInterfaceParamFn_paramIndexing{ W: moq.ParamIndexByHash, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -9522,263 +5332,106 @@ func NewMoqGenericInterfaceParamFn[W testmoqs.MyWriter](scene *moq.Scene, config // 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 + return func(w W) (string, error) { + m.Moq.Scene.T.Helper() + params := MoqGenericInterfaceParamFn_params[W]{ + W: w, } - 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)) + var result1 string + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } + return result1, result2 } - - 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]{ +func (m *MoqGenericInterfaceParamFn[W]) OnCall(w W) *MoqGenericInterfaceParamFn_recorder[W] { + return &MoqGenericInterfaceParamFn_recorder[W]{ + Recorder: m.Moq.OnCall(MoqGenericInterfaceParamFn_params[W]{ W: w, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -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(r.Params)) +func (r *MoqGenericInterfaceParamFn_recorder[W]) Any() *MoqGenericInterfaceParamFn_anyParams[W] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqGenericInterfaceParamFn_anyParams[W]{Recorder: r} } -func (a *MoqGenericInterfaceParamFn_anyParams[W]) W() *MoqGenericInterfaceParamFn_fnRecorder[W] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqGenericInterfaceParamFn_anyParams[W]) W() *MoqGenericInterfaceParamFn_recorder[W] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -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(r.Params)) +func (r *MoqGenericInterfaceParamFn_recorder[W]) Seq() *MoqGenericInterfaceParamFn_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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(r.Params)) +func (r *MoqGenericInterfaceParamFn_recorder[W]) NoSeq() *MoqGenericInterfaceParamFn_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqGenericInterfaceParamFn_fnRecorder[W]) ReturnResults(sResult string, err error) *MoqGenericInterfaceParamFn_fnRecorder[W] { - 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 MoqGenericInterfaceParamFn_doFn[W] - DoReturnFn MoqGenericInterfaceParamFn_doReturnFn[W] - }{ - Values: &struct { - SResult string - Err error - }{ - SResult: sResult, - Err: err, - }, - Sequence: sequence, +func (r *MoqGenericInterfaceParamFn_recorder[W]) ReturnResults(sResult string, err error) *MoqGenericInterfaceParamFn_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqGenericInterfaceParamFn_results[W]{ + SResult: sResult, + Err: err, }) return r } -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") +func (r *MoqGenericInterfaceParamFn_recorder[W]) AndDo(fn MoqGenericInterfaceParamFn_doFn[W]) *MoqGenericInterfaceParamFn_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqGenericInterfaceParamFn_params[W]) { + fn(params.W) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqGenericInterfaceParamFn_fnRecorder[W]) DoReturnResults(fn MoqGenericInterfaceParamFn_doReturnFn[W]) *MoqGenericInterfaceParamFn_fnRecorder[W] { - 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 +func (r *MoqGenericInterfaceParamFn_recorder[W]) DoReturnResults(fn MoqGenericInterfaceParamFn_doReturnFn[W]) *MoqGenericInterfaceParamFn_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqGenericInterfaceParamFn_params[W]) *MoqGenericInterfaceParamFn_results[W] { + sResult, err := fn(params.W) + return &MoqGenericInterfaceParamFn_results[W]{ + SResult: sResult, + Err: err, } - Sequence uint32 - DoFn MoqGenericInterfaceParamFn_doFn[W] - DoReturnFn MoqGenericInterfaceParamFn_doReturnFn[W] - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqGenericInterfaceParamFn_fnRecorder[W]) 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 *MoqGenericInterfaceParamFn_resultsByParams[W] - 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 = &MoqGenericInterfaceParamFn_resultsByParams[W]{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqGenericInterfaceParamFn_paramsKey[W]]*MoqGenericInterfaceParamFn_results[W]{}, - } - 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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqGenericInterfaceParamFn_results[W]{ - 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 *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") - 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 MoqGenericInterfaceParamFn_doFn[W] - DoReturnFn MoqGenericInterfaceParamFn_doReturnFn[W] - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqGenericInterfaceParamFn_recorder[W]) Repeat(repeaters ...moq.Repeater) *MoqGenericInterfaceParamFn_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqGenericInterfaceParamFn[W]) PrettyParams(params MoqGenericInterfaceParamFn_params[W]) string { +func (*MoqGenericInterfaceParamFn_adaptor[W]) PrettyParams(params MoqGenericInterfaceParamFn_params[W]) string { return fmt.Sprintf("GenericInterfaceParamFn(%#v)", params.W) } -func (m *MoqGenericInterfaceParamFn[W]) ParamsKey(params MoqGenericInterfaceParamFn_params[W], anyParams uint64) MoqGenericInterfaceParamFn_paramsKey[W] { - m.Scene.T.Helper() - var wUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - 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) - } +func (a *MoqGenericInterfaceParamFn_adaptor[W]) ParamsKey(params MoqGenericInterfaceParamFn_params[W], anyParams uint64) MoqGenericInterfaceParamFn_paramsKey[W] { + a.Moq.Moq.Scene.T.Helper() + wUsedHash := impl.HashOnlyParamKey(a.Moq.Moq.Scene.T, + params.W, "w", 1, a.Moq.Runtime.ParameterIndexing.W, anyParams) return MoqGenericInterfaceParamFn_paramsKey[W]{ Params: struct{}{}, Hashes: struct{ W hash.Hash }{ @@ -9788,41 +5441,37 @@ func (m *MoqGenericInterfaceParamFn[W]) ParamsKey(params MoqGenericInterfacePara } // Reset resets the state of the moq -func (m *MoqGenericInterfaceParamFn[W]) Reset() { m.ResultsByParams = nil } +func (m *MoqGenericInterfaceParamFn[W]) Reset() { + m.Moq.Reset() +} // 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // 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] + Moq *impl.Moq[ + *MoqGenericInterfaceResultFn_adaptor[R], + MoqGenericInterfaceResultFn_params[R], + MoqGenericInterfaceResultFn_paramsKey[R], + MoqGenericInterfaceResultFn_results[R]] - ResultsByParams []MoqGenericInterfaceResultFn_resultsByParams[R] - - Runtime struct { - ParameterIndexing struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - } + Runtime MoqGenericInterfaceResultFn_runtime } -// MoqGenericInterfaceResultFn_mock isolates the mock interface of the +// MoqGenericInterfaceResultFn_runtime holds runtime configuration for the // GenericInterfaceResultFn type -type MoqGenericInterfaceResultFn_mock[R testmoqs.MyReader] struct { +type MoqGenericInterfaceResultFn_runtime struct { + ParameterIndexing MoqGenericInterfaceResultFn_paramIndexing +} + +// MoqGenericInterfaceResultFn_adaptor adapts MoqGenericInterfaceResultFn as +// needed by the runtime +type MoqGenericInterfaceResultFn_adaptor[R testmoqs.MyReader] struct { Moq *MoqGenericInterfaceResultFn[R] } @@ -9846,12 +5495,15 @@ type MoqGenericInterfaceResultFn_paramsKey[R testmoqs.MyReader] struct { } } -// 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_results holds the results of the +// GenericInterfaceResultFn type +type MoqGenericInterfaceResultFn_results[R testmoqs.MyReader] struct{ Result1 R } + +// MoqGenericInterfaceResultFn_paramIndexing holds the parameter indexing +// runtime configuration for the GenericInterfaceResultFn type +type MoqGenericInterfaceResultFn_paramIndexing struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing } // MoqGenericInterfaceResultFn_doFn defines the type of function needed when @@ -9862,61 +5514,39 @@ type MoqGenericInterfaceResultFn_doFn[R testmoqs.MyReader] func(sParam string, b // 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_recorder 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] +type MoqGenericInterfaceResultFn_recorder[R testmoqs.MyReader] struct { + Recorder *impl.Recorder[ + *MoqGenericInterfaceResultFn_adaptor[R], + MoqGenericInterfaceResultFn_params[R], + MoqGenericInterfaceResultFn_paramsKey[R], + MoqGenericInterfaceResultFn_results[R]] } // MoqGenericInterfaceResultFn_anyParams isolates the any params functions of // the GenericInterfaceResultFn type type MoqGenericInterfaceResultFn_anyParams[R testmoqs.MyReader] struct { - Recorder *MoqGenericInterfaceResultFn_fnRecorder[R] + Recorder *MoqGenericInterfaceResultFn_recorder[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{} - } + adaptor1 := &MoqGenericInterfaceResultFn_adaptor[R]{} 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 - }{ + Moq: impl.NewMoq[ + *MoqGenericInterfaceResultFn_adaptor[R], + MoqGenericInterfaceResultFn_params[R], + MoqGenericInterfaceResultFn_paramsKey[R], + MoqGenericInterfaceResultFn_results[R]](scene, adaptor1, config), + + Runtime: MoqGenericInterfaceResultFn_runtime{ParameterIndexing: MoqGenericInterfaceResultFn_paramIndexing{ SParam: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -9924,267 +5554,111 @@ func NewMoqGenericInterfaceResultFn[R testmoqs.MyReader](scene *moq.Scene, confi // 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 func(sParam string, bParam bool) R { + m.Moq.Scene.T.Helper() + params := MoqGenericInterfaceResultFn_params[R]{ + SParam: sParam, + BParam: bParam, } - 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 + var result1 R + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 } - i = results.Repeat.ResultCount - 1 + return result1 } +} - 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]{ +func (m *MoqGenericInterfaceResultFn[R]) OnCall(sParam string, bParam bool) *MoqGenericInterfaceResultFn_recorder[R] { + return &MoqGenericInterfaceResultFn_recorder[R]{ + Recorder: m.Moq.OnCall(MoqGenericInterfaceResultFn_params[R]{ SParam: sParam, BParam: bParam, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -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(r.Params)) +func (r *MoqGenericInterfaceResultFn_recorder[R]) Any() *MoqGenericInterfaceResultFn_anyParams[R] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqGenericInterfaceResultFn_anyParams[R]{Recorder: r} } -func (a *MoqGenericInterfaceResultFn_anyParams[R]) SParam() *MoqGenericInterfaceResultFn_fnRecorder[R] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqGenericInterfaceResultFn_anyParams[R]) SParam() *MoqGenericInterfaceResultFn_recorder[R] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqGenericInterfaceResultFn_anyParams[R]) BParam() *MoqGenericInterfaceResultFn_fnRecorder[R] { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqGenericInterfaceResultFn_anyParams[R]) BParam() *MoqGenericInterfaceResultFn_recorder[R] { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -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(r.Params)) +func (r *MoqGenericInterfaceResultFn_recorder[R]) Seq() *MoqGenericInterfaceResultFn_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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(r.Params)) +func (r *MoqGenericInterfaceResultFn_recorder[R]) NoSeq() *MoqGenericInterfaceResultFn_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqGenericInterfaceResultFn_fnRecorder[R]) ReturnResults(result1 R) *MoqGenericInterfaceResultFn_fnRecorder[R] { - 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 R } - Sequence uint32 - DoFn MoqGenericInterfaceResultFn_doFn[R] - DoReturnFn MoqGenericInterfaceResultFn_doReturnFn[R] - }{ - Values: &struct{ Result1 R }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqGenericInterfaceResultFn_recorder[R]) ReturnResults(result1 R) *MoqGenericInterfaceResultFn_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqGenericInterfaceResultFn_results[R]{ + Result1: result1, }) return r } -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") +func (r *MoqGenericInterfaceResultFn_recorder[R]) AndDo(fn MoqGenericInterfaceResultFn_doFn[R]) *MoqGenericInterfaceResultFn_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqGenericInterfaceResultFn_params[R]) { + fn(params.SParam, params.BParam) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn - return r -} - -func (r *MoqGenericInterfaceResultFn_fnRecorder[R]) DoReturnResults(fn MoqGenericInterfaceResultFn_doReturnFn[R]) *MoqGenericInterfaceResultFn_fnRecorder[R] { - 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 R } - Sequence uint32 - DoFn MoqGenericInterfaceResultFn_doFn[R] - DoReturnFn MoqGenericInterfaceResultFn_doReturnFn[R] - }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqGenericInterfaceResultFn_fnRecorder[R]) 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 *MoqGenericInterfaceResultFn_resultsByParams[R] - 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 = &MoqGenericInterfaceResultFn_resultsByParams[R]{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqGenericInterfaceResultFn_paramsKey[R]]*MoqGenericInterfaceResultFn_results[R]{}, - } - 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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqGenericInterfaceResultFn_results[R]{ - Params: r.Params, - Results: nil, - Index: 0, - Repeat: &moq.RepeatVal{}, +func (r *MoqGenericInterfaceResultFn_recorder[R]) DoReturnResults(fn MoqGenericInterfaceResultFn_doReturnFn[R]) *MoqGenericInterfaceResultFn_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqGenericInterfaceResultFn_params[R]) *MoqGenericInterfaceResultFn_results[R] { + result1 := fn(params.SParam, params.BParam) + return &MoqGenericInterfaceResultFn_results[R]{ + Result1: result1, } - results.Results[paramsKey] = r.Results - } - - r.Results.Repeat.Increment(r.Moq.Scene.T) + }) + return r } -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") +func (r *MoqGenericInterfaceResultFn_recorder[R]) Repeat(repeaters ...moq.Repeater) *MoqGenericInterfaceResultFn_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 R } - Sequence uint32 - DoFn MoqGenericInterfaceResultFn_doFn[R] - DoReturnFn MoqGenericInterfaceResultFn_doReturnFn[R] - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqGenericInterfaceResultFn[R]) PrettyParams(params MoqGenericInterfaceResultFn_params[R]) string { +func (*MoqGenericInterfaceResultFn_adaptor[R]) PrettyParams(params MoqGenericInterfaceResultFn_params[R]) string { return fmt.Sprintf("GenericInterfaceResultFn(%#v, %#v)", params.SParam, params.BParam) } -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.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.BParam == moq.ParamIndexByValue { - bParamUsed = params.BParam - } else { - bParamUsedHash = hash.DeepHash(params.BParam) - } - } +func (a *MoqGenericInterfaceResultFn_adaptor[R]) ParamsKey(params MoqGenericInterfaceResultFn_params[R], anyParams uint64) MoqGenericInterfaceResultFn_paramsKey[R] { + a.Moq.Moq.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.SParam, 1, a.Moq.Runtime.ParameterIndexing.SParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 2, a.Moq.Runtime.ParameterIndexing.BParam, anyParams) return MoqGenericInterfaceResultFn_paramsKey[R]{ Params: struct { SParam string @@ -10204,19 +5678,14 @@ func (m *MoqGenericInterfaceResultFn[R]) ParamsKey(params MoqGenericInterfaceRes } // Reset resets the state of the moq -func (m *MoqGenericInterfaceResultFn[R]) Reset() { m.ResultsByParams = nil } +func (m *MoqGenericInterfaceResultFn[R]) Reset() { + m.Moq.Reset() +} // 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } // The following type assertion assures that testmoqs.Usual is mocked @@ -10225,112 +5694,139 @@ 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_PassByArray []MoqUsual_PassByArray_resultsByParams - ResultsByParams_PassByChan []MoqUsual_PassByChan_resultsByParams - ResultsByParams_PassByEllipsis []MoqUsual_PassByEllipsis_resultsByParams - ResultsByParams_PassByMap []MoqUsual_PassByMap_resultsByParams - ResultsByParams_PassByReference []MoqUsual_PassByReference_resultsByParams - ResultsByParams_PassBySlice []MoqUsual_PassBySlice_resultsByParams - ResultsByParams_PassByValue []MoqUsual_PassByValue_resultsByParams - ResultsByParams_InterfaceParam []MoqUsual_InterfaceParam_resultsByParams - ResultsByParams_InterfaceResult []MoqUsual_InterfaceResult_resultsByParams - ResultsByParams_FnParam []MoqUsual_FnParam_resultsByParams - ResultsByParams_Other []MoqUsual_Other_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{} - PassByArray struct { - P moq.ParamIndexing - } - PassByChan struct { - P moq.ParamIndexing - } - PassByEllipsis struct { - P moq.ParamIndexing - } - PassByMap struct { - P moq.ParamIndexing - } - PassByReference struct { - P moq.ParamIndexing - } - PassBySlice struct { - P moq.ParamIndexing - } - PassByValue struct { - P moq.ParamIndexing - } - InterfaceParam struct { - W moq.ParamIndexing - } - InterfaceResult struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - FnParam struct { - Fn moq.ParamIndexing - } - Other struct { - Param1 moq.ParamIndexing - } - } - } - // MoqUsual_mock isolates the mock interface of the Usual type -} - + Moq *MoqUsual_mock + + Moq_Usual *impl.Moq[ + *MoqUsual_Usual_adaptor, + MoqUsual_Usual_params, + MoqUsual_Usual_paramsKey, + MoqUsual_Usual_results, + ] + Moq_NoNames *impl.Moq[ + *MoqUsual_NoNames_adaptor, + MoqUsual_NoNames_params, + MoqUsual_NoNames_paramsKey, + MoqUsual_NoNames_results, + ] + Moq_NoResults *impl.Moq[ + *MoqUsual_NoResults_adaptor, + MoqUsual_NoResults_params, + MoqUsual_NoResults_paramsKey, + MoqUsual_NoResults_results, + ] + Moq_NoParams *impl.Moq[ + *MoqUsual_NoParams_adaptor, + MoqUsual_NoParams_params, + MoqUsual_NoParams_paramsKey, + MoqUsual_NoParams_results, + ] + Moq_Nothing *impl.Moq[ + *MoqUsual_Nothing_adaptor, + MoqUsual_Nothing_params, + MoqUsual_Nothing_paramsKey, + MoqUsual_Nothing_results, + ] + Moq_Variadic *impl.Moq[ + *MoqUsual_Variadic_adaptor, + MoqUsual_Variadic_params, + MoqUsual_Variadic_paramsKey, + MoqUsual_Variadic_results, + ] + Moq_RepeatedIds *impl.Moq[ + *MoqUsual_RepeatedIds_adaptor, + MoqUsual_RepeatedIds_params, + MoqUsual_RepeatedIds_paramsKey, + MoqUsual_RepeatedIds_results, + ] + Moq_Times *impl.Moq[ + *MoqUsual_Times_adaptor, + MoqUsual_Times_params, + MoqUsual_Times_paramsKey, + MoqUsual_Times_results, + ] + Moq_DifficultParamNames *impl.Moq[ + *MoqUsual_DifficultParamNames_adaptor, + MoqUsual_DifficultParamNames_params, + MoqUsual_DifficultParamNames_paramsKey, + MoqUsual_DifficultParamNames_results, + ] + Moq_DifficultResultNames *impl.Moq[ + *MoqUsual_DifficultResultNames_adaptor, + MoqUsual_DifficultResultNames_params, + MoqUsual_DifficultResultNames_paramsKey, + MoqUsual_DifficultResultNames_results, + ] + Moq_PassByArray *impl.Moq[ + *MoqUsual_PassByArray_adaptor, + MoqUsual_PassByArray_params, + MoqUsual_PassByArray_paramsKey, + MoqUsual_PassByArray_results, + ] + Moq_PassByChan *impl.Moq[ + *MoqUsual_PassByChan_adaptor, + MoqUsual_PassByChan_params, + MoqUsual_PassByChan_paramsKey, + MoqUsual_PassByChan_results, + ] + Moq_PassByEllipsis *impl.Moq[ + *MoqUsual_PassByEllipsis_adaptor, + MoqUsual_PassByEllipsis_params, + MoqUsual_PassByEllipsis_paramsKey, + MoqUsual_PassByEllipsis_results, + ] + Moq_PassByMap *impl.Moq[ + *MoqUsual_PassByMap_adaptor, + MoqUsual_PassByMap_params, + MoqUsual_PassByMap_paramsKey, + MoqUsual_PassByMap_results, + ] + Moq_PassByReference *impl.Moq[ + *MoqUsual_PassByReference_adaptor, + MoqUsual_PassByReference_params, + MoqUsual_PassByReference_paramsKey, + MoqUsual_PassByReference_results, + ] + Moq_PassBySlice *impl.Moq[ + *MoqUsual_PassBySlice_adaptor, + MoqUsual_PassBySlice_params, + MoqUsual_PassBySlice_paramsKey, + MoqUsual_PassBySlice_results, + ] + Moq_PassByValue *impl.Moq[ + *MoqUsual_PassByValue_adaptor, + MoqUsual_PassByValue_params, + MoqUsual_PassByValue_paramsKey, + MoqUsual_PassByValue_results, + ] + Moq_InterfaceParam *impl.Moq[ + *MoqUsual_InterfaceParam_adaptor, + MoqUsual_InterfaceParam_params, + MoqUsual_InterfaceParam_paramsKey, + MoqUsual_InterfaceParam_results, + ] + Moq_InterfaceResult *impl.Moq[ + *MoqUsual_InterfaceResult_adaptor, + MoqUsual_InterfaceResult_params, + MoqUsual_InterfaceResult_paramsKey, + MoqUsual_InterfaceResult_results, + ] + Moq_FnParam *impl.Moq[ + *MoqUsual_FnParam_adaptor, + MoqUsual_FnParam_params, + MoqUsual_FnParam_paramsKey, + MoqUsual_FnParam_results, + ] + Moq_Other *impl.Moq[ + *MoqUsual_Other_adaptor, + MoqUsual_Other_params, + MoqUsual_Other_paramsKey, + MoqUsual_Other_results, + ] + + Runtime MoqUsual_runtime +} + +// MoqUsual_mock isolates the mock interface of the Usual type type MoqUsual_mock struct { Moq *MoqUsual } @@ -10340,6 +5836,38 @@ type MoqUsual_recorder struct { Moq *MoqUsual } +// MoqUsual_runtime holds runtime configuration for the Usual type +type MoqUsual_runtime struct { + ParameterIndexing struct { + Usual MoqUsual_Usual_paramIndexing + NoNames MoqUsual_NoNames_paramIndexing + NoResults MoqUsual_NoResults_paramIndexing + NoParams MoqUsual_NoParams_paramIndexing + Nothing MoqUsual_Nothing_paramIndexing + Variadic MoqUsual_Variadic_paramIndexing + RepeatedIds MoqUsual_RepeatedIds_paramIndexing + Times MoqUsual_Times_paramIndexing + DifficultParamNames MoqUsual_DifficultParamNames_paramIndexing + DifficultResultNames MoqUsual_DifficultResultNames_paramIndexing + PassByArray MoqUsual_PassByArray_paramIndexing + PassByChan MoqUsual_PassByChan_paramIndexing + PassByEllipsis MoqUsual_PassByEllipsis_paramIndexing + PassByMap MoqUsual_PassByMap_paramIndexing + PassByReference MoqUsual_PassByReference_paramIndexing + PassBySlice MoqUsual_PassBySlice_paramIndexing + PassByValue MoqUsual_PassByValue_paramIndexing + InterfaceParam MoqUsual_InterfaceParam_paramIndexing + InterfaceResult MoqUsual_InterfaceResult_paramIndexing + FnParam MoqUsual_FnParam_paramIndexing + Other MoqUsual_Other_paramIndexing + } +} + +// MoqUsual_Usual_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_Usual_adaptor struct { + Moq *MoqUsual +} + // MoqUsual_Usual_params holds the params of the Usual type type MoqUsual_Usual_params struct { SParam string @@ -10358,12 +5886,17 @@ type MoqUsual_Usual_paramsKey struct { } } -// 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_results holds the results of the Usual type +type MoqUsual_Usual_results struct { + SResult string + Err error +} + +// MoqUsual_Usual_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_Usual_paramIndexing struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing } // MoqUsual_Usual_doFn defines the type of function needed when calling AndDo @@ -10374,34 +5907,24 @@ type MoqUsual_Usual_doFn func(sParam string, bParam bool) // 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_recorder routes recorded function calls to the MoqUsual moq +type MoqUsual_Usual_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_Usual_adaptor, + MoqUsual_Usual_params, + MoqUsual_Usual_paramsKey, + MoqUsual_Usual_results, + ] } // MoqUsual_Usual_anyParams isolates the any params functions of the Usual type type MoqUsual_Usual_anyParams struct { - Recorder *MoqUsual_Usual_fnRecorder + Recorder *MoqUsual_Usual_recorder +} + +// MoqUsual_NoNames_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_NoNames_adaptor struct { + Moq *MoqUsual } // MoqUsual_NoNames_params holds the params of the Usual type @@ -10422,12 +5945,17 @@ type MoqUsual_NoNames_paramsKey struct { } } -// 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_results holds the results of the Usual type +type MoqUsual_NoNames_results struct { + Result1 string + Result2 error +} + +// MoqUsual_NoNames_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_NoNames_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqUsual_NoNames_doFn defines the type of function needed when calling AndDo @@ -10438,36 +5966,25 @@ type MoqUsual_NoNames_doFn func(string, bool) // 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_recorder routes recorded function calls to the MoqUsual moq +type MoqUsual_NoNames_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_NoNames_adaptor, + MoqUsual_NoNames_params, + MoqUsual_NoNames_paramsKey, + MoqUsual_NoNames_results, + ] } // MoqUsual_NoNames_anyParams isolates the any params functions of the Usual // type type MoqUsual_NoNames_anyParams struct { - Recorder *MoqUsual_NoNames_fnRecorder + Recorder *MoqUsual_NoNames_recorder +} + +// MoqUsual_NoResults_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_NoResults_adaptor struct { + Moq *MoqUsual } // MoqUsual_NoResults_params holds the params of the Usual type @@ -10488,12 +6005,14 @@ type MoqUsual_NoResults_paramsKey struct { } } -// 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_results holds the results of the Usual type +type MoqUsual_NoResults_results struct{} + +// MoqUsual_NoResults_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_NoResults_paramIndexing struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing } // MoqUsual_NoResults_doFn defines the type of function needed when calling @@ -10504,33 +6023,26 @@ type MoqUsual_NoResults_doFn func(sParam string, bParam bool) // 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 +// MoqUsual_NoResults_recorder 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 +type MoqUsual_NoResults_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_NoResults_adaptor, + MoqUsual_NoResults_params, + MoqUsual_NoResults_paramsKey, + MoqUsual_NoResults_results, + ] } // MoqUsual_NoResults_anyParams isolates the any params functions of the Usual // type type MoqUsual_NoResults_anyParams struct { - Recorder *MoqUsual_NoResults_fnRecorder + Recorder *MoqUsual_NoResults_recorder +} + +// MoqUsual_NoParams_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_NoParams_adaptor struct { + Moq *MoqUsual } // MoqUsual_NoParams_params holds the params of the Usual type @@ -10542,14 +6054,16 @@ type MoqUsual_NoParams_paramsKey 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_results holds the results of the Usual type +type MoqUsual_NoParams_results struct { + SResult string + Err error } +// MoqUsual_NoParams_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_NoParams_paramIndexing struct{} + // MoqUsual_NoParams_doFn defines the type of function needed when calling // AndDo for the Usual type type MoqUsual_NoParams_doFn func() @@ -10558,36 +6072,26 @@ type MoqUsual_NoParams_doFn func() // 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 +// MoqUsual_NoParams_recorder 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 +type MoqUsual_NoParams_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_NoParams_adaptor, + MoqUsual_NoParams_params, + MoqUsual_NoParams_paramsKey, + MoqUsual_NoParams_results, + ] } // MoqUsual_NoParams_anyParams isolates the any params functions of the Usual // type type MoqUsual_NoParams_anyParams struct { - Recorder *MoqUsual_NoParams_fnRecorder + Recorder *MoqUsual_NoParams_recorder +} + +// MoqUsual_Nothing_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_Nothing_adaptor struct { + Moq *MoqUsual } // MoqUsual_Nothing_params holds the params of the Usual type @@ -10599,13 +6103,12 @@ type MoqUsual_Nothing_paramsKey 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_results holds the results of the Usual type +type MoqUsual_Nothing_results struct{} + +// MoqUsual_Nothing_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_Nothing_paramIndexing struct{} // MoqUsual_Nothing_doFn defines the type of function needed when calling AndDo // for the Usual type @@ -10615,33 +6118,25 @@ type MoqUsual_Nothing_doFn func() // 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_recorder routes recorded function calls to the MoqUsual moq +type MoqUsual_Nothing_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_Nothing_adaptor, + MoqUsual_Nothing_params, + MoqUsual_Nothing_paramsKey, + MoqUsual_Nothing_results, + ] } // MoqUsual_Nothing_anyParams isolates the any params functions of the Usual // type type MoqUsual_Nothing_anyParams struct { - Recorder *MoqUsual_Nothing_fnRecorder + Recorder *MoqUsual_Nothing_recorder +} + +// MoqUsual_Variadic_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_Variadic_adaptor struct { + Moq *MoqUsual } // MoqUsual_Variadic_params holds the params of the Usual type @@ -10659,12 +6154,17 @@ type MoqUsual_Variadic_paramsKey struct { } } -// 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_results holds the results of the Usual type +type MoqUsual_Variadic_results struct { + SResult string + Err error +} + +// MoqUsual_Variadic_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_Variadic_paramIndexing struct { + Other moq.ParamIndexing + Args moq.ParamIndexing } // MoqUsual_Variadic_doFn defines the type of function needed when calling @@ -10675,36 +6175,26 @@ type MoqUsual_Variadic_doFn func(other bool, args ...string) // 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 +// MoqUsual_Variadic_recorder 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 +type MoqUsual_Variadic_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_Variadic_adaptor, + MoqUsual_Variadic_params, + MoqUsual_Variadic_paramsKey, + MoqUsual_Variadic_results, + ] } // MoqUsual_Variadic_anyParams isolates the any params functions of the Usual // type type MoqUsual_Variadic_anyParams struct { - Recorder *MoqUsual_Variadic_fnRecorder + Recorder *MoqUsual_Variadic_recorder +} + +// MoqUsual_RepeatedIds_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_RepeatedIds_adaptor struct { + Moq *MoqUsual } // MoqUsual_RepeatedIds_params holds the params of the Usual type @@ -10725,12 +6215,17 @@ type MoqUsual_RepeatedIds_paramsKey struct { } } -// 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_results holds the results of the Usual type +type MoqUsual_RepeatedIds_results struct { + SResult1, SResult2 string + Err error +} + +// MoqUsual_RepeatedIds_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_RepeatedIds_paramIndexing struct { + SParam1, SParam2 moq.ParamIndexing + BParam moq.ParamIndexing } // MoqUsual_RepeatedIds_doFn defines the type of function needed when calling @@ -10741,36 +6236,26 @@ type MoqUsual_RepeatedIds_doFn func(sParam1, sParam2 string, bParam bool) // 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_recorder routes recorded function calls to the MoqUsual +// moq +type MoqUsual_RepeatedIds_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_RepeatedIds_adaptor, + MoqUsual_RepeatedIds_params, + MoqUsual_RepeatedIds_paramsKey, + MoqUsual_RepeatedIds_results, + ] } // MoqUsual_RepeatedIds_anyParams isolates the any params functions of the // Usual type type MoqUsual_RepeatedIds_anyParams struct { - Recorder *MoqUsual_RepeatedIds_fnRecorder + Recorder *MoqUsual_RepeatedIds_recorder +} + +// MoqUsual_Times_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_Times_adaptor struct { + Moq *MoqUsual } // MoqUsual_Times_params holds the params of the Usual type @@ -10791,12 +6276,17 @@ type MoqUsual_Times_paramsKey struct { } } -// 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_results holds the results of the Usual type +type MoqUsual_Times_results struct { + SResult string + Err error +} + +// MoqUsual_Times_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_Times_paramIndexing struct { + SParam moq.ParamIndexing + Times moq.ParamIndexing } // MoqUsual_Times_doFn defines the type of function needed when calling AndDo @@ -10807,34 +6297,25 @@ type MoqUsual_Times_doFn func(sParam string, times bool) // 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_recorder routes recorded function calls to the MoqUsual moq +type MoqUsual_Times_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_Times_adaptor, + MoqUsual_Times_params, + MoqUsual_Times_paramsKey, + MoqUsual_Times_results, + ] } // MoqUsual_Times_anyParams isolates the any params functions of the Usual type type MoqUsual_Times_anyParams struct { - Recorder *MoqUsual_Times_fnRecorder + Recorder *MoqUsual_Times_recorder +} + +// MoqUsual_DifficultParamNames_adaptor adapts MoqUsual as needed by the +// runtime +type MoqUsual_DifficultParamNames_adaptor struct { + Moq *MoqUsual } // MoqUsual_DifficultParamNames_params holds the params of the Usual type @@ -10862,12 +6343,16 @@ type MoqUsual_DifficultParamNames_paramsKey struct { } } -// 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_results holds the results of the Usual type +type MoqUsual_DifficultParamNames_results struct{} + +// MoqUsual_DifficultParamNames_paramIndexing holds the parameter indexing +// runtime configuration for the Usual type +type MoqUsual_DifficultParamNames_paramIndexing struct { + Param1, Param2 moq.ParamIndexing + Param3 moq.ParamIndexing + Param, Param5, Param6 moq.ParamIndexing + Param7, Param8, Param9 moq.ParamIndexing } // MoqUsual_DifficultParamNames_doFn defines the type of function needed when @@ -10878,33 +6363,27 @@ type MoqUsual_DifficultParamNames_doFn func(m, r bool, sequence string, param, p // 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_recorder routes recorded function calls to the +// MoqUsual moq +type MoqUsual_DifficultParamNames_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_DifficultParamNames_adaptor, + MoqUsual_DifficultParamNames_params, + MoqUsual_DifficultParamNames_paramsKey, + MoqUsual_DifficultParamNames_results, + ] } // MoqUsual_DifficultParamNames_anyParams isolates the any params functions of // the Usual type type MoqUsual_DifficultParamNames_anyParams struct { - Recorder *MoqUsual_DifficultParamNames_fnRecorder + Recorder *MoqUsual_DifficultParamNames_recorder +} + +// MoqUsual_DifficultResultNames_adaptor adapts MoqUsual as needed by the +// runtime +type MoqUsual_DifficultResultNames_adaptor struct { + Moq *MoqUsual } // MoqUsual_DifficultResultNames_params holds the params of the Usual type @@ -10917,14 +6396,18 @@ type MoqUsual_DifficultResultNames_paramsKey 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_results holds the results of the Usual type +type MoqUsual_DifficultResultNames_results struct { + Result1, Result2 string + Result3 error + Param, Result5, Result6 int + Result7, Result8, Result9 float32 } +// MoqUsual_DifficultResultNames_paramIndexing holds the parameter indexing +// runtime configuration for the Usual type +type MoqUsual_DifficultResultNames_paramIndexing struct{} + // MoqUsual_DifficultResultNames_doFn defines the type of function needed when // calling AndDo for the Usual type type MoqUsual_DifficultResultNames_doFn func() @@ -10933,38 +6416,26 @@ type MoqUsual_DifficultResultNames_doFn func() // 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_recorder routes recorded function calls to the +// MoqUsual moq +type MoqUsual_DifficultResultNames_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_DifficultResultNames_adaptor, + MoqUsual_DifficultResultNames_params, + MoqUsual_DifficultResultNames_paramsKey, + MoqUsual_DifficultResultNames_results, + ] } // MoqUsual_DifficultResultNames_anyParams isolates the any params functions of // the Usual type type MoqUsual_DifficultResultNames_anyParams struct { - Recorder *MoqUsual_DifficultResultNames_fnRecorder + Recorder *MoqUsual_DifficultResultNames_recorder +} + +// MoqUsual_PassByArray_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_PassByArray_adaptor struct { + Moq *MoqUsual } // MoqUsual_PassByArray_params holds the params of the Usual type @@ -10976,12 +6447,15 @@ type MoqUsual_PassByArray_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqUsual_PassByArray_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_PassByArray_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_PassByArray_paramsKey]*MoqUsual_PassByArray_results +// MoqUsual_PassByArray_results holds the results of the Usual type +type MoqUsual_PassByArray_results struct { + Result1 [3]testmoqs.Results +} + +// MoqUsual_PassByArray_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_PassByArray_paramIndexing struct { + P moq.ParamIndexing } // MoqUsual_PassByArray_doFn defines the type of function needed when calling @@ -10992,35 +6466,26 @@ type MoqUsual_PassByArray_doFn func(p [3]testmoqs.Params) // calling DoReturnResults for the Usual type type MoqUsual_PassByArray_doReturnFn func(p [3]testmoqs.Params) [3]testmoqs.Results -// MoqUsual_PassByArray_results holds the results of the Usual type -type MoqUsual_PassByArray_results struct { - Params MoqUsual_PassByArray_params - Results []struct { - Values *struct { - Result1 [3]testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByArray_doFn - DoReturnFn MoqUsual_PassByArray_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsual_PassByArray_fnRecorder routes recorded function calls to the -// MoqUsual moq -type MoqUsual_PassByArray_fnRecorder struct { - Params MoqUsual_PassByArray_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_PassByArray_results - Moq *MoqUsual +// MoqUsual_PassByArray_recorder routes recorded function calls to the MoqUsual +// moq +type MoqUsual_PassByArray_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_PassByArray_adaptor, + MoqUsual_PassByArray_params, + MoqUsual_PassByArray_paramsKey, + MoqUsual_PassByArray_results, + ] } // MoqUsual_PassByArray_anyParams isolates the any params functions of the // Usual type type MoqUsual_PassByArray_anyParams struct { - Recorder *MoqUsual_PassByArray_fnRecorder + Recorder *MoqUsual_PassByArray_recorder +} + +// MoqUsual_PassByChan_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_PassByChan_adaptor struct { + Moq *MoqUsual } // MoqUsual_PassByChan_params holds the params of the Usual type @@ -11032,12 +6497,15 @@ type MoqUsual_PassByChan_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqUsual_PassByChan_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_PassByChan_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_PassByChan_paramsKey]*MoqUsual_PassByChan_results +// MoqUsual_PassByChan_results holds the results of the Usual type +type MoqUsual_PassByChan_results struct { + Result1 chan testmoqs.Results +} + +// MoqUsual_PassByChan_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_PassByChan_paramIndexing struct { + P moq.ParamIndexing } // MoqUsual_PassByChan_doFn defines the type of function needed when calling @@ -11048,35 +6516,26 @@ type MoqUsual_PassByChan_doFn func(p chan testmoqs.Params) // calling DoReturnResults for the Usual type type MoqUsual_PassByChan_doReturnFn func(p chan testmoqs.Params) chan testmoqs.Results -// MoqUsual_PassByChan_results holds the results of the Usual type -type MoqUsual_PassByChan_results struct { - Params MoqUsual_PassByChan_params - Results []struct { - Values *struct { - Result1 chan testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByChan_doFn - DoReturnFn MoqUsual_PassByChan_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsual_PassByChan_fnRecorder routes recorded function calls to the -// MoqUsual moq -type MoqUsual_PassByChan_fnRecorder struct { - Params MoqUsual_PassByChan_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_PassByChan_results - Moq *MoqUsual +// MoqUsual_PassByChan_recorder routes recorded function calls to the MoqUsual +// moq +type MoqUsual_PassByChan_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_PassByChan_adaptor, + MoqUsual_PassByChan_params, + MoqUsual_PassByChan_paramsKey, + MoqUsual_PassByChan_results, + ] } // MoqUsual_PassByChan_anyParams isolates the any params functions of the Usual // type type MoqUsual_PassByChan_anyParams struct { - Recorder *MoqUsual_PassByChan_fnRecorder + Recorder *MoqUsual_PassByChan_recorder +} + +// MoqUsual_PassByEllipsis_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_PassByEllipsis_adaptor struct { + Moq *MoqUsual } // MoqUsual_PassByEllipsis_params holds the params of the Usual type @@ -11088,12 +6547,16 @@ type MoqUsual_PassByEllipsis_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqUsual_PassByEllipsis_resultsByParams contains the results for a given set -// of parameters for the Usual type -type MoqUsual_PassByEllipsis_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_PassByEllipsis_paramsKey]*MoqUsual_PassByEllipsis_results +// MoqUsual_PassByEllipsis_results holds the results of the Usual type +type MoqUsual_PassByEllipsis_results struct { + Result1 string + Result2 error +} + +// MoqUsual_PassByEllipsis_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_PassByEllipsis_paramIndexing struct { + P moq.ParamIndexing } // MoqUsual_PassByEllipsis_doFn defines the type of function needed when @@ -11104,36 +6567,26 @@ type MoqUsual_PassByEllipsis_doFn func(p ...testmoqs.Params) // calling DoReturnResults for the Usual type type MoqUsual_PassByEllipsis_doReturnFn func(p ...testmoqs.Params) (string, error) -// MoqUsual_PassByEllipsis_results holds the results of the Usual type -type MoqUsual_PassByEllipsis_results struct { - Params MoqUsual_PassByEllipsis_params - Results []struct { - Values *struct { - Result1 string - Result2 error - } - Sequence uint32 - DoFn MoqUsual_PassByEllipsis_doFn - DoReturnFn MoqUsual_PassByEllipsis_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsual_PassByEllipsis_fnRecorder routes recorded function calls to the +// MoqUsual_PassByEllipsis_recorder routes recorded function calls to the // MoqUsual moq -type MoqUsual_PassByEllipsis_fnRecorder struct { - Params MoqUsual_PassByEllipsis_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_PassByEllipsis_results - Moq *MoqUsual +type MoqUsual_PassByEllipsis_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_PassByEllipsis_adaptor, + MoqUsual_PassByEllipsis_params, + MoqUsual_PassByEllipsis_paramsKey, + MoqUsual_PassByEllipsis_results, + ] } // MoqUsual_PassByEllipsis_anyParams isolates the any params functions of the // Usual type type MoqUsual_PassByEllipsis_anyParams struct { - Recorder *MoqUsual_PassByEllipsis_fnRecorder + Recorder *MoqUsual_PassByEllipsis_recorder +} + +// MoqUsual_PassByMap_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_PassByMap_adaptor struct { + Moq *MoqUsual } // MoqUsual_PassByMap_params holds the params of the Usual type @@ -11145,12 +6598,15 @@ type MoqUsual_PassByMap_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqUsual_PassByMap_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_PassByMap_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_PassByMap_paramsKey]*MoqUsual_PassByMap_results +// MoqUsual_PassByMap_results holds the results of the Usual type +type MoqUsual_PassByMap_results struct { + Result1 map[string]testmoqs.Results +} + +// MoqUsual_PassByMap_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_PassByMap_paramIndexing struct { + P moq.ParamIndexing } // MoqUsual_PassByMap_doFn defines the type of function needed when calling @@ -11161,35 +6617,26 @@ type MoqUsual_PassByMap_doFn func(p map[string]testmoqs.Params) // calling DoReturnResults for the Usual type type MoqUsual_PassByMap_doReturnFn func(p map[string]testmoqs.Params) map[string]testmoqs.Results -// MoqUsual_PassByMap_results holds the results of the Usual type -type MoqUsual_PassByMap_results struct { - Params MoqUsual_PassByMap_params - Results []struct { - Values *struct { - Result1 map[string]testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByMap_doFn - DoReturnFn MoqUsual_PassByMap_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsual_PassByMap_fnRecorder routes recorded function calls to the MoqUsual +// MoqUsual_PassByMap_recorder routes recorded function calls to the MoqUsual // moq -type MoqUsual_PassByMap_fnRecorder struct { - Params MoqUsual_PassByMap_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_PassByMap_results - Moq *MoqUsual +type MoqUsual_PassByMap_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_PassByMap_adaptor, + MoqUsual_PassByMap_params, + MoqUsual_PassByMap_paramsKey, + MoqUsual_PassByMap_results, + ] } // MoqUsual_PassByMap_anyParams isolates the any params functions of the Usual // type type MoqUsual_PassByMap_anyParams struct { - Recorder *MoqUsual_PassByMap_fnRecorder + Recorder *MoqUsual_PassByMap_recorder +} + +// MoqUsual_PassByReference_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_PassByReference_adaptor struct { + Moq *MoqUsual } // MoqUsual_PassByReference_params holds the params of the Usual type @@ -11202,12 +6649,15 @@ type MoqUsual_PassByReference_paramsKey struct { 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_results holds the results of the Usual type +type MoqUsual_PassByReference_results struct { + Result1 *testmoqs.Results +} + +// MoqUsual_PassByReference_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_PassByReference_paramIndexing struct { + P moq.ParamIndexing } // MoqUsual_PassByReference_doFn defines the type of function needed when @@ -11218,35 +6668,26 @@ type MoqUsual_PassByReference_doFn func(p *testmoqs.Params) // calling DoReturnResults for the Usual type type MoqUsual_PassByReference_doReturnFn func(p *testmoqs.Params) *testmoqs.Results -// MoqUsual_PassByReference_results holds the results of the Usual type -type MoqUsual_PassByReference_results struct { - Params MoqUsual_PassByReference_params - Results []struct { - Values *struct { - Result1 *testmoqs.Results - } - 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_PassByReference_recorder 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 +type MoqUsual_PassByReference_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_PassByReference_adaptor, + MoqUsual_PassByReference_params, + MoqUsual_PassByReference_paramsKey, + MoqUsual_PassByReference_results, + ] } // MoqUsual_PassByReference_anyParams isolates the any params functions of the // Usual type type MoqUsual_PassByReference_anyParams struct { - Recorder *MoqUsual_PassByReference_fnRecorder + Recorder *MoqUsual_PassByReference_recorder +} + +// MoqUsual_PassBySlice_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_PassBySlice_adaptor struct { + Moq *MoqUsual } // MoqUsual_PassBySlice_params holds the params of the Usual type @@ -11258,12 +6699,15 @@ type MoqUsual_PassBySlice_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqUsual_PassBySlice_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_PassBySlice_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_PassBySlice_paramsKey]*MoqUsual_PassBySlice_results +// MoqUsual_PassBySlice_results holds the results of the Usual type +type MoqUsual_PassBySlice_results struct { + Result1 []testmoqs.Results +} + +// MoqUsual_PassBySlice_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_PassBySlice_paramIndexing struct { + P moq.ParamIndexing } // MoqUsual_PassBySlice_doFn defines the type of function needed when calling @@ -11274,38 +6718,29 @@ type MoqUsual_PassBySlice_doFn func(p []testmoqs.Params) // calling DoReturnResults for the Usual type type MoqUsual_PassBySlice_doReturnFn func(p []testmoqs.Params) []testmoqs.Results -// MoqUsual_PassBySlice_results holds the results of the Usual type -type MoqUsual_PassBySlice_results struct { - Params MoqUsual_PassBySlice_params - Results []struct { - Values *struct { - Result1 []testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassBySlice_doFn - DoReturnFn MoqUsual_PassBySlice_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsual_PassBySlice_fnRecorder routes recorded function calls to the -// MoqUsual moq -type MoqUsual_PassBySlice_fnRecorder struct { - Params MoqUsual_PassBySlice_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_PassBySlice_results - Moq *MoqUsual +// MoqUsual_PassBySlice_recorder routes recorded function calls to the MoqUsual +// moq +type MoqUsual_PassBySlice_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_PassBySlice_adaptor, + MoqUsual_PassBySlice_params, + MoqUsual_PassBySlice_paramsKey, + MoqUsual_PassBySlice_results, + ] } // MoqUsual_PassBySlice_anyParams isolates the any params functions of the // Usual type type MoqUsual_PassBySlice_anyParams struct { - Recorder *MoqUsual_PassBySlice_fnRecorder + Recorder *MoqUsual_PassBySlice_recorder } -// MoqUsual_PassByValue_params holds the params of the Usual type +// MoqUsual_PassByValue_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_PassByValue_adaptor struct { + Moq *MoqUsual +} + +// MoqUsual_PassByValue_params holds the params of the Usual type type MoqUsual_PassByValue_params struct{ P testmoqs.Params } // MoqUsual_PassByValue_paramsKey holds the map key params of the Usual type @@ -11314,12 +6749,15 @@ type MoqUsual_PassByValue_paramsKey struct { Hashes struct{ P hash.Hash } } -// MoqUsual_PassByValue_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_PassByValue_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_PassByValue_paramsKey]*MoqUsual_PassByValue_results +// MoqUsual_PassByValue_results holds the results of the Usual type +type MoqUsual_PassByValue_results struct { + Result1 testmoqs.Results +} + +// MoqUsual_PassByValue_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_PassByValue_paramIndexing struct { + P moq.ParamIndexing } // MoqUsual_PassByValue_doFn defines the type of function needed when calling @@ -11330,35 +6768,26 @@ type MoqUsual_PassByValue_doFn func(p testmoqs.Params) // calling DoReturnResults for the Usual type type MoqUsual_PassByValue_doReturnFn func(p testmoqs.Params) testmoqs.Results -// MoqUsual_PassByValue_results holds the results of the Usual type -type MoqUsual_PassByValue_results struct { - Params MoqUsual_PassByValue_params - Results []struct { - Values *struct { - Result1 testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByValue_doFn - DoReturnFn MoqUsual_PassByValue_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsual_PassByValue_fnRecorder routes recorded function calls to the -// MoqUsual moq -type MoqUsual_PassByValue_fnRecorder struct { - Params MoqUsual_PassByValue_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_PassByValue_results - Moq *MoqUsual +// MoqUsual_PassByValue_recorder routes recorded function calls to the MoqUsual +// moq +type MoqUsual_PassByValue_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_PassByValue_adaptor, + MoqUsual_PassByValue_params, + MoqUsual_PassByValue_paramsKey, + MoqUsual_PassByValue_results, + ] } // MoqUsual_PassByValue_anyParams isolates the any params functions of the // Usual type type MoqUsual_PassByValue_anyParams struct { - Recorder *MoqUsual_PassByValue_fnRecorder + Recorder *MoqUsual_PassByValue_recorder +} + +// MoqUsual_InterfaceParam_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_InterfaceParam_adaptor struct { + Moq *MoqUsual } // MoqUsual_InterfaceParam_params holds the params of the Usual type @@ -11370,12 +6799,16 @@ type MoqUsual_InterfaceParam_paramsKey struct { 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_results holds the results of the Usual type +type MoqUsual_InterfaceParam_results struct { + SResult string + Err error +} + +// MoqUsual_InterfaceParam_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_InterfaceParam_paramIndexing struct { + W moq.ParamIndexing } // MoqUsual_InterfaceParam_doFn defines the type of function needed when @@ -11386,36 +6819,26 @@ type MoqUsual_InterfaceParam_doFn func(w io.Writer) // 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_InterfaceParam_recorder 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 +type MoqUsual_InterfaceParam_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_InterfaceParam_adaptor, + MoqUsual_InterfaceParam_params, + MoqUsual_InterfaceParam_paramsKey, + MoqUsual_InterfaceParam_results, + ] } // MoqUsual_InterfaceParam_anyParams isolates the any params functions of the // Usual type type MoqUsual_InterfaceParam_anyParams struct { - Recorder *MoqUsual_InterfaceParam_fnRecorder + Recorder *MoqUsual_InterfaceParam_recorder +} + +// MoqUsual_InterfaceResult_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_InterfaceResult_adaptor struct { + Moq *MoqUsual } // MoqUsual_InterfaceResult_params holds the params of the Usual type @@ -11437,12 +6860,14 @@ type MoqUsual_InterfaceResult_paramsKey struct { } } -// 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_results holds the results of the Usual type +type MoqUsual_InterfaceResult_results struct{ Result1 io.Reader } + +// MoqUsual_InterfaceResult_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_InterfaceResult_paramIndexing struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing } // MoqUsual_InterfaceResult_doFn defines the type of function needed when @@ -11453,33 +6878,26 @@ type MoqUsual_InterfaceResult_doFn func(sParam string, bParam bool) // 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_InterfaceResult_recorder 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 +type MoqUsual_InterfaceResult_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_InterfaceResult_adaptor, + MoqUsual_InterfaceResult_params, + MoqUsual_InterfaceResult_paramsKey, + MoqUsual_InterfaceResult_results, + ] } // MoqUsual_InterfaceResult_anyParams isolates the any params functions of the // Usual type type MoqUsual_InterfaceResult_anyParams struct { - Recorder *MoqUsual_InterfaceResult_fnRecorder + Recorder *MoqUsual_InterfaceResult_recorder +} + +// MoqUsual_FnParam_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_FnParam_adaptor struct { + Moq *MoqUsual } // MoqUsual_FnParam_params holds the params of the Usual type @@ -11491,12 +6909,13 @@ type MoqUsual_FnParam_paramsKey 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_results holds the results of the Usual type +type MoqUsual_FnParam_results struct{} + +// MoqUsual_FnParam_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_FnParam_paramIndexing struct { + Fn moq.ParamIndexing } // MoqUsual_FnParam_doFn defines the type of function needed when calling AndDo @@ -11507,33 +6926,25 @@ type MoqUsual_FnParam_doFn func(fn func()) // 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_recorder routes recorded function calls to the MoqUsual moq +type MoqUsual_FnParam_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_FnParam_adaptor, + MoqUsual_FnParam_params, + MoqUsual_FnParam_paramsKey, + MoqUsual_FnParam_results, + ] } // MoqUsual_FnParam_anyParams isolates the any params functions of the Usual // type type MoqUsual_FnParam_anyParams struct { - Recorder *MoqUsual_FnParam_fnRecorder + Recorder *MoqUsual_FnParam_recorder +} + +// MoqUsual_Other_adaptor adapts MoqUsual as needed by the runtime +type MoqUsual_Other_adaptor struct { + Moq *MoqUsual } // MoqUsual_Other_params holds the params of the Usual type @@ -11545,12 +6956,15 @@ type MoqUsual_Other_paramsKey struct { Hashes struct{ Param1 hash.Hash } } -// MoqUsual_Other_resultsByParams contains the results for a given set of -// parameters for the Usual type -type MoqUsual_Other_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUsual_Other_paramsKey]*MoqUsual_Other_results +// MoqUsual_Other_results holds the results of the Usual type +type MoqUsual_Other_results struct { + Result1 other.Results +} + +// MoqUsual_Other_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type MoqUsual_Other_paramIndexing struct { + Param1 moq.ParamIndexing } // MoqUsual_Other_doFn defines the type of function needed when calling AndDo @@ -11561,253 +6975,225 @@ type MoqUsual_Other_doFn func(other.Params) // DoReturnResults for the Usual type type MoqUsual_Other_doReturnFn func(other.Params) other.Results -// MoqUsual_Other_results holds the results of the Usual type -type MoqUsual_Other_results struct { - Params MoqUsual_Other_params - Results []struct { - Values *struct { - Result1 other.Results - } - Sequence uint32 - DoFn MoqUsual_Other_doFn - DoReturnFn MoqUsual_Other_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUsual_Other_fnRecorder routes recorded function calls to the MoqUsual moq -type MoqUsual_Other_fnRecorder struct { - Params MoqUsual_Other_params - AnyParams uint64 - Sequence bool - Results *MoqUsual_Other_results - Moq *MoqUsual +// MoqUsual_Other_recorder routes recorded function calls to the MoqUsual moq +type MoqUsual_Other_recorder struct { + Recorder *impl.Recorder[ + *MoqUsual_Other_adaptor, + MoqUsual_Other_params, + MoqUsual_Other_paramsKey, + MoqUsual_Other_results, + ] } // MoqUsual_Other_anyParams isolates the any params functions of the Usual type type MoqUsual_Other_anyParams struct { - Recorder *MoqUsual_Other_fnRecorder + Recorder *MoqUsual_Other_recorder } // NewMoqUsual creates a new moq of the Usual type func NewMoqUsual(scene *moq.Scene, config *moq.Config) *MoqUsual { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqUsual_Usual_adaptor{} + adaptor2 := &MoqUsual_NoNames_adaptor{} + adaptor3 := &MoqUsual_NoResults_adaptor{} + adaptor4 := &MoqUsual_NoParams_adaptor{} + adaptor5 := &MoqUsual_Nothing_adaptor{} + adaptor6 := &MoqUsual_Variadic_adaptor{} + adaptor7 := &MoqUsual_RepeatedIds_adaptor{} + adaptor8 := &MoqUsual_Times_adaptor{} + adaptor9 := &MoqUsual_DifficultParamNames_adaptor{} + adaptor10 := &MoqUsual_DifficultResultNames_adaptor{} + adaptor11 := &MoqUsual_PassByArray_adaptor{} + adaptor12 := &MoqUsual_PassByChan_adaptor{} + adaptor13 := &MoqUsual_PassByEllipsis_adaptor{} + adaptor14 := &MoqUsual_PassByMap_adaptor{} + adaptor15 := &MoqUsual_PassByReference_adaptor{} + adaptor16 := &MoqUsual_PassBySlice_adaptor{} + adaptor17 := &MoqUsual_PassByValue_adaptor{} + adaptor18 := &MoqUsual_InterfaceParam_adaptor{} + adaptor19 := &MoqUsual_InterfaceResult_adaptor{} + adaptor20 := &MoqUsual_FnParam_adaptor{} + adaptor21 := &MoqUsual_Other_adaptor{} 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{} - PassByArray struct { - P moq.ParamIndexing - } - PassByChan struct { - P moq.ParamIndexing - } - PassByEllipsis struct { - P moq.ParamIndexing - } - PassByMap struct { - P moq.ParamIndexing - } - PassByReference struct { - P moq.ParamIndexing - } - PassBySlice struct { - P moq.ParamIndexing - } - PassByValue struct { - P moq.ParamIndexing - } - InterfaceParam struct { - W moq.ParamIndexing - } - InterfaceResult struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - FnParam struct { - Fn moq.ParamIndexing - } - Other struct { - Param1 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{} - PassByArray struct { - P moq.ParamIndexing - } - PassByChan struct { - P moq.ParamIndexing - } - PassByEllipsis struct { - P moq.ParamIndexing - } - PassByMap struct { - P moq.ParamIndexing - } - PassByReference struct { - P moq.ParamIndexing - } - PassBySlice struct { - P moq.ParamIndexing - } - PassByValue struct { - P moq.ParamIndexing - } - InterfaceParam struct { - W moq.ParamIndexing - } - InterfaceResult struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - FnParam struct { - Fn moq.ParamIndexing - } - Other struct { - Param1 moq.ParamIndexing - } + Moq: &MoqUsual_mock{}, + + Moq_Usual: impl.NewMoq[ + *MoqUsual_Usual_adaptor, + MoqUsual_Usual_params, + MoqUsual_Usual_paramsKey, + MoqUsual_Usual_results, + ](scene, adaptor1, config), + Moq_NoNames: impl.NewMoq[ + *MoqUsual_NoNames_adaptor, + MoqUsual_NoNames_params, + MoqUsual_NoNames_paramsKey, + MoqUsual_NoNames_results, + ](scene, adaptor2, config), + Moq_NoResults: impl.NewMoq[ + *MoqUsual_NoResults_adaptor, + MoqUsual_NoResults_params, + MoqUsual_NoResults_paramsKey, + MoqUsual_NoResults_results, + ](scene, adaptor3, config), + Moq_NoParams: impl.NewMoq[ + *MoqUsual_NoParams_adaptor, + MoqUsual_NoParams_params, + MoqUsual_NoParams_paramsKey, + MoqUsual_NoParams_results, + ](scene, adaptor4, config), + Moq_Nothing: impl.NewMoq[ + *MoqUsual_Nothing_adaptor, + MoqUsual_Nothing_params, + MoqUsual_Nothing_paramsKey, + MoqUsual_Nothing_results, + ](scene, adaptor5, config), + Moq_Variadic: impl.NewMoq[ + *MoqUsual_Variadic_adaptor, + MoqUsual_Variadic_params, + MoqUsual_Variadic_paramsKey, + MoqUsual_Variadic_results, + ](scene, adaptor6, config), + Moq_RepeatedIds: impl.NewMoq[ + *MoqUsual_RepeatedIds_adaptor, + MoqUsual_RepeatedIds_params, + MoqUsual_RepeatedIds_paramsKey, + MoqUsual_RepeatedIds_results, + ](scene, adaptor7, config), + Moq_Times: impl.NewMoq[ + *MoqUsual_Times_adaptor, + MoqUsual_Times_params, + MoqUsual_Times_paramsKey, + MoqUsual_Times_results, + ](scene, adaptor8, config), + Moq_DifficultParamNames: impl.NewMoq[ + *MoqUsual_DifficultParamNames_adaptor, + MoqUsual_DifficultParamNames_params, + MoqUsual_DifficultParamNames_paramsKey, + MoqUsual_DifficultParamNames_results, + ](scene, adaptor9, config), + Moq_DifficultResultNames: impl.NewMoq[ + *MoqUsual_DifficultResultNames_adaptor, + MoqUsual_DifficultResultNames_params, + MoqUsual_DifficultResultNames_paramsKey, + MoqUsual_DifficultResultNames_results, + ](scene, adaptor10, config), + Moq_PassByArray: impl.NewMoq[ + *MoqUsual_PassByArray_adaptor, + MoqUsual_PassByArray_params, + MoqUsual_PassByArray_paramsKey, + MoqUsual_PassByArray_results, + ](scene, adaptor11, config), + Moq_PassByChan: impl.NewMoq[ + *MoqUsual_PassByChan_adaptor, + MoqUsual_PassByChan_params, + MoqUsual_PassByChan_paramsKey, + MoqUsual_PassByChan_results, + ](scene, adaptor12, config), + Moq_PassByEllipsis: impl.NewMoq[ + *MoqUsual_PassByEllipsis_adaptor, + MoqUsual_PassByEllipsis_params, + MoqUsual_PassByEllipsis_paramsKey, + MoqUsual_PassByEllipsis_results, + ](scene, adaptor13, config), + Moq_PassByMap: impl.NewMoq[ + *MoqUsual_PassByMap_adaptor, + MoqUsual_PassByMap_params, + MoqUsual_PassByMap_paramsKey, + MoqUsual_PassByMap_results, + ](scene, adaptor14, config), + Moq_PassByReference: impl.NewMoq[ + *MoqUsual_PassByReference_adaptor, + MoqUsual_PassByReference_params, + MoqUsual_PassByReference_paramsKey, + MoqUsual_PassByReference_results, + ](scene, adaptor15, config), + Moq_PassBySlice: impl.NewMoq[ + *MoqUsual_PassBySlice_adaptor, + MoqUsual_PassBySlice_params, + MoqUsual_PassBySlice_paramsKey, + MoqUsual_PassBySlice_results, + ](scene, adaptor16, config), + Moq_PassByValue: impl.NewMoq[ + *MoqUsual_PassByValue_adaptor, + MoqUsual_PassByValue_params, + MoqUsual_PassByValue_paramsKey, + MoqUsual_PassByValue_results, + ](scene, adaptor17, config), + Moq_InterfaceParam: impl.NewMoq[ + *MoqUsual_InterfaceParam_adaptor, + MoqUsual_InterfaceParam_params, + MoqUsual_InterfaceParam_paramsKey, + MoqUsual_InterfaceParam_results, + ](scene, adaptor18, config), + Moq_InterfaceResult: impl.NewMoq[ + *MoqUsual_InterfaceResult_adaptor, + MoqUsual_InterfaceResult_params, + MoqUsual_InterfaceResult_paramsKey, + MoqUsual_InterfaceResult_results, + ](scene, adaptor19, config), + Moq_FnParam: impl.NewMoq[ + *MoqUsual_FnParam_adaptor, + MoqUsual_FnParam_params, + MoqUsual_FnParam_paramsKey, + MoqUsual_FnParam_results, + ](scene, adaptor20, config), + Moq_Other: impl.NewMoq[ + *MoqUsual_Other_adaptor, + MoqUsual_Other_params, + MoqUsual_Other_paramsKey, + MoqUsual_Other_results, + ](scene, adaptor21, config), + + Runtime: MoqUsual_runtime{ParameterIndexing: struct { + Usual MoqUsual_Usual_paramIndexing + NoNames MoqUsual_NoNames_paramIndexing + NoResults MoqUsual_NoResults_paramIndexing + NoParams MoqUsual_NoParams_paramIndexing + Nothing MoqUsual_Nothing_paramIndexing + Variadic MoqUsual_Variadic_paramIndexing + RepeatedIds MoqUsual_RepeatedIds_paramIndexing + Times MoqUsual_Times_paramIndexing + DifficultParamNames MoqUsual_DifficultParamNames_paramIndexing + DifficultResultNames MoqUsual_DifficultResultNames_paramIndexing + PassByArray MoqUsual_PassByArray_paramIndexing + PassByChan MoqUsual_PassByChan_paramIndexing + PassByEllipsis MoqUsual_PassByEllipsis_paramIndexing + PassByMap MoqUsual_PassByMap_paramIndexing + PassByReference MoqUsual_PassByReference_paramIndexing + PassBySlice MoqUsual_PassBySlice_paramIndexing + PassByValue MoqUsual_PassByValue_paramIndexing + InterfaceParam MoqUsual_InterfaceParam_paramIndexing + InterfaceResult MoqUsual_InterfaceResult_paramIndexing + FnParam MoqUsual_FnParam_paramIndexing + Other MoqUsual_Other_paramIndexing }{ - Usual: struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - }{ + Usual: MoqUsual_Usual_paramIndexing{ SParam: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }, - NoNames: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - }{ + NoNames: MoqUsual_NoNames_paramIndexing{ Param1: moq.ParamIndexByValue, Param2: moq.ParamIndexByValue, }, - NoResults: struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - }{ + NoResults: MoqUsual_NoResults_paramIndexing{ SParam: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }, - NoParams: struct{}{}, - Nothing: struct{}{}, - Variadic: struct { - Other moq.ParamIndexing - Args moq.ParamIndexing - }{ + NoParams: MoqUsual_NoParams_paramIndexing{}, + Nothing: MoqUsual_Nothing_paramIndexing{}, + Variadic: MoqUsual_Variadic_paramIndexing{ Other: moq.ParamIndexByValue, Args: moq.ParamIndexByHash, }, - RepeatedIds: struct { - SParam1 moq.ParamIndexing - SParam2 moq.ParamIndexing - BParam moq.ParamIndexing - }{ + RepeatedIds: MoqUsual_RepeatedIds_paramIndexing{ SParam1: moq.ParamIndexByValue, SParam2: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }, - Times: struct { - SParam moq.ParamIndexing - Times moq.ParamIndexing - }{ + Times: MoqUsual_Times_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 - }{ + DifficultParamNames: MoqUsual_DifficultParamNames_paramIndexing{ Param1: moq.ParamIndexByValue, Param2: moq.ParamIndexByValue, Param3: moq.ParamIndexByValue, @@ -11818,68 +7204,67 @@ func NewMoqUsual(scene *moq.Scene, config *moq.Config) *MoqUsual { Param8: moq.ParamIndexByValue, Param9: moq.ParamIndexByValue, }, - DifficultResultNames: struct{}{}, - PassByArray: struct { - P moq.ParamIndexing - }{ + DifficultResultNames: MoqUsual_DifficultResultNames_paramIndexing{}, + PassByArray: MoqUsual_PassByArray_paramIndexing{ P: moq.ParamIndexByValue, }, - PassByChan: struct { - P moq.ParamIndexing - }{ + PassByChan: MoqUsual_PassByChan_paramIndexing{ P: moq.ParamIndexByValue, }, - PassByEllipsis: struct { - P moq.ParamIndexing - }{ + PassByEllipsis: MoqUsual_PassByEllipsis_paramIndexing{ P: moq.ParamIndexByHash, }, - PassByMap: struct { - P moq.ParamIndexing - }{ + PassByMap: MoqUsual_PassByMap_paramIndexing{ P: moq.ParamIndexByHash, }, - PassByReference: struct { - P moq.ParamIndexing - }{ + PassByReference: MoqUsual_PassByReference_paramIndexing{ P: moq.ParamIndexByHash, }, - PassBySlice: struct { - P moq.ParamIndexing - }{ + PassBySlice: MoqUsual_PassBySlice_paramIndexing{ P: moq.ParamIndexByHash, }, - PassByValue: struct { - P moq.ParamIndexing - }{ + PassByValue: MoqUsual_PassByValue_paramIndexing{ P: moq.ParamIndexByValue, }, - InterfaceParam: struct { - W moq.ParamIndexing - }{ + InterfaceParam: MoqUsual_InterfaceParam_paramIndexing{ W: moq.ParamIndexByHash, }, - InterfaceResult: struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - }{ + InterfaceResult: MoqUsual_InterfaceResult_paramIndexing{ SParam: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }, - FnParam: struct { - Fn moq.ParamIndexing - }{ + FnParam: MoqUsual_FnParam_paramIndexing{ Fn: moq.ParamIndexByHash, }, - Other: struct { - Param1 moq.ParamIndexing - }{ + Other: MoqUsual_Other_paramIndexing{ Param1: moq.ParamIndexByValue, }, }}, } m.Moq.Moq = m + adaptor1.Moq = m + adaptor2.Moq = m + adaptor3.Moq = m + adaptor4.Moq = m + adaptor5.Moq = m + adaptor6.Moq = m + adaptor7.Moq = m + adaptor8.Moq = m + adaptor9.Moq = m + adaptor10.Moq = m + adaptor11.Moq = m + adaptor12.Moq = m + adaptor13.Moq = m + adaptor14.Moq = m + adaptor15.Moq = m + adaptor16.Moq = m + adaptor17.Moq = m + adaptor18.Moq = m + adaptor19.Moq = m + adaptor20.Moq = m + adaptor21.Moq = m + scene.AddMoq(m) return m } @@ -11887,436 +7272,121 @@ func NewMoqUsual(scene *moq.Scene, config *moq.Config) *MoqUsual { // 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() +func (m *MoqUsual_mock) Usual(sParam string, bParam bool) (string, error) { + m.Moq.Moq_Usual.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 + var result1 string + var result2 error + if result := m.Moq.Moq_Usual.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn(sParam, bParam) - } - return + return result1, result2 } -func (m *MoqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, result2 error) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) NoNames(param1 string, param2 bool) (string, error) { + m.Moq.Moq_NoNames.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) + var result1 string + var result2 error + if result := m.Moq.Moq_NoNames.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } - - if result.Values != nil { - result1 = result.Values.Result1 - result2 = result.Values.Result2 - } - if result.DoReturnFn != nil { - result1, result2 = result.DoReturnFn(param1, param2) - } - return + return result1, result2 } func (m *MoqUsual_mock) NoResults(sParam string, bParam bool) { - m.Moq.Scene.T.Helper() + m.Moq.Moq_NoResults.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 + m.Moq.Moq_NoResults.Function(params) } -func (m *MoqUsual_mock) NoParams() (sResult string, err error) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) NoParams() (string, error) { + m.Moq.Moq_NoParams.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() + var result1 string + var result2 error + if result := m.Moq.Moq_NoParams.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } - - if result.Values != nil { - sResult = result.Values.SResult - err = result.Values.Err - } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn() - } - return + return result1, result2 } func (m *MoqUsual_mock) Nothing() { - m.Moq.Scene.T.Helper() + m.Moq.Moq_Nothing.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 + m.Moq.Moq_Nothing.Function(params) } -func (m *MoqUsual_mock) Variadic(other bool, args ...string) (sResult string, err error) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) Variadic(other bool, args ...string) (string, error) { + m.Moq.Moq_Variadic.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 + var result1 string + var result2 error + if result := m.Moq.Moq_Variadic.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } - - 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 + return result1, result2 } -func (m *MoqUsual_mock) RepeatedIds(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) RepeatedIds(sParam1, sParam2 string, bParam bool) (string, string, error) { + m.Moq.Moq_RepeatedIds.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) + var result1 string + var result2 string + var result3 error + if result := m.Moq.Moq_RepeatedIds.Function(params); result != nil { + result1 = result.SResult1 + result2 = result.SResult2 + result3 = result.Err } - - 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 + return result1, result2, result3 } -func (m *MoqUsual_mock) Times(sParam string, times bool) (sResult string, err error) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) Times(sParam string, times bool) (string, error) { + m.Moq.Moq_Times.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) + var result1 string + var result2 error + if result := m.Moq.Moq_Times.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } - return + return result1, result2 } func (m *MoqUsual_mock) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) { - m.Moq.Scene.T.Helper() + m.Moq.Moq_DifficultParamNames.Scene.T.Helper() params := MoqUsual_DifficultParamNames_params{ Param1: param1, Param2: param2, @@ -12328,691 +7398,179 @@ func (m *MoqUsual_mock) DifficultParamNames(param1, param2 bool, param3 string, 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 + m.Moq.Moq_DifficultParamNames.Function(params) } -func (m *MoqUsual_mock) DifficultResultNames() (result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) DifficultResultNames() (string, string, error, int, int, int, float32, float32, float32) { + m.Moq.Moq_DifficultResultNames.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) PassByArray(p [3]testmoqs.Params) (result1 [3]testmoqs.Results) { - m.Moq.Scene.T.Helper() + var result1 string + var result2 string + var result3 error + var result4 int + var result5 int + var result6 int + var result7 float32 + var result8 float32 + var result9 float32 + if result := m.Moq.Moq_DifficultResultNames.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 + result3 = result.Result3 + result4 = result.Param + result5 = result.Result5 + result6 = result.Result6 + result7 = result.Result7 + result8 = result.Result8 + result9 = result.Result9 + } + return result1, result2, result3, result4, result5, result6, result7, result8, result9 +} + +func (m *MoqUsual_mock) PassByArray(p [3]testmoqs.Params) [3]testmoqs.Results { + m.Moq.Moq_PassByArray.Scene.T.Helper() params := MoqUsual_PassByArray_params{ P: p, } - var results *MoqUsual_PassByArray_results - for _, resultsByParams := range m.Moq.ResultsByParams_PassByArray { - paramsKey := m.Moq.ParamsKey_PassByArray(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_PassByArray(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_PassByArray(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_PassByArray(params)) - } - } - - if result.DoFn != nil { - result.DoFn(p) - } - if result.Values != nil { - result1 = result.Values.Result1 + var result1 [3]testmoqs.Results + if result := m.Moq.Moq_PassByArray.Function(params); result != nil { + result1 = result.Result1 } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) - } - return + return result1 } -func (m *MoqUsual_mock) PassByChan(p chan testmoqs.Params) (result1 chan testmoqs.Results) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) PassByChan(p chan testmoqs.Params) chan testmoqs.Results { + m.Moq.Moq_PassByChan.Scene.T.Helper() params := MoqUsual_PassByChan_params{ P: p, } - var results *MoqUsual_PassByChan_results - for _, resultsByParams := range m.Moq.ResultsByParams_PassByChan { - paramsKey := m.Moq.ParamsKey_PassByChan(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_PassByChan(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_PassByChan(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_PassByChan(params)) - } - } - - if result.DoFn != nil { - result.DoFn(p) - } - if result.Values != nil { - result1 = result.Values.Result1 + var result1 chan testmoqs.Results + if result := m.Moq.Moq_PassByChan.Function(params); result != nil { + result1 = result.Result1 } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) - } - return + return result1 } -func (m *MoqUsual_mock) PassByEllipsis(p ...testmoqs.Params) (result1 string, result2 error) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) PassByEllipsis(p ...testmoqs.Params) (string, error) { + m.Moq.Moq_PassByEllipsis.Scene.T.Helper() params := MoqUsual_PassByEllipsis_params{ P: p, } - var results *MoqUsual_PassByEllipsis_results - for _, resultsByParams := range m.Moq.ResultsByParams_PassByEllipsis { - paramsKey := m.Moq.ParamsKey_PassByEllipsis(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_PassByEllipsis(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_PassByEllipsis(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_PassByEllipsis(params)) - } - } - if result.DoFn != nil { - result.DoFn(p...) + var result1 string + var result2 error + if result := m.Moq.Moq_PassByEllipsis.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } - - if result.Values != nil { - result1 = result.Values.Result1 - result2 = result.Values.Result2 - } - if result.DoReturnFn != nil { - result1, result2 = result.DoReturnFn(p...) - } - return + return result1, result2 } -func (m *MoqUsual_mock) PassByMap(p map[string]testmoqs.Params) (result1 map[string]testmoqs.Results) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) PassByMap(p map[string]testmoqs.Params) map[string]testmoqs.Results { + m.Moq.Moq_PassByMap.Scene.T.Helper() params := MoqUsual_PassByMap_params{ P: p, } - var results *MoqUsual_PassByMap_results - for _, resultsByParams := range m.Moq.ResultsByParams_PassByMap { - paramsKey := m.Moq.ParamsKey_PassByMap(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_PassByMap(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_PassByMap(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_PassByMap(params)) - } - } - - if result.DoFn != nil { - result.DoFn(p) - } - - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) + var result1 map[string]testmoqs.Results + if result := m.Moq.Moq_PassByMap.Function(params); result != nil { + result1 = result.Result1 } - return + return result1 } -func (m *MoqUsual_mock) PassByReference(p *testmoqs.Params) (result1 *testmoqs.Results) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) PassByReference(p *testmoqs.Params) *testmoqs.Results { + m.Moq.Moq_PassByReference.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 + var result1 *testmoqs.Results + if result := m.Moq.Moq_PassByReference.Function(params); result != nil { + result1 = result.Result1 } - - 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 { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) - } - return + return result1 } -func (m *MoqUsual_mock) PassBySlice(p []testmoqs.Params) (result1 []testmoqs.Results) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) PassBySlice(p []testmoqs.Params) []testmoqs.Results { + m.Moq.Moq_PassBySlice.Scene.T.Helper() params := MoqUsual_PassBySlice_params{ P: p, } - var results *MoqUsual_PassBySlice_results - for _, resultsByParams := range m.Moq.ResultsByParams_PassBySlice { - paramsKey := m.Moq.ParamsKey_PassBySlice(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_PassBySlice(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_PassBySlice(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_PassBySlice(params)) - } - } - - if result.DoFn != nil { - result.DoFn(p) - } - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) + var result1 []testmoqs.Results + if result := m.Moq.Moq_PassBySlice.Function(params); result != nil { + result1 = result.Result1 } - return + return result1 } -func (m *MoqUsual_mock) PassByValue(p testmoqs.Params) (result1 testmoqs.Results) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) PassByValue(p testmoqs.Params) testmoqs.Results { + m.Moq.Moq_PassByValue.Scene.T.Helper() params := MoqUsual_PassByValue_params{ P: p, } - var results *MoqUsual_PassByValue_results - for _, resultsByParams := range m.Moq.ResultsByParams_PassByValue { - paramsKey := m.Moq.ParamsKey_PassByValue(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_PassByValue(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_PassByValue(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_PassByValue(params)) - } - } - - if result.DoFn != nil { - result.DoFn(p) - } - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(p) + var result1 testmoqs.Results + if result := m.Moq.Moq_PassByValue.Function(params); result != nil { + result1 = result.Result1 } - return + return result1 } -func (m *MoqUsual_mock) InterfaceParam(w io.Writer) (sResult string, err error) { - m.Moq.Scene.T.Helper() +func (m *MoqUsual_mock) InterfaceParam(w io.Writer) (string, error) { + m.Moq.Moq_InterfaceParam.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 -} - -func (m *MoqUsual_mock) Other(param1 other.Params) (result1 other.Results) { - m.Moq.Scene.T.Helper() - params := MoqUsual_Other_params{ - Param1: param1, - } - var results *MoqUsual_Other_results - for _, resultsByParams := range m.Moq.ResultsByParams_Other { - paramsKey := m.Moq.ParamsKey_Other(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_Other(params)) - } - return + var result1 string + var result2 error + if result := m.Moq.Moq_InterfaceParam.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } + return result1, result2 +} - 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_Other(params)) - } - return - } - i = results.Repeat.ResultCount - 1 +func (m *MoqUsual_mock) InterfaceResult(sParam string, bParam bool) io.Reader { + m.Moq.Moq_InterfaceResult.Scene.T.Helper() + params := MoqUsual_InterfaceResult_params{ + SParam: sParam, + BParam: bParam, } - 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_Other(params)) - } + var result1 io.Reader + if result := m.Moq.Moq_InterfaceResult.Function(params); result != nil { + result1 = result.Result1 } + return result1 +} - if result.DoFn != nil { - result.DoFn(param1) +func (m *MoqUsual_mock) FnParam(fn func()) { + m.Moq.Moq_FnParam.Scene.T.Helper() + params := MoqUsual_FnParam_params{ + Fn: fn, } - if result.Values != nil { - result1 = result.Values.Result1 + m.Moq.Moq_FnParam.Function(params) +} + +func (m *MoqUsual_mock) Other(param1 other.Params) other.Results { + m.Moq.Moq_Other.Scene.T.Helper() + params := MoqUsual_Other_params{ + Param1: param1, } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(param1) + + var result1 other.Results + if result := m.Moq.Moq_Other.Function(params); result != nil { + result1 = result.Result1 } - return + return result1 } // OnCall returns the recorder implementation of the Usual type @@ -13022,219 +7580,98 @@ func (m *MoqUsual) OnCall() *MoqUsual_recorder { } } -func (m *MoqUsual_recorder) Usual(sParam string, bParam bool) *MoqUsual_Usual_fnRecorder { - return &MoqUsual_Usual_fnRecorder{ - Params: MoqUsual_Usual_params{ +func (m *MoqUsual_recorder) Usual(sParam string, bParam bool) *MoqUsual_Usual_recorder { + return &MoqUsual_Usual_recorder{ + Recorder: m.Moq.Moq_Usual.OnCall(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)) +func (r *MoqUsual_Usual_recorder) Any() *MoqUsual_Usual_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_Usual_anyParams{Recorder: r} } -func (a *MoqUsual_Usual_anyParams) SParam() *MoqUsual_Usual_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_Usual_anyParams) SParam() *MoqUsual_Usual_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqUsual_Usual_anyParams) BParam() *MoqUsual_Usual_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqUsual_Usual_anyParams) BParam() *MoqUsual_Usual_recorder { + a.Recorder.Recorder.AnyParam(2) 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)) +func (r *MoqUsual_Usual_recorder) Seq() *MoqUsual_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { 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)) +func (r *MoqUsual_Usual_recorder) NoSeq() *MoqUsual_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { 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, +func (r *MoqUsual_Usual_recorder) ReturnResults(sResult string, err error) *MoqUsual_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_Usual_results{ + SResult: sResult, + Err: err, }) 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") +func (r *MoqUsual_Usual_recorder) AndDo(fn MoqUsual_Usual_doFn) *MoqUsual_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_Usual_params) { + fn(params.SParam, params.BParam) + }, true) { 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 +func (r *MoqUsual_Usual_recorder) DoReturnResults(fn MoqUsual_Usual_doReturnFn) *MoqUsual_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_Usual_params) *MoqUsual_Usual_results { + sResult, err := fn(params.SParam, params.BParam) + return &MoqUsual_Usual_results{ + SResult: sResult, + Err: err, } - 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) +func (r *MoqUsual_Usual_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqUsual) PrettyParams_Usual(params MoqUsual_Usual_params) string { +func (*MoqUsual_Usual_adaptor) PrettyParams(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) - } - } +func (a *MoqUsual_Usual_adaptor) ParamsKey(params MoqUsual_Usual_params, anyParams uint64) MoqUsual_Usual_paramsKey { + a.Moq.Moq_Usual.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.SParam, 1, a.Moq.Runtime.ParameterIndexing.Usual.SParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 2, a.Moq.Runtime.ParameterIndexing.Usual.BParam, anyParams) return MoqUsual_Usual_paramsKey{ Params: struct { SParam string @@ -13253,219 +7690,98 @@ func (m *MoqUsual) ParamsKey_Usual(params MoqUsual_Usual_params, anyParams uint6 } } -func (m *MoqUsual_recorder) NoNames(param1 string, param2 bool) *MoqUsual_NoNames_fnRecorder { - return &MoqUsual_NoNames_fnRecorder{ - Params: MoqUsual_NoNames_params{ +func (m *MoqUsual_recorder) NoNames(param1 string, param2 bool) *MoqUsual_NoNames_recorder { + return &MoqUsual_NoNames_recorder{ + Recorder: m.Moq.Moq_NoNames.OnCall(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)) +func (r *MoqUsual_NoNames_recorder) Any() *MoqUsual_NoNames_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_NoNames_anyParams{Recorder: r} } -func (a *MoqUsual_NoNames_anyParams) Param1() *MoqUsual_NoNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_NoNames_anyParams) Param1() *MoqUsual_NoNames_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqUsual_NoNames_anyParams) Param2() *MoqUsual_NoNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqUsual_NoNames_anyParams) Param2() *MoqUsual_NoNames_recorder { + a.Recorder.Recorder.AnyParam(2) 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)) +func (r *MoqUsual_NoNames_recorder) Seq() *MoqUsual_NoNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { 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)) +func (r *MoqUsual_NoNames_recorder) NoSeq() *MoqUsual_NoNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { 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, +func (r *MoqUsual_NoNames_recorder) ReturnResults(result1 string, result2 error) *MoqUsual_NoNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_NoNames_results{ + Result1: result1, + Result2: result2, }) 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") +func (r *MoqUsual_NoNames_recorder) AndDo(fn MoqUsual_NoNames_doFn) *MoqUsual_NoNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_NoNames_params) { + fn(params.Param1, params.Param2) + }, true) { 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 +func (r *MoqUsual_NoNames_recorder) DoReturnResults(fn MoqUsual_NoNames_doReturnFn) *MoqUsual_NoNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_NoNames_params) *MoqUsual_NoNames_results { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqUsual_NoNames_results{ + Result1: result1, + Result2: result2, } - 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) +func (r *MoqUsual_NoNames_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_NoNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqUsual) PrettyParams_NoNames(params MoqUsual_NoNames_params) string { +func (*MoqUsual_NoNames_adaptor) PrettyParams(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) - } - } +func (a *MoqUsual_NoNames_adaptor) ParamsKey(params MoqUsual_NoNames_params, anyParams uint64) MoqUsual_NoNames_paramsKey { + a.Moq.Moq_NoNames.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.NoNames.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.NoNames.Param2, anyParams) return MoqUsual_NoNames_paramsKey{ Params: struct { Param1 string @@ -13484,204 +7800,92 @@ func (m *MoqUsual) ParamsKey_NoNames(params MoqUsual_NoNames_params, anyParams u } } -func (m *MoqUsual_recorder) NoResults(sParam string, bParam bool) *MoqUsual_NoResults_fnRecorder { - return &MoqUsual_NoResults_fnRecorder{ - Params: MoqUsual_NoResults_params{ +func (m *MoqUsual_recorder) NoResults(sParam string, bParam bool) *MoqUsual_NoResults_recorder { + return &MoqUsual_NoResults_recorder{ + Recorder: m.Moq.Moq_NoResults.OnCall(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)) +func (r *MoqUsual_NoResults_recorder) Any() *MoqUsual_NoResults_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_NoResults_anyParams{Recorder: r} } -func (a *MoqUsual_NoResults_anyParams) SParam() *MoqUsual_NoResults_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_NoResults_anyParams) SParam() *MoqUsual_NoResults_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqUsual_NoResults_anyParams) BParam() *MoqUsual_NoResults_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqUsual_NoResults_anyParams) BParam() *MoqUsual_NoResults_recorder { + a.Recorder.Recorder.AnyParam(2) 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)) +func (r *MoqUsual_NoResults_recorder) Seq() *MoqUsual_NoResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { 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)) +func (r *MoqUsual_NoResults_recorder) NoSeq() *MoqUsual_NoResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { 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, - }) +func (r *MoqUsual_NoResults_recorder) ReturnResults() *MoqUsual_NoResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_NoResults_results{}) 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") +func (r *MoqUsual_NoResults_recorder) AndDo(fn MoqUsual_NoResults_doFn) *MoqUsual_NoResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_NoResults_params) { + fn(params.SParam, params.BParam) + }, true) { 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}) +func (r *MoqUsual_NoResults_recorder) DoReturnResults(fn MoqUsual_NoResults_doReturnFn) *MoqUsual_NoResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_NoResults_params) *MoqUsual_NoResults_results { + fn(params.SParam, params.BParam) + return &MoqUsual_NoResults_results{} + }) 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") +func (r *MoqUsual_NoResults_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_NoResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 { +func (*MoqUsual_NoResults_adaptor) PrettyParams(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) - } - } +func (a *MoqUsual_NoResults_adaptor) ParamsKey(params MoqUsual_NoResults_params, anyParams uint64) MoqUsual_NoResults_paramsKey { + a.Moq.Moq_NoResults.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.SParam, 1, a.Moq.Runtime.ParameterIndexing.NoResults.SParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 2, a.Moq.Runtime.ParameterIndexing.NoResults.BParam, anyParams) return MoqUsual_NoResults_paramsKey{ Params: struct { SParam string @@ -13700,578 +7904,254 @@ func (m *MoqUsual) ParamsKey_NoResults(params MoqUsual_NoResults_params, anyPara } } -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 (m *MoqUsual_recorder) NoParams() *MoqUsual_NoParams_recorder { + return &MoqUsual_NoParams_recorder{ + Recorder: m.Moq.Moq_NoParams.OnCall(MoqUsual_NoParams_params{}), } } -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)) +func (r *MoqUsual_NoParams_recorder) Any() *MoqUsual_NoParams_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { 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)) +func (r *MoqUsual_NoParams_recorder) Seq() *MoqUsual_NoParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { 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)) +func (r *MoqUsual_NoParams_recorder) NoSeq() *MoqUsual_NoParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { 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, +func (r *MoqUsual_NoParams_recorder) ReturnResults(sResult string, err error) *MoqUsual_NoParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_NoParams_results{ + SResult: sResult, + Err: err, }) 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") +func (r *MoqUsual_NoParams_recorder) AndDo(fn MoqUsual_NoParams_doFn) *MoqUsual_NoParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_NoParams_params) { + fn() + }, true) { 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 +func (r *MoqUsual_NoParams_recorder) DoReturnResults(fn MoqUsual_NoParams_doReturnFn) *MoqUsual_NoParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_NoParams_params) *MoqUsual_NoParams_results { + sResult, err := fn() + return &MoqUsual_NoParams_results{ + SResult: sResult, + Err: err, } - 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) +func (r *MoqUsual_NoParams_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_NoParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqUsual) PrettyParams_NoParams(params MoqUsual_NoParams_params) string { +func (*MoqUsual_NoParams_adaptor) PrettyParams(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() +func (a *MoqUsual_NoParams_adaptor) ParamsKey(params MoqUsual_NoParams_params, anyParams uint64) MoqUsual_NoParams_paramsKey { + a.Moq.Moq_NoParams.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 (m *MoqUsual_recorder) Nothing() *MoqUsual_Nothing_recorder { + return &MoqUsual_Nothing_recorder{ + Recorder: m.Moq.Moq_Nothing.OnCall(MoqUsual_Nothing_params{}), } } -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)) +func (r *MoqUsual_Nothing_recorder) Any() *MoqUsual_Nothing_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { 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)) +func (r *MoqUsual_Nothing_recorder) Seq() *MoqUsual_Nothing_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { 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)) +func (r *MoqUsual_Nothing_recorder) NoSeq() *MoqUsual_Nothing_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { 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, - }) +func (r *MoqUsual_Nothing_recorder) ReturnResults() *MoqUsual_Nothing_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_Nothing_results{}) 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") +func (r *MoqUsual_Nothing_recorder) AndDo(fn MoqUsual_Nothing_doFn) *MoqUsual_Nothing_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_Nothing_params) { + fn() + }, true) { 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}) +func (r *MoqUsual_Nothing_recorder) DoReturnResults(fn MoqUsual_Nothing_doReturnFn) *MoqUsual_Nothing_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_Nothing_params) *MoqUsual_Nothing_results { + fn() + return &MoqUsual_Nothing_results{} + }) 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") +func (r *MoqUsual_Nothing_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Nothing_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 { +func (*MoqUsual_Nothing_adaptor) PrettyParams(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() +func (a *MoqUsual_Nothing_adaptor) ParamsKey(params MoqUsual_Nothing_params, anyParams uint64) MoqUsual_Nothing_paramsKey { + a.Moq.Moq_Nothing.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{ +func (m *MoqUsual_recorder) Variadic(other bool, args ...string) *MoqUsual_Variadic_recorder { + return &MoqUsual_Variadic_recorder{ + Recorder: m.Moq.Moq_Variadic.OnCall(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)) +func (r *MoqUsual_Variadic_recorder) Any() *MoqUsual_Variadic_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_Variadic_anyParams{Recorder: r} } -func (a *MoqUsual_Variadic_anyParams) Other() *MoqUsual_Variadic_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_Variadic_anyParams) Other() *MoqUsual_Variadic_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqUsual_Variadic_anyParams) Args() *MoqUsual_Variadic_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqUsual_Variadic_anyParams) Args() *MoqUsual_Variadic_recorder { + a.Recorder.Recorder.AnyParam(2) 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)) +func (r *MoqUsual_Variadic_recorder) Seq() *MoqUsual_Variadic_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { 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)) +func (r *MoqUsual_Variadic_recorder) NoSeq() *MoqUsual_Variadic_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { 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, +func (r *MoqUsual_Variadic_recorder) ReturnResults(sResult string, err error) *MoqUsual_Variadic_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_Variadic_results{ + SResult: sResult, + Err: err, }) 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") +func (r *MoqUsual_Variadic_recorder) AndDo(fn MoqUsual_Variadic_doFn) *MoqUsual_Variadic_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_Variadic_params) { + fn(params.Other, params.Args...) + }, true) { 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 +func (r *MoqUsual_Variadic_recorder) DoReturnResults(fn MoqUsual_Variadic_doReturnFn) *MoqUsual_Variadic_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_Variadic_params) *MoqUsual_Variadic_results { + sResult, err := fn(params.Other, params.Args...) + return &MoqUsual_Variadic_results{ + SResult: sResult, + Err: err, } - 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) +func (r *MoqUsual_Variadic_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Variadic_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqUsual) PrettyParams_Variadic(params MoqUsual_Variadic_params) string { +func (*MoqUsual_Variadic_adaptor) PrettyParams(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) - } +func (a *MoqUsual_Variadic_adaptor) ParamsKey(params MoqUsual_Variadic_params, anyParams uint64) MoqUsual_Variadic_paramsKey { + a.Moq.Moq_Variadic.Scene.T.Helper() + otherUsed, otherUsedHash := impl.ParamKey( + params.Other, 1, a.Moq.Runtime.ParameterIndexing.Variadic.Other, anyParams) + argsUsedHash := impl.HashOnlyParamKey(a.Moq.Moq_Variadic.Scene.T, + params.Args, "args", 2, a.Moq.Runtime.ParameterIndexing.Variadic.Args, anyParams) return MoqUsual_Variadic_paramsKey{ Params: struct{ Other bool }{ Other: otherUsed, @@ -14286,235 +8166,108 @@ func (m *MoqUsual) ParamsKey_Variadic(params MoqUsual_Variadic_params, anyParams } } -func (m *MoqUsual_recorder) RepeatedIds(sParam1, sParam2 string, bParam bool) *MoqUsual_RepeatedIds_fnRecorder { - return &MoqUsual_RepeatedIds_fnRecorder{ - Params: MoqUsual_RepeatedIds_params{ +func (m *MoqUsual_recorder) RepeatedIds(sParam1, sParam2 string, bParam bool) *MoqUsual_RepeatedIds_recorder { + return &MoqUsual_RepeatedIds_recorder{ + Recorder: m.Moq.Moq_RepeatedIds.OnCall(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)) +func (r *MoqUsual_RepeatedIds_recorder) Any() *MoqUsual_RepeatedIds_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_RepeatedIds_anyParams{Recorder: r} } -func (a *MoqUsual_RepeatedIds_anyParams) SParam1() *MoqUsual_RepeatedIds_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_RepeatedIds_anyParams) SParam1() *MoqUsual_RepeatedIds_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqUsual_RepeatedIds_anyParams) SParam2() *MoqUsual_RepeatedIds_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqUsual_RepeatedIds_anyParams) SParam2() *MoqUsual_RepeatedIds_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (a *MoqUsual_RepeatedIds_anyParams) BParam() *MoqUsual_RepeatedIds_fnRecorder { - a.Recorder.AnyParams |= 1 << 2 +func (a *MoqUsual_RepeatedIds_anyParams) BParam() *MoqUsual_RepeatedIds_recorder { + a.Recorder.Recorder.AnyParam(3) 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)) +func (r *MoqUsual_RepeatedIds_recorder) Seq() *MoqUsual_RepeatedIds_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { 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)) +func (r *MoqUsual_RepeatedIds_recorder) NoSeq() *MoqUsual_RepeatedIds_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { 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, +func (r *MoqUsual_RepeatedIds_recorder) ReturnResults(sResult1, sResult2 string, err error) *MoqUsual_RepeatedIds_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_RepeatedIds_results{ + SResult1: sResult1, + SResult2: sResult2, + Err: err, }) 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") +func (r *MoqUsual_RepeatedIds_recorder) AndDo(fn MoqUsual_RepeatedIds_doFn) *MoqUsual_RepeatedIds_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_RepeatedIds_params) { + fn(params.SParam1, params.SParam2, params.BParam) + }, true) { 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 +func (r *MoqUsual_RepeatedIds_recorder) DoReturnResults(fn MoqUsual_RepeatedIds_doReturnFn) *MoqUsual_RepeatedIds_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_RepeatedIds_params) *MoqUsual_RepeatedIds_results { + sResult1, sResult2, err := fn(params.SParam1, params.SParam2, params.BParam) + return &MoqUsual_RepeatedIds_results{ + SResult1: sResult1, + SResult2: sResult2, + Err: err, } - 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) +func (r *MoqUsual_RepeatedIds_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_RepeatedIds_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqUsual) PrettyParams_RepeatedIds(params MoqUsual_RepeatedIds_params) string { +func (*MoqUsual_RepeatedIds_adaptor) PrettyParams(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) - } - } +func (a *MoqUsual_RepeatedIds_adaptor) ParamsKey(params MoqUsual_RepeatedIds_params, anyParams uint64) MoqUsual_RepeatedIds_paramsKey { + a.Moq.Moq_RepeatedIds.Scene.T.Helper() + sParam1Used, sParam1UsedHash := impl.ParamKey( + params.SParam1, 1, a.Moq.Runtime.ParameterIndexing.RepeatedIds.SParam1, anyParams) + sParam2Used, sParam2UsedHash := impl.ParamKey( + params.SParam2, 2, a.Moq.Runtime.ParameterIndexing.RepeatedIds.SParam2, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 3, a.Moq.Runtime.ParameterIndexing.RepeatedIds.BParam, anyParams) return MoqUsual_RepeatedIds_paramsKey{ Params: struct { SParam1, SParam2 string @@ -14535,219 +8288,98 @@ func (m *MoqUsual) ParamsKey_RepeatedIds(params MoqUsual_RepeatedIds_params, any } } -func (m *MoqUsual_recorder) Times(sParam string, times bool) *MoqUsual_Times_fnRecorder { - return &MoqUsual_Times_fnRecorder{ - Params: MoqUsual_Times_params{ +func (m *MoqUsual_recorder) Times(sParam string, times bool) *MoqUsual_Times_recorder { + return &MoqUsual_Times_recorder{ + Recorder: m.Moq.Moq_Times.OnCall(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)) +func (r *MoqUsual_Times_recorder) Any() *MoqUsual_Times_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_Times_anyParams{Recorder: r} } -func (a *MoqUsual_Times_anyParams) SParam() *MoqUsual_Times_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_Times_anyParams) SParam() *MoqUsual_Times_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqUsual_Times_anyParams) Times() *MoqUsual_Times_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqUsual_Times_anyParams) Times() *MoqUsual_Times_recorder { + a.Recorder.Recorder.AnyParam(2) 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)) +func (r *MoqUsual_Times_recorder) Seq() *MoqUsual_Times_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { 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)) +func (r *MoqUsual_Times_recorder) NoSeq() *MoqUsual_Times_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { 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, +func (r *MoqUsual_Times_recorder) ReturnResults(sResult string, err error) *MoqUsual_Times_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_Times_results{ + SResult: sResult, + Err: err, }) 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") +func (r *MoqUsual_Times_recorder) AndDo(fn MoqUsual_Times_doFn) *MoqUsual_Times_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_Times_params) { + fn(params.SParam, params.Times) + }, true) { 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(), - } +func (r *MoqUsual_Times_recorder) DoReturnResults(fn MoqUsual_Times_doReturnFn) *MoqUsual_Times_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_Times_params) *MoqUsual_Times_results { + sResult, err := fn(params.SParam, params.Times) + return &MoqUsual_Times_results{ + SResult: sResult, + Err: err, } - r.Results.Results = append(r.Results.Results, last) + }) + return r +} + +func (r *MoqUsual_Times_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Times_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqUsual) PrettyParams_Times(params MoqUsual_Times_params) string { +func (*MoqUsual_Times_adaptor) PrettyParams(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) - } - } +func (a *MoqUsual_Times_adaptor) ParamsKey(params MoqUsual_Times_params, anyParams uint64) MoqUsual_Times_paramsKey { + a.Moq.Moq_Times.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.SParam, 1, a.Moq.Runtime.ParameterIndexing.Times.SParam, anyParams) + timesUsed, timesUsedHash := impl.ParamKey( + params.Times, 2, a.Moq.Runtime.ParameterIndexing.Times.Times, anyParams) return MoqUsual_Times_paramsKey{ Params: struct { SParam string @@ -14766,9 +8398,9 @@ func (m *MoqUsual) ParamsKey_Times(params MoqUsual_Times_params, anyParams uint6 } } -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{ +func (m *MoqUsual_recorder) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) *MoqUsual_DifficultParamNames_recorder { + return &MoqUsual_DifficultParamNames_recorder{ + Recorder: m.Moq.Moq_DifficultParamNames.OnCall(MoqUsual_DifficultParamNames_params{ Param1: param1, Param2: param2, Param3: param3, @@ -14778,297 +8410,136 @@ func (m *MoqUsual_recorder) DifficultParamNames(param1, param2 bool, param3 stri 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)) +func (r *MoqUsual_DifficultParamNames_recorder) Any() *MoqUsual_DifficultParamNames_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_DifficultParamNames_anyParams{Recorder: r} } -func (a *MoqUsual_DifficultParamNames_anyParams) Param1() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_DifficultParamNames_anyParams) Param1() *MoqUsual_DifficultParamNames_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqUsual_DifficultParamNames_anyParams) Param2() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqUsual_DifficultParamNames_anyParams) Param2() *MoqUsual_DifficultParamNames_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (a *MoqUsual_DifficultParamNames_anyParams) Param3() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 2 +func (a *MoqUsual_DifficultParamNames_anyParams) Param3() *MoqUsual_DifficultParamNames_recorder { + a.Recorder.Recorder.AnyParam(3) return a.Recorder } -func (a *MoqUsual_DifficultParamNames_anyParams) Param() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 3 +func (a *MoqUsual_DifficultParamNames_anyParams) Param() *MoqUsual_DifficultParamNames_recorder { + a.Recorder.Recorder.AnyParam(4) return a.Recorder } -func (a *MoqUsual_DifficultParamNames_anyParams) Param5() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 4 +func (a *MoqUsual_DifficultParamNames_anyParams) Param5() *MoqUsual_DifficultParamNames_recorder { + a.Recorder.Recorder.AnyParam(5) return a.Recorder } -func (a *MoqUsual_DifficultParamNames_anyParams) Param6() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 5 +func (a *MoqUsual_DifficultParamNames_anyParams) Param6() *MoqUsual_DifficultParamNames_recorder { + a.Recorder.Recorder.AnyParam(6) return a.Recorder } -func (a *MoqUsual_DifficultParamNames_anyParams) Param7() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 6 +func (a *MoqUsual_DifficultParamNames_anyParams) Param7() *MoqUsual_DifficultParamNames_recorder { + a.Recorder.Recorder.AnyParam(7) return a.Recorder } -func (a *MoqUsual_DifficultParamNames_anyParams) Param8() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 7 +func (a *MoqUsual_DifficultParamNames_anyParams) Param8() *MoqUsual_DifficultParamNames_recorder { + a.Recorder.Recorder.AnyParam(8) return a.Recorder } -func (a *MoqUsual_DifficultParamNames_anyParams) Param9() *MoqUsual_DifficultParamNames_fnRecorder { - a.Recorder.AnyParams |= 1 << 8 +func (a *MoqUsual_DifficultParamNames_anyParams) Param9() *MoqUsual_DifficultParamNames_recorder { + a.Recorder.Recorder.AnyParam(9) 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)) +func (r *MoqUsual_DifficultParamNames_recorder) Seq() *MoqUsual_DifficultParamNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { 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)) +func (r *MoqUsual_DifficultParamNames_recorder) NoSeq() *MoqUsual_DifficultParamNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { 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, - }) +func (r *MoqUsual_DifficultParamNames_recorder) ReturnResults() *MoqUsual_DifficultParamNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_DifficultParamNames_results{}) 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") +func (r *MoqUsual_DifficultParamNames_recorder) AndDo(fn MoqUsual_DifficultParamNames_doFn) *MoqUsual_DifficultParamNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_DifficultParamNames_params) { + fn(params.Param1, params.Param2, params.Param3, params.Param, params.Param5, params.Param6, params.Param7, params.Param8, params.Param9) + }, true) { 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}) +func (r *MoqUsual_DifficultParamNames_recorder) DoReturnResults(fn MoqUsual_DifficultParamNames_doReturnFn) *MoqUsual_DifficultParamNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_DifficultParamNames_params) *MoqUsual_DifficultParamNames_results { + fn(params.Param1, params.Param2, params.Param3, params.Param, params.Param5, params.Param6, params.Param7, params.Param8, params.Param9) + return &MoqUsual_DifficultParamNames_results{} + }) 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") +func (r *MoqUsual_DifficultParamNames_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_DifficultParamNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 { +func (*MoqUsual_DifficultParamNames_adaptor) PrettyParams(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) - } - } +func (a *MoqUsual_DifficultParamNames_adaptor) ParamsKey(params MoqUsual_DifficultParamNames_params, anyParams uint64) MoqUsual_DifficultParamNames_paramsKey { + a.Moq.Moq_DifficultParamNames.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.DifficultParamNames.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.DifficultParamNames.Param2, anyParams) + param3Used, param3UsedHash := impl.ParamKey( + params.Param3, 3, a.Moq.Runtime.ParameterIndexing.DifficultParamNames.Param3, anyParams) + paramUsed, paramUsedHash := impl.ParamKey( + params.Param, 4, a.Moq.Runtime.ParameterIndexing.DifficultParamNames.Param, anyParams) + param5Used, param5UsedHash := impl.ParamKey( + params.Param5, 5, a.Moq.Runtime.ParameterIndexing.DifficultParamNames.Param5, anyParams) + param6Used, param6UsedHash := impl.ParamKey( + params.Param6, 6, a.Moq.Runtime.ParameterIndexing.DifficultParamNames.Param6, anyParams) + param7Used, param7UsedHash := impl.ParamKey( + params.Param7, 7, a.Moq.Runtime.ParameterIndexing.DifficultParamNames.Param7, anyParams) + param8Used, param8UsedHash := impl.ParamKey( + params.Param8, 8, a.Moq.Runtime.ParameterIndexing.DifficultParamNames.Param8, anyParams) + param9Used, param9UsedHash := impl.ParamKey( + params.Param9, 9, a.Moq.Runtime.ParameterIndexing.DifficultParamNames.Param9, anyParams) return MoqUsual_DifficultParamNames_paramsKey{ Params: struct { Param1, Param2 bool @@ -15105,69 +8576,67 @@ func (m *MoqUsual) ParamsKey_DifficultParamNames(params MoqUsual_DifficultParamN } } -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 (m *MoqUsual_recorder) DifficultResultNames() *MoqUsual_DifficultResultNames_recorder { + return &MoqUsual_DifficultResultNames_recorder{ + Recorder: m.Moq.Moq_DifficultResultNames.OnCall(MoqUsual_DifficultResultNames_params{}), } } -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)) +func (r *MoqUsual_DifficultResultNames_recorder) Any() *MoqUsual_DifficultResultNames_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { 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)) +func (r *MoqUsual_DifficultResultNames_recorder) Seq() *MoqUsual_DifficultResultNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { 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)) +func (r *MoqUsual_DifficultResultNames_recorder) NoSeq() *MoqUsual_DifficultResultNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { 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() +func (r *MoqUsual_DifficultResultNames_recorder) ReturnResults(result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) *MoqUsual_DifficultResultNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_DifficultResultNames_results{ + Result1: result1, + Result2: result2, + Result3: result3, + Param: param, + Result5: result5, + Result6: result6, + Result7: result7, + Result8: result8, + Result9: result9, + }) + return r +} - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() +func (r *MoqUsual_DifficultResultNames_recorder) AndDo(fn MoqUsual_DifficultResultNames_doFn) *MoqUsual_DifficultResultNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_DifficultResultNames_params) { + fn() + }, true) { + return nil } + return r +} - 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 - }{ +func (r *MoqUsual_DifficultResultNames_recorder) DoReturnResults(fn MoqUsual_DifficultResultNames_doReturnFn) *MoqUsual_DifficultResultNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_DifficultResultNames_params) *MoqUsual_DifficultResultNames_results { + result1, result2, result3, param, result5, result6, result7, result8, result9 := fn() + return &MoqUsual_DifficultResultNames_results{ Result1: result1, Result2: result2, Result3: result3, @@ -15177,330 +8646,113 @@ func (r *MoqUsual_DifficultResultNames_fnRecorder) ReturnResults(result1, result 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") +func (r *MoqUsual_DifficultResultNames_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_DifficultResultNames_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 { +func (*MoqUsual_DifficultResultNames_adaptor) PrettyParams(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() +func (a *MoqUsual_DifficultResultNames_adaptor) ParamsKey(params MoqUsual_DifficultResultNames_params, anyParams uint64) MoqUsual_DifficultResultNames_paramsKey { + a.Moq.Moq_DifficultResultNames.Scene.T.Helper() return MoqUsual_DifficultResultNames_paramsKey{ Params: struct{}{}, Hashes: struct{}{}, } } -func (m *MoqUsual_recorder) PassByArray(p [3]testmoqs.Params) *MoqUsual_PassByArray_fnRecorder { - return &MoqUsual_PassByArray_fnRecorder{ - Params: MoqUsual_PassByArray_params{ +func (m *MoqUsual_recorder) PassByArray(p [3]testmoqs.Params) *MoqUsual_PassByArray_recorder { + return &MoqUsual_PassByArray_recorder{ + Recorder: m.Moq.Moq_PassByArray.OnCall(MoqUsual_PassByArray_params{ P: p, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqUsual_PassByArray_fnRecorder) Any() *MoqUsual_PassByArray_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_PassByArray(r.Params)) +func (r *MoqUsual_PassByArray_recorder) Any() *MoqUsual_PassByArray_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_PassByArray_anyParams{Recorder: r} } -func (a *MoqUsual_PassByArray_anyParams) P() *MoqUsual_PassByArray_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_PassByArray_anyParams) P() *MoqUsual_PassByArray_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqUsual_PassByArray_fnRecorder) Seq() *MoqUsual_PassByArray_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_PassByArray(r.Params)) +func (r *MoqUsual_PassByArray_recorder) Seq() *MoqUsual_PassByArray_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqUsual_PassByArray_fnRecorder) NoSeq() *MoqUsual_PassByArray_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_PassByArray(r.Params)) +func (r *MoqUsual_PassByArray_recorder) NoSeq() *MoqUsual_PassByArray_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUsual_PassByArray_fnRecorder) ReturnResults(result1 [3]testmoqs.Results) *MoqUsual_PassByArray_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 [3]testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByArray_doFn - DoReturnFn MoqUsual_PassByArray_doReturnFn - }{ - Values: &struct { - Result1 [3]testmoqs.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqUsual_PassByArray_recorder) ReturnResults(result1 [3]testmoqs.Results) *MoqUsual_PassByArray_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_PassByArray_results{ + Result1: result1, }) return r } -func (r *MoqUsual_PassByArray_fnRecorder) AndDo(fn MoqUsual_PassByArray_doFn) *MoqUsual_PassByArray_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqUsual_PassByArray_recorder) AndDo(fn MoqUsual_PassByArray_doFn) *MoqUsual_PassByArray_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_PassByArray_params) { + fn(params.P) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqUsual_PassByArray_fnRecorder) DoReturnResults(fn MoqUsual_PassByArray_doReturnFn) *MoqUsual_PassByArray_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 [3]testmoqs.Results +func (r *MoqUsual_PassByArray_recorder) DoReturnResults(fn MoqUsual_PassByArray_doReturnFn) *MoqUsual_PassByArray_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_PassByArray_params) *MoqUsual_PassByArray_results { + result1 := fn(params.P) + return &MoqUsual_PassByArray_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqUsual_PassByArray_doFn - DoReturnFn MoqUsual_PassByArray_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqUsual_PassByArray_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_PassByArray_resultsByParams - for n, res := range r.Moq.ResultsByParams_PassByArray { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqUsual_PassByArray_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_PassByArray_paramsKey]*MoqUsual_PassByArray_results{}, - } - r.Moq.ResultsByParams_PassByArray = append(r.Moq.ResultsByParams_PassByArray, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_PassByArray) { - copy(r.Moq.ResultsByParams_PassByArray[insertAt+1:], r.Moq.ResultsByParams_PassByArray[insertAt:0]) - r.Moq.ResultsByParams_PassByArray[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_PassByArray(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_PassByArray_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_PassByArray_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByArray_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqUsual_PassByArray_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByArray_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 [3]testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByArray_doFn - DoReturnFn MoqUsual_PassByArray_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqUsual) PrettyParams_PassByArray(params MoqUsual_PassByArray_params) string { +func (*MoqUsual_PassByArray_adaptor) PrettyParams(params MoqUsual_PassByArray_params) string { return fmt.Sprintf("PassByArray(%#v)", params.P) } -func (m *MoqUsual) ParamsKey_PassByArray(params MoqUsual_PassByArray_params, anyParams uint64) MoqUsual_PassByArray_paramsKey { - m.Scene.T.Helper() - var pUsed [3]testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.PassByArray.P == moq.ParamIndexByValue { - pUsed = params.P - } else { - pUsedHash = hash.DeepHash(params.P) - } - } +func (a *MoqUsual_PassByArray_adaptor) ParamsKey(params MoqUsual_PassByArray_params, anyParams uint64) MoqUsual_PassByArray_paramsKey { + a.Moq.Moq_PassByArray.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.P, 1, a.Moq.Runtime.ParameterIndexing.PassByArray.P, anyParams) return MoqUsual_PassByArray_paramsKey{ Params: struct{ P [3]testmoqs.Params }{ P: pUsed, @@ -15511,199 +8763,88 @@ func (m *MoqUsual) ParamsKey_PassByArray(params MoqUsual_PassByArray_params, any } } -func (m *MoqUsual_recorder) PassByChan(p chan testmoqs.Params) *MoqUsual_PassByChan_fnRecorder { - return &MoqUsual_PassByChan_fnRecorder{ - Params: MoqUsual_PassByChan_params{ +func (m *MoqUsual_recorder) PassByChan(p chan testmoqs.Params) *MoqUsual_PassByChan_recorder { + return &MoqUsual_PassByChan_recorder{ + Recorder: m.Moq.Moq_PassByChan.OnCall(MoqUsual_PassByChan_params{ P: p, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqUsual_PassByChan_fnRecorder) Any() *MoqUsual_PassByChan_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_PassByChan(r.Params)) +func (r *MoqUsual_PassByChan_recorder) Any() *MoqUsual_PassByChan_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_PassByChan_anyParams{Recorder: r} } -func (a *MoqUsual_PassByChan_anyParams) P() *MoqUsual_PassByChan_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_PassByChan_anyParams) P() *MoqUsual_PassByChan_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqUsual_PassByChan_fnRecorder) Seq() *MoqUsual_PassByChan_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_PassByChan(r.Params)) +func (r *MoqUsual_PassByChan_recorder) Seq() *MoqUsual_PassByChan_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqUsual_PassByChan_fnRecorder) NoSeq() *MoqUsual_PassByChan_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_PassByChan(r.Params)) +func (r *MoqUsual_PassByChan_recorder) NoSeq() *MoqUsual_PassByChan_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUsual_PassByChan_fnRecorder) ReturnResults(result1 chan testmoqs.Results) *MoqUsual_PassByChan_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 chan testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByChan_doFn - DoReturnFn MoqUsual_PassByChan_doReturnFn - }{ - Values: &struct { - Result1 chan testmoqs.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqUsual_PassByChan_recorder) ReturnResults(result1 chan testmoqs.Results) *MoqUsual_PassByChan_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_PassByChan_results{ + Result1: result1, }) return r } -func (r *MoqUsual_PassByChan_fnRecorder) AndDo(fn MoqUsual_PassByChan_doFn) *MoqUsual_PassByChan_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqUsual_PassByChan_recorder) AndDo(fn MoqUsual_PassByChan_doFn) *MoqUsual_PassByChan_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_PassByChan_params) { + fn(params.P) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqUsual_PassByChan_fnRecorder) DoReturnResults(fn MoqUsual_PassByChan_doReturnFn) *MoqUsual_PassByChan_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 chan testmoqs.Results +func (r *MoqUsual_PassByChan_recorder) DoReturnResults(fn MoqUsual_PassByChan_doReturnFn) *MoqUsual_PassByChan_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_PassByChan_params) *MoqUsual_PassByChan_results { + result1 := fn(params.P) + return &MoqUsual_PassByChan_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqUsual_PassByChan_doFn - DoReturnFn MoqUsual_PassByChan_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqUsual_PassByChan_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_PassByChan_resultsByParams - for n, res := range r.Moq.ResultsByParams_PassByChan { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqUsual_PassByChan_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_PassByChan_paramsKey]*MoqUsual_PassByChan_results{}, - } - r.Moq.ResultsByParams_PassByChan = append(r.Moq.ResultsByParams_PassByChan, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_PassByChan) { - copy(r.Moq.ResultsByParams_PassByChan[insertAt+1:], r.Moq.ResultsByParams_PassByChan[insertAt:0]) - r.Moq.ResultsByParams_PassByChan[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_PassByChan(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_PassByChan_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_PassByChan_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByChan_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqUsual_PassByChan_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByChan_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 chan testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByChan_doFn - DoReturnFn MoqUsual_PassByChan_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqUsual) PrettyParams_PassByChan(params MoqUsual_PassByChan_params) string { +func (*MoqUsual_PassByChan_adaptor) PrettyParams(params MoqUsual_PassByChan_params) string { return fmt.Sprintf("PassByChan(%#v)", params.P) } -func (m *MoqUsual) ParamsKey_PassByChan(params MoqUsual_PassByChan_params, anyParams uint64) MoqUsual_PassByChan_paramsKey { - m.Scene.T.Helper() - var pUsed chan testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.PassByChan.P == moq.ParamIndexByValue { - pUsed = params.P - } else { - pUsedHash = hash.DeepHash(params.P) - } - } +func (a *MoqUsual_PassByChan_adaptor) ParamsKey(params MoqUsual_PassByChan_params, anyParams uint64) MoqUsual_PassByChan_paramsKey { + a.Moq.Moq_PassByChan.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.P, 1, a.Moq.Runtime.ParameterIndexing.PassByChan.P, anyParams) return MoqUsual_PassByChan_paramsKey{ Params: struct{ P chan testmoqs.Params }{ P: pUsed, @@ -15714,202 +8855,90 @@ func (m *MoqUsual) ParamsKey_PassByChan(params MoqUsual_PassByChan_params, anyPa } } -func (m *MoqUsual_recorder) PassByEllipsis(p ...testmoqs.Params) *MoqUsual_PassByEllipsis_fnRecorder { - return &MoqUsual_PassByEllipsis_fnRecorder{ - Params: MoqUsual_PassByEllipsis_params{ +func (m *MoqUsual_recorder) PassByEllipsis(p ...testmoqs.Params) *MoqUsual_PassByEllipsis_recorder { + return &MoqUsual_PassByEllipsis_recorder{ + Recorder: m.Moq.Moq_PassByEllipsis.OnCall(MoqUsual_PassByEllipsis_params{ P: p, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqUsual_PassByEllipsis_fnRecorder) Any() *MoqUsual_PassByEllipsis_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_PassByEllipsis(r.Params)) +func (r *MoqUsual_PassByEllipsis_recorder) Any() *MoqUsual_PassByEllipsis_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_PassByEllipsis_anyParams{Recorder: r} } -func (a *MoqUsual_PassByEllipsis_anyParams) P() *MoqUsual_PassByEllipsis_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_PassByEllipsis_anyParams) P() *MoqUsual_PassByEllipsis_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqUsual_PassByEllipsis_fnRecorder) Seq() *MoqUsual_PassByEllipsis_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_PassByEllipsis(r.Params)) +func (r *MoqUsual_PassByEllipsis_recorder) Seq() *MoqUsual_PassByEllipsis_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqUsual_PassByEllipsis_fnRecorder) NoSeq() *MoqUsual_PassByEllipsis_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_PassByEllipsis(r.Params)) +func (r *MoqUsual_PassByEllipsis_recorder) NoSeq() *MoqUsual_PassByEllipsis_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUsual_PassByEllipsis_fnRecorder) ReturnResults(result1 string, result2 error) *MoqUsual_PassByEllipsis_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_PassByEllipsis_doFn - DoReturnFn MoqUsual_PassByEllipsis_doReturnFn - }{ - Values: &struct { - Result1 string - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqUsual_PassByEllipsis_recorder) ReturnResults(result1 string, result2 error) *MoqUsual_PassByEllipsis_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_PassByEllipsis_results{ + Result1: result1, + Result2: result2, }) return r } -func (r *MoqUsual_PassByEllipsis_fnRecorder) AndDo(fn MoqUsual_PassByEllipsis_doFn) *MoqUsual_PassByEllipsis_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqUsual_PassByEllipsis_recorder) AndDo(fn MoqUsual_PassByEllipsis_doFn) *MoqUsual_PassByEllipsis_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_PassByEllipsis_params) { + fn(params.P...) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqUsual_PassByEllipsis_fnRecorder) DoReturnResults(fn MoqUsual_PassByEllipsis_doReturnFn) *MoqUsual_PassByEllipsis_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 +func (r *MoqUsual_PassByEllipsis_recorder) DoReturnResults(fn MoqUsual_PassByEllipsis_doReturnFn) *MoqUsual_PassByEllipsis_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_PassByEllipsis_params) *MoqUsual_PassByEllipsis_results { + result1, result2 := fn(params.P...) + return &MoqUsual_PassByEllipsis_results{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqUsual_PassByEllipsis_doFn - DoReturnFn MoqUsual_PassByEllipsis_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqUsual_PassByEllipsis_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_PassByEllipsis_resultsByParams - for n, res := range r.Moq.ResultsByParams_PassByEllipsis { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqUsual_PassByEllipsis_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_PassByEllipsis_paramsKey]*MoqUsual_PassByEllipsis_results{}, - } - r.Moq.ResultsByParams_PassByEllipsis = append(r.Moq.ResultsByParams_PassByEllipsis, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_PassByEllipsis) { - copy(r.Moq.ResultsByParams_PassByEllipsis[insertAt+1:], r.Moq.ResultsByParams_PassByEllipsis[insertAt:0]) - r.Moq.ResultsByParams_PassByEllipsis[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_PassByEllipsis(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_PassByEllipsis_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_PassByEllipsis_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByEllipsis_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_PassByEllipsis_doFn - DoReturnFn MoqUsual_PassByEllipsis_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqUsual_PassByEllipsis_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByEllipsis_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqUsual) PrettyParams_PassByEllipsis(params MoqUsual_PassByEllipsis_params) string { +func (*MoqUsual_PassByEllipsis_adaptor) PrettyParams(params MoqUsual_PassByEllipsis_params) string { return fmt.Sprintf("PassByEllipsis(%#v)", params.P) } -func (m *MoqUsual) ParamsKey_PassByEllipsis(params MoqUsual_PassByEllipsis_params, anyParams uint64) MoqUsual_PassByEllipsis_paramsKey { - m.Scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.PassByEllipsis.P == moq.ParamIndexByValue { - m.Scene.T.Fatalf("The p parameter of the PassByEllipsis function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.P) - } +func (a *MoqUsual_PassByEllipsis_adaptor) ParamsKey(params MoqUsual_PassByEllipsis_params, anyParams uint64) MoqUsual_PassByEllipsis_paramsKey { + a.Moq.Moq_PassByEllipsis.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.Moq.Moq_PassByEllipsis.Scene.T, + params.P, "p", 1, a.Moq.Runtime.ParameterIndexing.PassByEllipsis.P, anyParams) return MoqUsual_PassByEllipsis_paramsKey{ Params: struct{}{}, Hashes: struct{ P hash.Hash }{ @@ -15918,197 +8947,88 @@ func (m *MoqUsual) ParamsKey_PassByEllipsis(params MoqUsual_PassByEllipsis_param } } -func (m *MoqUsual_recorder) PassByMap(p map[string]testmoqs.Params) *MoqUsual_PassByMap_fnRecorder { - return &MoqUsual_PassByMap_fnRecorder{ - Params: MoqUsual_PassByMap_params{ +func (m *MoqUsual_recorder) PassByMap(p map[string]testmoqs.Params) *MoqUsual_PassByMap_recorder { + return &MoqUsual_PassByMap_recorder{ + Recorder: m.Moq.Moq_PassByMap.OnCall(MoqUsual_PassByMap_params{ P: p, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqUsual_PassByMap_fnRecorder) Any() *MoqUsual_PassByMap_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_PassByMap(r.Params)) +func (r *MoqUsual_PassByMap_recorder) Any() *MoqUsual_PassByMap_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_PassByMap_anyParams{Recorder: r} } -func (a *MoqUsual_PassByMap_anyParams) P() *MoqUsual_PassByMap_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_PassByMap_anyParams) P() *MoqUsual_PassByMap_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqUsual_PassByMap_fnRecorder) Seq() *MoqUsual_PassByMap_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_PassByMap(r.Params)) +func (r *MoqUsual_PassByMap_recorder) Seq() *MoqUsual_PassByMap_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqUsual_PassByMap_fnRecorder) NoSeq() *MoqUsual_PassByMap_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_PassByMap(r.Params)) +func (r *MoqUsual_PassByMap_recorder) NoSeq() *MoqUsual_PassByMap_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUsual_PassByMap_fnRecorder) ReturnResults(result1 map[string]testmoqs.Results) *MoqUsual_PassByMap_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 map[string]testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByMap_doFn - DoReturnFn MoqUsual_PassByMap_doReturnFn - }{ - Values: &struct { - Result1 map[string]testmoqs.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqUsual_PassByMap_recorder) ReturnResults(result1 map[string]testmoqs.Results) *MoqUsual_PassByMap_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_PassByMap_results{ + Result1: result1, }) return r } -func (r *MoqUsual_PassByMap_fnRecorder) AndDo(fn MoqUsual_PassByMap_doFn) *MoqUsual_PassByMap_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqUsual_PassByMap_recorder) AndDo(fn MoqUsual_PassByMap_doFn) *MoqUsual_PassByMap_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_PassByMap_params) { + fn(params.P) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqUsual_PassByMap_fnRecorder) DoReturnResults(fn MoqUsual_PassByMap_doReturnFn) *MoqUsual_PassByMap_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 map[string]testmoqs.Results +func (r *MoqUsual_PassByMap_recorder) DoReturnResults(fn MoqUsual_PassByMap_doReturnFn) *MoqUsual_PassByMap_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_PassByMap_params) *MoqUsual_PassByMap_results { + result1 := fn(params.P) + return &MoqUsual_PassByMap_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqUsual_PassByMap_doFn - DoReturnFn MoqUsual_PassByMap_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqUsual_PassByMap_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_PassByMap_resultsByParams - for n, res := range r.Moq.ResultsByParams_PassByMap { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqUsual_PassByMap_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_PassByMap_paramsKey]*MoqUsual_PassByMap_results{}, - } - r.Moq.ResultsByParams_PassByMap = append(r.Moq.ResultsByParams_PassByMap, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_PassByMap) { - copy(r.Moq.ResultsByParams_PassByMap[insertAt+1:], r.Moq.ResultsByParams_PassByMap[insertAt:0]) - r.Moq.ResultsByParams_PassByMap[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_PassByMap(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_PassByMap_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_PassByMap_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByMap_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqUsual_PassByMap_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByMap_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 map[string]testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByMap_doFn - DoReturnFn MoqUsual_PassByMap_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqUsual) PrettyParams_PassByMap(params MoqUsual_PassByMap_params) string { +func (*MoqUsual_PassByMap_adaptor) PrettyParams(params MoqUsual_PassByMap_params) string { return fmt.Sprintf("PassByMap(%#v)", params.P) } -func (m *MoqUsual) ParamsKey_PassByMap(params MoqUsual_PassByMap_params, anyParams uint64) MoqUsual_PassByMap_paramsKey { - m.Scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.PassByMap.P == moq.ParamIndexByValue { - m.Scene.T.Fatalf("The p parameter of the PassByMap function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.P) - } +func (a *MoqUsual_PassByMap_adaptor) ParamsKey(params MoqUsual_PassByMap_params, anyParams uint64) MoqUsual_PassByMap_paramsKey { + a.Moq.Moq_PassByMap.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.Moq.Moq_PassByMap.Scene.T, + params.P, "p", 1, a.Moq.Runtime.ParameterIndexing.PassByMap.P, anyParams) return MoqUsual_PassByMap_paramsKey{ Params: struct{}{}, Hashes: struct{ P hash.Hash }{ @@ -16117,199 +9037,88 @@ func (m *MoqUsual) ParamsKey_PassByMap(params MoqUsual_PassByMap_params, anyPara } } -func (m *MoqUsual_recorder) PassByReference(p *testmoqs.Params) *MoqUsual_PassByReference_fnRecorder { - return &MoqUsual_PassByReference_fnRecorder{ - Params: MoqUsual_PassByReference_params{ +func (m *MoqUsual_recorder) PassByReference(p *testmoqs.Params) *MoqUsual_PassByReference_recorder { + return &MoqUsual_PassByReference_recorder{ + Recorder: m.Moq.Moq_PassByReference.OnCall(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)) +func (r *MoqUsual_PassByReference_recorder) Any() *MoqUsual_PassByReference_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_PassByReference_anyParams{Recorder: r} } -func (a *MoqUsual_PassByReference_anyParams) P() *MoqUsual_PassByReference_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_PassByReference_anyParams) P() *MoqUsual_PassByReference_recorder { + a.Recorder.Recorder.AnyParam(1) 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(result1 *testmoqs.Results) *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 { - Result1 *testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByReference_doFn - DoReturnFn MoqUsual_PassByReference_doReturnFn - }{ - Values: &struct { - Result1 *testmoqs.Results - }{ - Result1: result1, - }, - 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") +func (r *MoqUsual_PassByReference_recorder) Seq() *MoqUsual_PassByReference_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { 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 { - Result1 *testmoqs.Results - } - 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 +func (r *MoqUsual_PassByReference_recorder) NoSeq() *MoqUsual_PassByReference_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { + return nil } + return r +} - r.Results.Repeat.Increment(r.Moq.Scene.T) +func (r *MoqUsual_PassByReference_recorder) ReturnResults(result1 *testmoqs.Results) *MoqUsual_PassByReference_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_PassByReference_results{ + Result1: result1, + }) + return r } -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") +func (r *MoqUsual_PassByReference_recorder) AndDo(fn MoqUsual_PassByReference_doFn) *MoqUsual_PassByReference_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_PassByReference_params) { + fn(params.P) + }, true) { 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 *testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByReference_doFn - DoReturnFn MoqUsual_PassByReference_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } + return r +} + +func (r *MoqUsual_PassByReference_recorder) DoReturnResults(fn MoqUsual_PassByReference_doReturnFn) *MoqUsual_PassByReference_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_PassByReference_params) *MoqUsual_PassByReference_results { + result1 := fn(params.P) + return &MoqUsual_PassByReference_results{ + Result1: result1, } - r.Results.Results = append(r.Results.Results, last) + }) + return r +} + +func (r *MoqUsual_PassByReference_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByReference_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqUsual) PrettyParams_PassByReference(params MoqUsual_PassByReference_params) string { +func (*MoqUsual_PassByReference_adaptor) PrettyParams(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.Params - 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) - } - } +func (a *MoqUsual_PassByReference_adaptor) ParamsKey(params MoqUsual_PassByReference_params, anyParams uint64) MoqUsual_PassByReference_paramsKey { + a.Moq.Moq_PassByReference.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.P, 1, a.Moq.Runtime.ParameterIndexing.PassByReference.P, anyParams) return MoqUsual_PassByReference_paramsKey{ Params: struct{ P *testmoqs.Params }{ P: pUsed, @@ -16320,197 +9129,88 @@ func (m *MoqUsual) ParamsKey_PassByReference(params MoqUsual_PassByReference_par } } -func (m *MoqUsual_recorder) PassBySlice(p []testmoqs.Params) *MoqUsual_PassBySlice_fnRecorder { - return &MoqUsual_PassBySlice_fnRecorder{ - Params: MoqUsual_PassBySlice_params{ +func (m *MoqUsual_recorder) PassBySlice(p []testmoqs.Params) *MoqUsual_PassBySlice_recorder { + return &MoqUsual_PassBySlice_recorder{ + Recorder: m.Moq.Moq_PassBySlice.OnCall(MoqUsual_PassBySlice_params{ P: p, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqUsual_PassBySlice_fnRecorder) Any() *MoqUsual_PassBySlice_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_PassBySlice(r.Params)) +func (r *MoqUsual_PassBySlice_recorder) Any() *MoqUsual_PassBySlice_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_PassBySlice_anyParams{Recorder: r} } -func (a *MoqUsual_PassBySlice_anyParams) P() *MoqUsual_PassBySlice_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_PassBySlice_anyParams) P() *MoqUsual_PassBySlice_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqUsual_PassBySlice_fnRecorder) Seq() *MoqUsual_PassBySlice_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_PassBySlice(r.Params)) +func (r *MoqUsual_PassBySlice_recorder) Seq() *MoqUsual_PassBySlice_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqUsual_PassBySlice_fnRecorder) NoSeq() *MoqUsual_PassBySlice_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_PassBySlice(r.Params)) +func (r *MoqUsual_PassBySlice_recorder) NoSeq() *MoqUsual_PassBySlice_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUsual_PassBySlice_fnRecorder) ReturnResults(result1 []testmoqs.Results) *MoqUsual_PassBySlice_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 []testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassBySlice_doFn - DoReturnFn MoqUsual_PassBySlice_doReturnFn - }{ - Values: &struct { - Result1 []testmoqs.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqUsual_PassBySlice_recorder) ReturnResults(result1 []testmoqs.Results) *MoqUsual_PassBySlice_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_PassBySlice_results{ + Result1: result1, }) return r } -func (r *MoqUsual_PassBySlice_fnRecorder) AndDo(fn MoqUsual_PassBySlice_doFn) *MoqUsual_PassBySlice_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqUsual_PassBySlice_recorder) AndDo(fn MoqUsual_PassBySlice_doFn) *MoqUsual_PassBySlice_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_PassBySlice_params) { + fn(params.P) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqUsual_PassBySlice_fnRecorder) DoReturnResults(fn MoqUsual_PassBySlice_doReturnFn) *MoqUsual_PassBySlice_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 []testmoqs.Results +func (r *MoqUsual_PassBySlice_recorder) DoReturnResults(fn MoqUsual_PassBySlice_doReturnFn) *MoqUsual_PassBySlice_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_PassBySlice_params) *MoqUsual_PassBySlice_results { + result1 := fn(params.P) + return &MoqUsual_PassBySlice_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqUsual_PassBySlice_doFn - DoReturnFn MoqUsual_PassBySlice_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqUsual_PassBySlice_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_PassBySlice_resultsByParams - for n, res := range r.Moq.ResultsByParams_PassBySlice { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqUsual_PassBySlice_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_PassBySlice_paramsKey]*MoqUsual_PassBySlice_results{}, - } - r.Moq.ResultsByParams_PassBySlice = append(r.Moq.ResultsByParams_PassBySlice, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_PassBySlice) { - copy(r.Moq.ResultsByParams_PassBySlice[insertAt+1:], r.Moq.ResultsByParams_PassBySlice[insertAt:0]) - r.Moq.ResultsByParams_PassBySlice[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_PassBySlice(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_PassBySlice_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_PassBySlice_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassBySlice_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqUsual_PassBySlice_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassBySlice_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 []testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassBySlice_doFn - DoReturnFn MoqUsual_PassBySlice_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqUsual) PrettyParams_PassBySlice(params MoqUsual_PassBySlice_params) string { +func (*MoqUsual_PassBySlice_adaptor) PrettyParams(params MoqUsual_PassBySlice_params) string { return fmt.Sprintf("PassBySlice(%#v)", params.P) } -func (m *MoqUsual) ParamsKey_PassBySlice(params MoqUsual_PassBySlice_params, anyParams uint64) MoqUsual_PassBySlice_paramsKey { - m.Scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.PassBySlice.P == moq.ParamIndexByValue { - m.Scene.T.Fatalf("The p parameter of the PassBySlice function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.P) - } +func (a *MoqUsual_PassBySlice_adaptor) ParamsKey(params MoqUsual_PassBySlice_params, anyParams uint64) MoqUsual_PassBySlice_paramsKey { + a.Moq.Moq_PassBySlice.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.Moq.Moq_PassBySlice.Scene.T, + params.P, "p", 1, a.Moq.Runtime.ParameterIndexing.PassBySlice.P, anyParams) return MoqUsual_PassBySlice_paramsKey{ Params: struct{}{}, Hashes: struct{ P hash.Hash }{ @@ -16519,199 +9219,88 @@ func (m *MoqUsual) ParamsKey_PassBySlice(params MoqUsual_PassBySlice_params, any } } -func (m *MoqUsual_recorder) PassByValue(p testmoqs.Params) *MoqUsual_PassByValue_fnRecorder { - return &MoqUsual_PassByValue_fnRecorder{ - Params: MoqUsual_PassByValue_params{ +func (m *MoqUsual_recorder) PassByValue(p testmoqs.Params) *MoqUsual_PassByValue_recorder { + return &MoqUsual_PassByValue_recorder{ + Recorder: m.Moq.Moq_PassByValue.OnCall(MoqUsual_PassByValue_params{ P: p, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqUsual_PassByValue_fnRecorder) Any() *MoqUsual_PassByValue_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_PassByValue(r.Params)) +func (r *MoqUsual_PassByValue_recorder) Any() *MoqUsual_PassByValue_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_PassByValue_anyParams{Recorder: r} } -func (a *MoqUsual_PassByValue_anyParams) P() *MoqUsual_PassByValue_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_PassByValue_anyParams) P() *MoqUsual_PassByValue_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqUsual_PassByValue_fnRecorder) Seq() *MoqUsual_PassByValue_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_PassByValue(r.Params)) +func (r *MoqUsual_PassByValue_recorder) Seq() *MoqUsual_PassByValue_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqUsual_PassByValue_fnRecorder) NoSeq() *MoqUsual_PassByValue_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_PassByValue(r.Params)) +func (r *MoqUsual_PassByValue_recorder) NoSeq() *MoqUsual_PassByValue_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUsual_PassByValue_fnRecorder) ReturnResults(result1 testmoqs.Results) *MoqUsual_PassByValue_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 testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByValue_doFn - DoReturnFn MoqUsual_PassByValue_doReturnFn - }{ - Values: &struct { - Result1 testmoqs.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqUsual_PassByValue_recorder) ReturnResults(result1 testmoqs.Results) *MoqUsual_PassByValue_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_PassByValue_results{ + Result1: result1, }) return r } -func (r *MoqUsual_PassByValue_fnRecorder) AndDo(fn MoqUsual_PassByValue_doFn) *MoqUsual_PassByValue_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqUsual_PassByValue_recorder) AndDo(fn MoqUsual_PassByValue_doFn) *MoqUsual_PassByValue_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_PassByValue_params) { + fn(params.P) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqUsual_PassByValue_fnRecorder) DoReturnResults(fn MoqUsual_PassByValue_doReturnFn) *MoqUsual_PassByValue_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 testmoqs.Results +func (r *MoqUsual_PassByValue_recorder) DoReturnResults(fn MoqUsual_PassByValue_doReturnFn) *MoqUsual_PassByValue_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_PassByValue_params) *MoqUsual_PassByValue_results { + result1 := fn(params.P) + return &MoqUsual_PassByValue_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqUsual_PassByValue_doFn - DoReturnFn MoqUsual_PassByValue_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqUsual_PassByValue_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_PassByValue_resultsByParams - for n, res := range r.Moq.ResultsByParams_PassByValue { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqUsual_PassByValue_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_PassByValue_paramsKey]*MoqUsual_PassByValue_results{}, - } - r.Moq.ResultsByParams_PassByValue = append(r.Moq.ResultsByParams_PassByValue, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_PassByValue) { - copy(r.Moq.ResultsByParams_PassByValue[insertAt+1:], r.Moq.ResultsByParams_PassByValue[insertAt:0]) - r.Moq.ResultsByParams_PassByValue[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_PassByValue(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_PassByValue_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_PassByValue_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByValue_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqUsual_PassByValue_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_PassByValue_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 testmoqs.Results - } - Sequence uint32 - DoFn MoqUsual_PassByValue_doFn - DoReturnFn MoqUsual_PassByValue_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqUsual) PrettyParams_PassByValue(params MoqUsual_PassByValue_params) string { +func (*MoqUsual_PassByValue_adaptor) PrettyParams(params MoqUsual_PassByValue_params) string { return fmt.Sprintf("PassByValue(%#v)", params.P) } -func (m *MoqUsual) ParamsKey_PassByValue(params MoqUsual_PassByValue_params, anyParams uint64) MoqUsual_PassByValue_paramsKey { - m.Scene.T.Helper() - var pUsed testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.PassByValue.P == moq.ParamIndexByValue { - pUsed = params.P - } else { - pUsedHash = hash.DeepHash(params.P) - } - } +func (a *MoqUsual_PassByValue_adaptor) ParamsKey(params MoqUsual_PassByValue_params, anyParams uint64) MoqUsual_PassByValue_paramsKey { + a.Moq.Moq_PassByValue.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.P, 1, a.Moq.Runtime.ParameterIndexing.PassByValue.P, anyParams) return MoqUsual_PassByValue_paramsKey{ Params: struct{ P testmoqs.Params }{ P: pUsed, @@ -16722,204 +9311,90 @@ func (m *MoqUsual) ParamsKey_PassByValue(params MoqUsual_PassByValue_params, any } } -func (m *MoqUsual_recorder) InterfaceParam(w io.Writer) *MoqUsual_InterfaceParam_fnRecorder { - return &MoqUsual_InterfaceParam_fnRecorder{ - Params: MoqUsual_InterfaceParam_params{ +func (m *MoqUsual_recorder) InterfaceParam(w io.Writer) *MoqUsual_InterfaceParam_recorder { + return &MoqUsual_InterfaceParam_recorder{ + Recorder: m.Moq.Moq_InterfaceParam.OnCall(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_InterfaceParam(r.Params)) +func (r *MoqUsual_InterfaceParam_recorder) Any() *MoqUsual_InterfaceParam_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_InterfaceParam_anyParams{Recorder: r} } -func (a *MoqUsual_InterfaceParam_anyParams) W() *MoqUsual_InterfaceParam_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_InterfaceParam_anyParams) W() *MoqUsual_InterfaceParam_recorder { + a.Recorder.Recorder.AnyParam(1) 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_InterfaceParam(r.Params)) +func (r *MoqUsual_InterfaceParam_recorder) Seq() *MoqUsual_InterfaceParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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_InterfaceParam(r.Params)) +func (r *MoqUsual_InterfaceParam_recorder) NoSeq() *MoqUsual_InterfaceParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUsual_InterfaceParam_fnRecorder) ReturnResults(sResult string, err error) *MoqUsual_InterfaceParam_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_InterfaceParam_doFn - DoReturnFn MoqUsual_InterfaceParam_doReturnFn - }{ - Values: &struct { - SResult string - Err error - }{ - SResult: sResult, - Err: err, - }, - Sequence: sequence, +func (r *MoqUsual_InterfaceParam_recorder) ReturnResults(sResult string, err error) *MoqUsual_InterfaceParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_InterfaceParam_results{ + SResult: sResult, + Err: err, }) return r } -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") +func (r *MoqUsual_InterfaceParam_recorder) AndDo(fn MoqUsual_InterfaceParam_doFn) *MoqUsual_InterfaceParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_InterfaceParam_params) { + fn(params.W) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqUsual_InterfaceParam_fnRecorder) DoReturnResults(fn MoqUsual_InterfaceParam_doReturnFn) *MoqUsual_InterfaceParam_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 +func (r *MoqUsual_InterfaceParam_recorder) DoReturnResults(fn MoqUsual_InterfaceParam_doReturnFn) *MoqUsual_InterfaceParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_InterfaceParam_params) *MoqUsual_InterfaceParam_results { + sResult, err := fn(params.W) + return &MoqUsual_InterfaceParam_results{ + SResult: sResult, + Err: err, } - Sequence uint32 - DoFn MoqUsual_InterfaceParam_doFn - DoReturnFn MoqUsual_InterfaceParam_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqUsual_InterfaceParam_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_InterfaceParam_resultsByParams - for n, res := range r.Moq.ResultsByParams_InterfaceParam { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqUsual_InterfaceParam_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_InterfaceParam_paramsKey]*MoqUsual_InterfaceParam_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_InterfaceParam(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_InterfaceParam_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_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") - 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_InterfaceParam_doFn - DoReturnFn MoqUsual_InterfaceParam_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqUsual_InterfaceParam_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_InterfaceParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqUsual) PrettyParams_InterfaceParam(params MoqUsual_InterfaceParam_params) string { +func (*MoqUsual_InterfaceParam_adaptor) PrettyParams(params MoqUsual_InterfaceParam_params) string { return fmt.Sprintf("InterfaceParam(%#v)", params.W) } -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) - } - } +func (a *MoqUsual_InterfaceParam_adaptor) ParamsKey(params MoqUsual_InterfaceParam_params, anyParams uint64) MoqUsual_InterfaceParam_paramsKey { + a.Moq.Moq_InterfaceParam.Scene.T.Helper() + wUsed, wUsedHash := impl.ParamKey( + params.W, 1, a.Moq.Runtime.ParameterIndexing.InterfaceParam.W, anyParams) return MoqUsual_InterfaceParam_paramsKey{ Params: struct{ W io.Writer }{ W: wUsed, @@ -16930,206 +9405,96 @@ func (m *MoqUsual) ParamsKey_InterfaceParam(params MoqUsual_InterfaceParam_param } } -func (m *MoqUsual_recorder) InterfaceResult(sParam string, bParam bool) *MoqUsual_InterfaceResult_fnRecorder { - return &MoqUsual_InterfaceResult_fnRecorder{ - Params: MoqUsual_InterfaceResult_params{ +func (m *MoqUsual_recorder) InterfaceResult(sParam string, bParam bool) *MoqUsual_InterfaceResult_recorder { + return &MoqUsual_InterfaceResult_recorder{ + Recorder: m.Moq.Moq_InterfaceResult.OnCall(MoqUsual_InterfaceResult_params{ SParam: sParam, BParam: bParam, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -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_InterfaceResult(r.Params)) +func (r *MoqUsual_InterfaceResult_recorder) Any() *MoqUsual_InterfaceResult_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_InterfaceResult_anyParams{Recorder: r} } -func (a *MoqUsual_InterfaceResult_anyParams) SParam() *MoqUsual_InterfaceResult_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_InterfaceResult_anyParams) SParam() *MoqUsual_InterfaceResult_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqUsual_InterfaceResult_anyParams) BParam() *MoqUsual_InterfaceResult_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqUsual_InterfaceResult_anyParams) BParam() *MoqUsual_InterfaceResult_recorder { + a.Recorder.Recorder.AnyParam(2) 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_InterfaceResult(r.Params)) +func (r *MoqUsual_InterfaceResult_recorder) Seq() *MoqUsual_InterfaceResult_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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_InterfaceResult(r.Params)) +func (r *MoqUsual_InterfaceResult_recorder) NoSeq() *MoqUsual_InterfaceResult_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUsual_InterfaceResult_fnRecorder) ReturnResults(result1 io.Reader) *MoqUsual_InterfaceResult_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 io.Reader } - Sequence uint32 - DoFn MoqUsual_InterfaceResult_doFn - DoReturnFn MoqUsual_InterfaceResult_doReturnFn - }{ - Values: &struct{ Result1 io.Reader }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqUsual_InterfaceResult_recorder) ReturnResults(result1 io.Reader) *MoqUsual_InterfaceResult_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_InterfaceResult_results{ + Result1: result1, }) return r } -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") +func (r *MoqUsual_InterfaceResult_recorder) AndDo(fn MoqUsual_InterfaceResult_doFn) *MoqUsual_InterfaceResult_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_InterfaceResult_params) { + fn(params.SParam, params.BParam) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn - return r -} - -func (r *MoqUsual_InterfaceResult_fnRecorder) DoReturnResults(fn MoqUsual_InterfaceResult_doReturnFn) *MoqUsual_InterfaceResult_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 io.Reader } - Sequence uint32 - DoFn MoqUsual_InterfaceResult_doFn - DoReturnFn MoqUsual_InterfaceResult_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqUsual_InterfaceResult_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_InterfaceResult_resultsByParams - for n, res := range r.Moq.ResultsByParams_InterfaceResult { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqUsual_InterfaceResult_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_InterfaceResult_paramsKey]*MoqUsual_InterfaceResult_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_InterfaceResult(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_InterfaceResult_results{ - Params: r.Params, - Results: nil, - Index: 0, - Repeat: &moq.RepeatVal{}, +func (r *MoqUsual_InterfaceResult_recorder) DoReturnResults(fn MoqUsual_InterfaceResult_doReturnFn) *MoqUsual_InterfaceResult_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_InterfaceResult_params) *MoqUsual_InterfaceResult_results { + result1 := fn(params.SParam, params.BParam) + return &MoqUsual_InterfaceResult_results{ + Result1: result1, } - results.Results[paramsKey] = r.Results - } - - r.Results.Repeat.Increment(r.Moq.Scene.T) + }) + return r } -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") +func (r *MoqUsual_InterfaceResult_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_InterfaceResult_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 io.Reader } - Sequence uint32 - DoFn MoqUsual_InterfaceResult_doFn - DoReturnFn MoqUsual_InterfaceResult_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqUsual) PrettyParams_InterfaceResult(params MoqUsual_InterfaceResult_params) string { +func (*MoqUsual_InterfaceResult_adaptor) PrettyParams(params MoqUsual_InterfaceResult_params) string { return fmt.Sprintf("InterfaceResult(%#v, %#v)", params.SParam, params.BParam) } -func (m *MoqUsual) ParamsKey_InterfaceResult(params MoqUsual_InterfaceResult_params, anyParams uint64) MoqUsual_InterfaceResult_paramsKey { - m.Scene.T.Helper() - 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) - } - } +func (a *MoqUsual_InterfaceResult_adaptor) ParamsKey(params MoqUsual_InterfaceResult_params, anyParams uint64) MoqUsual_InterfaceResult_paramsKey { + a.Moq.Moq_InterfaceResult.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.SParam, 1, a.Moq.Runtime.ParameterIndexing.InterfaceResult.SParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 2, a.Moq.Runtime.ParameterIndexing.InterfaceResult.BParam, anyParams) return MoqUsual_InterfaceResult_paramsKey{ Params: struct { SParam string @@ -17148,187 +9513,84 @@ func (m *MoqUsual) ParamsKey_InterfaceResult(params MoqUsual_InterfaceResult_par } } -func (m *MoqUsual_recorder) FnParam(fn func()) *MoqUsual_FnParam_fnRecorder { - return &MoqUsual_FnParam_fnRecorder{ - Params: MoqUsual_FnParam_params{ +func (m *MoqUsual_recorder) FnParam(fn func()) *MoqUsual_FnParam_recorder { + return &MoqUsual_FnParam_recorder{ + Recorder: m.Moq.Moq_FnParam.OnCall(MoqUsual_FnParam_params{ Fn: fn, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -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_FnParam(r.Params)) +func (r *MoqUsual_FnParam_recorder) Any() *MoqUsual_FnParam_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_FnParam_anyParams{Recorder: r} } -func (a *MoqUsual_FnParam_anyParams) Fn() *MoqUsual_FnParam_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_FnParam_anyParams) Fn() *MoqUsual_FnParam_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -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_FnParam(r.Params)) +func (r *MoqUsual_FnParam_recorder) Seq() *MoqUsual_FnParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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_FnParam(r.Params)) +func (r *MoqUsual_FnParam_recorder) NoSeq() *MoqUsual_FnParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUsual_FnParam_fnRecorder) ReturnResults() *MoqUsual_FnParam_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_FnParam_doFn - DoReturnFn MoqUsual_FnParam_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqUsual_FnParam_recorder) ReturnResults() *MoqUsual_FnParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_FnParam_results{}) return r } -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") +func (r *MoqUsual_FnParam_recorder) AndDo(fn MoqUsual_FnParam_doFn) *MoqUsual_FnParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_FnParam_params) { + fn(params.Fn) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqUsual_FnParam_fnRecorder) DoReturnResults(fn MoqUsual_FnParam_doReturnFn) *MoqUsual_FnParam_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_FnParam_doFn - DoReturnFn MoqUsual_FnParam_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqUsual_FnParam_recorder) DoReturnResults(fn MoqUsual_FnParam_doReturnFn) *MoqUsual_FnParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_FnParam_params) *MoqUsual_FnParam_results { + fn(params.Fn) + return &MoqUsual_FnParam_results{} + }) return r } -func (r *MoqUsual_FnParam_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_FnParam_resultsByParams - for n, res := range r.Moq.ResultsByParams_FnParam { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqUsual_FnParam_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_FnParam_paramsKey]*MoqUsual_FnParam_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_FnParam(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_FnParam_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_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") +func (r *MoqUsual_FnParam_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_FnParam_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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_FnParam_doFn - DoReturnFn MoqUsual_FnParam_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqUsual) PrettyParams_FnParam(params MoqUsual_FnParam_params) string { +func (*MoqUsual_FnParam_adaptor) PrettyParams(params MoqUsual_FnParam_params) string { return fmt.Sprintf("FnParam(%#v)", moq.FnString(params.Fn)) } -func (m *MoqUsual) ParamsKey_FnParam(params MoqUsual_FnParam_params, anyParams uint64) MoqUsual_FnParam_paramsKey { - m.Scene.T.Helper() - var fnUsedHash 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") - } - fnUsedHash = hash.DeepHash(params.Fn) - } +func (a *MoqUsual_FnParam_adaptor) ParamsKey(params MoqUsual_FnParam_params, anyParams uint64) MoqUsual_FnParam_paramsKey { + a.Moq.Moq_FnParam.Scene.T.Helper() + fnUsedHash := impl.HashOnlyParamKey(a.Moq.Moq_FnParam.Scene.T, + params.Fn, "fn", 1, a.Moq.Runtime.ParameterIndexing.FnParam.Fn, anyParams) return MoqUsual_FnParam_paramsKey{ Params: struct{}{}, Hashes: struct{ Fn hash.Hash }{ @@ -17337,199 +9599,88 @@ func (m *MoqUsual) ParamsKey_FnParam(params MoqUsual_FnParam_params, anyParams u } } -func (m *MoqUsual_recorder) Other(param1 other.Params) *MoqUsual_Other_fnRecorder { - return &MoqUsual_Other_fnRecorder{ - Params: MoqUsual_Other_params{ +func (m *MoqUsual_recorder) Other(param1 other.Params) *MoqUsual_Other_recorder { + return &MoqUsual_Other_recorder{ + Recorder: m.Moq.Moq_Other.OnCall(MoqUsual_Other_params{ Param1: param1, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqUsual_Other_fnRecorder) Any() *MoqUsual_Other_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_Other(r.Params)) +func (r *MoqUsual_Other_recorder) Any() *MoqUsual_Other_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUsual_Other_anyParams{Recorder: r} } -func (a *MoqUsual_Other_anyParams) Param1() *MoqUsual_Other_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqUsual_Other_anyParams) Param1() *MoqUsual_Other_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqUsual_Other_fnRecorder) Seq() *MoqUsual_Other_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_Other(r.Params)) +func (r *MoqUsual_Other_recorder) Seq() *MoqUsual_Other_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqUsual_Other_fnRecorder) NoSeq() *MoqUsual_Other_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_Other(r.Params)) +func (r *MoqUsual_Other_recorder) NoSeq() *MoqUsual_Other_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUsual_Other_fnRecorder) ReturnResults(result1 other.Results) *MoqUsual_Other_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 other.Results - } - Sequence uint32 - DoFn MoqUsual_Other_doFn - DoReturnFn MoqUsual_Other_doReturnFn - }{ - Values: &struct { - Result1 other.Results - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqUsual_Other_recorder) ReturnResults(result1 other.Results) *MoqUsual_Other_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUsual_Other_results{ + Result1: result1, }) return r } -func (r *MoqUsual_Other_fnRecorder) AndDo(fn MoqUsual_Other_doFn) *MoqUsual_Other_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqUsual_Other_recorder) AndDo(fn MoqUsual_Other_doFn) *MoqUsual_Other_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUsual_Other_params) { + fn(params.Param1) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqUsual_Other_fnRecorder) DoReturnResults(fn MoqUsual_Other_doReturnFn) *MoqUsual_Other_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 other.Results +func (r *MoqUsual_Other_recorder) DoReturnResults(fn MoqUsual_Other_doReturnFn) *MoqUsual_Other_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUsual_Other_params) *MoqUsual_Other_results { + result1 := fn(params.Param1) + return &MoqUsual_Other_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqUsual_Other_doFn - DoReturnFn MoqUsual_Other_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqUsual_Other_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_Other_resultsByParams - for n, res := range r.Moq.ResultsByParams_Other { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqUsual_Other_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUsual_Other_paramsKey]*MoqUsual_Other_results{}, - } - r.Moq.ResultsByParams_Other = append(r.Moq.ResultsByParams_Other, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Other) { - copy(r.Moq.ResultsByParams_Other[insertAt+1:], r.Moq.ResultsByParams_Other[insertAt:0]) - r.Moq.ResultsByParams_Other[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_Other(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUsual_Other_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_Other_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Other_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqUsual_Other_recorder) Repeat(repeaters ...moq.Repeater) *MoqUsual_Other_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 other.Results - } - Sequence uint32 - DoFn MoqUsual_Other_doFn - DoReturnFn MoqUsual_Other_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqUsual) PrettyParams_Other(params MoqUsual_Other_params) string { +func (*MoqUsual_Other_adaptor) PrettyParams(params MoqUsual_Other_params) string { return fmt.Sprintf("Other(%#v)", params.Param1) } -func (m *MoqUsual) ParamsKey_Other(params MoqUsual_Other_params, anyParams uint64) MoqUsual_Other_paramsKey { - m.Scene.T.Helper() - var param1Used other.Params - var param1UsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.Other.Param1 == moq.ParamIndexByValue { - param1Used = params.Param1 - } else { - param1UsedHash = hash.DeepHash(params.Param1) - } - } +func (a *MoqUsual_Other_adaptor) ParamsKey(params MoqUsual_Other_params, anyParams uint64) MoqUsual_Other_paramsKey { + a.Moq.Moq_Other.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.Other.Param1, anyParams) return MoqUsual_Other_paramsKey{ Params: struct{ Param1 other.Params }{ Param1: param1Used, @@ -17542,200 +9693,53 @@ func (m *MoqUsual) ParamsKey_Other(params MoqUsual_Other_params, anyParams uint6 // 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_PassByArray = nil - m.ResultsByParams_PassByChan = nil - m.ResultsByParams_PassByEllipsis = nil - m.ResultsByParams_PassByMap = nil - m.ResultsByParams_PassByReference = nil - m.ResultsByParams_PassBySlice = nil - m.ResultsByParams_PassByValue = nil - m.ResultsByParams_InterfaceParam = nil - m.ResultsByParams_InterfaceResult = nil - m.ResultsByParams_FnParam = nil - m.ResultsByParams_Other = nil + m.Moq_Usual.Reset() + m.Moq_NoNames.Reset() + m.Moq_NoResults.Reset() + m.Moq_NoParams.Reset() + m.Moq_Nothing.Reset() + m.Moq_Variadic.Reset() + m.Moq_RepeatedIds.Reset() + m.Moq_Times.Reset() + m.Moq_DifficultParamNames.Reset() + m.Moq_DifficultResultNames.Reset() + m.Moq_PassByArray.Reset() + m.Moq_PassByChan.Reset() + m.Moq_PassByEllipsis.Reset() + m.Moq_PassByMap.Reset() + m.Moq_PassByReference.Reset() + m.Moq_PassBySlice.Reset() + m.Moq_PassByValue.Reset() + m.Moq_InterfaceParam.Reset() + m.Moq_InterfaceResult.Reset() + m.Moq_FnParam.Reset() + m.Moq_Other.Reset() } // 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)) - } - } - } - 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_PassByArray { - 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_PassByArray(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_PassByChan { - 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_PassByChan(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_PassByEllipsis { - 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_PassByEllipsis(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_PassByMap { - 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_PassByMap(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_PassBySlice { - 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_PassBySlice(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_PassByValue { - 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_PassByValue(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)) - } - } - } - for _, res := range m.ResultsByParams_Other { - 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_Other(results.Params)) - } - } - } + m.Moq_Usual.Scene.T.Helper() + m.Moq_Usual.AssertExpectationsMet() + m.Moq_NoNames.AssertExpectationsMet() + m.Moq_NoResults.AssertExpectationsMet() + m.Moq_NoParams.AssertExpectationsMet() + m.Moq_Nothing.AssertExpectationsMet() + m.Moq_Variadic.AssertExpectationsMet() + m.Moq_RepeatedIds.AssertExpectationsMet() + m.Moq_Times.AssertExpectationsMet() + m.Moq_DifficultParamNames.AssertExpectationsMet() + m.Moq_DifficultResultNames.AssertExpectationsMet() + m.Moq_PassByArray.AssertExpectationsMet() + m.Moq_PassByChan.AssertExpectationsMet() + m.Moq_PassByEllipsis.AssertExpectationsMet() + m.Moq_PassByMap.AssertExpectationsMet() + m.Moq_PassByReference.AssertExpectationsMet() + m.Moq_PassBySlice.AssertExpectationsMet() + m.Moq_PassByValue.AssertExpectationsMet() + m.Moq_InterfaceParam.AssertExpectationsMet() + m.Moq_InterfaceResult.AssertExpectationsMet() + m.Moq_FnParam.AssertExpectationsMet() + m.Moq_Other.AssertExpectationsMet() } // The following type assertion assures that testmoqs.GenericParams is mocked @@ -17744,23 +9748,18 @@ var _ testmoqs.GenericParams[any, any] = (*MoqGenericParams_mock[any, any])(nil) // 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] - - 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 + Moq *MoqGenericParams_mock[S, B] + + Moq_Usual *impl.Moq[ + *MoqGenericParams_Usual_adaptor[S, B], + MoqGenericParams_Usual_params[S, B], + MoqGenericParams_Usual_paramsKey[S, B], + MoqGenericParams_Usual_results[S, B]] + + Runtime MoqGenericParams_runtime } +// MoqGenericParams_mock isolates the mock interface of the GenericParams type type MoqGenericParams_mock[S, B any] struct { Moq *MoqGenericParams[S, B] } @@ -17771,6 +9770,20 @@ type MoqGenericParams_recorder[S, B any] struct { Moq *MoqGenericParams[S, B] } +// MoqGenericParams_runtime holds runtime configuration for the GenericParams +// type +type MoqGenericParams_runtime struct { + ParameterIndexing struct { + Usual MoqGenericParams_Usual_paramIndexing + } +} + +// MoqGenericParams_Usual_adaptor adapts MoqGenericParams as needed by the +// runtime +type MoqGenericParams_Usual_adaptor[S, B any] struct { + Moq *MoqGenericParams[S, B] +} + // MoqGenericParams_Usual_params holds the params of the GenericParams type type MoqGenericParams_Usual_params[S, B any] struct { Param1 S @@ -17787,12 +9800,17 @@ type MoqGenericParams_Usual_paramsKey[S, B any] 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_results holds the results of the GenericParams type +type MoqGenericParams_Usual_results[S, B any] struct { + Result1 string + Result2 error +} + +// MoqGenericParams_Usual_paramIndexing holds the parameter indexing runtime +// configuration for the GenericParams type +type MoqGenericParams_Usual_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqGenericParams_Usual_doFn defines the type of function needed when calling @@ -17803,65 +9821,38 @@ type MoqGenericParams_Usual_doFn[S, B any] func(S, B) // 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 { - Result1 string - Result2 error - } - Sequence uint32 - DoFn MoqGenericParams_Usual_doFn[S, B] - DoReturnFn MoqGenericParams_Usual_doReturnFn[S, B] - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqGenericParams_Usual_fnRecorder routes recorded function calls to the +// MoqGenericParams_Usual_recorder 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] +type MoqGenericParams_Usual_recorder[S, B any] struct { + Recorder *impl.Recorder[ + *MoqGenericParams_Usual_adaptor[S, B], + MoqGenericParams_Usual_params[S, B], + MoqGenericParams_Usual_paramsKey[S, B], + MoqGenericParams_Usual_results[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] + Recorder *MoqGenericParams_Usual_recorder[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{} - } + adaptor1 := &MoqGenericParams_Usual_adaptor[S, B]{} m := &MoqGenericParams[S, B]{ - Scene: scene, - Config: *config, - Moq: &MoqGenericParams_mock[S, B]{}, - - Runtime: struct { - ParameterIndexing struct { - Usual struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - } - }{ParameterIndexing: struct { - Usual struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } + Moq: &MoqGenericParams_mock[S, B]{}, + + Moq_Usual: impl.NewMoq[ + *MoqGenericParams_Usual_adaptor[S, B], + MoqGenericParams_Usual_params[S, B], + MoqGenericParams_Usual_paramsKey[S, B], + MoqGenericParams_Usual_results[S, B]](scene, adaptor1, config), + + Runtime: MoqGenericParams_runtime{ParameterIndexing: struct { + Usual MoqGenericParams_Usual_paramIndexing }{ - Usual: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - }{ + Usual: MoqGenericParams_Usual_paramIndexing{ Param1: moq.ParamIndexByHash, Param2: moq.ParamIndexByHash, }, @@ -17869,6 +9860,8 @@ func NewMoqGenericParams[S, B any](scene *moq.Scene, config *moq.Config) *MoqGen } m.Moq.Moq = m + adaptor1.Moq = m + scene.AddMoq(m) return m } @@ -17876,59 +9869,20 @@ func NewMoqGenericParams[S, B any](scene *moq.Scene, config *moq.Config) *MoqGen // 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() +func (m *MoqGenericParams_mock[S, B]) Usual(param1 S, param2 B) (string, error) { + m.Moq.Moq_Usual.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 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) + var result1 string + var result2 error + if result := m.Moq.Moq_Usual.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } - return + return result1, result2 } // OnCall returns the recorder implementation of the GenericParams type @@ -17938,215 +9892,98 @@ func (m *MoqGenericParams[S, B]) OnCall() *MoqGenericParams_recorder[S, B] { } } -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]{ +func (m *MoqGenericParams_recorder[S, B]) Usual(param1 S, param2 B) *MoqGenericParams_Usual_recorder[S, B] { + return &MoqGenericParams_Usual_recorder[S, B]{ + Recorder: m.Moq.Moq_Usual.OnCall(MoqGenericParams_Usual_params[S, B]{ Param1: param1, Param2: param2, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -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_Usual(r.Params)) +func (r *MoqGenericParams_Usual_recorder[S, B]) Any() *MoqGenericParams_Usual_anyParams[S, B] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqGenericParams_Usual_anyParams[S, B]{Recorder: r} } -func (a *MoqGenericParams_Usual_anyParams[S, B]) Param1() *MoqGenericParams_Usual_fnRecorder[S, B] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqGenericParams_Usual_anyParams[S, B]) Param1() *MoqGenericParams_Usual_recorder[S, B] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqGenericParams_Usual_anyParams[S, B]) Param2() *MoqGenericParams_Usual_fnRecorder[S, B] { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqGenericParams_Usual_anyParams[S, B]) Param2() *MoqGenericParams_Usual_recorder[S, B] { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -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_Usual(r.Params)) +func (r *MoqGenericParams_Usual_recorder[S, B]) Seq() *MoqGenericParams_Usual_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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_Usual(r.Params)) +func (r *MoqGenericParams_Usual_recorder[S, B]) NoSeq() *MoqGenericParams_Usual_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqGenericParams_Usual_fnRecorder[S, B]) ReturnResults(result1 string, result2 error) *MoqGenericParams_Usual_fnRecorder[S, B] { - 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 MoqGenericParams_Usual_doFn[S, B] - DoReturnFn MoqGenericParams_Usual_doReturnFn[S, B] - }{ - Values: &struct { - Result1 string - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqGenericParams_Usual_recorder[S, B]) ReturnResults(result1 string, result2 error) *MoqGenericParams_Usual_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqGenericParams_Usual_results[S, B]{ + Result1: result1, + Result2: result2, }) return r } -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") +func (r *MoqGenericParams_Usual_recorder[S, B]) AndDo(fn MoqGenericParams_Usual_doFn[S, B]) *MoqGenericParams_Usual_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqGenericParams_Usual_params[S, B]) { + fn(params.Param1, params.Param2) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -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() - - 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 +func (r *MoqGenericParams_Usual_recorder[S, B]) DoReturnResults(fn MoqGenericParams_Usual_doReturnFn[S, B]) *MoqGenericParams_Usual_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqGenericParams_Usual_params[S, B]) *MoqGenericParams_Usual_results[S, B] { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqGenericParams_Usual_results[S, B]{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqGenericParams_Usual_doFn[S, B] - DoReturnFn MoqGenericParams_Usual_doReturnFn[S, B] - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -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) - return - } - - anyCount := bits.OnesCount64(r.AnyParams) - insertAt := -1 - var results *MoqGenericParams_Usual_resultsByParams[S, B] - 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 = &MoqGenericParams_Usual_resultsByParams[S, B]{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqGenericParams_Usual_paramsKey[S, B]]*MoqGenericParams_Usual_results[S, B]{}, - } - 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 = &MoqGenericParams_Usual_results[S, B]{ - 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 *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") - 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 MoqGenericParams_Usual_doFn[S, B] - DoReturnFn MoqGenericParams_Usual_doReturnFn[S, B] - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqGenericParams_Usual_recorder[S, B]) Repeat(repeaters ...moq.Repeater) *MoqGenericParams_Usual_recorder[S, B] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqGenericParams[S, B]) PrettyParams_Usual(params MoqGenericParams_Usual_params[S, B]) string { +func (*MoqGenericParams_Usual_adaptor[S, B]) PrettyParams(params MoqGenericParams_Usual_params[S, B]) string { return fmt.Sprintf("Usual(%#v, %#v)", params.Param1, params.Param2) } -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 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 param2UsedHash hash.Hash - if anyParams&(1<<1) == 0 { - 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) - } +func (a *MoqGenericParams_Usual_adaptor[S, B]) ParamsKey(params MoqGenericParams_Usual_params[S, B], anyParams uint64) MoqGenericParams_Usual_paramsKey[S, B] { + a.Moq.Moq_Usual.Scene.T.Helper() + param1UsedHash := impl.HashOnlyParamKey(a.Moq.Moq_Usual.Scene.T, + params.Param1, "param1", 1, a.Moq.Runtime.ParameterIndexing.Usual.Param1, anyParams) + param2UsedHash := impl.HashOnlyParamKey(a.Moq.Moq_Usual.Scene.T, + params.Param2, "param2", 2, a.Moq.Runtime.ParameterIndexing.Usual.Param2, anyParams) return MoqGenericParams_Usual_paramsKey[S, B]{ Params: struct{}{}, Hashes: struct { @@ -18160,19 +9997,14 @@ func (m *MoqGenericParams[S, B]) ParamsKey_Usual(params MoqGenericParams_Usual_p } // Reset resets the state of the moq -func (m *MoqGenericParams[S, B]) Reset() { m.ResultsByParams_Usual = nil } +func (m *MoqGenericParams[S, B]) Reset() { + m.Moq_Usual.Reset() +} // 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)) - } - } - } + m.Moq_Usual.Scene.T.Helper() + m.Moq_Usual.AssertExpectationsMet() } // The following type assertion assures that testmoqs.PartialGenericParams is @@ -18182,23 +10014,18 @@ var _ testmoqs.PartialGenericParams[any] = (*MoqPartialGenericParams_mock[any])( // 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] - - ResultsByParams_Usual []MoqPartialGenericParams_Usual_resultsByParams[S] - - Runtime struct { - ParameterIndexing struct { - Usual struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - } - } - // MoqPartialGenericParams_mock isolates the mock interface of the + Moq *MoqPartialGenericParams_mock[S] + + Moq_Usual *impl.Moq[ + *MoqPartialGenericParams_Usual_adaptor[S], + MoqPartialGenericParams_Usual_params[S], + MoqPartialGenericParams_Usual_paramsKey[S], + MoqPartialGenericParams_Usual_results[S]] + + Runtime MoqPartialGenericParams_runtime } +// MoqPartialGenericParams_mock isolates the mock interface of the // PartialGenericParams type type MoqPartialGenericParams_mock[S any] struct { Moq *MoqPartialGenericParams[S] @@ -18210,6 +10037,20 @@ type MoqPartialGenericParams_recorder[S any] struct { Moq *MoqPartialGenericParams[S] } +// MoqPartialGenericParams_runtime holds runtime configuration for the +// PartialGenericParams type +type MoqPartialGenericParams_runtime struct { + ParameterIndexing struct { + Usual MoqPartialGenericParams_Usual_paramIndexing + } +} + +// MoqPartialGenericParams_Usual_adaptor adapts MoqPartialGenericParams as +// needed by the runtime +type MoqPartialGenericParams_Usual_adaptor[S any] struct { + Moq *MoqPartialGenericParams[S] +} + // MoqPartialGenericParams_Usual_params holds the params of the // PartialGenericParams type type MoqPartialGenericParams_Usual_params[S any] struct { @@ -18227,12 +10068,18 @@ type MoqPartialGenericParams_Usual_paramsKey[S any] struct { } } -// 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_results holds the results of the +// PartialGenericParams type +type MoqPartialGenericParams_Usual_results[S any] struct { + Result1 string + Result2 error +} + +// MoqPartialGenericParams_Usual_paramIndexing holds the parameter indexing +// runtime configuration for the PartialGenericParams type +type MoqPartialGenericParams_Usual_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqPartialGenericParams_Usual_doFn defines the type of function needed when @@ -18243,67 +10090,39 @@ type MoqPartialGenericParams_Usual_doFn[S any] func(S, bool) // 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 - } - Sequence uint32 - DoFn MoqPartialGenericParams_Usual_doFn[S] - DoReturnFn MoqPartialGenericParams_Usual_doReturnFn[S] - } - Index uint32 - Repeat *moq.RepeatVal -} - -// 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] +// MoqPartialGenericParams_Usual_recorder routes recorded function calls to the +// MoqPartialGenericParams moq +type MoqPartialGenericParams_Usual_recorder[S any] struct { + Recorder *impl.Recorder[ + *MoqPartialGenericParams_Usual_adaptor[S], + MoqPartialGenericParams_Usual_params[S], + MoqPartialGenericParams_Usual_paramsKey[S], + MoqPartialGenericParams_Usual_results[S]] } // MoqPartialGenericParams_Usual_anyParams isolates the any params functions of // the PartialGenericParams type type MoqPartialGenericParams_Usual_anyParams[S any] struct { - Recorder *MoqPartialGenericParams_Usual_fnRecorder[S] + Recorder *MoqPartialGenericParams_Usual_recorder[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{} - } + adaptor1 := &MoqPartialGenericParams_Usual_adaptor[S]{} 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 - } + Moq: &MoqPartialGenericParams_mock[S]{}, + + Moq_Usual: impl.NewMoq[ + *MoqPartialGenericParams_Usual_adaptor[S], + MoqPartialGenericParams_Usual_params[S], + MoqPartialGenericParams_Usual_paramsKey[S], + MoqPartialGenericParams_Usual_results[S]](scene, adaptor1, config), + + Runtime: MoqPartialGenericParams_runtime{ParameterIndexing: struct { + Usual MoqPartialGenericParams_Usual_paramIndexing }{ - Usual: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - }{ + Usual: MoqPartialGenericParams_Usual_paramIndexing{ Param1: moq.ParamIndexByHash, Param2: moq.ParamIndexByValue, }, @@ -18311,6 +10130,8 @@ func NewMoqPartialGenericParams[S any](scene *moq.Scene, config *moq.Config) *Mo } m.Moq.Moq = m + adaptor1.Moq = m + scene.AddMoq(m) return m } @@ -18318,59 +10139,20 @@ func NewMoqPartialGenericParams[S any](scene *moq.Scene, config *moq.Config) *Mo // 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() +func (m *MoqPartialGenericParams_mock[S]) Usual(param1 S, param2 bool) (string, error) { + m.Moq.Moq_Usual.Scene.T.Helper() params := MoqPartialGenericParams_Usual_params[S]{ Param1: param1, Param2: param2, } - 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 - } - } - 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) + var result1 string + var result2 error + if result := m.Moq.Moq_Usual.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } - return + return result1, result2 } // OnCall returns the recorder implementation of the PartialGenericParams type @@ -18380,217 +10162,98 @@ func (m *MoqPartialGenericParams[S]) OnCall() *MoqPartialGenericParams_recorder[ } } -func (m *MoqPartialGenericParams_recorder[S]) Usual(param1 S, param2 bool) *MoqPartialGenericParams_Usual_fnRecorder[S] { - return &MoqPartialGenericParams_Usual_fnRecorder[S]{ - Params: MoqPartialGenericParams_Usual_params[S]{ +func (m *MoqPartialGenericParams_recorder[S]) Usual(param1 S, param2 bool) *MoqPartialGenericParams_Usual_recorder[S] { + return &MoqPartialGenericParams_Usual_recorder[S]{ + Recorder: m.Moq.Moq_Usual.OnCall(MoqPartialGenericParams_Usual_params[S]{ Param1: param1, Param2: param2, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -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_Usual(r.Params)) +func (r *MoqPartialGenericParams_Usual_recorder[S]) Any() *MoqPartialGenericParams_Usual_anyParams[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPartialGenericParams_Usual_anyParams[S]{Recorder: r} } -func (a *MoqPartialGenericParams_Usual_anyParams[S]) Param1() *MoqPartialGenericParams_Usual_fnRecorder[S] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPartialGenericParams_Usual_anyParams[S]) Param1() *MoqPartialGenericParams_Usual_recorder[S] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqPartialGenericParams_Usual_anyParams[S]) Param2() *MoqPartialGenericParams_Usual_fnRecorder[S] { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqPartialGenericParams_Usual_anyParams[S]) Param2() *MoqPartialGenericParams_Usual_recorder[S] { + a.Recorder.Recorder.AnyParam(2) 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_Usual(r.Params)) +func (r *MoqPartialGenericParams_Usual_recorder[S]) Seq() *MoqPartialGenericParams_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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_Usual(r.Params)) +func (r *MoqPartialGenericParams_Usual_recorder[S]) NoSeq() *MoqPartialGenericParams_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPartialGenericParams_Usual_fnRecorder[S]) ReturnResults(result1 string, result2 error) *MoqPartialGenericParams_Usual_fnRecorder[S] { - 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 MoqPartialGenericParams_Usual_doFn[S] - DoReturnFn MoqPartialGenericParams_Usual_doReturnFn[S] - }{ - Values: &struct { - Result1 string - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqPartialGenericParams_Usual_recorder[S]) ReturnResults(result1 string, result2 error) *MoqPartialGenericParams_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPartialGenericParams_Usual_results[S]{ + Result1: result1, + Result2: result2, }) return r } -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") +func (r *MoqPartialGenericParams_Usual_recorder[S]) AndDo(fn MoqPartialGenericParams_Usual_doFn[S]) *MoqPartialGenericParams_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPartialGenericParams_Usual_params[S]) { + fn(params.Param1, params.Param2) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPartialGenericParams_Usual_fnRecorder[S]) DoReturnResults(fn MoqPartialGenericParams_Usual_doReturnFn[S]) *MoqPartialGenericParams_Usual_fnRecorder[S] { - 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 +func (r *MoqPartialGenericParams_Usual_recorder[S]) DoReturnResults(fn MoqPartialGenericParams_Usual_doReturnFn[S]) *MoqPartialGenericParams_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPartialGenericParams_Usual_params[S]) *MoqPartialGenericParams_Usual_results[S] { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqPartialGenericParams_Usual_results[S]{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqPartialGenericParams_Usual_doFn[S] - DoReturnFn MoqPartialGenericParams_Usual_doReturnFn[S] - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPartialGenericParams_Usual_fnRecorder[S]) 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 *MoqPartialGenericParams_Usual_resultsByParams[S] - 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 = &MoqPartialGenericParams_Usual_resultsByParams[S]{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPartialGenericParams_Usual_paramsKey[S]]*MoqPartialGenericParams_Usual_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 - } - } - - paramsKey := r.Moq.ParamsKey_Usual(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqPartialGenericParams_Usual_results[S]{ - 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 *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") - 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 MoqPartialGenericParams_Usual_doFn[S] - DoReturnFn MoqPartialGenericParams_Usual_doReturnFn[S] - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqPartialGenericParams_Usual_recorder[S]) Repeat(repeaters ...moq.Repeater) *MoqPartialGenericParams_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqPartialGenericParams[S]) PrettyParams_Usual(params MoqPartialGenericParams_Usual_params[S]) string { +func (*MoqPartialGenericParams_Usual_adaptor[S]) PrettyParams(params MoqPartialGenericParams_Usual_params[S]) string { return fmt.Sprintf("Usual(%#v, %#v)", params.Param1, params.Param2) } -func (m *MoqPartialGenericParams[S]) ParamsKey_Usual(params MoqPartialGenericParams_Usual_params[S], anyParams uint64) MoqPartialGenericParams_Usual_paramsKey[S] { - m.Scene.T.Helper() - 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) - } - } +func (a *MoqPartialGenericParams_Usual_adaptor[S]) ParamsKey(params MoqPartialGenericParams_Usual_params[S], anyParams uint64) MoqPartialGenericParams_Usual_paramsKey[S] { + a.Moq.Moq_Usual.Scene.T.Helper() + param1UsedHash := impl.HashOnlyParamKey(a.Moq.Moq_Usual.Scene.T, + params.Param1, "param1", 1, a.Moq.Runtime.ParameterIndexing.Usual.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.Usual.Param2, anyParams) return MoqPartialGenericParams_Usual_paramsKey[S]{ Params: struct{ Param2 bool }{ Param2: param2Used, @@ -18606,19 +10269,14 @@ func (m *MoqPartialGenericParams[S]) ParamsKey_Usual(params MoqPartialGenericPar } // Reset resets the state of the moq -func (m *MoqPartialGenericParams[S]) Reset() { m.ResultsByParams_Usual = nil } +func (m *MoqPartialGenericParams[S]) Reset() { + m.Moq_Usual.Reset() +} // 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)) - } - } - } + m.Moq_Usual.Scene.T.Helper() + m.Moq_Usual.AssertExpectationsMet() } // The following type assertion assures that testmoqs.GenericResults is mocked @@ -18627,23 +10285,18 @@ var _ testmoqs.GenericResults[string, error] = (*MoqGenericResults_mock[string, // 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 + Moq *MoqGenericResults_mock[S, E] + + Moq_Usual *impl.Moq[ + *MoqGenericResults_Usual_adaptor[S, E], + MoqGenericResults_Usual_params[S, E], + MoqGenericResults_Usual_paramsKey[S, E], + MoqGenericResults_Usual_results[S, E]] + + Runtime MoqGenericResults_runtime } +// MoqGenericResults_mock isolates the mock interface of the GenericResults // type type MoqGenericResults_mock[S ~string, E error] struct { Moq *MoqGenericResults[S, E] @@ -18655,6 +10308,20 @@ type MoqGenericResults_recorder[S ~string, E error] struct { Moq *MoqGenericResults[S, E] } +// MoqGenericResults_runtime holds runtime configuration for the GenericResults +// type +type MoqGenericResults_runtime struct { + ParameterIndexing struct { + Usual MoqGenericResults_Usual_paramIndexing + } +} + +// MoqGenericResults_Usual_adaptor adapts MoqGenericResults as needed by the +// runtime +type MoqGenericResults_Usual_adaptor[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 @@ -18674,12 +10341,17 @@ type MoqGenericResults_Usual_paramsKey[S ~string, E error] struct { } } -// 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_results holds the results of the GenericResults type +type MoqGenericResults_Usual_results[S ~string, E error] struct { + Result1 S + Result2 E +} + +// MoqGenericResults_Usual_paramIndexing holds the parameter indexing runtime +// configuration for the GenericResults type +type MoqGenericResults_Usual_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqGenericResults_Usual_doFn defines the type of function needed when @@ -18690,65 +10362,38 @@ type MoqGenericResults_Usual_doFn[S ~string, E error] func(string, bool) // 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_Usual_recorder 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] +type MoqGenericResults_Usual_recorder[S ~string, E error] struct { + Recorder *impl.Recorder[ + *MoqGenericResults_Usual_adaptor[S, E], + MoqGenericResults_Usual_params[S, E], + MoqGenericResults_Usual_paramsKey[S, E], + MoqGenericResults_Usual_results[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] + Recorder *MoqGenericResults_Usual_recorder[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{} - } + adaptor1 := &MoqGenericResults_Usual_adaptor[S, E]{} 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 - } + Moq: &MoqGenericResults_mock[S, E]{}, + + Moq_Usual: impl.NewMoq[ + *MoqGenericResults_Usual_adaptor[S, E], + MoqGenericResults_Usual_params[S, E], + MoqGenericResults_Usual_paramsKey[S, E], + MoqGenericResults_Usual_results[S, E]](scene, adaptor1, config), + + Runtime: MoqGenericResults_runtime{ParameterIndexing: struct { + Usual MoqGenericResults_Usual_paramIndexing }{ - Usual: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - }{ + Usual: MoqGenericResults_Usual_paramIndexing{ Param1: moq.ParamIndexByValue, Param2: moq.ParamIndexByValue, }, @@ -18756,6 +10401,8 @@ func NewMoqGenericResults[S ~string, E error](scene *moq.Scene, config *moq.Conf } m.Moq.Moq = m + adaptor1.Moq = m + scene.AddMoq(m) return m } @@ -18763,59 +10410,20 @@ func NewMoqGenericResults[S ~string, E error](scene *moq.Scene, config *moq.Conf // 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() +func (m *MoqGenericResults_mock[S, E]) Usual(param1 string, param2 bool) (S, E) { + m.Moq.Moq_Usual.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) + var result1 S + var result2 E + if result := m.Moq.Moq_Usual.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } - - if result.Values != nil { - result1 = result.Values.Result1 - result2 = result.Values.Result2 - } - if result.DoReturnFn != nil { - result1, result2 = result.DoReturnFn(param1, param2) - } - return + return result1, result2 } // OnCall returns the recorder implementation of the GenericResults type @@ -18825,219 +10433,98 @@ func (m *MoqGenericResults[S, E]) OnCall() *MoqGenericResults_recorder[S, E] { } } -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]{ +func (m *MoqGenericResults_recorder[S, E]) Usual(param1 string, param2 bool) *MoqGenericResults_Usual_recorder[S, E] { + return &MoqGenericResults_Usual_recorder[S, E]{ + Recorder: m.Moq.Moq_Usual.OnCall(MoqGenericResults_Usual_params[S, E]{ Param1: param1, Param2: param2, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -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_Usual(r.Params)) +func (r *MoqGenericResults_Usual_recorder[S, E]) Any() *MoqGenericResults_Usual_anyParams[S, E] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqGenericResults_Usual_anyParams[S, E]{Recorder: r} } -func (a *MoqGenericResults_Usual_anyParams[S, E]) Param1() *MoqGenericResults_Usual_fnRecorder[S, E] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqGenericResults_Usual_anyParams[S, E]) Param1() *MoqGenericResults_Usual_recorder[S, E] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqGenericResults_Usual_anyParams[S, E]) Param2() *MoqGenericResults_Usual_fnRecorder[S, E] { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqGenericResults_Usual_anyParams[S, E]) Param2() *MoqGenericResults_Usual_recorder[S, E] { + a.Recorder.Recorder.AnyParam(2) 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_Usual(r.Params)) +func (r *MoqGenericResults_Usual_recorder[S, E]) Seq() *MoqGenericResults_Usual_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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_Usual(r.Params)) +func (r *MoqGenericResults_Usual_recorder[S, E]) NoSeq() *MoqGenericResults_Usual_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqGenericResults_Usual_fnRecorder[S, E]) ReturnResults(result1 S, result2 E) *MoqGenericResults_Usual_fnRecorder[S, E] { - 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 S - Result2 E - } - Sequence uint32 - DoFn MoqGenericResults_Usual_doFn[S, E] - DoReturnFn MoqGenericResults_Usual_doReturnFn[S, E] - }{ - Values: &struct { - Result1 S - Result2 E - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqGenericResults_Usual_recorder[S, E]) ReturnResults(result1 S, result2 E) *MoqGenericResults_Usual_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqGenericResults_Usual_results[S, E]{ + Result1: result1, + Result2: result2, }) return r } -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") +func (r *MoqGenericResults_Usual_recorder[S, E]) AndDo(fn MoqGenericResults_Usual_doFn[S, E]) *MoqGenericResults_Usual_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqGenericResults_Usual_params[S, E]) { + fn(params.Param1, params.Param2) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -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() - - var sequence uint32 - if r.Sequence { - sequence = r.Moq.Scene.NextRecorderSequence() - } - - r.Results.Results = append(r.Results.Results, struct { - Values *struct { - Result1 S - Result2 E +func (r *MoqGenericResults_Usual_recorder[S, E]) DoReturnResults(fn MoqGenericResults_Usual_doReturnFn[S, E]) *MoqGenericResults_Usual_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqGenericResults_Usual_params[S, E]) *MoqGenericResults_Usual_results[S, E] { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqGenericResults_Usual_results[S, E]{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqGenericResults_Usual_doFn[S, E] - DoReturnFn MoqGenericResults_Usual_doReturnFn[S, E] - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -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) - return - } - - anyCount := bits.OnesCount64(r.AnyParams) - insertAt := -1 - var results *MoqGenericResults_Usual_resultsByParams[S, E] - 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 = &MoqGenericResults_Usual_resultsByParams[S, E]{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqGenericResults_Usual_paramsKey[S, E]]*MoqGenericResults_Usual_results[S, E]{}, - } - 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 = &MoqGenericResults_Usual_results[S, E]{ - 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 *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") - 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 S - Result2 E - } - Sequence uint32 - DoFn MoqGenericResults_Usual_doFn[S, E] - DoReturnFn MoqGenericResults_Usual_doReturnFn[S, E] - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqGenericResults_Usual_recorder[S, E]) Repeat(repeaters ...moq.Repeater) *MoqGenericResults_Usual_recorder[S, E] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqGenericResults[S, E]) PrettyParams_Usual(params MoqGenericResults_Usual_params[S, E]) string { +func (*MoqGenericResults_Usual_adaptor[S, E]) PrettyParams(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) - } - } +func (a *MoqGenericResults_Usual_adaptor[S, E]) ParamsKey(params MoqGenericResults_Usual_params[S, E], anyParams uint64) MoqGenericResults_Usual_paramsKey[S, E] { + a.Moq.Moq_Usual.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.Usual.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.Usual.Param2, anyParams) return MoqGenericResults_Usual_paramsKey[S, E]{ Params: struct { Param1 string @@ -19057,19 +10544,14 @@ func (m *MoqGenericResults[S, E]) ParamsKey_Usual(params MoqGenericResults_Usual } // Reset resets the state of the moq -func (m *MoqGenericResults[S, E]) Reset() { m.ResultsByParams_Usual = nil } +func (m *MoqGenericResults[S, E]) Reset() { + m.Moq_Usual.Reset() +} // 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)) - } - } - } + m.Moq_Usual.Scene.T.Helper() + m.Moq_Usual.AssertExpectationsMet() } // The following type assertion assures that testmoqs.PartialGenericResults is @@ -19079,23 +10561,18 @@ var _ testmoqs.PartialGenericResults[string] = (*MoqPartialGenericResults_mock[s // 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 + Moq *MoqPartialGenericResults_mock[S] + + Moq_Usual *impl.Moq[ + *MoqPartialGenericResults_Usual_adaptor[S], + MoqPartialGenericResults_Usual_params[S], + MoqPartialGenericResults_Usual_paramsKey[S], + MoqPartialGenericResults_Usual_results[S]] + + Runtime MoqPartialGenericResults_runtime } +// MoqPartialGenericResults_mock isolates the mock interface of the // PartialGenericResults type type MoqPartialGenericResults_mock[S ~string] struct { Moq *MoqPartialGenericResults[S] @@ -19107,6 +10584,20 @@ type MoqPartialGenericResults_recorder[S ~string] struct { Moq *MoqPartialGenericResults[S] } +// MoqPartialGenericResults_runtime holds runtime configuration for the +// PartialGenericResults type +type MoqPartialGenericResults_runtime struct { + ParameterIndexing struct { + Usual MoqPartialGenericResults_Usual_paramIndexing + } +} + +// MoqPartialGenericResults_Usual_adaptor adapts MoqPartialGenericResults as +// needed by the runtime +type MoqPartialGenericResults_Usual_adaptor[S ~string] struct { + Moq *MoqPartialGenericResults[S] +} + // MoqPartialGenericResults_Usual_params holds the params of the // PartialGenericResults type type MoqPartialGenericResults_Usual_params[S ~string] struct { @@ -19127,12 +10618,18 @@ type MoqPartialGenericResults_Usual_paramsKey[S ~string] struct { } } -// 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_results holds the results of the +// PartialGenericResults type +type MoqPartialGenericResults_Usual_results[S ~string] struct { + Result1 S + Result2 error +} + +// MoqPartialGenericResults_Usual_paramIndexing holds the parameter indexing +// runtime configuration for the PartialGenericResults type +type MoqPartialGenericResults_Usual_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqPartialGenericResults_Usual_doFn defines the type of function needed when @@ -19143,67 +10640,39 @@ type MoqPartialGenericResults_Usual_doFn[S ~string] func(string, bool) // 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 +// MoqPartialGenericResults_Usual_recorder 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] +type MoqPartialGenericResults_Usual_recorder[S ~string] struct { + Recorder *impl.Recorder[ + *MoqPartialGenericResults_Usual_adaptor[S], + MoqPartialGenericResults_Usual_params[S], + MoqPartialGenericResults_Usual_paramsKey[S], + MoqPartialGenericResults_Usual_results[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] + Recorder *MoqPartialGenericResults_Usual_recorder[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{} - } + adaptor1 := &MoqPartialGenericResults_Usual_adaptor[S]{} 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 - } + Moq: &MoqPartialGenericResults_mock[S]{}, + + Moq_Usual: impl.NewMoq[ + *MoqPartialGenericResults_Usual_adaptor[S], + MoqPartialGenericResults_Usual_params[S], + MoqPartialGenericResults_Usual_paramsKey[S], + MoqPartialGenericResults_Usual_results[S]](scene, adaptor1, config), + + Runtime: MoqPartialGenericResults_runtime{ParameterIndexing: struct { + Usual MoqPartialGenericResults_Usual_paramIndexing }{ - Usual: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - }{ + Usual: MoqPartialGenericResults_Usual_paramIndexing{ Param1: moq.ParamIndexByValue, Param2: moq.ParamIndexByValue, }, @@ -19211,66 +10680,29 @@ func NewMoqPartialGenericResults[S ~string](scene *moq.Scene, config *moq.Config } 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 - } + adaptor1.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_Usual(params)) - } - return - } - i = results.Repeat.ResultCount - 1 - } + scene.AddMoq(m) + return m +} - 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)) - } - } +// Mock returns the mock implementation of the PartialGenericResults type +func (m *MoqPartialGenericResults[S]) Mock() *MoqPartialGenericResults_mock[S] { return m.Moq } - if result.DoFn != nil { - result.DoFn(param1, param2) +func (m *MoqPartialGenericResults_mock[S]) Usual(param1 string, param2 bool) (S, error) { + m.Moq.Moq_Usual.Scene.T.Helper() + params := MoqPartialGenericResults_Usual_params[S]{ + Param1: param1, + Param2: param2, } - if result.Values != nil { - result1 = result.Values.Result1 - result2 = result.Values.Result2 + var result1 S + var result2 error + if result := m.Moq.Moq_Usual.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } - if result.DoReturnFn != nil { - result1, result2 = result.DoReturnFn(param1, param2) - } - return + return result1, result2 } // OnCall returns the recorder implementation of the PartialGenericResults type @@ -19280,219 +10712,98 @@ func (m *MoqPartialGenericResults[S]) OnCall() *MoqPartialGenericResults_recorde } } -func (m *MoqPartialGenericResults_recorder[S]) Usual(param1 string, param2 bool) *MoqPartialGenericResults_Usual_fnRecorder[S] { - return &MoqPartialGenericResults_Usual_fnRecorder[S]{ - Params: MoqPartialGenericResults_Usual_params[S]{ +func (m *MoqPartialGenericResults_recorder[S]) Usual(param1 string, param2 bool) *MoqPartialGenericResults_Usual_recorder[S] { + return &MoqPartialGenericResults_Usual_recorder[S]{ + Recorder: m.Moq.Moq_Usual.OnCall(MoqPartialGenericResults_Usual_params[S]{ Param1: param1, Param2: param2, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -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_Usual(r.Params)) +func (r *MoqPartialGenericResults_Usual_recorder[S]) Any() *MoqPartialGenericResults_Usual_anyParams[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPartialGenericResults_Usual_anyParams[S]{Recorder: r} } -func (a *MoqPartialGenericResults_Usual_anyParams[S]) Param1() *MoqPartialGenericResults_Usual_fnRecorder[S] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPartialGenericResults_Usual_anyParams[S]) Param1() *MoqPartialGenericResults_Usual_recorder[S] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqPartialGenericResults_Usual_anyParams[S]) Param2() *MoqPartialGenericResults_Usual_fnRecorder[S] { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqPartialGenericResults_Usual_anyParams[S]) Param2() *MoqPartialGenericResults_Usual_recorder[S] { + a.Recorder.Recorder.AnyParam(2) 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_Usual(r.Params)) +func (r *MoqPartialGenericResults_Usual_recorder[S]) Seq() *MoqPartialGenericResults_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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_Usual(r.Params)) +func (r *MoqPartialGenericResults_Usual_recorder[S]) NoSeq() *MoqPartialGenericResults_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPartialGenericResults_Usual_fnRecorder[S]) ReturnResults(result1 S, result2 error) *MoqPartialGenericResults_Usual_fnRecorder[S] { - 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 S - Result2 error - } - Sequence uint32 - DoFn MoqPartialGenericResults_Usual_doFn[S] - DoReturnFn MoqPartialGenericResults_Usual_doReturnFn[S] - }{ - Values: &struct { - Result1 S - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqPartialGenericResults_Usual_recorder[S]) ReturnResults(result1 S, result2 error) *MoqPartialGenericResults_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPartialGenericResults_Usual_results[S]{ + Result1: result1, + Result2: result2, }) return r } -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") +func (r *MoqPartialGenericResults_Usual_recorder[S]) AndDo(fn MoqPartialGenericResults_Usual_doFn[S]) *MoqPartialGenericResults_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPartialGenericResults_Usual_params[S]) { + fn(params.Param1, params.Param2) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPartialGenericResults_Usual_fnRecorder[S]) DoReturnResults(fn MoqPartialGenericResults_Usual_doReturnFn[S]) *MoqPartialGenericResults_Usual_fnRecorder[S] { - 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 S - Result2 error +func (r *MoqPartialGenericResults_Usual_recorder[S]) DoReturnResults(fn MoqPartialGenericResults_Usual_doReturnFn[S]) *MoqPartialGenericResults_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPartialGenericResults_Usual_params[S]) *MoqPartialGenericResults_Usual_results[S] { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqPartialGenericResults_Usual_results[S]{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqPartialGenericResults_Usual_doFn[S] - DoReturnFn MoqPartialGenericResults_Usual_doReturnFn[S] - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPartialGenericResults_Usual_fnRecorder[S]) 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 *MoqPartialGenericResults_Usual_resultsByParams[S] - 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 = &MoqPartialGenericResults_Usual_resultsByParams[S]{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPartialGenericResults_Usual_paramsKey[S]]*MoqPartialGenericResults_Usual_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 - } - } - - paramsKey := r.Moq.ParamsKey_Usual(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqPartialGenericResults_Usual_results[S]{ - 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 *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") - 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 S - Result2 error - } - Sequence uint32 - DoFn MoqPartialGenericResults_Usual_doFn[S] - DoReturnFn MoqPartialGenericResults_Usual_doReturnFn[S] - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqPartialGenericResults_Usual_recorder[S]) Repeat(repeaters ...moq.Repeater) *MoqPartialGenericResults_Usual_recorder[S] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqPartialGenericResults[S]) PrettyParams_Usual(params MoqPartialGenericResults_Usual_params[S]) string { +func (*MoqPartialGenericResults_Usual_adaptor[S]) PrettyParams(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) - } - } +func (a *MoqPartialGenericResults_Usual_adaptor[S]) ParamsKey(params MoqPartialGenericResults_Usual_params[S], anyParams uint64) MoqPartialGenericResults_Usual_paramsKey[S] { + a.Moq.Moq_Usual.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.Usual.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.Usual.Param2, anyParams) return MoqPartialGenericResults_Usual_paramsKey[S]{ Params: struct { Param1 string @@ -19512,19 +10823,14 @@ func (m *MoqPartialGenericResults[S]) ParamsKey_Usual(params MoqPartialGenericRe } // Reset resets the state of the moq -func (m *MoqPartialGenericResults[S]) Reset() { m.ResultsByParams_Usual = nil } +func (m *MoqPartialGenericResults[S]) Reset() { + m.Moq_Usual.Reset() +} // 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)) - } - } - } + m.Moq_Usual.Scene.T.Helper() + m.Moq_Usual.AssertExpectationsMet() } // The following type assertion assures that testmoqs.GenericInterfaceParam is @@ -19534,22 +10840,18 @@ var _ testmoqs.GenericInterfaceParam[testmoqs.MyWriter] = (*MoqGenericInterfaceP // 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] + Moq *MoqGenericInterfaceParam_mock[W] - ResultsByParams_Usual []MoqGenericInterfaceParam_Usual_resultsByParams[W] + Moq_Usual *impl.Moq[ + *MoqGenericInterfaceParam_Usual_adaptor[W], + MoqGenericInterfaceParam_Usual_params[W], + MoqGenericInterfaceParam_Usual_paramsKey[W], + MoqGenericInterfaceParam_Usual_results[W]] - Runtime struct { - ParameterIndexing struct { - Usual struct { - W moq.ParamIndexing - } - } - } - // MoqGenericInterfaceParam_mock isolates the mock interface of the + Runtime MoqGenericInterfaceParam_runtime } +// MoqGenericInterfaceParam_mock isolates the mock interface of the // GenericInterfaceParam type type MoqGenericInterfaceParam_mock[W testmoqs.MyWriter] struct { Moq *MoqGenericInterfaceParam[W] @@ -19561,6 +10863,20 @@ type MoqGenericInterfaceParam_recorder[W testmoqs.MyWriter] struct { Moq *MoqGenericInterfaceParam[W] } +// MoqGenericInterfaceParam_runtime holds runtime configuration for the +// GenericInterfaceParam type +type MoqGenericInterfaceParam_runtime struct { + ParameterIndexing struct { + Usual MoqGenericInterfaceParam_Usual_paramIndexing + } +} + +// MoqGenericInterfaceParam_Usual_adaptor adapts MoqGenericInterfaceParam as +// needed by the runtime +type MoqGenericInterfaceParam_Usual_adaptor[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 } @@ -19572,12 +10888,17 @@ type MoqGenericInterfaceParam_Usual_paramsKey[W testmoqs.MyWriter] 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_results holds the results of the +// GenericInterfaceParam type +type MoqGenericInterfaceParam_Usual_results[W testmoqs.MyWriter] struct { + SResult string + Err error +} + +// MoqGenericInterfaceParam_Usual_paramIndexing holds the parameter indexing +// runtime configuration for the GenericInterfaceParam type +type MoqGenericInterfaceParam_Usual_paramIndexing struct { + W moq.ParamIndexing } // MoqGenericInterfaceParam_Usual_doFn defines the type of function needed when @@ -19588,70 +10909,47 @@ type MoqGenericInterfaceParam_Usual_doFn[W testmoqs.MyWriter] func(w W) // 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 +// MoqGenericInterfaceParam_Usual_recorder 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] +type MoqGenericInterfaceParam_Usual_recorder[W testmoqs.MyWriter] struct { + Recorder *impl.Recorder[ + *MoqGenericInterfaceParam_Usual_adaptor[W], + MoqGenericInterfaceParam_Usual_params[W], + MoqGenericInterfaceParam_Usual_paramsKey[W], + MoqGenericInterfaceParam_Usual_results[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] + Recorder *MoqGenericInterfaceParam_Usual_recorder[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{} - } + adaptor1 := &MoqGenericInterfaceParam_Usual_adaptor[W]{} 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 - } + Moq: &MoqGenericInterfaceParam_mock[W]{}, + + Moq_Usual: impl.NewMoq[ + *MoqGenericInterfaceParam_Usual_adaptor[W], + MoqGenericInterfaceParam_Usual_params[W], + MoqGenericInterfaceParam_Usual_paramsKey[W], + MoqGenericInterfaceParam_Usual_results[W]](scene, adaptor1, config), + + Runtime: MoqGenericInterfaceParam_runtime{ParameterIndexing: struct { + Usual MoqGenericInterfaceParam_Usual_paramIndexing }{ - Usual: struct { - W moq.ParamIndexing - }{ + Usual: MoqGenericInterfaceParam_Usual_paramIndexing{ W: moq.ParamIndexByHash, }, }}, } m.Moq.Moq = m + adaptor1.Moq = m + scene.AddMoq(m) return m } @@ -19659,58 +10957,19 @@ func NewMoqGenericInterfaceParam[W testmoqs.MyWriter](scene *moq.Scene, config * // 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() +func (m *MoqGenericInterfaceParam_mock[W]) Usual(w W) (string, error) { + m.Moq.Moq_Usual.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) + var result1 string + var result2 error + if result := m.Moq.Moq_Usual.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } - - if result.Values != nil { - sResult = result.Values.SResult - err = result.Values.Err - } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn(w) - } - return + return result1, result2 } // OnCall returns the recorder implementation of the GenericInterfaceParam type @@ -19720,202 +10979,90 @@ func (m *MoqGenericInterfaceParam[W]) OnCall() *MoqGenericInterfaceParam_recorde } } -func (m *MoqGenericInterfaceParam_recorder[W]) Usual(w W) *MoqGenericInterfaceParam_Usual_fnRecorder[W] { - return &MoqGenericInterfaceParam_Usual_fnRecorder[W]{ - Params: MoqGenericInterfaceParam_Usual_params[W]{ +func (m *MoqGenericInterfaceParam_recorder[W]) Usual(w W) *MoqGenericInterfaceParam_Usual_recorder[W] { + return &MoqGenericInterfaceParam_Usual_recorder[W]{ + Recorder: m.Moq.Moq_Usual.OnCall(MoqGenericInterfaceParam_Usual_params[W]{ W: w, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -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_Usual(r.Params)) +func (r *MoqGenericInterfaceParam_Usual_recorder[W]) Any() *MoqGenericInterfaceParam_Usual_anyParams[W] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqGenericInterfaceParam_Usual_anyParams[W]{Recorder: r} } -func (a *MoqGenericInterfaceParam_Usual_anyParams[W]) W() *MoqGenericInterfaceParam_Usual_fnRecorder[W] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqGenericInterfaceParam_Usual_anyParams[W]) W() *MoqGenericInterfaceParam_Usual_recorder[W] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -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_Usual(r.Params)) +func (r *MoqGenericInterfaceParam_Usual_recorder[W]) Seq() *MoqGenericInterfaceParam_Usual_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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_Usual(r.Params)) +func (r *MoqGenericInterfaceParam_Usual_recorder[W]) NoSeq() *MoqGenericInterfaceParam_Usual_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqGenericInterfaceParam_Usual_fnRecorder[W]) ReturnResults(sResult string, err error) *MoqGenericInterfaceParam_Usual_fnRecorder[W] { - 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 MoqGenericInterfaceParam_Usual_doFn[W] - DoReturnFn MoqGenericInterfaceParam_Usual_doReturnFn[W] - }{ - Values: &struct { - SResult string - Err error - }{ - SResult: sResult, - Err: err, - }, - Sequence: sequence, +func (r *MoqGenericInterfaceParam_Usual_recorder[W]) ReturnResults(sResult string, err error) *MoqGenericInterfaceParam_Usual_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqGenericInterfaceParam_Usual_results[W]{ + SResult: sResult, + Err: err, }) return r } -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") +func (r *MoqGenericInterfaceParam_Usual_recorder[W]) AndDo(fn MoqGenericInterfaceParam_Usual_doFn[W]) *MoqGenericInterfaceParam_Usual_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqGenericInterfaceParam_Usual_params[W]) { + fn(params.W) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqGenericInterfaceParam_Usual_fnRecorder[W]) DoReturnResults(fn MoqGenericInterfaceParam_Usual_doReturnFn[W]) *MoqGenericInterfaceParam_Usual_fnRecorder[W] { - 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 +func (r *MoqGenericInterfaceParam_Usual_recorder[W]) DoReturnResults(fn MoqGenericInterfaceParam_Usual_doReturnFn[W]) *MoqGenericInterfaceParam_Usual_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqGenericInterfaceParam_Usual_params[W]) *MoqGenericInterfaceParam_Usual_results[W] { + sResult, err := fn(params.W) + return &MoqGenericInterfaceParam_Usual_results[W]{ + SResult: sResult, + Err: err, } - Sequence uint32 - DoFn MoqGenericInterfaceParam_Usual_doFn[W] - DoReturnFn MoqGenericInterfaceParam_Usual_doReturnFn[W] - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqGenericInterfaceParam_Usual_fnRecorder[W]) 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 *MoqGenericInterfaceParam_Usual_resultsByParams[W] - 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 = &MoqGenericInterfaceParam_Usual_resultsByParams[W]{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqGenericInterfaceParam_Usual_paramsKey[W]]*MoqGenericInterfaceParam_Usual_results[W]{}, - } - 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 = &MoqGenericInterfaceParam_Usual_results[W]{ - 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 *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") - 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 MoqGenericInterfaceParam_Usual_doFn[W] - DoReturnFn MoqGenericInterfaceParam_Usual_doReturnFn[W] - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) +func (r *MoqGenericInterfaceParam_Usual_recorder[W]) Repeat(repeaters ...moq.Repeater) *MoqGenericInterfaceParam_Usual_recorder[W] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { + return nil } return r } -func (m *MoqGenericInterfaceParam[W]) PrettyParams_Usual(params MoqGenericInterfaceParam_Usual_params[W]) string { +func (*MoqGenericInterfaceParam_Usual_adaptor[W]) PrettyParams(params MoqGenericInterfaceParam_Usual_params[W]) string { return fmt.Sprintf("Usual(%#v)", params.W) } -func (m *MoqGenericInterfaceParam[W]) ParamsKey_Usual(params MoqGenericInterfaceParam_Usual_params[W], anyParams uint64) MoqGenericInterfaceParam_Usual_paramsKey[W] { - m.Scene.T.Helper() - var wUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - 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) - } +func (a *MoqGenericInterfaceParam_Usual_adaptor[W]) ParamsKey(params MoqGenericInterfaceParam_Usual_params[W], anyParams uint64) MoqGenericInterfaceParam_Usual_paramsKey[W] { + a.Moq.Moq_Usual.Scene.T.Helper() + wUsedHash := impl.HashOnlyParamKey(a.Moq.Moq_Usual.Scene.T, + params.W, "w", 1, a.Moq.Runtime.ParameterIndexing.Usual.W, anyParams) return MoqGenericInterfaceParam_Usual_paramsKey[W]{ Params: struct{}{}, Hashes: struct{ W hash.Hash }{ @@ -19925,19 +11072,14 @@ func (m *MoqGenericInterfaceParam[W]) ParamsKey_Usual(params MoqGenericInterface } // Reset resets the state of the moq -func (m *MoqGenericInterfaceParam[W]) Reset() { m.ResultsByParams_Usual = nil } +func (m *MoqGenericInterfaceParam[W]) Reset() { + m.Moq_Usual.Reset() +} // 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)) - } - } - } + m.Moq_Usual.Scene.T.Helper() + m.Moq_Usual.AssertExpectationsMet() } // The following type assertion assures that testmoqs.GenericInterfaceResult is @@ -19947,23 +11089,18 @@ var _ testmoqs.GenericInterfaceResult[testmoqs.MyReader] = (*MoqGenericInterface // 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 + Moq *MoqGenericInterfaceResult_mock[R] + + Moq_Usual *impl.Moq[ + *MoqGenericInterfaceResult_Usual_adaptor[R], + MoqGenericInterfaceResult_Usual_params[R], + MoqGenericInterfaceResult_Usual_paramsKey[R], + MoqGenericInterfaceResult_Usual_results[R]] + + Runtime MoqGenericInterfaceResult_runtime } +// MoqGenericInterfaceResult_mock isolates the mock interface of the // GenericInterfaceResult type type MoqGenericInterfaceResult_mock[R testmoqs.MyReader] struct { Moq *MoqGenericInterfaceResult[R] @@ -19975,6 +11112,20 @@ type MoqGenericInterfaceResult_recorder[R testmoqs.MyReader] struct { Moq *MoqGenericInterfaceResult[R] } +// MoqGenericInterfaceResult_runtime holds runtime configuration for the +// GenericInterfaceResult type +type MoqGenericInterfaceResult_runtime struct { + ParameterIndexing struct { + Usual MoqGenericInterfaceResult_Usual_paramIndexing + } +} + +// MoqGenericInterfaceResult_Usual_adaptor adapts MoqGenericInterfaceResult as +// needed by the runtime +type MoqGenericInterfaceResult_Usual_adaptor[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 { @@ -19995,12 +11146,15 @@ type MoqGenericInterfaceResult_Usual_paramsKey[R testmoqs.MyReader] struct { } } -// 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_results holds the results of the +// GenericInterfaceResult type +type MoqGenericInterfaceResult_Usual_results[R testmoqs.MyReader] struct{ Result1 R } + +// MoqGenericInterfaceResult_Usual_paramIndexing holds the parameter indexing +// runtime configuration for the GenericInterfaceResult type +type MoqGenericInterfaceResult_Usual_paramIndexing struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing } // MoqGenericInterfaceResult_Usual_doFn defines the type of function needed @@ -20011,64 +11165,39 @@ type MoqGenericInterfaceResult_Usual_doFn[R testmoqs.MyReader] func(sParam strin // 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 +// MoqGenericInterfaceResult_Usual_recorder 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] +type MoqGenericInterfaceResult_Usual_recorder[R testmoqs.MyReader] struct { + Recorder *impl.Recorder[ + *MoqGenericInterfaceResult_Usual_adaptor[R], + MoqGenericInterfaceResult_Usual_params[R], + MoqGenericInterfaceResult_Usual_paramsKey[R], + MoqGenericInterfaceResult_Usual_results[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] + Recorder *MoqGenericInterfaceResult_Usual_recorder[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{} - } + adaptor1 := &MoqGenericInterfaceResult_Usual_adaptor[R]{} 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 - } + Moq: &MoqGenericInterfaceResult_mock[R]{}, + + Moq_Usual: impl.NewMoq[ + *MoqGenericInterfaceResult_Usual_adaptor[R], + MoqGenericInterfaceResult_Usual_params[R], + MoqGenericInterfaceResult_Usual_paramsKey[R], + MoqGenericInterfaceResult_Usual_results[R]](scene, adaptor1, config), + + Runtime: MoqGenericInterfaceResult_runtime{ParameterIndexing: struct { + Usual MoqGenericInterfaceResult_Usual_paramIndexing }{ - Usual: struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - }{ + Usual: MoqGenericInterfaceResult_Usual_paramIndexing{ SParam: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }, @@ -20076,6 +11205,8 @@ func NewMoqGenericInterfaceResult[R testmoqs.MyReader](scene *moq.Scene, config } m.Moq.Moq = m + adaptor1.Moq = m + scene.AddMoq(m) return m } @@ -20083,58 +11214,18 @@ func NewMoqGenericInterfaceResult[R testmoqs.MyReader](scene *moq.Scene, config // 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() +func (m *MoqGenericInterfaceResult_mock[R]) Usual(sParam string, bParam bool) R { + m.Moq.Moq_Usual.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)) - } - } - - if result.DoFn != nil { - result.DoFn(sParam, bParam) - } - if result.Values != nil { - result1 = result.Values.Result1 + var result1 R + if result := m.Moq.Moq_Usual.Function(params); result != nil { + result1 = result.Result1 } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn(sParam, bParam) - } - return + return result1 } // OnCall returns the recorder implementation of the GenericInterfaceResult @@ -20145,206 +11236,96 @@ func (m *MoqGenericInterfaceResult[R]) OnCall() *MoqGenericInterfaceResult_recor } } -func (m *MoqGenericInterfaceResult_recorder[R]) Usual(sParam string, bParam bool) *MoqGenericInterfaceResult_Usual_fnRecorder[R] { - return &MoqGenericInterfaceResult_Usual_fnRecorder[R]{ - Params: MoqGenericInterfaceResult_Usual_params[R]{ +func (m *MoqGenericInterfaceResult_recorder[R]) Usual(sParam string, bParam bool) *MoqGenericInterfaceResult_Usual_recorder[R] { + return &MoqGenericInterfaceResult_Usual_recorder[R]{ + Recorder: m.Moq.Moq_Usual.OnCall(MoqGenericInterfaceResult_Usual_params[R]{ SParam: sParam, BParam: bParam, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -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_Usual(r.Params)) +func (r *MoqGenericInterfaceResult_Usual_recorder[R]) Any() *MoqGenericInterfaceResult_Usual_anyParams[R] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqGenericInterfaceResult_Usual_anyParams[R]{Recorder: r} } -func (a *MoqGenericInterfaceResult_Usual_anyParams[R]) SParam() *MoqGenericInterfaceResult_Usual_fnRecorder[R] { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqGenericInterfaceResult_Usual_anyParams[R]) SParam() *MoqGenericInterfaceResult_Usual_recorder[R] { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqGenericInterfaceResult_Usual_anyParams[R]) BParam() *MoqGenericInterfaceResult_Usual_fnRecorder[R] { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqGenericInterfaceResult_Usual_anyParams[R]) BParam() *MoqGenericInterfaceResult_Usual_recorder[R] { + a.Recorder.Recorder.AnyParam(2) 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_Usual(r.Params)) +func (r *MoqGenericInterfaceResult_Usual_recorder[R]) Seq() *MoqGenericInterfaceResult_Usual_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -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_Usual(r.Params)) +func (r *MoqGenericInterfaceResult_Usual_recorder[R]) NoSeq() *MoqGenericInterfaceResult_Usual_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqGenericInterfaceResult_Usual_fnRecorder[R]) ReturnResults(result1 R) *MoqGenericInterfaceResult_Usual_fnRecorder[R] { - 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 R } - Sequence uint32 - DoFn MoqGenericInterfaceResult_Usual_doFn[R] - DoReturnFn MoqGenericInterfaceResult_Usual_doReturnFn[R] - }{ - Values: &struct{ Result1 R }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqGenericInterfaceResult_Usual_recorder[R]) ReturnResults(result1 R) *MoqGenericInterfaceResult_Usual_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqGenericInterfaceResult_Usual_results[R]{ + Result1: result1, }) return r } -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") +func (r *MoqGenericInterfaceResult_Usual_recorder[R]) AndDo(fn MoqGenericInterfaceResult_Usual_doFn[R]) *MoqGenericInterfaceResult_Usual_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqGenericInterfaceResult_Usual_params[R]) { + fn(params.SParam, params.BParam) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn - return r -} - -func (r *MoqGenericInterfaceResult_Usual_fnRecorder[R]) DoReturnResults(fn MoqGenericInterfaceResult_Usual_doReturnFn[R]) *MoqGenericInterfaceResult_Usual_fnRecorder[R] { - 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 R } - Sequence uint32 - DoFn MoqGenericInterfaceResult_Usual_doFn[R] - DoReturnFn MoqGenericInterfaceResult_Usual_doReturnFn[R] - }{Sequence: sequence, DoReturnFn: fn}) return r } -func (r *MoqGenericInterfaceResult_Usual_fnRecorder[R]) 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 *MoqGenericInterfaceResult_Usual_resultsByParams[R] - 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 = &MoqGenericInterfaceResult_Usual_resultsByParams[R]{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqGenericInterfaceResult_Usual_paramsKey[R]]*MoqGenericInterfaceResult_Usual_results[R]{}, - } - 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 = &MoqGenericInterfaceResult_Usual_results[R]{ - Params: r.Params, - Results: nil, - Index: 0, - Repeat: &moq.RepeatVal{}, +func (r *MoqGenericInterfaceResult_Usual_recorder[R]) DoReturnResults(fn MoqGenericInterfaceResult_Usual_doReturnFn[R]) *MoqGenericInterfaceResult_Usual_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqGenericInterfaceResult_Usual_params[R]) *MoqGenericInterfaceResult_Usual_results[R] { + result1 := fn(params.SParam, params.BParam) + return &MoqGenericInterfaceResult_Usual_results[R]{ + Result1: result1, } - results.Results[paramsKey] = r.Results - } - - r.Results.Repeat.Increment(r.Moq.Scene.T) + }) + return r } -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") +func (r *MoqGenericInterfaceResult_Usual_recorder[R]) Repeat(repeaters ...moq.Repeater) *MoqGenericInterfaceResult_Usual_recorder[R] { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 R } - Sequence uint32 - DoFn MoqGenericInterfaceResult_Usual_doFn[R] - DoReturnFn MoqGenericInterfaceResult_Usual_doReturnFn[R] - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqGenericInterfaceResult[R]) PrettyParams_Usual(params MoqGenericInterfaceResult_Usual_params[R]) string { +func (*MoqGenericInterfaceResult_Usual_adaptor[R]) PrettyParams(params MoqGenericInterfaceResult_Usual_params[R]) string { return fmt.Sprintf("Usual(%#v, %#v)", params.SParam, params.BParam) } -func (m *MoqGenericInterfaceResult[R]) ParamsKey_Usual(params MoqGenericInterfaceResult_Usual_params[R], anyParams uint64) MoqGenericInterfaceResult_Usual_paramsKey[R] { - 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) - } - } +func (a *MoqGenericInterfaceResult_Usual_adaptor[R]) ParamsKey(params MoqGenericInterfaceResult_Usual_params[R], anyParams uint64) MoqGenericInterfaceResult_Usual_paramsKey[R] { + a.Moq.Moq_Usual.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.SParam, 1, a.Moq.Runtime.ParameterIndexing.Usual.SParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 2, a.Moq.Runtime.ParameterIndexing.Usual.BParam, anyParams) return MoqGenericInterfaceResult_Usual_paramsKey[R]{ Params: struct { SParam string @@ -20364,37 +11345,37 @@ func (m *MoqGenericInterfaceResult[R]) ParamsKey_Usual(params MoqGenericInterfac } // Reset resets the state of the moq -func (m *MoqGenericInterfaceResult[R]) Reset() { m.ResultsByParams_Usual = nil } +func (m *MoqGenericInterfaceResult[R]) Reset() { + m.Moq_Usual.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqGenericInterfaceResult[R]) 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)) - } - } - } + m.Moq_Usual.Scene.T.Helper() + m.Moq_Usual.AssertExpectationsMet() } // MoqUnsafePointerFn holds the state of a moq of the UnsafePointerFn type type MoqUnsafePointerFn struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqUnsafePointerFn_mock + Moq *impl.Moq[ + *MoqUnsafePointerFn_adaptor, + MoqUnsafePointerFn_params, + MoqUnsafePointerFn_paramsKey, + MoqUnsafePointerFn_results, + ] - ResultsByParams []MoqUnsafePointerFn_resultsByParams + Runtime MoqUnsafePointerFn_runtime +} - Runtime struct { - ParameterIndexing struct{} - } +// MoqUnsafePointerFn_runtime holds runtime configuration for the +// UnsafePointerFn type +type MoqUnsafePointerFn_runtime struct { + ParameterIndexing MoqUnsafePointerFn_paramIndexing } -// MoqUnsafePointerFn_mock isolates the mock interface of the UnsafePointerFn -// type -type MoqUnsafePointerFn_mock struct { +// MoqUnsafePointerFn_adaptor adapts MoqUnsafePointerFn as needed by the +// runtime +type MoqUnsafePointerFn_adaptor struct { Moq *MoqUnsafePointerFn } @@ -20408,14 +11389,15 @@ type MoqUnsafePointerFn_paramsKey struct { Hashes struct{} } -// MoqUnsafePointerFn_resultsByParams contains the results for a given set of -// parameters for the UnsafePointerFn type -type MoqUnsafePointerFn_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqUnsafePointerFn_paramsKey]*MoqUnsafePointerFn_results +// MoqUnsafePointerFn_results holds the results of the UnsafePointerFn type +type MoqUnsafePointerFn_results struct { + Result1 unsafe.Pointer } +// MoqUnsafePointerFn_paramIndexing holds the parameter indexing runtime +// configuration for the UnsafePointerFn type +type MoqUnsafePointerFn_paramIndexing struct{} + // MoqUnsafePointerFn_doFn defines the type of function needed when calling // AndDo for the UnsafePointerFn type type MoqUnsafePointerFn_doFn func() @@ -20424,52 +11406,37 @@ type MoqUnsafePointerFn_doFn func() // calling DoReturnResults for the UnsafePointerFn type type MoqUnsafePointerFn_doReturnFn func() unsafe.Pointer -// MoqUnsafePointerFn_results holds the results of the UnsafePointerFn type -type MoqUnsafePointerFn_results struct { - Params MoqUnsafePointerFn_params - Results []struct { - Values *struct { - Result1 unsafe.Pointer - } - Sequence uint32 - DoFn MoqUnsafePointerFn_doFn - DoReturnFn MoqUnsafePointerFn_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqUnsafePointerFn_fnRecorder routes recorded function calls to the +// MoqUnsafePointerFn_recorder routes recorded function calls to the // MoqUnsafePointerFn moq -type MoqUnsafePointerFn_fnRecorder struct { - Params MoqUnsafePointerFn_params - AnyParams uint64 - Sequence bool - Results *MoqUnsafePointerFn_results - Moq *MoqUnsafePointerFn +type MoqUnsafePointerFn_recorder struct { + Recorder *impl.Recorder[ + *MoqUnsafePointerFn_adaptor, + MoqUnsafePointerFn_params, + MoqUnsafePointerFn_paramsKey, + MoqUnsafePointerFn_results, + ] } // MoqUnsafePointerFn_anyParams isolates the any params functions of the // UnsafePointerFn type type MoqUnsafePointerFn_anyParams struct { - Recorder *MoqUnsafePointerFn_fnRecorder + Recorder *MoqUnsafePointerFn_recorder } // NewMoqUnsafePointerFn creates a new moq of the UnsafePointerFn type func NewMoqUnsafePointerFn(scene *moq.Scene, config *moq.Config) *MoqUnsafePointerFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqUnsafePointerFn_adaptor{} m := &MoqUnsafePointerFn{ - Scene: scene, - Config: *config, - Moq: &MoqUnsafePointerFn_mock{}, + Moq: impl.NewMoq[ + *MoqUnsafePointerFn_adaptor, + MoqUnsafePointerFn_params, + MoqUnsafePointerFn_paramsKey, + MoqUnsafePointerFn_results, + ](scene, adaptor1, config), - Runtime: struct { - ParameterIndexing struct{} - }{ParameterIndexing: struct{}{}}, + Runtime: MoqUnsafePointerFn_runtime{ParameterIndexing: MoqUnsafePointerFn_paramIndexing{}}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -20477,237 +11444,91 @@ func NewMoqUnsafePointerFn(scene *moq.Scene, config *moq.Config) *MoqUnsafePoint // Mock returns the moq implementation of the UnsafePointerFn type func (m *MoqUnsafePointerFn) Mock() testmoqs.UnsafePointerFn { - return func() unsafe.Pointer { m.Scene.T.Helper(); moq := &MoqUnsafePointerFn_mock{Moq: m}; return moq.Fn() } -} - -func (m *MoqUnsafePointerFn_mock) Fn() (result1 unsafe.Pointer) { - m.Moq.Scene.T.Helper() - params := MoqUnsafePointerFn_params{} - var results *MoqUnsafePointerFn_results - 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 - } + return func() unsafe.Pointer { + m.Moq.Scene.T.Helper() + params := MoqUnsafePointerFn_params{} - 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)) + var result1 unsafe.Pointer + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 } + return result1 } - - if result.DoFn != nil { - result.DoFn() - } - - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn() - } - return } -func (m *MoqUnsafePointerFn) OnCall() *MoqUnsafePointerFn_fnRecorder { - return &MoqUnsafePointerFn_fnRecorder{ - Params: MoqUnsafePointerFn_params{}, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, +func (m *MoqUnsafePointerFn) OnCall() *MoqUnsafePointerFn_recorder { + return &MoqUnsafePointerFn_recorder{ + Recorder: m.Moq.OnCall(MoqUnsafePointerFn_params{}), } } -func (r *MoqUnsafePointerFn_fnRecorder) Any() *MoqUnsafePointerFn_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(r.Params)) +func (r *MoqUnsafePointerFn_recorder) Any() *MoqUnsafePointerFn_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqUnsafePointerFn_anyParams{Recorder: r} } -func (r *MoqUnsafePointerFn_fnRecorder) Seq() *MoqUnsafePointerFn_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(r.Params)) +func (r *MoqUnsafePointerFn_recorder) Seq() *MoqUnsafePointerFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqUnsafePointerFn_fnRecorder) NoSeq() *MoqUnsafePointerFn_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(r.Params)) +func (r *MoqUnsafePointerFn_recorder) NoSeq() *MoqUnsafePointerFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqUnsafePointerFn_fnRecorder) ReturnResults(result1 unsafe.Pointer) *MoqUnsafePointerFn_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 unsafe.Pointer - } - Sequence uint32 - DoFn MoqUnsafePointerFn_doFn - DoReturnFn MoqUnsafePointerFn_doReturnFn - }{ - Values: &struct { - Result1 unsafe.Pointer - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqUnsafePointerFn_recorder) ReturnResults(result1 unsafe.Pointer) *MoqUnsafePointerFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqUnsafePointerFn_results{ + Result1: result1, }) return r } -func (r *MoqUnsafePointerFn_fnRecorder) AndDo(fn MoqUnsafePointerFn_doFn) *MoqUnsafePointerFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqUnsafePointerFn_recorder) AndDo(fn MoqUnsafePointerFn_doFn) *MoqUnsafePointerFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqUnsafePointerFn_params) { + fn() + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqUnsafePointerFn_fnRecorder) DoReturnResults(fn MoqUnsafePointerFn_doReturnFn) *MoqUnsafePointerFn_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 unsafe.Pointer +func (r *MoqUnsafePointerFn_recorder) DoReturnResults(fn MoqUnsafePointerFn_doReturnFn) *MoqUnsafePointerFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqUnsafePointerFn_params) *MoqUnsafePointerFn_results { + result1 := fn() + return &MoqUnsafePointerFn_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqUnsafePointerFn_doFn - DoReturnFn MoqUnsafePointerFn_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqUnsafePointerFn_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 *MoqUnsafePointerFn_resultsByParams - 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 = &MoqUnsafePointerFn_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqUnsafePointerFn_paramsKey]*MoqUnsafePointerFn_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqUnsafePointerFn_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 *MoqUnsafePointerFn_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqUnsafePointerFn_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqUnsafePointerFn_recorder) Repeat(repeaters ...moq.Repeater) *MoqUnsafePointerFn_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 unsafe.Pointer - } - Sequence uint32 - DoFn MoqUnsafePointerFn_doFn - DoReturnFn MoqUnsafePointerFn_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqUnsafePointerFn) PrettyParams(params MoqUnsafePointerFn_params) string { +func (*MoqUnsafePointerFn_adaptor) PrettyParams(params MoqUnsafePointerFn_params) string { return fmt.Sprintf("UnsafePointerFn()") } -func (m *MoqUnsafePointerFn) ParamsKey(params MoqUnsafePointerFn_params, anyParams uint64) MoqUnsafePointerFn_paramsKey { - m.Scene.T.Helper() +func (a *MoqUnsafePointerFn_adaptor) ParamsKey(params MoqUnsafePointerFn_params, anyParams uint64) MoqUnsafePointerFn_paramsKey { + a.Moq.Moq.Scene.T.Helper() return MoqUnsafePointerFn_paramsKey{ Params: struct{}{}, Hashes: struct{}{}, @@ -20715,17 +11536,12 @@ func (m *MoqUnsafePointerFn) ParamsKey(params MoqUnsafePointerFn_params, anyPara } // Reset resets the state of the moq -func (m *MoqUnsafePointerFn) Reset() { m.ResultsByParams = nil } +func (m *MoqUnsafePointerFn) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqUnsafePointerFn) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } diff --git a/generator/testmoqs/fnadaptors_test.go b/generator/testmoqs/fnadaptors_test.go index d85c39f..f0a9215 100644 --- a/generator/testmoqs/fnadaptors_test.go +++ b/generator/testmoqs/fnadaptors_test.go @@ -42,7 +42,7 @@ func (a *usualFnAdaptor) sceneMoq() moq.Moq { } type usualFnRecorder struct { - r *moqUsualFn_fnRecorder + r *moqUsualFn_recorder } func (r *usualFnRecorder) anySParam() { @@ -141,7 +141,7 @@ func (a *exportedUsualFnAdaptor) sceneMoq() moq.Moq { } type exportedUsualFnRecorder struct { - r *exported.MoqUsualFn_fnRecorder + r *exported.MoqUsualFn_recorder } func (r *exportedUsualFnRecorder) anySParam() { @@ -238,7 +238,7 @@ func (a *noNamesFnAdaptor) sceneMoq() moq.Moq { } type noNamesFnRecorder struct { - r *moqNoNamesFn_fnRecorder + r *moqNoNamesFn_recorder } func (r *noNamesFnRecorder) anySParam() { @@ -337,7 +337,7 @@ func (a *exportedNoNamesFnAdaptor) sceneMoq() moq.Moq { } type exportedNoNamesFnRecorder struct { - r *exported.MoqNoNamesFn_fnRecorder + r *exported.MoqNoNamesFn_recorder } func (r *exportedNoNamesFnRecorder) anySParam() { @@ -428,7 +428,7 @@ func (a *noResultsFnAdaptor) sceneMoq() moq.Moq { } type noResultsFnRecorder struct { - r *moqNoResultsFn_fnRecorder + r *moqNoResultsFn_recorder } func (r *noResultsFnRecorder) anySParam() { @@ -520,7 +520,7 @@ func (a *exportedNoResultsFnAdaptor) sceneMoq() moq.Moq { } type exportedNoResultsFnRecorder struct { - r *exported.MoqNoResultsFn_fnRecorder + r *exported.MoqNoResultsFn_recorder } func (r *exportedNoResultsFnRecorder) anySParam() { @@ -618,7 +618,7 @@ func (a *noParamsFnAdaptor) sceneMoq() moq.Moq { } type noParamsFnRecorder struct { - r *moqNoParamsFn_fnRecorder + r *moqNoParamsFn_recorder } func (r *noParamsFnRecorder) anySParam() {} @@ -693,7 +693,7 @@ func (a *exportedNoParamsFnAdaptor) sceneMoq() moq.Moq { } type exportedNoParamsFnRecorder struct { - r *exported.MoqNoParamsFn_fnRecorder + r *exported.MoqNoParamsFn_recorder } func (r *exportedNoParamsFnRecorder) anySParam() {} @@ -762,7 +762,7 @@ func (a *nothingFnAdaptor) sceneMoq() moq.Moq { } type nothingFnRecorder struct { - r *moqNothingFn_fnRecorder + r *moqNothingFn_recorder } func (r *nothingFnRecorder) anySParam() {} @@ -830,7 +830,7 @@ func (a *exportedNothingFnAdaptor) sceneMoq() moq.Moq { } type exportedNothingFnRecorder struct { - r *exported.MoqNothingFn_fnRecorder + r *exported.MoqNothingFn_recorder } func (r *exportedNothingFnRecorder) anySParam() {} @@ -902,7 +902,7 @@ func (a *variadicFnAdaptor) sceneMoq() moq.Moq { } type variadicFnRecorder struct { - r *moqVariadicFn_fnRecorder + r *moqVariadicFn_recorder } func (r *variadicFnRecorder) anySParam() { @@ -1003,7 +1003,7 @@ func (a *exportedVariadicFnAdaptor) sceneMoq() moq.Moq { } type exportedVariadicFnRecorder struct { - r *exported.MoqVariadicFn_fnRecorder + r *exported.MoqVariadicFn_recorder } func (r *exportedVariadicFnRecorder) anySParam() { @@ -1103,7 +1103,7 @@ func (a *repeatedIdsFnAdaptor) sceneMoq() moq.Moq { } type repeatedIdsFnRecorder struct { - r *moqRepeatedIdsFn_fnRecorder + r *moqRepeatedIdsFn_recorder } func (r *repeatedIdsFnRecorder) anySParam() { @@ -1213,7 +1213,7 @@ func (a *exportedRepeatedIdsFnAdaptor) sceneMoq() moq.Moq { } type exportedRepeatedIdsFnRecorder struct { - r *exported.MoqRepeatedIdsFn_fnRecorder + r *exported.MoqRepeatedIdsFn_recorder } func (r *exportedRepeatedIdsFnRecorder) anySParam() { @@ -1316,7 +1316,7 @@ func (a *timesFnAdaptor) sceneMoq() moq.Moq { } type timesFnRecorder struct { - r *moqTimesFn_fnRecorder + r *moqTimesFn_recorder } func (r *timesFnRecorder) anySParam() { @@ -1415,7 +1415,7 @@ func (a *exportedTimesFnAdaptor) sceneMoq() moq.Moq { } type exportedTimesFnRecorder struct { - r *exported.MoqTimesFn_fnRecorder + r *exported.MoqTimesFn_recorder } func (r *exportedTimesFnRecorder) anySParam() { @@ -1506,7 +1506,7 @@ func (a *difficultParamNamesFnAdaptor) sceneMoq() moq.Moq { } type difficultParamNamesFnRecorder struct { - r *moqDifficultParamNamesFn_fnRecorder + r *moqDifficultParamNamesFn_recorder } func (r *difficultParamNamesFnRecorder) anySParam() { @@ -1602,7 +1602,7 @@ func (a *exportedDifficultParamNamesFnAdaptor) sceneMoq() moq.Moq { } type exportedDifficultParamNamesFnRecorder struct { - r *exported.MoqDifficultParamNamesFn_fnRecorder + r *exported.MoqDifficultParamNamesFn_recorder } func (r *exportedDifficultParamNamesFnRecorder) anySParam() { @@ -1705,7 +1705,7 @@ func (a *difficultResultNamesFnAdaptor) sceneMoq() moq.Moq { } type difficultResultNamesFnRecorder struct { - r *moqDifficultResultNamesFn_fnRecorder + r *moqDifficultResultNamesFn_recorder } func (r *difficultResultNamesFnRecorder) anySParam() {} @@ -1784,7 +1784,7 @@ func (a *exportedDifficultResultNamesFnAdaptor) sceneMoq() moq.Moq { } type exportedDifficultResultNamesFnRecorder struct { - r *exported.MoqDifficultResultNamesFn_fnRecorder + r *exported.MoqDifficultResultNamesFn_recorder } func (r *exportedDifficultResultNamesFnRecorder) anySParam() {} @@ -1877,7 +1877,7 @@ func (a *passByReferenceFnAdaptor) sceneMoq() moq.Moq { } type passByReferenceFnRecorder struct { - r *moqPassByReferenceFn_fnRecorder + r *moqPassByReferenceFn_recorder } func (r *passByReferenceFnRecorder) anySParam() { @@ -1996,7 +1996,7 @@ func (a *exportedPassByReferenceFnAdaptor) sceneMoq() moq.Moq { } type exportedPassByReferenceFnRecorder struct { - r *exported.MoqPassByReferenceFn_fnRecorder + r *exported.MoqPassByReferenceFn_recorder } func (r *exportedPassByReferenceFnRecorder) anySParam() { @@ -2106,7 +2106,7 @@ func (a *interfaceParamFnAdaptor) sceneMoq() moq.Moq { } type interfaceParamFnRecorder struct { - r *moqInterfaceParamFn_fnRecorder + r *moqInterfaceParamFn_recorder } func (r *interfaceParamFnRecorder) anySParam() { @@ -2227,7 +2227,7 @@ func (a *exportedInterfaceParamFnAdaptor) sceneMoq() moq.Moq { } type exportedInterfaceParamFnRecorder struct { - r *exported.MoqInterfaceParamFn_fnRecorder + r *exported.MoqInterfaceParamFn_recorder } func (r *exportedInterfaceParamFnRecorder) anySParam() { @@ -2346,7 +2346,7 @@ func (a *interfaceResultFnAdaptor) sceneMoq() moq.Moq { } type interfaceResultFnRecorder struct { - r *moqInterfaceResultFn_fnRecorder + r *moqInterfaceResultFn_recorder } func (r *interfaceResultFnRecorder) anySParam() { @@ -2466,7 +2466,7 @@ func (a *exportedInterfaceResultFnAdaptor) sceneMoq() moq.Moq { } type exportedInterfaceResultFnRecorder struct { - r *exported.MoqInterfaceResultFn_fnRecorder + r *exported.MoqInterfaceResultFn_recorder } func (r *exportedInterfaceResultFnRecorder) anySParam() { @@ -2569,7 +2569,7 @@ func (a *genericParamsFnAdaptor[S, B]) sceneMoq() moq.Moq { } type genericParamsFnRecorder[S, B any] struct { - r *moqGenericParamsFn_fnRecorder[S, B] + r *moqGenericParamsFn_recorder[S, B] } func (r *genericParamsFnRecorder[S, B]) anySParam() { @@ -2670,7 +2670,7 @@ func (a *exportedGenericParamsFnAdaptor[S, B]) sceneMoq() moq.Moq { } type exportedGenericParamsFnRecorder[S, B any] struct { - r *exported.MoqGenericParamsFn_fnRecorder[S, B] + r *exported.MoqGenericParamsFn_recorder[S, B] } func (r *exportedGenericParamsFnRecorder[S, B]) anySParam() { @@ -2771,7 +2771,7 @@ func (a *partialGenericParamsFnAdaptor[S]) sceneMoq() moq.Moq { } type partialGenericParamsFnRecorder[S any] struct { - r *moqPartialGenericParamsFn_fnRecorder[S] + r *moqPartialGenericParamsFn_recorder[S] } func (r *partialGenericParamsFnRecorder[S]) anySParam() { @@ -2872,7 +2872,7 @@ func (a *exportedPartialGenericParamsFnAdaptor[S]) sceneMoq() moq.Moq { } type exportedPartialGenericParamsFnRecorder[S any] struct { - r *exported.MoqPartialGenericParamsFn_fnRecorder[S] + r *exported.MoqPartialGenericParamsFn_recorder[S] } func (r *exportedPartialGenericParamsFnRecorder[S]) anySParam() { @@ -2973,7 +2973,7 @@ func (a *genericResultsFnAdaptor[S, E]) sceneMoq() moq.Moq { } type genericResultsFnRecorder[S ~string, E error] struct { - r *moqGenericResultsFn_fnRecorder[S, E] + r *moqGenericResultsFn_recorder[S, E] } func (r *genericResultsFnRecorder[S, E]) anySParam() { @@ -3082,7 +3082,7 @@ func (a *exportedGenericResultsFnAdaptor[S, E]) sceneMoq() moq.Moq { } type exportedGenericResultsFnRecorder[S ~string, E error] struct { - r *exported.MoqGenericResultsFn_fnRecorder[S, E] + r *exported.MoqGenericResultsFn_recorder[S, E] } func (r *exportedGenericResultsFnRecorder[S, E]) anySParam() { @@ -3191,7 +3191,7 @@ func (a *partialGenericResultsFnAdaptor[S]) sceneMoq() moq.Moq { } type partialGenericResultsFnRecorder[S ~string] struct { - r *moqPartialGenericResultsFn_fnRecorder[S] + r *moqPartialGenericResultsFn_recorder[S] } func (r *partialGenericResultsFnRecorder[S]) anySParam() { @@ -3294,7 +3294,7 @@ func (a *exportedPartialGenericResultsFnAdaptor[S]) sceneMoq() moq.Moq { } type exportedPartialGenericResultsFnRecorder[S ~string] struct { - r *exported.MoqPartialGenericResultsFn_fnRecorder[S] + r *exported.MoqPartialGenericResultsFn_recorder[S] } func (r *exportedPartialGenericResultsFnRecorder[S]) anySParam() { diff --git a/generator/testmoqs/moq_t_test.go b/generator/testmoqs/moq_t_test.go index 8cc9359..d1c5154 100644 --- a/generator/testmoqs/moq_t_test.go +++ b/generator/testmoqs/moq_t_test.go @@ -4,10 +4,9 @@ package testmoqs_test import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -16,27 +15,28 @@ var _ moq.T = (*moqT_mock)(nil) // moqT holds the state of a moq of the T type type moqT struct { - scene *moq.Scene - config moq.Config - moq *moqT_mock - - resultsByParams_Errorf []moqT_Errorf_resultsByParams - resultsByParams_Fatalf []moqT_Fatalf_resultsByParams - resultsByParams_Helper []moqT_Helper_resultsByParams - - runtime struct { - parameterIndexing struct { - Errorf struct { - format moq.ParamIndexing - args moq.ParamIndexing - } - Fatalf struct { - format moq.ParamIndexing - args moq.ParamIndexing - } - Helper struct{} - } - } + moq *moqT_mock + + moq_Errorf *impl.Moq[ + *moqT_Errorf_adaptor, + moqT_Errorf_params, + moqT_Errorf_paramsKey, + moqT_Errorf_results, + ] + moq_Fatalf *impl.Moq[ + *moqT_Fatalf_adaptor, + moqT_Fatalf_params, + moqT_Fatalf_paramsKey, + moqT_Fatalf_results, + ] + moq_Helper *impl.Moq[ + *moqT_Helper_adaptor, + moqT_Helper_params, + moqT_Helper_paramsKey, + moqT_Helper_results, + ] + + runtime moqT_runtime } // moqT_mock isolates the mock interface of the T type @@ -49,6 +49,20 @@ type moqT_recorder struct { moq *moqT } +// moqT_runtime holds runtime configuration for the T type +type moqT_runtime struct { + parameterIndexing struct { + Errorf moqT_Errorf_paramIndexing + Fatalf moqT_Fatalf_paramIndexing + Helper moqT_Helper_paramIndexing + } +} + +// moqT_Errorf_adaptor adapts moqT as needed by the runtime +type moqT_Errorf_adaptor struct { + moq *moqT +} + // moqT_Errorf_params holds the params of the T type type moqT_Errorf_params struct { format string @@ -64,12 +78,14 @@ type moqT_Errorf_paramsKey struct { } } -// moqT_Errorf_resultsByParams contains the results for a given set of -// parameters for the T type -type moqT_Errorf_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqT_Errorf_paramsKey]*moqT_Errorf_results +// moqT_Errorf_results holds the results of the T type +type moqT_Errorf_results struct{} + +// moqT_Errorf_paramIndexing holds the parameter indexing runtime configuration +// for the T type +type moqT_Errorf_paramIndexing struct { + format moq.ParamIndexing + args moq.ParamIndexing } // moqT_Errorf_doFn defines the type of function needed when calling andDo for @@ -80,31 +96,24 @@ type moqT_Errorf_doFn func(format string, args ...interface{}) // doReturnResults for the T type type moqT_Errorf_doReturnFn func(format string, args ...interface{}) -// moqT_Errorf_results holds the results of the T type -type moqT_Errorf_results struct { - params moqT_Errorf_params - results []struct { - values *struct{} - sequence uint32 - doFn moqT_Errorf_doFn - doReturnFn moqT_Errorf_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqT_Errorf_fnRecorder routes recorded function calls to the moqT moq -type moqT_Errorf_fnRecorder struct { - params moqT_Errorf_params - anyParams uint64 - sequence bool - results *moqT_Errorf_results - moq *moqT +// moqT_Errorf_recorder routes recorded function calls to the moqT moq +type moqT_Errorf_recorder struct { + recorder *impl.Recorder[ + *moqT_Errorf_adaptor, + moqT_Errorf_params, + moqT_Errorf_paramsKey, + moqT_Errorf_results, + ] } // moqT_Errorf_anyParams isolates the any params functions of the T type type moqT_Errorf_anyParams struct { - recorder *moqT_Errorf_fnRecorder + recorder *moqT_Errorf_recorder +} + +// moqT_Fatalf_adaptor adapts moqT as needed by the runtime +type moqT_Fatalf_adaptor struct { + moq *moqT } // moqT_Fatalf_params holds the params of the T type @@ -122,12 +131,14 @@ type moqT_Fatalf_paramsKey struct { } } -// moqT_Fatalf_resultsByParams contains the results for a given set of -// parameters for the T type -type moqT_Fatalf_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqT_Fatalf_paramsKey]*moqT_Fatalf_results +// moqT_Fatalf_results holds the results of the T type +type moqT_Fatalf_results struct{} + +// moqT_Fatalf_paramIndexing holds the parameter indexing runtime configuration +// for the T type +type moqT_Fatalf_paramIndexing struct { + format moq.ParamIndexing + args moq.ParamIndexing } // moqT_Fatalf_doFn defines the type of function needed when calling andDo for @@ -138,31 +149,24 @@ type moqT_Fatalf_doFn func(format string, args ...interface{}) // doReturnResults for the T type type moqT_Fatalf_doReturnFn func(format string, args ...interface{}) -// moqT_Fatalf_results holds the results of the T type -type moqT_Fatalf_results struct { - params moqT_Fatalf_params - results []struct { - values *struct{} - sequence uint32 - doFn moqT_Fatalf_doFn - doReturnFn moqT_Fatalf_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqT_Fatalf_fnRecorder routes recorded function calls to the moqT moq -type moqT_Fatalf_fnRecorder struct { - params moqT_Fatalf_params - anyParams uint64 - sequence bool - results *moqT_Fatalf_results - moq *moqT +// moqT_Fatalf_recorder routes recorded function calls to the moqT moq +type moqT_Fatalf_recorder struct { + recorder *impl.Recorder[ + *moqT_Fatalf_adaptor, + moqT_Fatalf_params, + moqT_Fatalf_paramsKey, + moqT_Fatalf_results, + ] } // moqT_Fatalf_anyParams isolates the any params functions of the T type type moqT_Fatalf_anyParams struct { - recorder *moqT_Fatalf_fnRecorder + recorder *moqT_Fatalf_recorder +} + +// moqT_Helper_adaptor adapts moqT as needed by the runtime +type moqT_Helper_adaptor struct { + moq *moqT } // moqT_Helper_params holds the params of the T type @@ -174,13 +178,12 @@ type moqT_Helper_paramsKey struct { hashes struct{} } -// moqT_Helper_resultsByParams contains the results for a given set of -// parameters for the T type -type moqT_Helper_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqT_Helper_paramsKey]*moqT_Helper_results -} +// moqT_Helper_results holds the results of the T type +type moqT_Helper_results struct{} + +// moqT_Helper_paramIndexing holds the parameter indexing runtime configuration +// for the T type +type moqT_Helper_paramIndexing struct{} // moqT_Helper_doFn defines the type of function needed when calling andDo for // the T type @@ -190,85 +193,70 @@ type moqT_Helper_doFn func() // doReturnResults for the T type type moqT_Helper_doReturnFn func() -// moqT_Helper_results holds the results of the T type -type moqT_Helper_results struct { - params moqT_Helper_params - results []struct { - values *struct{} - sequence uint32 - doFn moqT_Helper_doFn - doReturnFn moqT_Helper_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqT_Helper_fnRecorder routes recorded function calls to the moqT moq -type moqT_Helper_fnRecorder struct { - params moqT_Helper_params - anyParams uint64 - sequence bool - results *moqT_Helper_results - moq *moqT +// moqT_Helper_recorder routes recorded function calls to the moqT moq +type moqT_Helper_recorder struct { + recorder *impl.Recorder[ + *moqT_Helper_adaptor, + moqT_Helper_params, + moqT_Helper_paramsKey, + moqT_Helper_results, + ] } // moqT_Helper_anyParams isolates the any params functions of the T type type moqT_Helper_anyParams struct { - recorder *moqT_Helper_fnRecorder + recorder *moqT_Helper_recorder } // newMoqT creates a new moq of the T type func newMoqT(scene *moq.Scene, config *moq.Config) *moqT { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqT_Errorf_adaptor{} + adaptor2 := &moqT_Fatalf_adaptor{} + adaptor3 := &moqT_Helper_adaptor{} m := &moqT{ - scene: scene, - config: *config, - moq: &moqT_mock{}, - - runtime: struct { - parameterIndexing struct { - Errorf struct { - format moq.ParamIndexing - args moq.ParamIndexing - } - Fatalf struct { - format moq.ParamIndexing - args moq.ParamIndexing - } - Helper struct{} - } - }{parameterIndexing: struct { - Errorf struct { - format moq.ParamIndexing - args moq.ParamIndexing - } - Fatalf struct { - format moq.ParamIndexing - args moq.ParamIndexing - } - Helper struct{} + moq: &moqT_mock{}, + + moq_Errorf: impl.NewMoq[ + *moqT_Errorf_adaptor, + moqT_Errorf_params, + moqT_Errorf_paramsKey, + moqT_Errorf_results, + ](scene, adaptor1, config), + moq_Fatalf: impl.NewMoq[ + *moqT_Fatalf_adaptor, + moqT_Fatalf_params, + moqT_Fatalf_paramsKey, + moqT_Fatalf_results, + ](scene, adaptor2, config), + moq_Helper: impl.NewMoq[ + *moqT_Helper_adaptor, + moqT_Helper_params, + moqT_Helper_paramsKey, + moqT_Helper_results, + ](scene, adaptor3, config), + + runtime: moqT_runtime{parameterIndexing: struct { + Errorf moqT_Errorf_paramIndexing + Fatalf moqT_Fatalf_paramIndexing + Helper moqT_Helper_paramIndexing }{ - Errorf: struct { - format moq.ParamIndexing - args moq.ParamIndexing - }{ + Errorf: moqT_Errorf_paramIndexing{ format: moq.ParamIndexByValue, args: moq.ParamIndexByHash, }, - Fatalf: struct { - format moq.ParamIndexing - args moq.ParamIndexing - }{ + Fatalf: moqT_Fatalf_paramIndexing{ format: moq.ParamIndexByValue, args: moq.ParamIndexByHash, }, - Helper: struct{}{}, + Helper: moqT_Helper_paramIndexing{}, }}, } m.moq.moq = m + adaptor1.moq = m + adaptor2.moq = m + adaptor3.moq = m + scene.AddMoq(m) return m } @@ -277,153 +265,30 @@ func newMoqT(scene *moq.Scene, config *moq.Config) *moqT { func (m *moqT) mock() *moqT_mock { return m.moq } func (m *moqT_mock) Errorf(format string, args ...interface{}) { - m.moq.scene.T.Helper() + m.moq.moq_Errorf.Scene.T.Helper() params := moqT_Errorf_params{ format: format, args: args, } - var results *moqT_Errorf_results - for _, resultsByParams := range m.moq.resultsByParams_Errorf { - paramsKey := m.moq.paramsKey_Errorf(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_Errorf(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_Errorf(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_Errorf(params)) - } - } - if result.doFn != nil { - result.doFn(format, args...) - } - - if result.doReturnFn != nil { - result.doReturnFn(format, args...) - } - return + m.moq.moq_Errorf.Function(params) } func (m *moqT_mock) Fatalf(format string, args ...interface{}) { - m.moq.scene.T.Helper() + m.moq.moq_Fatalf.Scene.T.Helper() params := moqT_Fatalf_params{ format: format, args: args, } - var results *moqT_Fatalf_results - for _, resultsByParams := range m.moq.resultsByParams_Fatalf { - paramsKey := m.moq.paramsKey_Fatalf(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_Fatalf(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_Fatalf(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_Fatalf(params)) - } - } - - if result.doFn != nil { - result.doFn(format, args...) - } - - if result.doReturnFn != nil { - result.doReturnFn(format, args...) - } - return + m.moq.moq_Fatalf.Function(params) } func (m *moqT_mock) Helper() { - m.moq.scene.T.Helper() + m.moq.moq_Helper.Scene.T.Helper() params := moqT_Helper_params{} - var results *moqT_Helper_results - for _, resultsByParams := range m.moq.resultsByParams_Helper { - paramsKey := m.moq.paramsKey_Helper(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_Helper(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_Helper(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_Helper(params)) - } - } - - if result.doFn != nil { - result.doFn() - } - - if result.doReturnFn != nil { - result.doReturnFn() - } - return + m.moq.moq_Helper.Function(params) } // onCall returns the recorder implementation of the T type @@ -433,202 +298,92 @@ func (m *moqT) onCall() *moqT_recorder { } } -func (m *moqT_recorder) Errorf(format string, args ...interface{}) *moqT_Errorf_fnRecorder { - return &moqT_Errorf_fnRecorder{ - params: moqT_Errorf_params{ +func (m *moqT_recorder) Errorf(format string, args ...interface{}) *moqT_Errorf_recorder { + return &moqT_Errorf_recorder{ + recorder: m.moq.moq_Errorf.OnCall(moqT_Errorf_params{ format: format, args: args, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqT_Errorf_fnRecorder) any() *moqT_Errorf_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_Errorf(r.params)) +func (r *moqT_Errorf_recorder) any() *moqT_Errorf_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqT_Errorf_anyParams{recorder: r} } -func (a *moqT_Errorf_anyParams) format() *moqT_Errorf_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqT_Errorf_anyParams) format() *moqT_Errorf_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqT_Errorf_anyParams) args() *moqT_Errorf_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqT_Errorf_anyParams) args() *moqT_Errorf_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqT_Errorf_fnRecorder) seq() *moqT_Errorf_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_Errorf(r.params)) +func (r *moqT_Errorf_recorder) seq() *moqT_Errorf_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqT_Errorf_fnRecorder) noSeq() *moqT_Errorf_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_Errorf(r.params)) +func (r *moqT_Errorf_recorder) noSeq() *moqT_Errorf_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqT_Errorf_fnRecorder) returnResults() *moqT_Errorf_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 moqT_Errorf_doFn - doReturnFn moqT_Errorf_doReturnFn - }{ - values: &struct{}{}, - sequence: sequence, - }) +func (r *moqT_Errorf_recorder) returnResults() *moqT_Errorf_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqT_Errorf_results{}) return r } -func (r *moqT_Errorf_fnRecorder) andDo(fn moqT_Errorf_doFn) *moqT_Errorf_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqT_Errorf_recorder) andDo(fn moqT_Errorf_doFn) *moqT_Errorf_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqT_Errorf_params) { + fn(params.format, params.args...) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqT_Errorf_fnRecorder) doReturnResults(fn moqT_Errorf_doReturnFn) *moqT_Errorf_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 moqT_Errorf_doFn - doReturnFn moqT_Errorf_doReturnFn - }{sequence: sequence, doReturnFn: fn}) +func (r *moqT_Errorf_recorder) doReturnResults(fn moqT_Errorf_doReturnFn) *moqT_Errorf_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqT_Errorf_params) *moqT_Errorf_results { + fn(params.format, params.args...) + return &moqT_Errorf_results{} + }) return r } -func (r *moqT_Errorf_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 *moqT_Errorf_resultsByParams - for n, res := range r.moq.resultsByParams_Errorf { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqT_Errorf_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqT_Errorf_paramsKey]*moqT_Errorf_results{}, - } - r.moq.resultsByParams_Errorf = append(r.moq.resultsByParams_Errorf, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Errorf) { - copy(r.moq.resultsByParams_Errorf[insertAt+1:], r.moq.resultsByParams_Errorf[insertAt:0]) - r.moq.resultsByParams_Errorf[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Errorf(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqT_Errorf_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 *moqT_Errorf_fnRecorder) repeat(repeaters ...moq.Repeater) *moqT_Errorf_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqT_Errorf_recorder) repeat(repeaters ...moq.Repeater) *moqT_Errorf_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 moqT_Errorf_doFn - doReturnFn moqT_Errorf_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqT) prettyParams_Errorf(params moqT_Errorf_params) string { +func (*moqT_Errorf_adaptor) PrettyParams(params moqT_Errorf_params) string { return fmt.Sprintf("Errorf(%#v, %#v)", params.format, params.args) } -func (m *moqT) paramsKey_Errorf(params moqT_Errorf_params, anyParams uint64) moqT_Errorf_paramsKey { - m.scene.T.Helper() - var formatUsed string - var formatUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Errorf.format == moq.ParamIndexByValue { - formatUsed = params.format - } else { - formatUsedHash = hash.DeepHash(params.format) - } - } - var argsUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.Errorf.args == moq.ParamIndexByValue { - m.scene.T.Fatalf("The args parameter of the Errorf function can't be indexed by value") - } - argsUsedHash = hash.DeepHash(params.args) - } +func (a *moqT_Errorf_adaptor) ParamsKey(params moqT_Errorf_params, anyParams uint64) moqT_Errorf_paramsKey { + a.moq.moq_Errorf.Scene.T.Helper() + formatUsed, formatUsedHash := impl.ParamKey( + params.format, 1, a.moq.runtime.parameterIndexing.Errorf.format, anyParams) + argsUsedHash := impl.HashOnlyParamKey(a.moq.moq_Errorf.Scene.T, + params.args, "args", 2, a.moq.runtime.parameterIndexing.Errorf.args, anyParams) return moqT_Errorf_paramsKey{ params: struct{ format string }{ format: formatUsed, @@ -643,202 +398,92 @@ func (m *moqT) paramsKey_Errorf(params moqT_Errorf_params, anyParams uint64) moq } } -func (m *moqT_recorder) Fatalf(format string, args ...interface{}) *moqT_Fatalf_fnRecorder { - return &moqT_Fatalf_fnRecorder{ - params: moqT_Fatalf_params{ +func (m *moqT_recorder) Fatalf(format string, args ...interface{}) *moqT_Fatalf_recorder { + return &moqT_Fatalf_recorder{ + recorder: m.moq.moq_Fatalf.OnCall(moqT_Fatalf_params{ format: format, args: args, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqT_Fatalf_fnRecorder) any() *moqT_Fatalf_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_Fatalf(r.params)) +func (r *moqT_Fatalf_recorder) any() *moqT_Fatalf_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqT_Fatalf_anyParams{recorder: r} } -func (a *moqT_Fatalf_anyParams) format() *moqT_Fatalf_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqT_Fatalf_anyParams) format() *moqT_Fatalf_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqT_Fatalf_anyParams) args() *moqT_Fatalf_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqT_Fatalf_anyParams) args() *moqT_Fatalf_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqT_Fatalf_fnRecorder) seq() *moqT_Fatalf_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_Fatalf(r.params)) +func (r *moqT_Fatalf_recorder) seq() *moqT_Fatalf_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqT_Fatalf_fnRecorder) noSeq() *moqT_Fatalf_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_Fatalf(r.params)) +func (r *moqT_Fatalf_recorder) noSeq() *moqT_Fatalf_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqT_Fatalf_fnRecorder) returnResults() *moqT_Fatalf_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 moqT_Fatalf_doFn - doReturnFn moqT_Fatalf_doReturnFn - }{ - values: &struct{}{}, - sequence: sequence, - }) +func (r *moqT_Fatalf_recorder) returnResults() *moqT_Fatalf_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqT_Fatalf_results{}) return r } -func (r *moqT_Fatalf_fnRecorder) andDo(fn moqT_Fatalf_doFn) *moqT_Fatalf_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqT_Fatalf_recorder) andDo(fn moqT_Fatalf_doFn) *moqT_Fatalf_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqT_Fatalf_params) { + fn(params.format, params.args...) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqT_Fatalf_fnRecorder) doReturnResults(fn moqT_Fatalf_doReturnFn) *moqT_Fatalf_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 moqT_Fatalf_doFn - doReturnFn moqT_Fatalf_doReturnFn - }{sequence: sequence, doReturnFn: fn}) +func (r *moqT_Fatalf_recorder) doReturnResults(fn moqT_Fatalf_doReturnFn) *moqT_Fatalf_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqT_Fatalf_params) *moqT_Fatalf_results { + fn(params.format, params.args...) + return &moqT_Fatalf_results{} + }) return r } -func (r *moqT_Fatalf_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 *moqT_Fatalf_resultsByParams - for n, res := range r.moq.resultsByParams_Fatalf { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqT_Fatalf_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqT_Fatalf_paramsKey]*moqT_Fatalf_results{}, - } - r.moq.resultsByParams_Fatalf = append(r.moq.resultsByParams_Fatalf, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Fatalf) { - copy(r.moq.resultsByParams_Fatalf[insertAt+1:], r.moq.resultsByParams_Fatalf[insertAt:0]) - r.moq.resultsByParams_Fatalf[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Fatalf(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqT_Fatalf_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 *moqT_Fatalf_fnRecorder) repeat(repeaters ...moq.Repeater) *moqT_Fatalf_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqT_Fatalf_recorder) repeat(repeaters ...moq.Repeater) *moqT_Fatalf_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 moqT_Fatalf_doFn - doReturnFn moqT_Fatalf_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqT) prettyParams_Fatalf(params moqT_Fatalf_params) string { +func (*moqT_Fatalf_adaptor) PrettyParams(params moqT_Fatalf_params) string { return fmt.Sprintf("Fatalf(%#v, %#v)", params.format, params.args) } -func (m *moqT) paramsKey_Fatalf(params moqT_Fatalf_params, anyParams uint64) moqT_Fatalf_paramsKey { - m.scene.T.Helper() - var formatUsed string - var formatUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Fatalf.format == moq.ParamIndexByValue { - formatUsed = params.format - } else { - formatUsedHash = hash.DeepHash(params.format) - } - } - var argsUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.Fatalf.args == moq.ParamIndexByValue { - m.scene.T.Fatalf("The args parameter of the Fatalf function can't be indexed by value") - } - argsUsedHash = hash.DeepHash(params.args) - } +func (a *moqT_Fatalf_adaptor) ParamsKey(params moqT_Fatalf_params, anyParams uint64) moqT_Fatalf_paramsKey { + a.moq.moq_Fatalf.Scene.T.Helper() + formatUsed, formatUsedHash := impl.ParamKey( + params.format, 1, a.moq.runtime.parameterIndexing.Fatalf.format, anyParams) + argsUsedHash := impl.HashOnlyParamKey(a.moq.moq_Fatalf.Scene.T, + params.args, "args", 2, a.moq.runtime.parameterIndexing.Fatalf.args, anyParams) return moqT_Fatalf_paramsKey{ params: struct{ format string }{ format: formatUsed, @@ -853,171 +498,75 @@ func (m *moqT) paramsKey_Fatalf(params moqT_Fatalf_params, anyParams uint64) moq } } -func (m *moqT_recorder) Helper() *moqT_Helper_fnRecorder { - return &moqT_Helper_fnRecorder{ - params: moqT_Helper_params{}, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, +func (m *moqT_recorder) Helper() *moqT_Helper_recorder { + return &moqT_Helper_recorder{ + recorder: m.moq.moq_Helper.OnCall(moqT_Helper_params{}), } } -func (r *moqT_Helper_fnRecorder) any() *moqT_Helper_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_Helper(r.params)) +func (r *moqT_Helper_recorder) any() *moqT_Helper_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqT_Helper_anyParams{recorder: r} } -func (r *moqT_Helper_fnRecorder) seq() *moqT_Helper_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_Helper(r.params)) +func (r *moqT_Helper_recorder) seq() *moqT_Helper_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqT_Helper_fnRecorder) noSeq() *moqT_Helper_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_Helper(r.params)) +func (r *moqT_Helper_recorder) noSeq() *moqT_Helper_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqT_Helper_fnRecorder) returnResults() *moqT_Helper_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 moqT_Helper_doFn - doReturnFn moqT_Helper_doReturnFn - }{ - values: &struct{}{}, - sequence: sequence, - }) +func (r *moqT_Helper_recorder) returnResults() *moqT_Helper_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqT_Helper_results{}) return r } -func (r *moqT_Helper_fnRecorder) andDo(fn moqT_Helper_doFn) *moqT_Helper_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqT_Helper_recorder) andDo(fn moqT_Helper_doFn) *moqT_Helper_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqT_Helper_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqT_Helper_fnRecorder) doReturnResults(fn moqT_Helper_doReturnFn) *moqT_Helper_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 moqT_Helper_doFn - doReturnFn moqT_Helper_doReturnFn - }{sequence: sequence, doReturnFn: fn}) +func (r *moqT_Helper_recorder) doReturnResults(fn moqT_Helper_doReturnFn) *moqT_Helper_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqT_Helper_params) *moqT_Helper_results { + fn() + return &moqT_Helper_results{} + }) return r } -func (r *moqT_Helper_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 *moqT_Helper_resultsByParams - for n, res := range r.moq.resultsByParams_Helper { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqT_Helper_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqT_Helper_paramsKey]*moqT_Helper_results{}, - } - r.moq.resultsByParams_Helper = append(r.moq.resultsByParams_Helper, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Helper) { - copy(r.moq.resultsByParams_Helper[insertAt+1:], r.moq.resultsByParams_Helper[insertAt:0]) - r.moq.resultsByParams_Helper[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Helper(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqT_Helper_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 *moqT_Helper_fnRecorder) repeat(repeaters ...moq.Repeater) *moqT_Helper_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqT_Helper_recorder) repeat(repeaters ...moq.Repeater) *moqT_Helper_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 moqT_Helper_doFn - doReturnFn moqT_Helper_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqT) prettyParams_Helper(params moqT_Helper_params) string { return fmt.Sprintf("Helper()") } +func (*moqT_Helper_adaptor) PrettyParams(params moqT_Helper_params) string { + return fmt.Sprintf("Helper()") +} -func (m *moqT) paramsKey_Helper(params moqT_Helper_params, anyParams uint64) moqT_Helper_paramsKey { - m.scene.T.Helper() +func (a *moqT_Helper_adaptor) ParamsKey(params moqT_Helper_params, anyParams uint64) moqT_Helper_paramsKey { + a.moq.moq_Helper.Scene.T.Helper() return moqT_Helper_paramsKey{ params: struct{}{}, hashes: struct{}{}, @@ -1026,36 +575,15 @@ func (m *moqT) paramsKey_Helper(params moqT_Helper_params, anyParams uint64) moq // Reset resets the state of the moq func (m *moqT) Reset() { - m.resultsByParams_Errorf = nil - m.resultsByParams_Fatalf = nil - m.resultsByParams_Helper = nil + m.moq_Errorf.Reset() + m.moq_Fatalf.Reset() + m.moq_Helper.Reset() } // AssertExpectationsMet asserts that all expectations have been met func (m *moqT) AssertExpectationsMet() { - m.scene.T.Helper() - for _, res := range m.resultsByParams_Errorf { - 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_Errorf(results.params)) - } - } - } - for _, res := range m.resultsByParams_Fatalf { - 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_Fatalf(results.params)) - } - } - } - for _, res := range m.resultsByParams_Helper { - 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_Helper(results.params)) - } - } - } + m.moq_Errorf.Scene.T.Helper() + m.moq_Errorf.AssertExpectationsMet() + m.moq_Fatalf.AssertExpectationsMet() + m.moq_Helper.AssertExpectationsMet() } diff --git a/generator/testmoqs/moq_testmoqs_test.go b/generator/testmoqs/moq_testmoqs_test.go index a4c8d23..2e44f0f 100644 --- a/generator/testmoqs/moq_testmoqs_test.go +++ b/generator/testmoqs/moq_testmoqs_test.go @@ -5,34 +5,34 @@ package testmoqs_test import ( "fmt" "io" - "math/bits" - "sync/atomic" "unsafe" "moqueries.org/cli/generator/testmoqs" "moqueries.org/cli/generator/testmoqs/other" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqUsualFn holds the state of a moq of the UsualFn type type moqUsualFn struct { - scene *moq.Scene - config moq.Config - moq *moqUsualFn_mock + moq *impl.Moq[ + *moqUsualFn_adaptor, + moqUsualFn_params, + moqUsualFn_paramsKey, + moqUsualFn_results, + ] - resultsByParams []moqUsualFn_resultsByParams + runtime moqUsualFn_runtime +} - runtime struct { - parameterIndexing struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - } +// moqUsualFn_runtime holds runtime configuration for the UsualFn type +type moqUsualFn_runtime struct { + parameterIndexing moqUsualFn_paramIndexing } -// moqUsualFn_mock isolates the mock interface of the UsualFn type -type moqUsualFn_mock struct { +// moqUsualFn_adaptor adapts moqUsualFn as needed by the runtime +type moqUsualFn_adaptor struct { moq *moqUsualFn } @@ -54,12 +54,17 @@ type moqUsualFn_paramsKey struct { } } -// moqUsualFn_resultsByParams contains the results for a given set of -// parameters for the UsualFn type -type moqUsualFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsualFn_paramsKey]*moqUsualFn_results +// moqUsualFn_results holds the results of the UsualFn type +type moqUsualFn_results struct { + sResult string + err error +} + +// moqUsualFn_paramIndexing holds the parameter indexing runtime configuration +// for the UsualFn type +type moqUsualFn_paramIndexing struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing } // moqUsualFn_doFn defines the type of function needed when calling andDo for @@ -70,60 +75,38 @@ type moqUsualFn_doFn func(sParam string, bParam bool) // doReturnResults for the UsualFn type type moqUsualFn_doReturnFn func(sParam string, bParam bool) (sResult string, err error) -// moqUsualFn_results holds the results of the UsualFn type -type moqUsualFn_results struct { - params moqUsualFn_params - results []struct { - values *struct { - sResult string - err error - } - sequence uint32 - doFn moqUsualFn_doFn - doReturnFn moqUsualFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsualFn_fnRecorder routes recorded function calls to the moqUsualFn moq -type moqUsualFn_fnRecorder struct { - params moqUsualFn_params - anyParams uint64 - sequence bool - results *moqUsualFn_results - moq *moqUsualFn +// moqUsualFn_recorder routes recorded function calls to the moqUsualFn moq +type moqUsualFn_recorder struct { + recorder *impl.Recorder[ + *moqUsualFn_adaptor, + moqUsualFn_params, + moqUsualFn_paramsKey, + moqUsualFn_results, + ] } // moqUsualFn_anyParams isolates the any params functions of the UsualFn type type moqUsualFn_anyParams struct { - recorder *moqUsualFn_fnRecorder + recorder *moqUsualFn_recorder } // newMoqUsualFn creates a new moq of the UsualFn type func newMoqUsualFn(scene *moq.Scene, config *moq.Config) *moqUsualFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqUsualFn_adaptor{} m := &moqUsualFn{ - scene: scene, - config: *config, - moq: &moqUsualFn_mock{}, - - runtime: struct { - parameterIndexing struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - }{parameterIndexing: struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqUsualFn_adaptor, + moqUsualFn_params, + moqUsualFn_paramsKey, + moqUsualFn_results, + ](scene, adaptor1, config), + + runtime: moqUsualFn_runtime{parameterIndexing: moqUsualFn_paramIndexing{ sParam: moq.ParamIndexByValue, bParam: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -131,281 +114,115 @@ func newMoqUsualFn(scene *moq.Scene, config *moq.Config) *moqUsualFn { // mock returns the moq implementation of the UsualFn type func (m *moqUsualFn) mock() testmoqs.UsualFn { - return func(sParam string, bParam bool) (_ string, _ error) { - m.scene.T.Helper() - moq := &moqUsualFn_mock{moq: m} - return moq.fn(sParam, bParam) - } -} - -func (m *moqUsualFn_mock) fn(sParam string, bParam bool) (sResult string, err error) { - m.moq.scene.T.Helper() - params := moqUsualFn_params{ - sParam: sParam, - bParam: bParam, - } - var results *moqUsualFn_results - 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 + return func(sParam string, bParam bool) (string, error) { + m.moq.Scene.T.Helper() + params := moqUsualFn_params{ + sParam: sParam, + bParam: bParam, } - 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)) + var result1 string + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } + return result1, result2 } - - 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 *moqUsualFn) onCall(sParam string, bParam bool) *moqUsualFn_fnRecorder { - return &moqUsualFn_fnRecorder{ - params: moqUsualFn_params{ +func (m *moqUsualFn) onCall(sParam string, bParam bool) *moqUsualFn_recorder { + return &moqUsualFn_recorder{ + recorder: m.moq.OnCall(moqUsualFn_params{ sParam: sParam, bParam: bParam, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqUsualFn_fnRecorder) any() *moqUsualFn_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(r.params)) +func (r *moqUsualFn_recorder) any() *moqUsualFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsualFn_anyParams{recorder: r} } -func (a *moqUsualFn_anyParams) sParam() *moqUsualFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsualFn_anyParams) sParam() *moqUsualFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqUsualFn_anyParams) bParam() *moqUsualFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqUsualFn_anyParams) bParam() *moqUsualFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqUsualFn_fnRecorder) seq() *moqUsualFn_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(r.params)) +func (r *moqUsualFn_recorder) seq() *moqUsualFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqUsualFn_fnRecorder) noSeq() *moqUsualFn_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(r.params)) +func (r *moqUsualFn_recorder) noSeq() *moqUsualFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUsualFn_fnRecorder) returnResults(sResult string, err error) *moqUsualFn_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 moqUsualFn_doFn - doReturnFn moqUsualFn_doReturnFn - }{ - values: &struct { - sResult string - err error - }{ - sResult: sResult, - err: err, - }, - sequence: sequence, +func (r *moqUsualFn_recorder) returnResults(sResult string, err error) *moqUsualFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsualFn_results{ + sResult: sResult, + err: err, }) return r } -func (r *moqUsualFn_fnRecorder) andDo(fn moqUsualFn_doFn) *moqUsualFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqUsualFn_recorder) andDo(fn moqUsualFn_doFn) *moqUsualFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsualFn_params) { + fn(params.sParam, params.bParam) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqUsualFn_fnRecorder) doReturnResults(fn moqUsualFn_doReturnFn) *moqUsualFn_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 +func (r *moqUsualFn_recorder) doReturnResults(fn moqUsualFn_doReturnFn) *moqUsualFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsualFn_params) *moqUsualFn_results { + sResult, err := fn(params.sParam, params.bParam) + return &moqUsualFn_results{ + sResult: sResult, + err: err, } - sequence uint32 - doFn moqUsualFn_doFn - doReturnFn moqUsualFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqUsualFn_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 *moqUsualFn_resultsByParams - 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 = &moqUsualFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsualFn_paramsKey]*moqUsualFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsualFn_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 *moqUsualFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsualFn_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 moqUsualFn_doFn - doReturnFn moqUsualFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqUsualFn_recorder) repeat(repeaters ...moq.Repeater) *moqUsualFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqUsualFn) prettyParams(params moqUsualFn_params) string { +func (*moqUsualFn_adaptor) PrettyParams(params moqUsualFn_params) string { return fmt.Sprintf("UsualFn(%#v, %#v)", params.sParam, params.bParam) } -func (m *moqUsualFn) paramsKey(params moqUsualFn_params, anyParams uint64) moqUsualFn_paramsKey { - m.scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.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.bParam == moq.ParamIndexByValue { - bParamUsed = params.bParam - } else { - bParamUsedHash = hash.DeepHash(params.bParam) - } - } +func (a *moqUsualFn_adaptor) ParamsKey(params moqUsualFn_params, anyParams uint64) moqUsualFn_paramsKey { + a.moq.moq.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.sParam, 1, a.moq.runtime.parameterIndexing.sParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.bParam, 2, a.moq.runtime.parameterIndexing.bParam, anyParams) return moqUsualFn_paramsKey{ params: struct { sParam string @@ -425,39 +242,35 @@ func (m *moqUsualFn) paramsKey(params moqUsualFn_params, anyParams uint64) moqUs } // Reset resets the state of the moq -func (m *moqUsualFn) Reset() { m.resultsByParams = nil } +func (m *moqUsualFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqUsualFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqNoNamesFn holds the state of a moq of the NoNamesFn type type moqNoNamesFn struct { - scene *moq.Scene - config moq.Config - moq *moqNoNamesFn_mock + moq *impl.Moq[ + *moqNoNamesFn_adaptor, + moqNoNamesFn_params, + moqNoNamesFn_paramsKey, + moqNoNamesFn_results, + ] - resultsByParams []moqNoNamesFn_resultsByParams + runtime moqNoNamesFn_runtime +} - runtime struct { - parameterIndexing struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - } +// moqNoNamesFn_runtime holds runtime configuration for the NoNamesFn type +type moqNoNamesFn_runtime struct { + parameterIndexing moqNoNamesFn_paramIndexing } -// moqNoNamesFn_mock isolates the mock interface of the NoNamesFn type -type moqNoNamesFn_mock struct { +// moqNoNamesFn_adaptor adapts moqNoNamesFn as needed by the runtime +type moqNoNamesFn_adaptor struct { moq *moqNoNamesFn } @@ -479,12 +292,17 @@ type moqNoNamesFn_paramsKey struct { } } -// moqNoNamesFn_resultsByParams contains the results for a given set of -// parameters for the NoNamesFn type -type moqNoNamesFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqNoNamesFn_paramsKey]*moqNoNamesFn_results +// moqNoNamesFn_results holds the results of the NoNamesFn type +type moqNoNamesFn_results struct { + result1 string + result2 error +} + +// moqNoNamesFn_paramIndexing holds the parameter indexing runtime +// configuration for the NoNamesFn type +type moqNoNamesFn_paramIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } // moqNoNamesFn_doFn defines the type of function needed when calling andDo for @@ -495,62 +313,39 @@ type moqNoNamesFn_doFn func(string, bool) // doReturnResults for the NoNamesFn type type moqNoNamesFn_doReturnFn func(string, bool) (string, error) -// moqNoNamesFn_results holds the results of the NoNamesFn type -type moqNoNamesFn_results struct { - params moqNoNamesFn_params - results []struct { - values *struct { - result1 string - result2 error - } - sequence uint32 - doFn moqNoNamesFn_doFn - doReturnFn moqNoNamesFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqNoNamesFn_fnRecorder routes recorded function calls to the moqNoNamesFn -// moq -type moqNoNamesFn_fnRecorder struct { - params moqNoNamesFn_params - anyParams uint64 - sequence bool - results *moqNoNamesFn_results - moq *moqNoNamesFn +// moqNoNamesFn_recorder routes recorded function calls to the moqNoNamesFn moq +type moqNoNamesFn_recorder struct { + recorder *impl.Recorder[ + *moqNoNamesFn_adaptor, + moqNoNamesFn_params, + moqNoNamesFn_paramsKey, + moqNoNamesFn_results, + ] } // moqNoNamesFn_anyParams isolates the any params functions of the NoNamesFn // type type moqNoNamesFn_anyParams struct { - recorder *moqNoNamesFn_fnRecorder + recorder *moqNoNamesFn_recorder } // newMoqNoNamesFn creates a new moq of the NoNamesFn type func newMoqNoNamesFn(scene *moq.Scene, config *moq.Config) *moqNoNamesFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqNoNamesFn_adaptor{} m := &moqNoNamesFn{ - scene: scene, - config: *config, - moq: &moqNoNamesFn_mock{}, - - runtime: struct { - parameterIndexing struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - }{parameterIndexing: struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqNoNamesFn_adaptor, + moqNoNamesFn_params, + moqNoNamesFn_paramsKey, + moqNoNamesFn_results, + ](scene, adaptor1, config), + + runtime: moqNoNamesFn_runtime{parameterIndexing: moqNoNamesFn_paramIndexing{ param1: moq.ParamIndexByValue, param2: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -559,280 +354,114 @@ func newMoqNoNamesFn(scene *moq.Scene, config *moq.Config) *moqNoNamesFn { // mock returns the moq implementation of the NoNamesFn type func (m *moqNoNamesFn) mock() testmoqs.NoNamesFn { return func(param1 string, param2 bool) (string, error) { - m.scene.T.Helper() - moq := &moqNoNamesFn_mock{moq: m} - return moq.fn(param1, param2) - } -} - -func (m *moqNoNamesFn_mock) fn(param1 string, param2 bool) (result1 string, result2 error) { - m.moq.scene.T.Helper() - params := moqNoNamesFn_params{ - param1: param1, - param2: param2, - } - var results *moqNoNamesFn_results - 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 + m.moq.Scene.T.Helper() + params := moqNoNamesFn_params{ + param1: param1, + param2: param2, } - 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)) + var result1 string + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } + return result1, result2 } - - 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 *moqNoNamesFn) onCall(param1 string, param2 bool) *moqNoNamesFn_fnRecorder { - return &moqNoNamesFn_fnRecorder{ - params: moqNoNamesFn_params{ +func (m *moqNoNamesFn) onCall(param1 string, param2 bool) *moqNoNamesFn_recorder { + return &moqNoNamesFn_recorder{ + recorder: m.moq.OnCall(moqNoNamesFn_params{ param1: param1, param2: param2, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqNoNamesFn_fnRecorder) any() *moqNoNamesFn_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(r.params)) +func (r *moqNoNamesFn_recorder) any() *moqNoNamesFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqNoNamesFn_anyParams{recorder: r} } -func (a *moqNoNamesFn_anyParams) param1() *moqNoNamesFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqNoNamesFn_anyParams) param1() *moqNoNamesFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqNoNamesFn_anyParams) param2() *moqNoNamesFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqNoNamesFn_anyParams) param2() *moqNoNamesFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqNoNamesFn_fnRecorder) seq() *moqNoNamesFn_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(r.params)) +func (r *moqNoNamesFn_recorder) seq() *moqNoNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqNoNamesFn_fnRecorder) noSeq() *moqNoNamesFn_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(r.params)) +func (r *moqNoNamesFn_recorder) noSeq() *moqNoNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqNoNamesFn_fnRecorder) returnResults(result1 string, result2 error) *moqNoNamesFn_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 moqNoNamesFn_doFn - doReturnFn moqNoNamesFn_doReturnFn - }{ - values: &struct { - result1 string - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqNoNamesFn_recorder) returnResults(result1 string, result2 error) *moqNoNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqNoNamesFn_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqNoNamesFn_fnRecorder) andDo(fn moqNoNamesFn_doFn) *moqNoNamesFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqNoNamesFn_recorder) andDo(fn moqNoNamesFn_doFn) *moqNoNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqNoNamesFn_params) { + fn(params.param1, params.param2) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqNoNamesFn_fnRecorder) doReturnResults(fn moqNoNamesFn_doReturnFn) *moqNoNamesFn_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 +func (r *moqNoNamesFn_recorder) doReturnResults(fn moqNoNamesFn_doReturnFn) *moqNoNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqNoNamesFn_params) *moqNoNamesFn_results { + result1, result2 := fn(params.param1, params.param2) + return &moqNoNamesFn_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqNoNamesFn_doFn - doReturnFn moqNoNamesFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqNoNamesFn_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 *moqNoNamesFn_resultsByParams - 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 = &moqNoNamesFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqNoNamesFn_paramsKey]*moqNoNamesFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqNoNamesFn_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 *moqNoNamesFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqNoNamesFn_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 moqNoNamesFn_doFn - doReturnFn moqNoNamesFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqNoNamesFn_recorder) repeat(repeaters ...moq.Repeater) *moqNoNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqNoNamesFn) prettyParams(params moqNoNamesFn_params) string { +func (*moqNoNamesFn_adaptor) PrettyParams(params moqNoNamesFn_params) string { return fmt.Sprintf("NoNamesFn(%#v, %#v)", params.param1, params.param2) } -func (m *moqNoNamesFn) paramsKey(params moqNoNamesFn_params, anyParams uint64) moqNoNamesFn_paramsKey { - 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) - } - } - 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) - } - } +func (a *moqNoNamesFn_adaptor) ParamsKey(params moqNoNamesFn_params, anyParams uint64) moqNoNamesFn_paramsKey { + a.moq.moq.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.param1, 1, a.moq.runtime.parameterIndexing.param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.param2, 2, a.moq.runtime.parameterIndexing.param2, anyParams) return moqNoNamesFn_paramsKey{ params: struct { param1 string @@ -852,39 +481,35 @@ func (m *moqNoNamesFn) paramsKey(params moqNoNamesFn_params, anyParams uint64) m } // Reset resets the state of the moq -func (m *moqNoNamesFn) Reset() { m.resultsByParams = nil } +func (m *moqNoNamesFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqNoNamesFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqNoResultsFn holds the state of a moq of the NoResultsFn type type moqNoResultsFn struct { - scene *moq.Scene - config moq.Config - moq *moqNoResultsFn_mock + moq *impl.Moq[ + *moqNoResultsFn_adaptor, + moqNoResultsFn_params, + moqNoResultsFn_paramsKey, + moqNoResultsFn_results, + ] - resultsByParams []moqNoResultsFn_resultsByParams + runtime moqNoResultsFn_runtime +} - runtime struct { - parameterIndexing struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - } +// moqNoResultsFn_runtime holds runtime configuration for the NoResultsFn type +type moqNoResultsFn_runtime struct { + parameterIndexing moqNoResultsFn_paramIndexing } -// moqNoResultsFn_mock isolates the mock interface of the NoResultsFn type -type moqNoResultsFn_mock struct { +// moqNoResultsFn_adaptor adapts moqNoResultsFn as needed by the runtime +type moqNoResultsFn_adaptor struct { moq *moqNoResultsFn } @@ -906,12 +531,14 @@ type moqNoResultsFn_paramsKey struct { } } -// moqNoResultsFn_resultsByParams contains the results for a given set of -// parameters for the NoResultsFn type -type moqNoResultsFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqNoResultsFn_paramsKey]*moqNoResultsFn_results +// moqNoResultsFn_results holds the results of the NoResultsFn type +type moqNoResultsFn_results struct{} + +// moqNoResultsFn_paramIndexing holds the parameter indexing runtime +// configuration for the NoResultsFn type +type moqNoResultsFn_paramIndexing struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing } // moqNoResultsFn_doFn defines the type of function needed when calling andDo @@ -922,59 +549,40 @@ type moqNoResultsFn_doFn func(sParam string, bParam bool) // doReturnResults for the NoResultsFn type type moqNoResultsFn_doReturnFn func(sParam string, bParam bool) -// moqNoResultsFn_results holds the results of the NoResultsFn type -type moqNoResultsFn_results struct { - params moqNoResultsFn_params - results []struct { - values *struct{} - sequence uint32 - doFn moqNoResultsFn_doFn - doReturnFn moqNoResultsFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqNoResultsFn_fnRecorder routes recorded function calls to the -// moqNoResultsFn moq -type moqNoResultsFn_fnRecorder struct { - params moqNoResultsFn_params - anyParams uint64 - sequence bool - results *moqNoResultsFn_results - moq *moqNoResultsFn +// moqNoResultsFn_recorder routes recorded function calls to the moqNoResultsFn +// moq +type moqNoResultsFn_recorder struct { + recorder *impl.Recorder[ + *moqNoResultsFn_adaptor, + moqNoResultsFn_params, + moqNoResultsFn_paramsKey, + moqNoResultsFn_results, + ] } // moqNoResultsFn_anyParams isolates the any params functions of the // NoResultsFn type type moqNoResultsFn_anyParams struct { - recorder *moqNoResultsFn_fnRecorder + recorder *moqNoResultsFn_recorder } // newMoqNoResultsFn creates a new moq of the NoResultsFn type func newMoqNoResultsFn(scene *moq.Scene, config *moq.Config) *moqNoResultsFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqNoResultsFn_adaptor{} m := &moqNoResultsFn{ - scene: scene, - config: *config, - moq: &moqNoResultsFn_mock{}, - - runtime: struct { - parameterIndexing struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - }{parameterIndexing: struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqNoResultsFn_adaptor, + moqNoResultsFn_params, + moqNoResultsFn_paramsKey, + moqNoResultsFn_results, + ](scene, adaptor1, config), + + runtime: moqNoResultsFn_runtime{parameterIndexing: moqNoResultsFn_paramIndexing{ sParam: moq.ParamIndexByValue, bParam: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -983,261 +591,102 @@ func newMoqNoResultsFn(scene *moq.Scene, config *moq.Config) *moqNoResultsFn { // mock returns the moq implementation of the NoResultsFn type func (m *moqNoResultsFn) mock() testmoqs.NoResultsFn { return func(sParam string, bParam bool) { - m.scene.T.Helper() - moq := &moqNoResultsFn_mock{moq: m} - moq.fn(sParam, bParam) - } -} - -func (m *moqNoResultsFn_mock) fn(sParam string, bParam bool) { - m.moq.scene.T.Helper() - params := moqNoResultsFn_params{ - sParam: sParam, - bParam: bParam, - } - var results *moqNoResultsFn_results - 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)) + m.moq.Scene.T.Helper() + params := moqNoResultsFn_params{ + sParam: sParam, + bParam: bParam, } - } - - if result.doFn != nil { - result.doFn(sParam, bParam) - } - if result.doReturnFn != nil { - result.doReturnFn(sParam, bParam) + m.moq.Function(params) } - return } -func (m *moqNoResultsFn) onCall(sParam string, bParam bool) *moqNoResultsFn_fnRecorder { - return &moqNoResultsFn_fnRecorder{ - params: moqNoResultsFn_params{ +func (m *moqNoResultsFn) onCall(sParam string, bParam bool) *moqNoResultsFn_recorder { + return &moqNoResultsFn_recorder{ + recorder: m.moq.OnCall(moqNoResultsFn_params{ sParam: sParam, bParam: bParam, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqNoResultsFn_fnRecorder) any() *moqNoResultsFn_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(r.params)) +func (r *moqNoResultsFn_recorder) any() *moqNoResultsFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqNoResultsFn_anyParams{recorder: r} } -func (a *moqNoResultsFn_anyParams) sParam() *moqNoResultsFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqNoResultsFn_anyParams) sParam() *moqNoResultsFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqNoResultsFn_anyParams) bParam() *moqNoResultsFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqNoResultsFn_anyParams) bParam() *moqNoResultsFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqNoResultsFn_fnRecorder) seq() *moqNoResultsFn_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(r.params)) +func (r *moqNoResultsFn_recorder) seq() *moqNoResultsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqNoResultsFn_fnRecorder) noSeq() *moqNoResultsFn_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(r.params)) +func (r *moqNoResultsFn_recorder) noSeq() *moqNoResultsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqNoResultsFn_fnRecorder) returnResults() *moqNoResultsFn_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 moqNoResultsFn_doFn - doReturnFn moqNoResultsFn_doReturnFn - }{ - values: &struct{}{}, - sequence: sequence, - }) +func (r *moqNoResultsFn_recorder) returnResults() *moqNoResultsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqNoResultsFn_results{}) return r } -func (r *moqNoResultsFn_fnRecorder) andDo(fn moqNoResultsFn_doFn) *moqNoResultsFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqNoResultsFn_recorder) andDo(fn moqNoResultsFn_doFn) *moqNoResultsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqNoResultsFn_params) { + fn(params.sParam, params.bParam) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqNoResultsFn_fnRecorder) doReturnResults(fn moqNoResultsFn_doReturnFn) *moqNoResultsFn_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 moqNoResultsFn_doFn - doReturnFn moqNoResultsFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) +func (r *moqNoResultsFn_recorder) doReturnResults(fn moqNoResultsFn_doReturnFn) *moqNoResultsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqNoResultsFn_params) *moqNoResultsFn_results { + fn(params.sParam, params.bParam) + return &moqNoResultsFn_results{} + }) return r } -func (r *moqNoResultsFn_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 *moqNoResultsFn_resultsByParams - 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 = &moqNoResultsFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqNoResultsFn_paramsKey]*moqNoResultsFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqNoResultsFn_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 *moqNoResultsFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqNoResultsFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqNoResultsFn_recorder) repeat(repeaters ...moq.Repeater) *moqNoResultsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 moqNoResultsFn_doFn - doReturnFn moqNoResultsFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqNoResultsFn) prettyParams(params moqNoResultsFn_params) string { +func (*moqNoResultsFn_adaptor) PrettyParams(params moqNoResultsFn_params) string { return fmt.Sprintf("NoResultsFn(%#v, %#v)", params.sParam, params.bParam) } -func (m *moqNoResultsFn) paramsKey(params moqNoResultsFn_params, anyParams uint64) moqNoResultsFn_paramsKey { - m.scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.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.bParam == moq.ParamIndexByValue { - bParamUsed = params.bParam - } else { - bParamUsedHash = hash.DeepHash(params.bParam) - } - } +func (a *moqNoResultsFn_adaptor) ParamsKey(params moqNoResultsFn_params, anyParams uint64) moqNoResultsFn_paramsKey { + a.moq.moq.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.sParam, 1, a.moq.runtime.parameterIndexing.sParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.bParam, 2, a.moq.runtime.parameterIndexing.bParam, anyParams) return moqNoResultsFn_paramsKey{ params: struct { sParam string @@ -1257,36 +706,35 @@ func (m *moqNoResultsFn) paramsKey(params moqNoResultsFn_params, anyParams uint6 } // Reset resets the state of the moq -func (m *moqNoResultsFn) Reset() { m.resultsByParams = nil } +func (m *moqNoResultsFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqNoResultsFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqNoParamsFn holds the state of a moq of the NoParamsFn type type moqNoParamsFn struct { - scene *moq.Scene - config moq.Config - moq *moqNoParamsFn_mock + moq *impl.Moq[ + *moqNoParamsFn_adaptor, + moqNoParamsFn_params, + moqNoParamsFn_paramsKey, + moqNoParamsFn_results, + ] - resultsByParams []moqNoParamsFn_resultsByParams + runtime moqNoParamsFn_runtime +} - runtime struct { - parameterIndexing struct{} - } +// moqNoParamsFn_runtime holds runtime configuration for the NoParamsFn type +type moqNoParamsFn_runtime struct { + parameterIndexing moqNoParamsFn_paramIndexing } -// moqNoParamsFn_mock isolates the mock interface of the NoParamsFn type -type moqNoParamsFn_mock struct { +// moqNoParamsFn_adaptor adapts moqNoParamsFn as needed by the runtime +type moqNoParamsFn_adaptor struct { moq *moqNoParamsFn } @@ -1299,14 +747,16 @@ type moqNoParamsFn_paramsKey struct { hashes struct{} } -// moqNoParamsFn_resultsByParams contains the results for a given set of -// parameters for the NoParamsFn type -type moqNoParamsFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqNoParamsFn_paramsKey]*moqNoParamsFn_results +// moqNoParamsFn_results holds the results of the NoParamsFn type +type moqNoParamsFn_results struct { + sResult string + err error } +// moqNoParamsFn_paramIndexing holds the parameter indexing runtime +// configuration for the NoParamsFn type +type moqNoParamsFn_paramIndexing struct{} + // moqNoParamsFn_doFn defines the type of function needed when calling andDo // for the NoParamsFn type type moqNoParamsFn_doFn func() @@ -1315,53 +765,37 @@ type moqNoParamsFn_doFn func() // doReturnResults for the NoParamsFn type type moqNoParamsFn_doReturnFn func() (sResult string, err error) -// moqNoParamsFn_results holds the results of the NoParamsFn type -type moqNoParamsFn_results struct { - params moqNoParamsFn_params - results []struct { - values *struct { - sResult string - err error - } - sequence uint32 - doFn moqNoParamsFn_doFn - doReturnFn moqNoParamsFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqNoParamsFn_fnRecorder routes recorded function calls to the moqNoParamsFn +// moqNoParamsFn_recorder routes recorded function calls to the moqNoParamsFn // moq -type moqNoParamsFn_fnRecorder struct { - params moqNoParamsFn_params - anyParams uint64 - sequence bool - results *moqNoParamsFn_results - moq *moqNoParamsFn +type moqNoParamsFn_recorder struct { + recorder *impl.Recorder[ + *moqNoParamsFn_adaptor, + moqNoParamsFn_params, + moqNoParamsFn_paramsKey, + moqNoParamsFn_results, + ] } // moqNoParamsFn_anyParams isolates the any params functions of the NoParamsFn // type type moqNoParamsFn_anyParams struct { - recorder *moqNoParamsFn_fnRecorder + recorder *moqNoParamsFn_recorder } // newMoqNoParamsFn creates a new moq of the NoParamsFn type func newMoqNoParamsFn(scene *moq.Scene, config *moq.Config) *moqNoParamsFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqNoParamsFn_adaptor{} m := &moqNoParamsFn{ - scene: scene, - config: *config, - moq: &moqNoParamsFn_mock{}, + moq: impl.NewMoq[ + *moqNoParamsFn_adaptor, + moqNoParamsFn_params, + moqNoParamsFn_paramsKey, + moqNoParamsFn_results, + ](scene, adaptor1, config), - runtime: struct { - parameterIndexing struct{} - }{parameterIndexing: struct{}{}}, + runtime: moqNoParamsFn_runtime{parameterIndexing: moqNoParamsFn_paramIndexing{}}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -1369,280 +803,131 @@ func newMoqNoParamsFn(scene *moq.Scene, config *moq.Config) *moqNoParamsFn { // mock returns the moq implementation of the NoParamsFn type func (m *moqNoParamsFn) mock() testmoqs.NoParamsFn { - return func() (_ string, _ error) { m.scene.T.Helper(); moq := &moqNoParamsFn_mock{moq: m}; return moq.fn() } -} - -func (m *moqNoParamsFn_mock) fn() (sResult string, err error) { - m.moq.scene.T.Helper() - params := moqNoParamsFn_params{} - var results *moqNoParamsFn_results - 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 - } + return func() (string, error) { + m.moq.Scene.T.Helper() + params := moqNoParamsFn_params{} - 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)) + var result1 string + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } + return result1, result2 } - - 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 *moqNoParamsFn) onCall() *moqNoParamsFn_fnRecorder { - return &moqNoParamsFn_fnRecorder{ - params: moqNoParamsFn_params{}, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, +func (m *moqNoParamsFn) onCall() *moqNoParamsFn_recorder { + return &moqNoParamsFn_recorder{ + recorder: m.moq.OnCall(moqNoParamsFn_params{}), } } -func (r *moqNoParamsFn_fnRecorder) any() *moqNoParamsFn_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(r.params)) +func (r *moqNoParamsFn_recorder) any() *moqNoParamsFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqNoParamsFn_anyParams{recorder: r} } -func (r *moqNoParamsFn_fnRecorder) seq() *moqNoParamsFn_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(r.params)) +func (r *moqNoParamsFn_recorder) seq() *moqNoParamsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqNoParamsFn_fnRecorder) noSeq() *moqNoParamsFn_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(r.params)) +func (r *moqNoParamsFn_recorder) noSeq() *moqNoParamsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqNoParamsFn_fnRecorder) returnResults(sResult string, err error) *moqNoParamsFn_fnRecorder { - r.moq.scene.T.Helper() - r.findResults() +func (r *moqNoParamsFn_recorder) returnResults(sResult string, err error) *moqNoParamsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqNoParamsFn_results{ + sResult: sResult, + err: err, + }) + return r +} - var sequence uint32 - if r.sequence { - sequence = r.moq.scene.NextRecorderSequence() +func (r *moqNoParamsFn_recorder) andDo(fn moqNoParamsFn_doFn) *moqNoParamsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqNoParamsFn_params) { + fn() + }, false) { + return nil } + return r +} - r.results.results = append(r.results.results, struct { - values *struct { - sResult string - err error - } - sequence uint32 - doFn moqNoParamsFn_doFn - doReturnFn moqNoParamsFn_doReturnFn - }{ - values: &struct { - sResult string - err error - }{ +func (r *moqNoParamsFn_recorder) doReturnResults(fn moqNoParamsFn_doReturnFn) *moqNoParamsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqNoParamsFn_params) *moqNoParamsFn_results { + sResult, err := fn() + return &moqNoParamsFn_results{ sResult: sResult, err: err, - }, - sequence: sequence, + } }) return r } -func (r *moqNoParamsFn_fnRecorder) andDo(fn moqNoParamsFn_doFn) *moqNoParamsFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqNoParamsFn_recorder) repeat(repeaters ...moq.Repeater) *moqNoParamsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqNoParamsFn_fnRecorder) doReturnResults(fn moqNoParamsFn_doReturnFn) *moqNoParamsFn_fnRecorder { - r.moq.scene.T.Helper() - r.findResults() +func (*moqNoParamsFn_adaptor) PrettyParams(params moqNoParamsFn_params) string { + return fmt.Sprintf("NoParamsFn()") +} - var sequence uint32 - if r.sequence { - sequence = r.moq.scene.NextRecorderSequence() +func (a *moqNoParamsFn_adaptor) ParamsKey(params moqNoParamsFn_params, anyParams uint64) moqNoParamsFn_paramsKey { + a.moq.moq.Scene.T.Helper() + return moqNoParamsFn_paramsKey{ + params: struct{}{}, + hashes: struct{}{}, } +} - r.results.results = append(r.results.results, struct { - values *struct { - sResult string - err error - } - sequence uint32 - doFn moqNoParamsFn_doFn - doReturnFn moqNoParamsFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) - return r +// Reset resets the state of the moq +func (m *moqNoParamsFn) Reset() { + m.moq.Reset() } -func (r *moqNoParamsFn_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 *moqNoParamsFn_resultsByParams - 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 = &moqNoParamsFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqNoParamsFn_paramsKey]*moqNoParamsFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqNoParamsFn_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 *moqNoParamsFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqNoParamsFn_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 moqNoParamsFn_doFn - doReturnFn moqNoParamsFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } - return r -} - -func (m *moqNoParamsFn) prettyParams(params moqNoParamsFn_params) string { - return fmt.Sprintf("NoParamsFn()") -} - -func (m *moqNoParamsFn) paramsKey(params moqNoParamsFn_params, anyParams uint64) moqNoParamsFn_paramsKey { - m.scene.T.Helper() - return moqNoParamsFn_paramsKey{ - params: struct{}{}, - hashes: struct{}{}, - } -} - -// Reset resets the state of the moq -func (m *moqNoParamsFn) Reset() { m.resultsByParams = nil } - -// AssertExpectationsMet asserts that all expectations have been met -func (m *moqNoParamsFn) 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)) - } - } - } -} +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqNoParamsFn) AssertExpectationsMet() { + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() +} // moqNothingFn holds the state of a moq of the NothingFn type type moqNothingFn struct { - scene *moq.Scene - config moq.Config - moq *moqNothingFn_mock + moq *impl.Moq[ + *moqNothingFn_adaptor, + moqNothingFn_params, + moqNothingFn_paramsKey, + moqNothingFn_results, + ] - resultsByParams []moqNothingFn_resultsByParams + runtime moqNothingFn_runtime +} - runtime struct { - parameterIndexing struct{} - } +// moqNothingFn_runtime holds runtime configuration for the NothingFn type +type moqNothingFn_runtime struct { + parameterIndexing moqNothingFn_paramIndexing } -// moqNothingFn_mock isolates the mock interface of the NothingFn type -type moqNothingFn_mock struct { +// moqNothingFn_adaptor adapts moqNothingFn as needed by the runtime +type moqNothingFn_adaptor struct { moq *moqNothingFn } @@ -1655,13 +940,12 @@ type moqNothingFn_paramsKey struct { hashes struct{} } -// moqNothingFn_resultsByParams contains the results for a given set of -// parameters for the NothingFn type -type moqNothingFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqNothingFn_paramsKey]*moqNothingFn_results -} +// moqNothingFn_results holds the results of the NothingFn type +type moqNothingFn_results struct{} + +// moqNothingFn_paramIndexing holds the parameter indexing runtime +// configuration for the NothingFn type +type moqNothingFn_paramIndexing struct{} // moqNothingFn_doFn defines the type of function needed when calling andDo for // the NothingFn type @@ -1671,50 +955,36 @@ type moqNothingFn_doFn func() // doReturnResults for the NothingFn type type moqNothingFn_doReturnFn func() -// moqNothingFn_results holds the results of the NothingFn type -type moqNothingFn_results struct { - params moqNothingFn_params - results []struct { - values *struct{} - sequence uint32 - doFn moqNothingFn_doFn - doReturnFn moqNothingFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqNothingFn_fnRecorder routes recorded function calls to the moqNothingFn -// moq -type moqNothingFn_fnRecorder struct { - params moqNothingFn_params - anyParams uint64 - sequence bool - results *moqNothingFn_results - moq *moqNothingFn +// moqNothingFn_recorder routes recorded function calls to the moqNothingFn moq +type moqNothingFn_recorder struct { + recorder *impl.Recorder[ + *moqNothingFn_adaptor, + moqNothingFn_params, + moqNothingFn_paramsKey, + moqNothingFn_results, + ] } // moqNothingFn_anyParams isolates the any params functions of the NothingFn // type type moqNothingFn_anyParams struct { - recorder *moqNothingFn_fnRecorder + recorder *moqNothingFn_recorder } // newMoqNothingFn creates a new moq of the NothingFn type func newMoqNothingFn(scene *moq.Scene, config *moq.Config) *moqNothingFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqNothingFn_adaptor{} m := &moqNothingFn{ - scene: scene, - config: *config, - moq: &moqNothingFn_mock{}, + moq: impl.NewMoq[ + *moqNothingFn_adaptor, + moqNothingFn_params, + moqNothingFn_paramsKey, + moqNothingFn_results, + ](scene, adaptor1, config), - runtime: struct { - parameterIndexing struct{} - }{parameterIndexing: struct{}{}}, + runtime: moqNothingFn_runtime{parameterIndexing: moqNothingFn_paramIndexing{}}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -1722,224 +992,83 @@ func newMoqNothingFn(scene *moq.Scene, config *moq.Config) *moqNothingFn { // mock returns the moq implementation of the NothingFn type func (m *moqNothingFn) mock() testmoqs.NothingFn { - return func() { m.scene.T.Helper(); moq := &moqNothingFn_mock{moq: m}; moq.fn() } -} - -func (m *moqNothingFn_mock) fn() { - m.moq.scene.T.Helper() - params := moqNothingFn_params{} - var results *moqNothingFn_results - 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 - } + return func() { + m.moq.Scene.T.Helper() + params := moqNothingFn_params{} - 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() - } - - if result.doReturnFn != nil { - result.doReturnFn() + m.moq.Function(params) } - return } -func (m *moqNothingFn) onCall() *moqNothingFn_fnRecorder { - return &moqNothingFn_fnRecorder{ - params: moqNothingFn_params{}, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, +func (m *moqNothingFn) onCall() *moqNothingFn_recorder { + return &moqNothingFn_recorder{ + recorder: m.moq.OnCall(moqNothingFn_params{}), } } -func (r *moqNothingFn_fnRecorder) any() *moqNothingFn_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(r.params)) +func (r *moqNothingFn_recorder) any() *moqNothingFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqNothingFn_anyParams{recorder: r} } -func (r *moqNothingFn_fnRecorder) seq() *moqNothingFn_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(r.params)) +func (r *moqNothingFn_recorder) seq() *moqNothingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqNothingFn_fnRecorder) noSeq() *moqNothingFn_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(r.params)) +func (r *moqNothingFn_recorder) noSeq() *moqNothingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqNothingFn_fnRecorder) returnResults() *moqNothingFn_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 moqNothingFn_doFn - doReturnFn moqNothingFn_doReturnFn - }{ - values: &struct{}{}, - sequence: sequence, - }) +func (r *moqNothingFn_recorder) returnResults() *moqNothingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqNothingFn_results{}) return r } -func (r *moqNothingFn_fnRecorder) andDo(fn moqNothingFn_doFn) *moqNothingFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqNothingFn_recorder) andDo(fn moqNothingFn_doFn) *moqNothingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqNothingFn_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqNothingFn_fnRecorder) doReturnResults(fn moqNothingFn_doReturnFn) *moqNothingFn_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 moqNothingFn_doFn - doReturnFn moqNothingFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) +func (r *moqNothingFn_recorder) doReturnResults(fn moqNothingFn_doReturnFn) *moqNothingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqNothingFn_params) *moqNothingFn_results { + fn() + return &moqNothingFn_results{} + }) return r } -func (r *moqNothingFn_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 *moqNothingFn_resultsByParams - 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 = &moqNothingFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqNothingFn_paramsKey]*moqNothingFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqNothingFn_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 *moqNothingFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqNothingFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqNothingFn_recorder) repeat(repeaters ...moq.Repeater) *moqNothingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 moqNothingFn_doFn - doReturnFn moqNothingFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqNothingFn) prettyParams(params moqNothingFn_params) string { +func (*moqNothingFn_adaptor) PrettyParams(params moqNothingFn_params) string { return fmt.Sprintf("NothingFn()") } -func (m *moqNothingFn) paramsKey(params moqNothingFn_params, anyParams uint64) moqNothingFn_paramsKey { - m.scene.T.Helper() +func (a *moqNothingFn_adaptor) ParamsKey(params moqNothingFn_params, anyParams uint64) moqNothingFn_paramsKey { + a.moq.moq.Scene.T.Helper() return moqNothingFn_paramsKey{ params: struct{}{}, hashes: struct{}{}, @@ -1947,39 +1076,35 @@ func (m *moqNothingFn) paramsKey(params moqNothingFn_params, anyParams uint64) m } // Reset resets the state of the moq -func (m *moqNothingFn) Reset() { m.resultsByParams = nil } +func (m *moqNothingFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqNothingFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqVariadicFn holds the state of a moq of the VariadicFn type type moqVariadicFn struct { - scene *moq.Scene - config moq.Config - moq *moqVariadicFn_mock + moq *impl.Moq[ + *moqVariadicFn_adaptor, + moqVariadicFn_params, + moqVariadicFn_paramsKey, + moqVariadicFn_results, + ] - resultsByParams []moqVariadicFn_resultsByParams + runtime moqVariadicFn_runtime +} - runtime struct { - parameterIndexing struct { - other moq.ParamIndexing - args moq.ParamIndexing - } - } +// moqVariadicFn_runtime holds runtime configuration for the VariadicFn type +type moqVariadicFn_runtime struct { + parameterIndexing moqVariadicFn_paramIndexing } -// moqVariadicFn_mock isolates the mock interface of the VariadicFn type -type moqVariadicFn_mock struct { +// moqVariadicFn_adaptor adapts moqVariadicFn as needed by the runtime +type moqVariadicFn_adaptor struct { moq *moqVariadicFn } @@ -1998,12 +1123,17 @@ type moqVariadicFn_paramsKey struct { } } -// moqVariadicFn_resultsByParams contains the results for a given set of -// parameters for the VariadicFn type -type moqVariadicFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqVariadicFn_paramsKey]*moqVariadicFn_results +// moqVariadicFn_results holds the results of the VariadicFn type +type moqVariadicFn_results struct { + sResult string + err error +} + +// moqVariadicFn_paramIndexing holds the parameter indexing runtime +// configuration for the VariadicFn type +type moqVariadicFn_paramIndexing struct { + other moq.ParamIndexing + args moq.ParamIndexing } // moqVariadicFn_doFn defines the type of function needed when calling andDo @@ -2014,62 +1144,40 @@ type moqVariadicFn_doFn func(other bool, args ...string) // doReturnResults for the VariadicFn type type moqVariadicFn_doReturnFn func(other bool, args ...string) (sResult string, err error) -// moqVariadicFn_results holds the results of the VariadicFn type -type moqVariadicFn_results struct { - params moqVariadicFn_params - results []struct { - values *struct { - sResult string - err error - } - sequence uint32 - doFn moqVariadicFn_doFn - doReturnFn moqVariadicFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqVariadicFn_fnRecorder routes recorded function calls to the moqVariadicFn +// moqVariadicFn_recorder routes recorded function calls to the moqVariadicFn // moq -type moqVariadicFn_fnRecorder struct { - params moqVariadicFn_params - anyParams uint64 - sequence bool - results *moqVariadicFn_results - moq *moqVariadicFn +type moqVariadicFn_recorder struct { + recorder *impl.Recorder[ + *moqVariadicFn_adaptor, + moqVariadicFn_params, + moqVariadicFn_paramsKey, + moqVariadicFn_results, + ] } // moqVariadicFn_anyParams isolates the any params functions of the VariadicFn // type type moqVariadicFn_anyParams struct { - recorder *moqVariadicFn_fnRecorder + recorder *moqVariadicFn_recorder } // newMoqVariadicFn creates a new moq of the VariadicFn type func newMoqVariadicFn(scene *moq.Scene, config *moq.Config) *moqVariadicFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqVariadicFn_adaptor{} m := &moqVariadicFn{ - scene: scene, - config: *config, - moq: &moqVariadicFn_mock{}, - - runtime: struct { - parameterIndexing struct { - other moq.ParamIndexing - args moq.ParamIndexing - } - }{parameterIndexing: struct { - other moq.ParamIndexing - args moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqVariadicFn_adaptor, + moqVariadicFn_params, + moqVariadicFn_paramsKey, + moqVariadicFn_results, + ](scene, adaptor1, config), + + runtime: moqVariadicFn_runtime{parameterIndexing: moqVariadicFn_paramIndexing{ other: moq.ParamIndexByValue, args: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -2077,279 +1185,115 @@ func newMoqVariadicFn(scene *moq.Scene, config *moq.Config) *moqVariadicFn { // mock returns the moq implementation of the VariadicFn type func (m *moqVariadicFn) mock() testmoqs.VariadicFn { - return func(other bool, args ...string) (_ string, _ error) { - m.scene.T.Helper() - moq := &moqVariadicFn_mock{moq: m} - return moq.fn(other, args...) - } -} - -func (m *moqVariadicFn_mock) fn(other bool, args ...string) (sResult string, err error) { - m.moq.scene.T.Helper() - params := moqVariadicFn_params{ - other: other, - args: args, - } - var results *moqVariadicFn_results - 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 + return func(other bool, args ...string) (string, error) { + m.moq.Scene.T.Helper() + params := moqVariadicFn_params{ + other: other, + args: args, } - 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)) + var result1 string + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } + return result1, result2 } - - 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 *moqVariadicFn) onCall(other bool, args ...string) *moqVariadicFn_fnRecorder { - return &moqVariadicFn_fnRecorder{ - params: moqVariadicFn_params{ +func (m *moqVariadicFn) onCall(other bool, args ...string) *moqVariadicFn_recorder { + return &moqVariadicFn_recorder{ + recorder: m.moq.OnCall(moqVariadicFn_params{ other: other, args: args, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqVariadicFn_fnRecorder) any() *moqVariadicFn_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(r.params)) +func (r *moqVariadicFn_recorder) any() *moqVariadicFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqVariadicFn_anyParams{recorder: r} } -func (a *moqVariadicFn_anyParams) other() *moqVariadicFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqVariadicFn_anyParams) other() *moqVariadicFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqVariadicFn_anyParams) args() *moqVariadicFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqVariadicFn_anyParams) args() *moqVariadicFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqVariadicFn_fnRecorder) seq() *moqVariadicFn_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(r.params)) +func (r *moqVariadicFn_recorder) seq() *moqVariadicFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqVariadicFn_fnRecorder) noSeq() *moqVariadicFn_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(r.params)) +func (r *moqVariadicFn_recorder) noSeq() *moqVariadicFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqVariadicFn_fnRecorder) returnResults(sResult string, err error) *moqVariadicFn_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 moqVariadicFn_doFn - doReturnFn moqVariadicFn_doReturnFn - }{ - values: &struct { - sResult string - err error - }{ - sResult: sResult, - err: err, - }, - sequence: sequence, +func (r *moqVariadicFn_recorder) returnResults(sResult string, err error) *moqVariadicFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqVariadicFn_results{ + sResult: sResult, + err: err, }) return r } -func (r *moqVariadicFn_fnRecorder) andDo(fn moqVariadicFn_doFn) *moqVariadicFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqVariadicFn_recorder) andDo(fn moqVariadicFn_doFn) *moqVariadicFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqVariadicFn_params) { + fn(params.other, params.args...) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqVariadicFn_fnRecorder) doReturnResults(fn moqVariadicFn_doReturnFn) *moqVariadicFn_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 +func (r *moqVariadicFn_recorder) doReturnResults(fn moqVariadicFn_doReturnFn) *moqVariadicFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqVariadicFn_params) *moqVariadicFn_results { + sResult, err := fn(params.other, params.args...) + return &moqVariadicFn_results{ + sResult: sResult, + err: err, } - sequence uint32 - doFn moqVariadicFn_doFn - doReturnFn moqVariadicFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqVariadicFn_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 *moqVariadicFn_resultsByParams - 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 = &moqVariadicFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqVariadicFn_paramsKey]*moqVariadicFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqVariadicFn_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 *moqVariadicFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqVariadicFn_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 moqVariadicFn_doFn - doReturnFn moqVariadicFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqVariadicFn_recorder) repeat(repeaters ...moq.Repeater) *moqVariadicFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqVariadicFn) prettyParams(params moqVariadicFn_params) string { +func (*moqVariadicFn_adaptor) PrettyParams(params moqVariadicFn_params) string { return fmt.Sprintf("VariadicFn(%#v, %#v)", params.other, params.args) } -func (m *moqVariadicFn) paramsKey(params moqVariadicFn_params, anyParams uint64) moqVariadicFn_paramsKey { - m.scene.T.Helper() - var otherUsed bool - var otherUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.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.args == moq.ParamIndexByValue { - m.scene.T.Fatalf("The args parameter can't be indexed by value") - } - argsUsedHash = hash.DeepHash(params.args) - } +func (a *moqVariadicFn_adaptor) ParamsKey(params moqVariadicFn_params, anyParams uint64) moqVariadicFn_paramsKey { + a.moq.moq.Scene.T.Helper() + otherUsed, otherUsedHash := impl.ParamKey( + params.other, 1, a.moq.runtime.parameterIndexing.other, anyParams) + argsUsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.args, "args", 2, a.moq.runtime.parameterIndexing.args, anyParams) return moqVariadicFn_paramsKey{ params: struct{ other bool }{ other: otherUsed, @@ -2365,40 +1309,36 @@ func (m *moqVariadicFn) paramsKey(params moqVariadicFn_params, anyParams uint64) } // Reset resets the state of the moq -func (m *moqVariadicFn) Reset() { m.resultsByParams = nil } +func (m *moqVariadicFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqVariadicFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqRepeatedIdsFn holds the state of a moq of the RepeatedIdsFn type type moqRepeatedIdsFn struct { - scene *moq.Scene - config moq.Config - moq *moqRepeatedIdsFn_mock + moq *impl.Moq[ + *moqRepeatedIdsFn_adaptor, + moqRepeatedIdsFn_params, + moqRepeatedIdsFn_paramsKey, + moqRepeatedIdsFn_results, + ] - resultsByParams []moqRepeatedIdsFn_resultsByParams + runtime moqRepeatedIdsFn_runtime +} - runtime struct { - parameterIndexing struct { - sParam1 moq.ParamIndexing - sParam2 moq.ParamIndexing - bParam moq.ParamIndexing - } - } +// moqRepeatedIdsFn_runtime holds runtime configuration for the RepeatedIdsFn +// type +type moqRepeatedIdsFn_runtime struct { + parameterIndexing moqRepeatedIdsFn_paramIndexing } -// moqRepeatedIdsFn_mock isolates the mock interface of the RepeatedIdsFn type -type moqRepeatedIdsFn_mock struct { +// moqRepeatedIdsFn_adaptor adapts moqRepeatedIdsFn as needed by the runtime +type moqRepeatedIdsFn_adaptor struct { moq *moqRepeatedIdsFn } @@ -2421,12 +1361,17 @@ type moqRepeatedIdsFn_paramsKey struct { } } -// moqRepeatedIdsFn_resultsByParams contains the results for a given set of -// parameters for the RepeatedIdsFn type -type moqRepeatedIdsFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqRepeatedIdsFn_paramsKey]*moqRepeatedIdsFn_results +// moqRepeatedIdsFn_results holds the results of the RepeatedIdsFn type +type moqRepeatedIdsFn_results struct { + sResult1, sResult2 string + err error +} + +// moqRepeatedIdsFn_paramIndexing holds the parameter indexing runtime +// configuration for the RepeatedIdsFn type +type moqRepeatedIdsFn_paramIndexing struct { + sParam1, sParam2 moq.ParamIndexing + bParam moq.ParamIndexing } // moqRepeatedIdsFn_doFn defines the type of function needed when calling andDo @@ -2437,65 +1382,41 @@ type moqRepeatedIdsFn_doFn func(sParam1, sParam2 string, bParam bool) // doReturnResults for the RepeatedIdsFn type type moqRepeatedIdsFn_doReturnFn func(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) -// moqRepeatedIdsFn_results holds the results of the RepeatedIdsFn type -type moqRepeatedIdsFn_results struct { - params moqRepeatedIdsFn_params - results []struct { - values *struct { - sResult1, sResult2 string - err error - } - sequence uint32 - doFn moqRepeatedIdsFn_doFn - doReturnFn moqRepeatedIdsFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqRepeatedIdsFn_fnRecorder routes recorded function calls to the +// moqRepeatedIdsFn_recorder routes recorded function calls to the // moqRepeatedIdsFn moq -type moqRepeatedIdsFn_fnRecorder struct { - params moqRepeatedIdsFn_params - anyParams uint64 - sequence bool - results *moqRepeatedIdsFn_results - moq *moqRepeatedIdsFn +type moqRepeatedIdsFn_recorder struct { + recorder *impl.Recorder[ + *moqRepeatedIdsFn_adaptor, + moqRepeatedIdsFn_params, + moqRepeatedIdsFn_paramsKey, + moqRepeatedIdsFn_results, + ] } // moqRepeatedIdsFn_anyParams isolates the any params functions of the // RepeatedIdsFn type type moqRepeatedIdsFn_anyParams struct { - recorder *moqRepeatedIdsFn_fnRecorder + recorder *moqRepeatedIdsFn_recorder } // newMoqRepeatedIdsFn creates a new moq of the RepeatedIdsFn type func newMoqRepeatedIdsFn(scene *moq.Scene, config *moq.Config) *moqRepeatedIdsFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqRepeatedIdsFn_adaptor{} m := &moqRepeatedIdsFn{ - scene: scene, - config: *config, - moq: &moqRepeatedIdsFn_mock{}, - - runtime: struct { - parameterIndexing struct { - sParam1 moq.ParamIndexing - sParam2 moq.ParamIndexing - bParam moq.ParamIndexing - } - }{parameterIndexing: struct { - sParam1 moq.ParamIndexing - sParam2 moq.ParamIndexing - bParam moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqRepeatedIdsFn_adaptor, + moqRepeatedIdsFn_params, + moqRepeatedIdsFn_paramsKey, + moqRepeatedIdsFn_results, + ](scene, adaptor1, config), + + runtime: moqRepeatedIdsFn_runtime{parameterIndexing: moqRepeatedIdsFn_paramIndexing{ sParam1: moq.ParamIndexByValue, sParam2: moq.ParamIndexByValue, bParam: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -2503,299 +1424,128 @@ func newMoqRepeatedIdsFn(scene *moq.Scene, config *moq.Config) *moqRepeatedIdsFn // mock returns the moq implementation of the RepeatedIdsFn type func (m *moqRepeatedIdsFn) mock() testmoqs.RepeatedIdsFn { - return func(sParam1, sParam2 string, bParam bool) (_, _ string, _ error) { - m.scene.T.Helper() - moq := &moqRepeatedIdsFn_mock{moq: m} - return moq.fn(sParam1, sParam2, bParam) - } -} - -func (m *moqRepeatedIdsFn_mock) fn(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) { - m.moq.scene.T.Helper() - params := moqRepeatedIdsFn_params{ - sParam1: sParam1, - sParam2: sParam2, - bParam: bParam, - } - var results *moqRepeatedIdsFn_results - 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 + return func(sParam1, sParam2 string, bParam bool) (string, string, error) { + m.moq.Scene.T.Helper() + params := moqRepeatedIdsFn_params{ + sParam1: sParam1, + sParam2: sParam2, + bParam: bParam, } - 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)) + var result1 string + var result2 string + var result3 error + if result := m.moq.Function(params); result != nil { + result1 = result.sResult1 + result2 = result.sResult2 + result3 = result.err } + return result1, result2, result3 } - - 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 *moqRepeatedIdsFn) onCall(sParam1, sParam2 string, bParam bool) *moqRepeatedIdsFn_fnRecorder { - return &moqRepeatedIdsFn_fnRecorder{ - params: moqRepeatedIdsFn_params{ +func (m *moqRepeatedIdsFn) onCall(sParam1, sParam2 string, bParam bool) *moqRepeatedIdsFn_recorder { + return &moqRepeatedIdsFn_recorder{ + recorder: m.moq.OnCall(moqRepeatedIdsFn_params{ sParam1: sParam1, sParam2: sParam2, bParam: bParam, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqRepeatedIdsFn_fnRecorder) any() *moqRepeatedIdsFn_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(r.params)) +func (r *moqRepeatedIdsFn_recorder) any() *moqRepeatedIdsFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqRepeatedIdsFn_anyParams{recorder: r} } -func (a *moqRepeatedIdsFn_anyParams) sParam1() *moqRepeatedIdsFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqRepeatedIdsFn_anyParams) sParam1() *moqRepeatedIdsFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqRepeatedIdsFn_anyParams) sParam2() *moqRepeatedIdsFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqRepeatedIdsFn_anyParams) sParam2() *moqRepeatedIdsFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (a *moqRepeatedIdsFn_anyParams) bParam() *moqRepeatedIdsFn_fnRecorder { - a.recorder.anyParams |= 1 << 2 +func (a *moqRepeatedIdsFn_anyParams) bParam() *moqRepeatedIdsFn_recorder { + a.recorder.recorder.AnyParam(3) return a.recorder } -func (r *moqRepeatedIdsFn_fnRecorder) seq() *moqRepeatedIdsFn_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(r.params)) +func (r *moqRepeatedIdsFn_recorder) seq() *moqRepeatedIdsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqRepeatedIdsFn_fnRecorder) noSeq() *moqRepeatedIdsFn_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(r.params)) +func (r *moqRepeatedIdsFn_recorder) noSeq() *moqRepeatedIdsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqRepeatedIdsFn_fnRecorder) returnResults(sResult1, sResult2 string, err error) *moqRepeatedIdsFn_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 moqRepeatedIdsFn_doFn - doReturnFn moqRepeatedIdsFn_doReturnFn - }{ - values: &struct { - sResult1, sResult2 string - err error - }{ - sResult1: sResult1, - sResult2: sResult2, - err: err, - }, - sequence: sequence, +func (r *moqRepeatedIdsFn_recorder) returnResults(sResult1, sResult2 string, err error) *moqRepeatedIdsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqRepeatedIdsFn_results{ + sResult1: sResult1, + sResult2: sResult2, + err: err, }) return r } -func (r *moqRepeatedIdsFn_fnRecorder) andDo(fn moqRepeatedIdsFn_doFn) *moqRepeatedIdsFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqRepeatedIdsFn_recorder) andDo(fn moqRepeatedIdsFn_doFn) *moqRepeatedIdsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqRepeatedIdsFn_params) { + fn(params.sParam1, params.sParam2, params.bParam) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqRepeatedIdsFn_fnRecorder) doReturnResults(fn moqRepeatedIdsFn_doReturnFn) *moqRepeatedIdsFn_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 +func (r *moqRepeatedIdsFn_recorder) doReturnResults(fn moqRepeatedIdsFn_doReturnFn) *moqRepeatedIdsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqRepeatedIdsFn_params) *moqRepeatedIdsFn_results { + sResult1, sResult2, err := fn(params.sParam1, params.sParam2, params.bParam) + return &moqRepeatedIdsFn_results{ + sResult1: sResult1, + sResult2: sResult2, + err: err, } - sequence uint32 - doFn moqRepeatedIdsFn_doFn - doReturnFn moqRepeatedIdsFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqRepeatedIdsFn_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 *moqRepeatedIdsFn_resultsByParams - 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 = &moqRepeatedIdsFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqRepeatedIdsFn_paramsKey]*moqRepeatedIdsFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqRepeatedIdsFn_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 *moqRepeatedIdsFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqRepeatedIdsFn_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 moqRepeatedIdsFn_doFn - doReturnFn moqRepeatedIdsFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqRepeatedIdsFn_recorder) repeat(repeaters ...moq.Repeater) *moqRepeatedIdsFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqRepeatedIdsFn) prettyParams(params moqRepeatedIdsFn_params) string { +func (*moqRepeatedIdsFn_adaptor) PrettyParams(params moqRepeatedIdsFn_params) string { return fmt.Sprintf("RepeatedIdsFn(%#v, %#v, %#v)", params.sParam1, params.sParam2, params.bParam) } -func (m *moqRepeatedIdsFn) paramsKey(params moqRepeatedIdsFn_params, anyParams uint64) moqRepeatedIdsFn_paramsKey { - m.scene.T.Helper() - var sParam1Used string - var sParam1UsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.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.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.bParam == moq.ParamIndexByValue { - bParamUsed = params.bParam - } else { - bParamUsedHash = hash.DeepHash(params.bParam) - } - } +func (a *moqRepeatedIdsFn_adaptor) ParamsKey(params moqRepeatedIdsFn_params, anyParams uint64) moqRepeatedIdsFn_paramsKey { + a.moq.moq.Scene.T.Helper() + sParam1Used, sParam1UsedHash := impl.ParamKey( + params.sParam1, 1, a.moq.runtime.parameterIndexing.sParam1, anyParams) + sParam2Used, sParam2UsedHash := impl.ParamKey( + params.sParam2, 2, a.moq.runtime.parameterIndexing.sParam2, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.bParam, 3, a.moq.runtime.parameterIndexing.bParam, anyParams) return moqRepeatedIdsFn_paramsKey{ params: struct { sParam1, sParam2 string @@ -2817,39 +1567,35 @@ func (m *moqRepeatedIdsFn) paramsKey(params moqRepeatedIdsFn_params, anyParams u } // Reset resets the state of the moq -func (m *moqRepeatedIdsFn) Reset() { m.resultsByParams = nil } +func (m *moqRepeatedIdsFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqRepeatedIdsFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqTimesFn holds the state of a moq of the TimesFn type type moqTimesFn struct { - scene *moq.Scene - config moq.Config - moq *moqTimesFn_mock + moq *impl.Moq[ + *moqTimesFn_adaptor, + moqTimesFn_params, + moqTimesFn_paramsKey, + moqTimesFn_results, + ] - resultsByParams []moqTimesFn_resultsByParams + runtime moqTimesFn_runtime +} - runtime struct { - parameterIndexing struct { - times moq.ParamIndexing - bParam moq.ParamIndexing - } - } +// moqTimesFn_runtime holds runtime configuration for the TimesFn type +type moqTimesFn_runtime struct { + parameterIndexing moqTimesFn_paramIndexing } -// moqTimesFn_mock isolates the mock interface of the TimesFn type -type moqTimesFn_mock struct { +// moqTimesFn_adaptor adapts moqTimesFn as needed by the runtime +type moqTimesFn_adaptor struct { moq *moqTimesFn } @@ -2871,12 +1617,17 @@ type moqTimesFn_paramsKey struct { } } -// moqTimesFn_resultsByParams contains the results for a given set of -// parameters for the TimesFn type -type moqTimesFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTimesFn_paramsKey]*moqTimesFn_results +// moqTimesFn_results holds the results of the TimesFn type +type moqTimesFn_results struct { + sResult string + err error +} + +// moqTimesFn_paramIndexing holds the parameter indexing runtime configuration +// for the TimesFn type +type moqTimesFn_paramIndexing struct { + times moq.ParamIndexing + bParam moq.ParamIndexing } // moqTimesFn_doFn defines the type of function needed when calling andDo for @@ -2887,60 +1638,38 @@ type moqTimesFn_doFn func(times string, bParam bool) // doReturnResults for the TimesFn type type moqTimesFn_doReturnFn func(times string, bParam bool) (sResult string, err error) -// moqTimesFn_results holds the results of the TimesFn type -type moqTimesFn_results struct { - params moqTimesFn_params - results []struct { - values *struct { - sResult string - err error - } - sequence uint32 - doFn moqTimesFn_doFn - doReturnFn moqTimesFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTimesFn_fnRecorder routes recorded function calls to the moqTimesFn moq -type moqTimesFn_fnRecorder struct { - params moqTimesFn_params - anyParams uint64 - sequence bool - results *moqTimesFn_results - moq *moqTimesFn +// moqTimesFn_recorder routes recorded function calls to the moqTimesFn moq +type moqTimesFn_recorder struct { + recorder *impl.Recorder[ + *moqTimesFn_adaptor, + moqTimesFn_params, + moqTimesFn_paramsKey, + moqTimesFn_results, + ] } // moqTimesFn_anyParams isolates the any params functions of the TimesFn type type moqTimesFn_anyParams struct { - recorder *moqTimesFn_fnRecorder + recorder *moqTimesFn_recorder } // newMoqTimesFn creates a new moq of the TimesFn type func newMoqTimesFn(scene *moq.Scene, config *moq.Config) *moqTimesFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqTimesFn_adaptor{} m := &moqTimesFn{ - scene: scene, - config: *config, - moq: &moqTimesFn_mock{}, - - runtime: struct { - parameterIndexing struct { - times moq.ParamIndexing - bParam moq.ParamIndexing - } - }{parameterIndexing: struct { - times moq.ParamIndexing - bParam moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqTimesFn_adaptor, + moqTimesFn_params, + moqTimesFn_paramsKey, + moqTimesFn_results, + ](scene, adaptor1, config), + + runtime: moqTimesFn_runtime{parameterIndexing: moqTimesFn_paramIndexing{ times: moq.ParamIndexByValue, bParam: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -2948,281 +1677,115 @@ func newMoqTimesFn(scene *moq.Scene, config *moq.Config) *moqTimesFn { // mock returns the moq implementation of the TimesFn type func (m *moqTimesFn) mock() testmoqs.TimesFn { - return func(times string, bParam bool) (_ string, _ error) { - m.scene.T.Helper() - moq := &moqTimesFn_mock{moq: m} - return moq.fn(times, bParam) - } -} - -func (m *moqTimesFn_mock) fn(times string, bParam bool) (sResult string, err error) { - m.moq.scene.T.Helper() - params := moqTimesFn_params{ - times: times, - bParam: bParam, - } - var results *moqTimesFn_results - 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 func(times string, bParam bool) (string, error) { + m.moq.Scene.T.Helper() + params := moqTimesFn_params{ + times: times, + bParam: bParam, } - 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 + var result1 string + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } - i = results.repeat.ResultCount - 1 + return result1, result2 } +} - 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(times, bParam) - } - - if result.values != nil { - sResult = result.values.sResult - err = result.values.err - } - if result.doReturnFn != nil { - sResult, err = result.doReturnFn(times, bParam) - } - return -} - -func (m *moqTimesFn) onCall(times string, bParam bool) *moqTimesFn_fnRecorder { - return &moqTimesFn_fnRecorder{ - params: moqTimesFn_params{ +func (m *moqTimesFn) onCall(times string, bParam bool) *moqTimesFn_recorder { + return &moqTimesFn_recorder{ + recorder: m.moq.OnCall(moqTimesFn_params{ times: times, bParam: bParam, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqTimesFn_fnRecorder) any() *moqTimesFn_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(r.params)) +func (r *moqTimesFn_recorder) any() *moqTimesFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTimesFn_anyParams{recorder: r} } -func (a *moqTimesFn_anyParams) times() *moqTimesFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqTimesFn_anyParams) times() *moqTimesFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqTimesFn_anyParams) bParam() *moqTimesFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqTimesFn_anyParams) bParam() *moqTimesFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqTimesFn_fnRecorder) seq() *moqTimesFn_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(r.params)) +func (r *moqTimesFn_recorder) seq() *moqTimesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTimesFn_fnRecorder) noSeq() *moqTimesFn_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(r.params)) +func (r *moqTimesFn_recorder) noSeq() *moqTimesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTimesFn_fnRecorder) returnResults(sResult string, err error) *moqTimesFn_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 moqTimesFn_doFn - doReturnFn moqTimesFn_doReturnFn - }{ - values: &struct { - sResult string - err error - }{ - sResult: sResult, - err: err, - }, - sequence: sequence, +func (r *moqTimesFn_recorder) returnResults(sResult string, err error) *moqTimesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTimesFn_results{ + sResult: sResult, + err: err, }) return r } -func (r *moqTimesFn_fnRecorder) andDo(fn moqTimesFn_doFn) *moqTimesFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTimesFn_recorder) andDo(fn moqTimesFn_doFn) *moqTimesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTimesFn_params) { + fn(params.times, params.bParam) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTimesFn_fnRecorder) doReturnResults(fn moqTimesFn_doReturnFn) *moqTimesFn_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 +func (r *moqTimesFn_recorder) doReturnResults(fn moqTimesFn_doReturnFn) *moqTimesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTimesFn_params) *moqTimesFn_results { + sResult, err := fn(params.times, params.bParam) + return &moqTimesFn_results{ + sResult: sResult, + err: err, } - sequence uint32 - doFn moqTimesFn_doFn - doReturnFn moqTimesFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqTimesFn_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 *moqTimesFn_resultsByParams - 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 = &moqTimesFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTimesFn_paramsKey]*moqTimesFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTimesFn_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 *moqTimesFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTimesFn_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 moqTimesFn_doFn - doReturnFn moqTimesFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqTimesFn_recorder) repeat(repeaters ...moq.Repeater) *moqTimesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqTimesFn) prettyParams(params moqTimesFn_params) string { +func (*moqTimesFn_adaptor) PrettyParams(params moqTimesFn_params) string { return fmt.Sprintf("TimesFn(%#v, %#v)", params.times, params.bParam) } -func (m *moqTimesFn) paramsKey(params moqTimesFn_params, anyParams uint64) moqTimesFn_paramsKey { - m.scene.T.Helper() - var timesUsed string - var timesUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.times == moq.ParamIndexByValue { - timesUsed = params.times - } else { - timesUsedHash = hash.DeepHash(params.times) - } - } - var bParamUsed bool - var bParamUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.bParam == moq.ParamIndexByValue { - bParamUsed = params.bParam - } else { - bParamUsedHash = hash.DeepHash(params.bParam) - } - } +func (a *moqTimesFn_adaptor) ParamsKey(params moqTimesFn_params, anyParams uint64) moqTimesFn_paramsKey { + a.moq.moq.Scene.T.Helper() + timesUsed, timesUsedHash := impl.ParamKey( + params.times, 1, a.moq.runtime.parameterIndexing.times, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.bParam, 2, a.moq.runtime.parameterIndexing.bParam, anyParams) return moqTimesFn_paramsKey{ params: struct { times string @@ -3242,48 +1805,38 @@ func (m *moqTimesFn) paramsKey(params moqTimesFn_params, anyParams uint64) moqTi } // Reset resets the state of the moq -func (m *moqTimesFn) Reset() { m.resultsByParams = nil } +func (m *moqTimesFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqTimesFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqDifficultParamNamesFn holds the state of a moq of the // DifficultParamNamesFn type type moqDifficultParamNamesFn struct { - scene *moq.Scene - config moq.Config - moq *moqDifficultParamNamesFn_mock - - resultsByParams []moqDifficultParamNamesFn_resultsByParams - - runtime struct { - parameterIndexing 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 - } - } + moq *impl.Moq[ + *moqDifficultParamNamesFn_adaptor, + moqDifficultParamNamesFn_params, + moqDifficultParamNamesFn_paramsKey, + moqDifficultParamNamesFn_results, + ] + + runtime moqDifficultParamNamesFn_runtime } -// moqDifficultParamNamesFn_mock isolates the mock interface of the +// moqDifficultParamNamesFn_runtime holds runtime configuration for the // DifficultParamNamesFn type -type moqDifficultParamNamesFn_mock struct { +type moqDifficultParamNamesFn_runtime struct { + parameterIndexing moqDifficultParamNamesFn_paramIndexing +} + +// moqDifficultParamNamesFn_adaptor adapts moqDifficultParamNamesFn as needed +// by the runtime +type moqDifficultParamNamesFn_adaptor struct { moq *moqDifficultParamNamesFn } @@ -3313,12 +1866,17 @@ type moqDifficultParamNamesFn_paramsKey struct { } } -// moqDifficultParamNamesFn_resultsByParams contains the results for a given -// set of parameters for the DifficultParamNamesFn type -type moqDifficultParamNamesFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqDifficultParamNamesFn_paramsKey]*moqDifficultParamNamesFn_results +// moqDifficultParamNamesFn_results holds the results of the +// DifficultParamNamesFn type +type moqDifficultParamNamesFn_results struct{} + +// moqDifficultParamNamesFn_paramIndexing holds the parameter indexing runtime +// configuration for the DifficultParamNamesFn type +type moqDifficultParamNamesFn_paramIndexing struct { + param1, param2 moq.ParamIndexing + param3 moq.ParamIndexing + param, param5, param6 moq.ParamIndexing + param7, param8, param9 moq.ParamIndexing } // moqDifficultParamNamesFn_doFn defines the type of function needed when @@ -3329,70 +1887,36 @@ type moqDifficultParamNamesFn_doFn func(m, r bool, sequence string, param, param // calling doReturnResults for the DifficultParamNamesFn type type moqDifficultParamNamesFn_doReturnFn func(m, r bool, sequence string, param, params, i int, result, results, _ float32) -// moqDifficultParamNamesFn_results holds the results of the -// DifficultParamNamesFn type -type moqDifficultParamNamesFn_results struct { - params moqDifficultParamNamesFn_params - results []struct { - values *struct{} - sequence uint32 - doFn moqDifficultParamNamesFn_doFn - doReturnFn moqDifficultParamNamesFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqDifficultParamNamesFn_fnRecorder routes recorded function calls to the +// moqDifficultParamNamesFn_recorder routes recorded function calls to the // moqDifficultParamNamesFn moq -type moqDifficultParamNamesFn_fnRecorder struct { - params moqDifficultParamNamesFn_params - anyParams uint64 - sequence bool - results *moqDifficultParamNamesFn_results - moq *moqDifficultParamNamesFn +type moqDifficultParamNamesFn_recorder struct { + recorder *impl.Recorder[ + *moqDifficultParamNamesFn_adaptor, + moqDifficultParamNamesFn_params, + moqDifficultParamNamesFn_paramsKey, + moqDifficultParamNamesFn_results, + ] } // moqDifficultParamNamesFn_anyParams isolates the any params functions of the // DifficultParamNamesFn type type moqDifficultParamNamesFn_anyParams struct { - recorder *moqDifficultParamNamesFn_fnRecorder + recorder *moqDifficultParamNamesFn_recorder } // newMoqDifficultParamNamesFn creates a new moq of the DifficultParamNamesFn // type func newMoqDifficultParamNamesFn(scene *moq.Scene, config *moq.Config) *moqDifficultParamNamesFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqDifficultParamNamesFn_adaptor{} m := &moqDifficultParamNamesFn{ - scene: scene, - config: *config, - moq: &moqDifficultParamNamesFn_mock{}, - - runtime: struct { - parameterIndexing 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 - } - }{parameterIndexing: 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 - }{ + moq: impl.NewMoq[ + *moqDifficultParamNamesFn_adaptor, + moqDifficultParamNamesFn_params, + moqDifficultParamNamesFn_paramsKey, + moqDifficultParamNamesFn_results, + ](scene, adaptor1, config), + + runtime: moqDifficultParamNamesFn_runtime{parameterIndexing: moqDifficultParamNamesFn_paramIndexing{ param1: moq.ParamIndexByValue, param2: moq.ParamIndexByValue, param3: moq.ParamIndexByValue, @@ -3404,7 +1928,7 @@ func newMoqDifficultParamNamesFn(scene *moq.Scene, config *moq.Config) *moqDiffi param9: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -3413,73 +1937,26 @@ func newMoqDifficultParamNamesFn(scene *moq.Scene, config *moq.Config) *moqDiffi // mock returns the moq implementation of the DifficultParamNamesFn type func (m *moqDifficultParamNamesFn) mock() testmoqs.DifficultParamNamesFn { return func(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) { - m.scene.T.Helper() - moq := &moqDifficultParamNamesFn_mock{moq: m} - moq.fn(param1, param2, param3, param, param5, param6, param7, param8, param9) - } -} - -func (m *moqDifficultParamNamesFn_mock) fn(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) { - m.moq.scene.T.Helper() - params := moqDifficultParamNamesFn_params{ - param1: param1, - param2: param2, - param3: param3, - param: param, - param5: param5, - param6: param6, - param7: param7, - param8: param8, - param9: param9, - } - var results *moqDifficultParamNamesFn_results - 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)) + m.moq.Scene.T.Helper() + params := moqDifficultParamNamesFn_params{ + param1: param1, + param2: param2, + param3: param3, + param: param, + param5: param5, + param6: param6, + param7: param7, + param8: param8, + param9: param9, } - } - - 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) + m.moq.Function(params) } - return } -func (m *moqDifficultParamNamesFn) onCall(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) *moqDifficultParamNamesFn_fnRecorder { - return &moqDifficultParamNamesFn_fnRecorder{ - params: moqDifficultParamNamesFn_params{ +func (m *moqDifficultParamNamesFn) onCall(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) *moqDifficultParamNamesFn_recorder { + return &moqDifficultParamNamesFn_recorder{ + recorder: m.moq.OnCall(moqDifficultParamNamesFn_params{ param1: param1, param2: param2, param3: param3, @@ -3489,297 +1966,136 @@ func (m *moqDifficultParamNamesFn) onCall(param1, param2 bool, param3 string, pa param7: param7, param8: param8, param9: param9, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqDifficultParamNamesFn_fnRecorder) any() *moqDifficultParamNamesFn_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(r.params)) +func (r *moqDifficultParamNamesFn_recorder) any() *moqDifficultParamNamesFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqDifficultParamNamesFn_anyParams{recorder: r} } -func (a *moqDifficultParamNamesFn_anyParams) param1() *moqDifficultParamNamesFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqDifficultParamNamesFn_anyParams) param1() *moqDifficultParamNamesFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqDifficultParamNamesFn_anyParams) param2() *moqDifficultParamNamesFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqDifficultParamNamesFn_anyParams) param2() *moqDifficultParamNamesFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (a *moqDifficultParamNamesFn_anyParams) param3() *moqDifficultParamNamesFn_fnRecorder { - a.recorder.anyParams |= 1 << 2 +func (a *moqDifficultParamNamesFn_anyParams) param3() *moqDifficultParamNamesFn_recorder { + a.recorder.recorder.AnyParam(3) return a.recorder } -func (a *moqDifficultParamNamesFn_anyParams) param() *moqDifficultParamNamesFn_fnRecorder { - a.recorder.anyParams |= 1 << 3 +func (a *moqDifficultParamNamesFn_anyParams) param() *moqDifficultParamNamesFn_recorder { + a.recorder.recorder.AnyParam(4) return a.recorder } -func (a *moqDifficultParamNamesFn_anyParams) param5() *moqDifficultParamNamesFn_fnRecorder { - a.recorder.anyParams |= 1 << 4 +func (a *moqDifficultParamNamesFn_anyParams) param5() *moqDifficultParamNamesFn_recorder { + a.recorder.recorder.AnyParam(5) return a.recorder } -func (a *moqDifficultParamNamesFn_anyParams) param6() *moqDifficultParamNamesFn_fnRecorder { - a.recorder.anyParams |= 1 << 5 +func (a *moqDifficultParamNamesFn_anyParams) param6() *moqDifficultParamNamesFn_recorder { + a.recorder.recorder.AnyParam(6) return a.recorder } -func (a *moqDifficultParamNamesFn_anyParams) param7() *moqDifficultParamNamesFn_fnRecorder { - a.recorder.anyParams |= 1 << 6 +func (a *moqDifficultParamNamesFn_anyParams) param7() *moqDifficultParamNamesFn_recorder { + a.recorder.recorder.AnyParam(7) return a.recorder } -func (a *moqDifficultParamNamesFn_anyParams) param8() *moqDifficultParamNamesFn_fnRecorder { - a.recorder.anyParams |= 1 << 7 +func (a *moqDifficultParamNamesFn_anyParams) param8() *moqDifficultParamNamesFn_recorder { + a.recorder.recorder.AnyParam(8) return a.recorder } -func (a *moqDifficultParamNamesFn_anyParams) param9() *moqDifficultParamNamesFn_fnRecorder { - a.recorder.anyParams |= 1 << 8 +func (a *moqDifficultParamNamesFn_anyParams) param9() *moqDifficultParamNamesFn_recorder { + a.recorder.recorder.AnyParam(9) return a.recorder } -func (r *moqDifficultParamNamesFn_fnRecorder) seq() *moqDifficultParamNamesFn_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(r.params)) +func (r *moqDifficultParamNamesFn_recorder) seq() *moqDifficultParamNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqDifficultParamNamesFn_fnRecorder) noSeq() *moqDifficultParamNamesFn_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(r.params)) +func (r *moqDifficultParamNamesFn_recorder) noSeq() *moqDifficultParamNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqDifficultParamNamesFn_fnRecorder) returnResults() *moqDifficultParamNamesFn_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 moqDifficultParamNamesFn_doFn - doReturnFn moqDifficultParamNamesFn_doReturnFn - }{ - values: &struct{}{}, - sequence: sequence, - }) +func (r *moqDifficultParamNamesFn_recorder) returnResults() *moqDifficultParamNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqDifficultParamNamesFn_results{}) return r } -func (r *moqDifficultParamNamesFn_fnRecorder) andDo(fn moqDifficultParamNamesFn_doFn) *moqDifficultParamNamesFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqDifficultParamNamesFn_recorder) andDo(fn moqDifficultParamNamesFn_doFn) *moqDifficultParamNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqDifficultParamNamesFn_params) { + fn(params.param1, params.param2, params.param3, params.param, params.param5, params.param6, params.param7, params.param8, params.param9) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqDifficultParamNamesFn_fnRecorder) doReturnResults(fn moqDifficultParamNamesFn_doReturnFn) *moqDifficultParamNamesFn_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 moqDifficultParamNamesFn_doFn - doReturnFn moqDifficultParamNamesFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) +func (r *moqDifficultParamNamesFn_recorder) doReturnResults(fn moqDifficultParamNamesFn_doReturnFn) *moqDifficultParamNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqDifficultParamNamesFn_params) *moqDifficultParamNamesFn_results { + fn(params.param1, params.param2, params.param3, params.param, params.param5, params.param6, params.param7, params.param8, params.param9) + return &moqDifficultParamNamesFn_results{} + }) return r } -func (r *moqDifficultParamNamesFn_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 *moqDifficultParamNamesFn_resultsByParams - 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 = &moqDifficultParamNamesFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqDifficultParamNamesFn_paramsKey]*moqDifficultParamNamesFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqDifficultParamNamesFn_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 *moqDifficultParamNamesFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqDifficultParamNamesFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqDifficultParamNamesFn_recorder) repeat(repeaters ...moq.Repeater) *moqDifficultParamNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 moqDifficultParamNamesFn_doFn - doReturnFn moqDifficultParamNamesFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqDifficultParamNamesFn) prettyParams(params moqDifficultParamNamesFn_params) string { +func (*moqDifficultParamNamesFn_adaptor) PrettyParams(params moqDifficultParamNamesFn_params) string { return fmt.Sprintf("DifficultParamNamesFn(%#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 *moqDifficultParamNamesFn) paramsKey(params moqDifficultParamNamesFn_params, anyParams uint64) moqDifficultParamNamesFn_paramsKey { - m.scene.T.Helper() - var param1Used bool - 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) - } - } - 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) - } - } - var param3Used string - var param3UsedHash hash.Hash - if anyParams&(1<<2) == 0 { - if m.runtime.parameterIndexing.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.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.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.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.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.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.param9 == moq.ParamIndexByValue { - param9Used = params.param9 - } else { - param9UsedHash = hash.DeepHash(params.param9) - } - } +func (a *moqDifficultParamNamesFn_adaptor) ParamsKey(params moqDifficultParamNamesFn_params, anyParams uint64) moqDifficultParamNamesFn_paramsKey { + a.moq.moq.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.param1, 1, a.moq.runtime.parameterIndexing.param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.param2, 2, a.moq.runtime.parameterIndexing.param2, anyParams) + param3Used, param3UsedHash := impl.ParamKey( + params.param3, 3, a.moq.runtime.parameterIndexing.param3, anyParams) + paramUsed, paramUsedHash := impl.ParamKey( + params.param, 4, a.moq.runtime.parameterIndexing.param, anyParams) + param5Used, param5UsedHash := impl.ParamKey( + params.param5, 5, a.moq.runtime.parameterIndexing.param5, anyParams) + param6Used, param6UsedHash := impl.ParamKey( + params.param6, 6, a.moq.runtime.parameterIndexing.param6, anyParams) + param7Used, param7UsedHash := impl.ParamKey( + params.param7, 7, a.moq.runtime.parameterIndexing.param7, anyParams) + param8Used, param8UsedHash := impl.ParamKey( + params.param8, 8, a.moq.runtime.parameterIndexing.param8, anyParams) + param9Used, param9UsedHash := impl.ParamKey( + params.param9, 9, a.moq.runtime.parameterIndexing.param9, anyParams) return moqDifficultParamNamesFn_paramsKey{ params: struct { param1, param2 bool @@ -3817,38 +2133,38 @@ func (m *moqDifficultParamNamesFn) paramsKey(params moqDifficultParamNamesFn_par } // Reset resets the state of the moq -func (m *moqDifficultParamNamesFn) Reset() { m.resultsByParams = nil } +func (m *moqDifficultParamNamesFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqDifficultParamNamesFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqDifficultResultNamesFn holds the state of a moq of the // DifficultResultNamesFn type type moqDifficultResultNamesFn struct { - scene *moq.Scene - config moq.Config - moq *moqDifficultResultNamesFn_mock + moq *impl.Moq[ + *moqDifficultResultNamesFn_adaptor, + moqDifficultResultNamesFn_params, + moqDifficultResultNamesFn_paramsKey, + moqDifficultResultNamesFn_results, + ] - resultsByParams []moqDifficultResultNamesFn_resultsByParams - - runtime struct { - parameterIndexing struct{} - } + runtime moqDifficultResultNamesFn_runtime } -// moqDifficultResultNamesFn_mock isolates the mock interface of the +// moqDifficultResultNamesFn_runtime holds runtime configuration for the // DifficultResultNamesFn type -type moqDifficultResultNamesFn_mock struct { +type moqDifficultResultNamesFn_runtime struct { + parameterIndexing moqDifficultResultNamesFn_paramIndexing +} + +// moqDifficultResultNamesFn_adaptor adapts moqDifficultResultNamesFn as needed +// by the runtime +type moqDifficultResultNamesFn_adaptor struct { moq *moqDifficultResultNamesFn } @@ -3863,14 +2179,19 @@ type moqDifficultResultNamesFn_paramsKey struct { hashes struct{} } -// moqDifficultResultNamesFn_resultsByParams contains the results for a given -// set of parameters for the DifficultResultNamesFn type -type moqDifficultResultNamesFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqDifficultResultNamesFn_paramsKey]*moqDifficultResultNamesFn_results +// moqDifficultResultNamesFn_results holds the results of the +// DifficultResultNamesFn type +type moqDifficultResultNamesFn_results struct { + result1, result2 string + result3 error + param, result5, result6 int + result7, result8, result9 float32 } +// moqDifficultResultNamesFn_paramIndexing holds the parameter indexing runtime +// configuration for the DifficultResultNamesFn type +type moqDifficultResultNamesFn_paramIndexing struct{} + // moqDifficultResultNamesFn_doFn defines the type of function needed when // calling andDo for the DifficultResultNamesFn type type moqDifficultResultNamesFn_doFn func() @@ -3879,57 +2200,38 @@ type moqDifficultResultNamesFn_doFn func() // when calling doReturnResults for the DifficultResultNamesFn type type moqDifficultResultNamesFn_doReturnFn func() (m, r string, sequence error, param, params, i int, result, results, _ float32) -// moqDifficultResultNamesFn_results holds the results of the -// DifficultResultNamesFn type -type moqDifficultResultNamesFn_results struct { - params moqDifficultResultNamesFn_params - results []struct { - values *struct { - result1, result2 string - result3 error - param, result5, result6 int - result7, result8, result9 float32 - } - sequence uint32 - doFn moqDifficultResultNamesFn_doFn - doReturnFn moqDifficultResultNamesFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqDifficultResultNamesFn_fnRecorder routes recorded function calls to the +// moqDifficultResultNamesFn_recorder routes recorded function calls to the // moqDifficultResultNamesFn moq -type moqDifficultResultNamesFn_fnRecorder struct { - params moqDifficultResultNamesFn_params - anyParams uint64 - sequence bool - results *moqDifficultResultNamesFn_results - moq *moqDifficultResultNamesFn +type moqDifficultResultNamesFn_recorder struct { + recorder *impl.Recorder[ + *moqDifficultResultNamesFn_adaptor, + moqDifficultResultNamesFn_params, + moqDifficultResultNamesFn_paramsKey, + moqDifficultResultNamesFn_results, + ] } // moqDifficultResultNamesFn_anyParams isolates the any params functions of the // DifficultResultNamesFn type type moqDifficultResultNamesFn_anyParams struct { - recorder *moqDifficultResultNamesFn_fnRecorder + recorder *moqDifficultResultNamesFn_recorder } // newMoqDifficultResultNamesFn creates a new moq of the DifficultResultNamesFn // type func newMoqDifficultResultNamesFn(scene *moq.Scene, config *moq.Config) *moqDifficultResultNamesFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqDifficultResultNamesFn_adaptor{} m := &moqDifficultResultNamesFn{ - scene: scene, - config: *config, - moq: &moqDifficultResultNamesFn_mock{}, + moq: impl.NewMoq[ + *moqDifficultResultNamesFn_adaptor, + moqDifficultResultNamesFn_params, + moqDifficultResultNamesFn_paramsKey, + moqDifficultResultNamesFn_results, + ](scene, adaptor1, config), - runtime: struct { - parameterIndexing struct{} - }{parameterIndexing: struct{}{}}, + runtime: moqDifficultResultNamesFn_runtime{parameterIndexing: moqDifficultResultNamesFn_paramIndexing{}}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -3937,135 +2239,95 @@ func newMoqDifficultResultNamesFn(scene *moq.Scene, config *moq.Config) *moqDiff // mock returns the moq implementation of the DifficultResultNamesFn type func (m *moqDifficultResultNamesFn) mock() testmoqs.DifficultResultNamesFn { - return func() (_, _ string, _ error, _, _, _ int, _, _, _ float32) { - m.scene.T.Helper() - moq := &moqDifficultResultNamesFn_mock{moq: m} - return moq.fn() - } -} - -func (m *moqDifficultResultNamesFn_mock) fn() (result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) { - m.moq.scene.T.Helper() - params := moqDifficultResultNamesFn_params{} - var results *moqDifficultResultNamesFn_results - 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 - } + return func() (string, string, error, int, int, int, float32, float32, float32) { + m.moq.Scene.T.Helper() + params := moqDifficultResultNamesFn_params{} - 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)) + var result1 string + var result2 string + var result3 error + var result4 int + var result5 int + var result6 int + var result7 float32 + var result8 float32 + var result9 float32 + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 + result3 = result.result3 + result4 = result.param + result5 = result.result5 + result6 = result.result6 + result7 = result.result7 + result8 = result.result8 + result9 = result.result9 } + return result1, result2, result3, result4, result5, result6, result7, result8, result9 } - - 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 *moqDifficultResultNamesFn) onCall() *moqDifficultResultNamesFn_fnRecorder { - return &moqDifficultResultNamesFn_fnRecorder{ - params: moqDifficultResultNamesFn_params{}, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, +func (m *moqDifficultResultNamesFn) onCall() *moqDifficultResultNamesFn_recorder { + return &moqDifficultResultNamesFn_recorder{ + recorder: m.moq.OnCall(moqDifficultResultNamesFn_params{}), } } -func (r *moqDifficultResultNamesFn_fnRecorder) any() *moqDifficultResultNamesFn_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(r.params)) +func (r *moqDifficultResultNamesFn_recorder) any() *moqDifficultResultNamesFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqDifficultResultNamesFn_anyParams{recorder: r} } -func (r *moqDifficultResultNamesFn_fnRecorder) seq() *moqDifficultResultNamesFn_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(r.params)) +func (r *moqDifficultResultNamesFn_recorder) seq() *moqDifficultResultNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqDifficultResultNamesFn_fnRecorder) noSeq() *moqDifficultResultNamesFn_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(r.params)) +func (r *moqDifficultResultNamesFn_recorder) noSeq() *moqDifficultResultNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqDifficultResultNamesFn_fnRecorder) returnResults(result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) *moqDifficultResultNamesFn_fnRecorder { - r.moq.scene.T.Helper() - r.findResults() +func (r *moqDifficultResultNamesFn_recorder) returnResults(result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) *moqDifficultResultNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqDifficultResultNamesFn_results{ + result1: result1, + result2: result2, + result3: result3, + param: param, + result5: result5, + result6: result6, + result7: result7, + result8: result8, + result9: result9, + }) + return r +} - var sequence uint32 - if r.sequence { - sequence = r.moq.scene.NextRecorderSequence() +func (r *moqDifficultResultNamesFn_recorder) andDo(fn moqDifficultResultNamesFn_doFn) *moqDifficultResultNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqDifficultResultNamesFn_params) { + fn() + }, false) { + return nil } + return r +} - 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 moqDifficultResultNamesFn_doFn - doReturnFn moqDifficultResultNamesFn_doReturnFn - }{ - values: &struct { - result1, result2 string - result3 error - param, result5, result6 int - result7, result8, result9 float32 - }{ +func (r *moqDifficultResultNamesFn_recorder) doReturnResults(fn moqDifficultResultNamesFn_doReturnFn) *moqDifficultResultNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqDifficultResultNamesFn_params) *moqDifficultResultNamesFn_results { + result1, result2, result3, param, result5, result6, result7, result8, result9 := fn() + return &moqDifficultResultNamesFn_results{ result1: result1, result2: result2, result3: result3, @@ -4075,131 +2337,25 @@ func (r *moqDifficultResultNamesFn_fnRecorder) returnResults(result1, result2 st result7: result7, result8: result8, result9: result9, - }, - sequence: sequence, + } }) return r } -func (r *moqDifficultResultNamesFn_fnRecorder) andDo(fn moqDifficultResultNamesFn_doFn) *moqDifficultResultNamesFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqDifficultResultNamesFn_recorder) repeat(repeaters ...moq.Repeater) *moqDifficultResultNamesFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn - return r -} - -func (r *moqDifficultResultNamesFn_fnRecorder) doReturnResults(fn moqDifficultResultNamesFn_doReturnFn) *moqDifficultResultNamesFn_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 moqDifficultResultNamesFn_doFn - doReturnFn moqDifficultResultNamesFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) - return r -} - -func (r *moqDifficultResultNamesFn_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 *moqDifficultResultNamesFn_resultsByParams - 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 = &moqDifficultResultNamesFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqDifficultResultNamesFn_paramsKey]*moqDifficultResultNamesFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqDifficultResultNamesFn_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 *moqDifficultResultNamesFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqDifficultResultNamesFn_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 moqDifficultResultNamesFn_doFn - doReturnFn moqDifficultResultNamesFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqDifficultResultNamesFn) prettyParams(params moqDifficultResultNamesFn_params) string { +func (*moqDifficultResultNamesFn_adaptor) PrettyParams(params moqDifficultResultNamesFn_params) string { return fmt.Sprintf("DifficultResultNamesFn()") } -func (m *moqDifficultResultNamesFn) paramsKey(params moqDifficultResultNamesFn_params, anyParams uint64) moqDifficultResultNamesFn_paramsKey { - m.scene.T.Helper() +func (a *moqDifficultResultNamesFn_adaptor) ParamsKey(params moqDifficultResultNamesFn_params, anyParams uint64) moqDifficultResultNamesFn_paramsKey { + a.moq.moq.Scene.T.Helper() return moqDifficultResultNamesFn_paramsKey{ params: struct{}{}, hashes: struct{}{}, @@ -4207,38 +2363,36 @@ func (m *moqDifficultResultNamesFn) paramsKey(params moqDifficultResultNamesFn_p } // Reset resets the state of the moq -func (m *moqDifficultResultNamesFn) Reset() { m.resultsByParams = nil } +func (m *moqDifficultResultNamesFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqDifficultResultNamesFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqPassByArrayFn holds the state of a moq of the PassByArrayFn type type moqPassByArrayFn struct { - scene *moq.Scene - config moq.Config - moq *moqPassByArrayFn_mock + moq *impl.Moq[ + *moqPassByArrayFn_adaptor, + moqPassByArrayFn_params, + moqPassByArrayFn_paramsKey, + moqPassByArrayFn_results, + ] - resultsByParams []moqPassByArrayFn_resultsByParams + runtime moqPassByArrayFn_runtime +} - runtime struct { - parameterIndexing struct { - p moq.ParamIndexing - } - } +// moqPassByArrayFn_runtime holds runtime configuration for the PassByArrayFn +// type +type moqPassByArrayFn_runtime struct { + parameterIndexing moqPassByArrayFn_paramIndexing } -// moqPassByArrayFn_mock isolates the mock interface of the PassByArrayFn type -type moqPassByArrayFn_mock struct { +// moqPassByArrayFn_adaptor adapts moqPassByArrayFn as needed by the runtime +type moqPassByArrayFn_adaptor struct { moq *moqPassByArrayFn } @@ -4252,12 +2406,15 @@ type moqPassByArrayFn_paramsKey struct { hashes struct{ p hash.Hash } } -// moqPassByArrayFn_resultsByParams contains the results for a given set of -// parameters for the PassByArrayFn type -type moqPassByArrayFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqPassByArrayFn_paramsKey]*moqPassByArrayFn_results +// moqPassByArrayFn_results holds the results of the PassByArrayFn type +type moqPassByArrayFn_results struct { + result1 [3]testmoqs.Results +} + +// moqPassByArrayFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByArrayFn type +type moqPassByArrayFn_paramIndexing struct { + p moq.ParamIndexing } // moqPassByArrayFn_doFn defines the type of function needed when calling andDo @@ -4268,58 +2425,39 @@ type moqPassByArrayFn_doFn func(p [3]testmoqs.Params) // doReturnResults for the PassByArrayFn type type moqPassByArrayFn_doReturnFn func(p [3]testmoqs.Params) [3]testmoqs.Results -// moqPassByArrayFn_results holds the results of the PassByArrayFn type -type moqPassByArrayFn_results struct { - params moqPassByArrayFn_params - results []struct { - values *struct { - result1 [3]testmoqs.Results - } - sequence uint32 - doFn moqPassByArrayFn_doFn - doReturnFn moqPassByArrayFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqPassByArrayFn_fnRecorder routes recorded function calls to the +// moqPassByArrayFn_recorder routes recorded function calls to the // moqPassByArrayFn moq -type moqPassByArrayFn_fnRecorder struct { - params moqPassByArrayFn_params - anyParams uint64 - sequence bool - results *moqPassByArrayFn_results - moq *moqPassByArrayFn +type moqPassByArrayFn_recorder struct { + recorder *impl.Recorder[ + *moqPassByArrayFn_adaptor, + moqPassByArrayFn_params, + moqPassByArrayFn_paramsKey, + moqPassByArrayFn_results, + ] } // moqPassByArrayFn_anyParams isolates the any params functions of the // PassByArrayFn type type moqPassByArrayFn_anyParams struct { - recorder *moqPassByArrayFn_fnRecorder + recorder *moqPassByArrayFn_recorder } // newMoqPassByArrayFn creates a new moq of the PassByArrayFn type func newMoqPassByArrayFn(scene *moq.Scene, config *moq.Config) *moqPassByArrayFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqPassByArrayFn_adaptor{} m := &moqPassByArrayFn{ - scene: scene, - config: *config, - moq: &moqPassByArrayFn_mock{}, - - runtime: struct { - parameterIndexing struct { - p moq.ParamIndexing - } - }{parameterIndexing: struct { - p moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqPassByArrayFn_adaptor, + moqPassByArrayFn_params, + moqPassByArrayFn_paramsKey, + moqPassByArrayFn_results, + ](scene, adaptor1, config), + + runtime: moqPassByArrayFn_runtime{parameterIndexing: moqPassByArrayFn_paramIndexing{ p: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -4328,258 +2466,101 @@ func newMoqPassByArrayFn(scene *moq.Scene, config *moq.Config) *moqPassByArrayFn // mock returns the moq implementation of the PassByArrayFn type func (m *moqPassByArrayFn) mock() testmoqs.PassByArrayFn { return func(p [3]testmoqs.Params) [3]testmoqs.Results { - m.scene.T.Helper() - moq := &moqPassByArrayFn_mock{moq: m} - return moq.fn(p) - } -} - -func (m *moqPassByArrayFn_mock) fn(p [3]testmoqs.Params) (result1 [3]testmoqs.Results) { - m.moq.scene.T.Helper() - params := moqPassByArrayFn_params{ - p: p, - } - var results *moqPassByArrayFn_results - 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 + m.moq.Scene.T.Helper() + params := moqPassByArrayFn_params{ + p: p, } - 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)) + var result1 [3]testmoqs.Results + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } + return result1 } - - if result.doFn != nil { - result.doFn(p) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) - } - return } -func (m *moqPassByArrayFn) onCall(p [3]testmoqs.Params) *moqPassByArrayFn_fnRecorder { - return &moqPassByArrayFn_fnRecorder{ - params: moqPassByArrayFn_params{ +func (m *moqPassByArrayFn) onCall(p [3]testmoqs.Params) *moqPassByArrayFn_recorder { + return &moqPassByArrayFn_recorder{ + recorder: m.moq.OnCall(moqPassByArrayFn_params{ p: p, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqPassByArrayFn_fnRecorder) any() *moqPassByArrayFn_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(r.params)) +func (r *moqPassByArrayFn_recorder) any() *moqPassByArrayFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqPassByArrayFn_anyParams{recorder: r} } -func (a *moqPassByArrayFn_anyParams) p() *moqPassByArrayFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqPassByArrayFn_anyParams) p() *moqPassByArrayFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqPassByArrayFn_fnRecorder) seq() *moqPassByArrayFn_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(r.params)) +func (r *moqPassByArrayFn_recorder) seq() *moqPassByArrayFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqPassByArrayFn_fnRecorder) noSeq() *moqPassByArrayFn_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(r.params)) +func (r *moqPassByArrayFn_recorder) noSeq() *moqPassByArrayFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqPassByArrayFn_fnRecorder) returnResults(result1 [3]testmoqs.Results) *moqPassByArrayFn_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 [3]testmoqs.Results - } - sequence uint32 - doFn moqPassByArrayFn_doFn - doReturnFn moqPassByArrayFn_doReturnFn - }{ - values: &struct { - result1 [3]testmoqs.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqPassByArrayFn_recorder) returnResults(result1 [3]testmoqs.Results) *moqPassByArrayFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqPassByArrayFn_results{ + result1: result1, }) return r } -func (r *moqPassByArrayFn_fnRecorder) andDo(fn moqPassByArrayFn_doFn) *moqPassByArrayFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqPassByArrayFn_recorder) andDo(fn moqPassByArrayFn_doFn) *moqPassByArrayFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqPassByArrayFn_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqPassByArrayFn_fnRecorder) doReturnResults(fn moqPassByArrayFn_doReturnFn) *moqPassByArrayFn_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 [3]testmoqs.Results +func (r *moqPassByArrayFn_recorder) doReturnResults(fn moqPassByArrayFn_doReturnFn) *moqPassByArrayFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqPassByArrayFn_params) *moqPassByArrayFn_results { + result1 := fn(params.p) + return &moqPassByArrayFn_results{ + result1: result1, } - sequence uint32 - doFn moqPassByArrayFn_doFn - doReturnFn moqPassByArrayFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqPassByArrayFn_fnRecorder) findResults() { - r.moq.scene.T.Helper() - if r.results != nil { - r.results.repeat.Increment(r.moq.scene.T) - return +func (r *moqPassByArrayFn_recorder) repeat(repeaters ...moq.Repeater) *moqPassByArrayFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } + return r +} - anyCount := bits.OnesCount64(r.anyParams) - insertAt := -1 - var results *moqPassByArrayFn_resultsByParams - 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 = &moqPassByArrayFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqPassByArrayFn_paramsKey]*moqPassByArrayFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqPassByArrayFn_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 *moqPassByArrayFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqPassByArrayFn_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 [3]testmoqs.Results - } - sequence uint32 - doFn moqPassByArrayFn_doFn - doReturnFn moqPassByArrayFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } - return r -} - -func (m *moqPassByArrayFn) prettyParams(params moqPassByArrayFn_params) string { +func (*moqPassByArrayFn_adaptor) PrettyParams(params moqPassByArrayFn_params) string { return fmt.Sprintf("PassByArrayFn(%#v)", params.p) } -func (m *moqPassByArrayFn) paramsKey(params moqPassByArrayFn_params, anyParams uint64) moqPassByArrayFn_paramsKey { - m.scene.T.Helper() - var pUsed [3]testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.p == moq.ParamIndexByValue { - pUsed = params.p - } else { - pUsedHash = hash.DeepHash(params.p) - } - } +func (a *moqPassByArrayFn_adaptor) ParamsKey(params moqPassByArrayFn_params, anyParams uint64) moqPassByArrayFn_paramsKey { + a.moq.moq.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.p, 1, a.moq.runtime.parameterIndexing.p, anyParams) return moqPassByArrayFn_paramsKey{ params: struct{ p [3]testmoqs.Params }{ p: pUsed, @@ -4591,38 +2572,36 @@ func (m *moqPassByArrayFn) paramsKey(params moqPassByArrayFn_params, anyParams u } // Reset resets the state of the moq -func (m *moqPassByArrayFn) Reset() { m.resultsByParams = nil } +func (m *moqPassByArrayFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqPassByArrayFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqPassByChanFn holds the state of a moq of the PassByChanFn type type moqPassByChanFn struct { - scene *moq.Scene - config moq.Config - moq *moqPassByChanFn_mock + moq *impl.Moq[ + *moqPassByChanFn_adaptor, + moqPassByChanFn_params, + moqPassByChanFn_paramsKey, + moqPassByChanFn_results, + ] - resultsByParams []moqPassByChanFn_resultsByParams + runtime moqPassByChanFn_runtime +} - runtime struct { - parameterIndexing struct { - p moq.ParamIndexing - } - } +// moqPassByChanFn_runtime holds runtime configuration for the PassByChanFn +// type +type moqPassByChanFn_runtime struct { + parameterIndexing moqPassByChanFn_paramIndexing } -// moqPassByChanFn_mock isolates the mock interface of the PassByChanFn type -type moqPassByChanFn_mock struct { +// moqPassByChanFn_adaptor adapts moqPassByChanFn as needed by the runtime +type moqPassByChanFn_adaptor struct { moq *moqPassByChanFn } @@ -4635,12 +2614,15 @@ type moqPassByChanFn_paramsKey struct { hashes struct{ p hash.Hash } } -// moqPassByChanFn_resultsByParams contains the results for a given set of -// parameters for the PassByChanFn type -type moqPassByChanFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqPassByChanFn_paramsKey]*moqPassByChanFn_results +// moqPassByChanFn_results holds the results of the PassByChanFn type +type moqPassByChanFn_results struct { + result1 chan testmoqs.Results +} + +// moqPassByChanFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByChanFn type +type moqPassByChanFn_paramIndexing struct { + p moq.ParamIndexing } // moqPassByChanFn_doFn defines the type of function needed when calling andDo @@ -4651,58 +2633,39 @@ type moqPassByChanFn_doFn func(p chan testmoqs.Params) // doReturnResults for the PassByChanFn type type moqPassByChanFn_doReturnFn func(p chan testmoqs.Params) chan testmoqs.Results -// moqPassByChanFn_results holds the results of the PassByChanFn type -type moqPassByChanFn_results struct { - params moqPassByChanFn_params - results []struct { - values *struct { - result1 chan testmoqs.Results - } - sequence uint32 - doFn moqPassByChanFn_doFn - doReturnFn moqPassByChanFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqPassByChanFn_fnRecorder routes recorded function calls to the +// moqPassByChanFn_recorder routes recorded function calls to the // moqPassByChanFn moq -type moqPassByChanFn_fnRecorder struct { - params moqPassByChanFn_params - anyParams uint64 - sequence bool - results *moqPassByChanFn_results - moq *moqPassByChanFn +type moqPassByChanFn_recorder struct { + recorder *impl.Recorder[ + *moqPassByChanFn_adaptor, + moqPassByChanFn_params, + moqPassByChanFn_paramsKey, + moqPassByChanFn_results, + ] } // moqPassByChanFn_anyParams isolates the any params functions of the // PassByChanFn type type moqPassByChanFn_anyParams struct { - recorder *moqPassByChanFn_fnRecorder + recorder *moqPassByChanFn_recorder } // newMoqPassByChanFn creates a new moq of the PassByChanFn type func newMoqPassByChanFn(scene *moq.Scene, config *moq.Config) *moqPassByChanFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqPassByChanFn_adaptor{} m := &moqPassByChanFn{ - scene: scene, - config: *config, - moq: &moqPassByChanFn_mock{}, - - runtime: struct { - parameterIndexing struct { - p moq.ParamIndexing - } - }{parameterIndexing: struct { - p moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqPassByChanFn_adaptor, + moqPassByChanFn_params, + moqPassByChanFn_paramsKey, + moqPassByChanFn_results, + ](scene, adaptor1, config), + + runtime: moqPassByChanFn_runtime{parameterIndexing: moqPassByChanFn_paramIndexing{ p: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -4711,258 +2674,101 @@ func newMoqPassByChanFn(scene *moq.Scene, config *moq.Config) *moqPassByChanFn { // mock returns the moq implementation of the PassByChanFn type func (m *moqPassByChanFn) mock() testmoqs.PassByChanFn { return func(p chan testmoqs.Params) chan testmoqs.Results { - m.scene.T.Helper() - moq := &moqPassByChanFn_mock{moq: m} - return moq.fn(p) - } -} - -func (m *moqPassByChanFn_mock) fn(p chan testmoqs.Params) (result1 chan testmoqs.Results) { - m.moq.scene.T.Helper() - params := moqPassByChanFn_params{ - p: p, - } - var results *moqPassByChanFn_results - 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 + m.moq.Scene.T.Helper() + params := moqPassByChanFn_params{ + p: p, } - 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)) + var result1 chan testmoqs.Results + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } + return result1 } - - if result.doFn != nil { - result.doFn(p) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) - } - return } -func (m *moqPassByChanFn) onCall(p chan testmoqs.Params) *moqPassByChanFn_fnRecorder { - return &moqPassByChanFn_fnRecorder{ - params: moqPassByChanFn_params{ +func (m *moqPassByChanFn) onCall(p chan testmoqs.Params) *moqPassByChanFn_recorder { + return &moqPassByChanFn_recorder{ + recorder: m.moq.OnCall(moqPassByChanFn_params{ p: p, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqPassByChanFn_fnRecorder) any() *moqPassByChanFn_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(r.params)) +func (r *moqPassByChanFn_recorder) any() *moqPassByChanFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqPassByChanFn_anyParams{recorder: r} } -func (a *moqPassByChanFn_anyParams) p() *moqPassByChanFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqPassByChanFn_anyParams) p() *moqPassByChanFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqPassByChanFn_fnRecorder) seq() *moqPassByChanFn_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(r.params)) +func (r *moqPassByChanFn_recorder) seq() *moqPassByChanFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqPassByChanFn_fnRecorder) noSeq() *moqPassByChanFn_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(r.params)) +func (r *moqPassByChanFn_recorder) noSeq() *moqPassByChanFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqPassByChanFn_fnRecorder) returnResults(result1 chan testmoqs.Results) *moqPassByChanFn_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 chan testmoqs.Results - } - sequence uint32 - doFn moqPassByChanFn_doFn - doReturnFn moqPassByChanFn_doReturnFn - }{ - values: &struct { - result1 chan testmoqs.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqPassByChanFn_recorder) returnResults(result1 chan testmoqs.Results) *moqPassByChanFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqPassByChanFn_results{ + result1: result1, }) return r } -func (r *moqPassByChanFn_fnRecorder) andDo(fn moqPassByChanFn_doFn) *moqPassByChanFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqPassByChanFn_recorder) andDo(fn moqPassByChanFn_doFn) *moqPassByChanFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqPassByChanFn_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqPassByChanFn_fnRecorder) doReturnResults(fn moqPassByChanFn_doReturnFn) *moqPassByChanFn_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 chan testmoqs.Results +func (r *moqPassByChanFn_recorder) doReturnResults(fn moqPassByChanFn_doReturnFn) *moqPassByChanFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqPassByChanFn_params) *moqPassByChanFn_results { + result1 := fn(params.p) + return &moqPassByChanFn_results{ + result1: result1, } - sequence uint32 - doFn moqPassByChanFn_doFn - doReturnFn moqPassByChanFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqPassByChanFn_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 *moqPassByChanFn_resultsByParams - 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 = &moqPassByChanFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqPassByChanFn_paramsKey]*moqPassByChanFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqPassByChanFn_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 *moqPassByChanFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqPassByChanFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqPassByChanFn_recorder) repeat(repeaters ...moq.Repeater) *moqPassByChanFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 chan testmoqs.Results - } - sequence uint32 - doFn moqPassByChanFn_doFn - doReturnFn moqPassByChanFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqPassByChanFn) prettyParams(params moqPassByChanFn_params) string { +func (*moqPassByChanFn_adaptor) PrettyParams(params moqPassByChanFn_params) string { return fmt.Sprintf("PassByChanFn(%#v)", params.p) } -func (m *moqPassByChanFn) paramsKey(params moqPassByChanFn_params, anyParams uint64) moqPassByChanFn_paramsKey { - m.scene.T.Helper() - var pUsed chan testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.p == moq.ParamIndexByValue { - pUsed = params.p - } else { - pUsedHash = hash.DeepHash(params.p) - } - } +func (a *moqPassByChanFn_adaptor) ParamsKey(params moqPassByChanFn_params, anyParams uint64) moqPassByChanFn_paramsKey { + a.moq.moq.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.p, 1, a.moq.runtime.parameterIndexing.p, anyParams) return moqPassByChanFn_paramsKey{ params: struct{ p chan testmoqs.Params }{ p: pUsed, @@ -4974,39 +2780,37 @@ func (m *moqPassByChanFn) paramsKey(params moqPassByChanFn_params, anyParams uin } // Reset resets the state of the moq -func (m *moqPassByChanFn) Reset() { m.resultsByParams = nil } +func (m *moqPassByChanFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqPassByChanFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqPassByEllipsisFn holds the state of a moq of the PassByEllipsisFn type type moqPassByEllipsisFn struct { - scene *moq.Scene - config moq.Config - moq *moqPassByEllipsisFn_mock + moq *impl.Moq[ + *moqPassByEllipsisFn_adaptor, + moqPassByEllipsisFn_params, + moqPassByEllipsisFn_paramsKey, + moqPassByEllipsisFn_results, + ] - resultsByParams []moqPassByEllipsisFn_resultsByParams + runtime moqPassByEllipsisFn_runtime +} - runtime struct { - parameterIndexing struct { - p moq.ParamIndexing - } - } +// moqPassByEllipsisFn_runtime holds runtime configuration for the +// PassByEllipsisFn type +type moqPassByEllipsisFn_runtime struct { + parameterIndexing moqPassByEllipsisFn_paramIndexing } -// moqPassByEllipsisFn_mock isolates the mock interface of the PassByEllipsisFn -// type -type moqPassByEllipsisFn_mock struct { +// moqPassByEllipsisFn_adaptor adapts moqPassByEllipsisFn as needed by the +// runtime +type moqPassByEllipsisFn_adaptor struct { moq *moqPassByEllipsisFn } @@ -5020,12 +2824,16 @@ type moqPassByEllipsisFn_paramsKey struct { hashes struct{ p hash.Hash } } -// moqPassByEllipsisFn_resultsByParams contains the results for a given set of -// parameters for the PassByEllipsisFn type -type moqPassByEllipsisFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqPassByEllipsisFn_paramsKey]*moqPassByEllipsisFn_results +// moqPassByEllipsisFn_results holds the results of the PassByEllipsisFn type +type moqPassByEllipsisFn_results struct { + result1 string + result2 error +} + +// moqPassByEllipsisFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByEllipsisFn type +type moqPassByEllipsisFn_paramIndexing struct { + p moq.ParamIndexing } // moqPassByEllipsisFn_doFn defines the type of function needed when calling @@ -5036,59 +2844,39 @@ type moqPassByEllipsisFn_doFn func(p ...testmoqs.Params) // calling doReturnResults for the PassByEllipsisFn type type moqPassByEllipsisFn_doReturnFn func(p ...testmoqs.Params) (string, error) -// moqPassByEllipsisFn_results holds the results of the PassByEllipsisFn type -type moqPassByEllipsisFn_results struct { - params moqPassByEllipsisFn_params - results []struct { - values *struct { - result1 string - result2 error - } - sequence uint32 - doFn moqPassByEllipsisFn_doFn - doReturnFn moqPassByEllipsisFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqPassByEllipsisFn_fnRecorder routes recorded function calls to the +// moqPassByEllipsisFn_recorder routes recorded function calls to the // moqPassByEllipsisFn moq -type moqPassByEllipsisFn_fnRecorder struct { - params moqPassByEllipsisFn_params - anyParams uint64 - sequence bool - results *moqPassByEllipsisFn_results - moq *moqPassByEllipsisFn +type moqPassByEllipsisFn_recorder struct { + recorder *impl.Recorder[ + *moqPassByEllipsisFn_adaptor, + moqPassByEllipsisFn_params, + moqPassByEllipsisFn_paramsKey, + moqPassByEllipsisFn_results, + ] } // moqPassByEllipsisFn_anyParams isolates the any params functions of the // PassByEllipsisFn type type moqPassByEllipsisFn_anyParams struct { - recorder *moqPassByEllipsisFn_fnRecorder + recorder *moqPassByEllipsisFn_recorder } // newMoqPassByEllipsisFn creates a new moq of the PassByEllipsisFn type func newMoqPassByEllipsisFn(scene *moq.Scene, config *moq.Config) *moqPassByEllipsisFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqPassByEllipsisFn_adaptor{} m := &moqPassByEllipsisFn{ - scene: scene, - config: *config, - moq: &moqPassByEllipsisFn_mock{}, - - runtime: struct { - parameterIndexing struct { - p moq.ParamIndexing - } - }{parameterIndexing: struct { - p moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqPassByEllipsisFn_adaptor, + moqPassByEllipsisFn_params, + moqPassByEllipsisFn_paramsKey, + moqPassByEllipsisFn_results, + ](scene, adaptor1, config), + + runtime: moqPassByEllipsisFn_runtime{parameterIndexing: moqPassByEllipsisFn_paramIndexing{ p: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -5097,262 +2885,105 @@ func newMoqPassByEllipsisFn(scene *moq.Scene, config *moq.Config) *moqPassByElli // mock returns the moq implementation of the PassByEllipsisFn type func (m *moqPassByEllipsisFn) mock() testmoqs.PassByEllipsisFn { return func(p ...testmoqs.Params) (string, error) { - m.scene.T.Helper() - moq := &moqPassByEllipsisFn_mock{moq: m} - return moq.fn(p...) - } -} - -func (m *moqPassByEllipsisFn_mock) fn(p ...testmoqs.Params) (result1 string, result2 error) { - m.moq.scene.T.Helper() - params := moqPassByEllipsisFn_params{ - p: p, - } - var results *moqPassByEllipsisFn_results - 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 + m.moq.Scene.T.Helper() + params := moqPassByEllipsisFn_params{ + p: p, } - 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)) + var result1 string + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } + return result1, result2 } - - if result.doFn != nil { - result.doFn(p...) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(p...) - } - return } -func (m *moqPassByEllipsisFn) onCall(p ...testmoqs.Params) *moqPassByEllipsisFn_fnRecorder { - return &moqPassByEllipsisFn_fnRecorder{ - params: moqPassByEllipsisFn_params{ +func (m *moqPassByEllipsisFn) onCall(p ...testmoqs.Params) *moqPassByEllipsisFn_recorder { + return &moqPassByEllipsisFn_recorder{ + recorder: m.moq.OnCall(moqPassByEllipsisFn_params{ p: p, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqPassByEllipsisFn_fnRecorder) any() *moqPassByEllipsisFn_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(r.params)) +func (r *moqPassByEllipsisFn_recorder) any() *moqPassByEllipsisFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqPassByEllipsisFn_anyParams{recorder: r} } -func (a *moqPassByEllipsisFn_anyParams) p() *moqPassByEllipsisFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqPassByEllipsisFn_anyParams) p() *moqPassByEllipsisFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqPassByEllipsisFn_fnRecorder) seq() *moqPassByEllipsisFn_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(r.params)) +func (r *moqPassByEllipsisFn_recorder) seq() *moqPassByEllipsisFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqPassByEllipsisFn_fnRecorder) noSeq() *moqPassByEllipsisFn_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(r.params)) +func (r *moqPassByEllipsisFn_recorder) noSeq() *moqPassByEllipsisFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqPassByEllipsisFn_fnRecorder) returnResults(result1 string, result2 error) *moqPassByEllipsisFn_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 moqPassByEllipsisFn_doFn - doReturnFn moqPassByEllipsisFn_doReturnFn - }{ - values: &struct { - result1 string - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqPassByEllipsisFn_recorder) returnResults(result1 string, result2 error) *moqPassByEllipsisFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqPassByEllipsisFn_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqPassByEllipsisFn_fnRecorder) andDo(fn moqPassByEllipsisFn_doFn) *moqPassByEllipsisFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqPassByEllipsisFn_recorder) andDo(fn moqPassByEllipsisFn_doFn) *moqPassByEllipsisFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqPassByEllipsisFn_params) { + fn(params.p...) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqPassByEllipsisFn_fnRecorder) doReturnResults(fn moqPassByEllipsisFn_doReturnFn) *moqPassByEllipsisFn_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 +func (r *moqPassByEllipsisFn_recorder) doReturnResults(fn moqPassByEllipsisFn_doReturnFn) *moqPassByEllipsisFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqPassByEllipsisFn_params) *moqPassByEllipsisFn_results { + result1, result2 := fn(params.p...) + return &moqPassByEllipsisFn_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqPassByEllipsisFn_doFn - doReturnFn moqPassByEllipsisFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqPassByEllipsisFn_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 *moqPassByEllipsisFn_resultsByParams - 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 = &moqPassByEllipsisFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqPassByEllipsisFn_paramsKey]*moqPassByEllipsisFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqPassByEllipsisFn_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 *moqPassByEllipsisFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqPassByEllipsisFn_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 moqPassByEllipsisFn_doFn - doReturnFn moqPassByEllipsisFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqPassByEllipsisFn_recorder) repeat(repeaters ...moq.Repeater) *moqPassByEllipsisFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqPassByEllipsisFn) prettyParams(params moqPassByEllipsisFn_params) string { +func (*moqPassByEllipsisFn_adaptor) PrettyParams(params moqPassByEllipsisFn_params) string { return fmt.Sprintf("PassByEllipsisFn(%#v)", params.p) } -func (m *moqPassByEllipsisFn) paramsKey(params moqPassByEllipsisFn_params, anyParams uint64) moqPassByEllipsisFn_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqPassByEllipsisFn_adaptor) ParamsKey(params moqPassByEllipsisFn_params, anyParams uint64) moqPassByEllipsisFn_paramsKey { + a.moq.moq.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.p, anyParams) return moqPassByEllipsisFn_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -5362,38 +2993,35 @@ func (m *moqPassByEllipsisFn) paramsKey(params moqPassByEllipsisFn_params, anyPa } // Reset resets the state of the moq -func (m *moqPassByEllipsisFn) Reset() { m.resultsByParams = nil } +func (m *moqPassByEllipsisFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqPassByEllipsisFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqPassByMapFn holds the state of a moq of the PassByMapFn type type moqPassByMapFn struct { - scene *moq.Scene - config moq.Config - moq *moqPassByMapFn_mock + moq *impl.Moq[ + *moqPassByMapFn_adaptor, + moqPassByMapFn_params, + moqPassByMapFn_paramsKey, + moqPassByMapFn_results, + ] - resultsByParams []moqPassByMapFn_resultsByParams + runtime moqPassByMapFn_runtime +} - runtime struct { - parameterIndexing struct { - p moq.ParamIndexing - } - } +// moqPassByMapFn_runtime holds runtime configuration for the PassByMapFn type +type moqPassByMapFn_runtime struct { + parameterIndexing moqPassByMapFn_paramIndexing } -// moqPassByMapFn_mock isolates the mock interface of the PassByMapFn type -type moqPassByMapFn_mock struct { +// moqPassByMapFn_adaptor adapts moqPassByMapFn as needed by the runtime +type moqPassByMapFn_adaptor struct { moq *moqPassByMapFn } @@ -5406,12 +3034,15 @@ type moqPassByMapFn_paramsKey struct { hashes struct{ p hash.Hash } } -// moqPassByMapFn_resultsByParams contains the results for a given set of -// parameters for the PassByMapFn type -type moqPassByMapFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqPassByMapFn_paramsKey]*moqPassByMapFn_results +// moqPassByMapFn_results holds the results of the PassByMapFn type +type moqPassByMapFn_results struct { + result1 map[string]testmoqs.Results +} + +// moqPassByMapFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByMapFn type +type moqPassByMapFn_paramIndexing struct { + p moq.ParamIndexing } // moqPassByMapFn_doFn defines the type of function needed when calling andDo @@ -5422,58 +3053,39 @@ type moqPassByMapFn_doFn func(p map[string]testmoqs.Params) // doReturnResults for the PassByMapFn type type moqPassByMapFn_doReturnFn func(p map[string]testmoqs.Params) map[string]testmoqs.Results -// moqPassByMapFn_results holds the results of the PassByMapFn type -type moqPassByMapFn_results struct { - params moqPassByMapFn_params - results []struct { - values *struct { - result1 map[string]testmoqs.Results - } - sequence uint32 - doFn moqPassByMapFn_doFn - doReturnFn moqPassByMapFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqPassByMapFn_fnRecorder routes recorded function calls to the -// moqPassByMapFn moq -type moqPassByMapFn_fnRecorder struct { - params moqPassByMapFn_params - anyParams uint64 - sequence bool - results *moqPassByMapFn_results - moq *moqPassByMapFn +// moqPassByMapFn_recorder routes recorded function calls to the moqPassByMapFn +// moq +type moqPassByMapFn_recorder struct { + recorder *impl.Recorder[ + *moqPassByMapFn_adaptor, + moqPassByMapFn_params, + moqPassByMapFn_paramsKey, + moqPassByMapFn_results, + ] } // moqPassByMapFn_anyParams isolates the any params functions of the // PassByMapFn type type moqPassByMapFn_anyParams struct { - recorder *moqPassByMapFn_fnRecorder + recorder *moqPassByMapFn_recorder } // newMoqPassByMapFn creates a new moq of the PassByMapFn type func newMoqPassByMapFn(scene *moq.Scene, config *moq.Config) *moqPassByMapFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqPassByMapFn_adaptor{} m := &moqPassByMapFn{ - scene: scene, - config: *config, - moq: &moqPassByMapFn_mock{}, - - runtime: struct { - parameterIndexing struct { - p moq.ParamIndexing - } - }{parameterIndexing: struct { - p moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqPassByMapFn_adaptor, + moqPassByMapFn_params, + moqPassByMapFn_paramsKey, + moqPassByMapFn_results, + ](scene, adaptor1, config), + + runtime: moqPassByMapFn_runtime{parameterIndexing: moqPassByMapFn_paramIndexing{ p: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -5482,256 +3094,101 @@ func newMoqPassByMapFn(scene *moq.Scene, config *moq.Config) *moqPassByMapFn { // mock returns the moq implementation of the PassByMapFn type func (m *moqPassByMapFn) mock() testmoqs.PassByMapFn { return func(p map[string]testmoqs.Params) map[string]testmoqs.Results { - m.scene.T.Helper() - moq := &moqPassByMapFn_mock{moq: m} - return moq.fn(p) - } -} - -func (m *moqPassByMapFn_mock) fn(p map[string]testmoqs.Params) (result1 map[string]testmoqs.Results) { - m.moq.scene.T.Helper() - params := moqPassByMapFn_params{ - p: p, - } - var results *moqPassByMapFn_results - 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 + m.moq.Scene.T.Helper() + params := moqPassByMapFn_params{ + p: p, } - 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)) + var result1 map[string]testmoqs.Results + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } + return result1 } - - if result.doFn != nil { - result.doFn(p) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) - } - return } -func (m *moqPassByMapFn) onCall(p map[string]testmoqs.Params) *moqPassByMapFn_fnRecorder { - return &moqPassByMapFn_fnRecorder{ - params: moqPassByMapFn_params{ +func (m *moqPassByMapFn) onCall(p map[string]testmoqs.Params) *moqPassByMapFn_recorder { + return &moqPassByMapFn_recorder{ + recorder: m.moq.OnCall(moqPassByMapFn_params{ p: p, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqPassByMapFn_fnRecorder) any() *moqPassByMapFn_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(r.params)) +func (r *moqPassByMapFn_recorder) any() *moqPassByMapFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqPassByMapFn_anyParams{recorder: r} } -func (a *moqPassByMapFn_anyParams) p() *moqPassByMapFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqPassByMapFn_anyParams) p() *moqPassByMapFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqPassByMapFn_fnRecorder) seq() *moqPassByMapFn_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(r.params)) +func (r *moqPassByMapFn_recorder) seq() *moqPassByMapFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqPassByMapFn_fnRecorder) noSeq() *moqPassByMapFn_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(r.params)) +func (r *moqPassByMapFn_recorder) noSeq() *moqPassByMapFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqPassByMapFn_fnRecorder) returnResults(result1 map[string]testmoqs.Results) *moqPassByMapFn_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 map[string]testmoqs.Results - } - sequence uint32 - doFn moqPassByMapFn_doFn - doReturnFn moqPassByMapFn_doReturnFn - }{ - values: &struct { - result1 map[string]testmoqs.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqPassByMapFn_recorder) returnResults(result1 map[string]testmoqs.Results) *moqPassByMapFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqPassByMapFn_results{ + result1: result1, }) return r } -func (r *moqPassByMapFn_fnRecorder) andDo(fn moqPassByMapFn_doFn) *moqPassByMapFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqPassByMapFn_recorder) andDo(fn moqPassByMapFn_doFn) *moqPassByMapFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqPassByMapFn_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqPassByMapFn_fnRecorder) doReturnResults(fn moqPassByMapFn_doReturnFn) *moqPassByMapFn_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 map[string]testmoqs.Results +func (r *moqPassByMapFn_recorder) doReturnResults(fn moqPassByMapFn_doReturnFn) *moqPassByMapFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqPassByMapFn_params) *moqPassByMapFn_results { + result1 := fn(params.p) + return &moqPassByMapFn_results{ + result1: result1, } - sequence uint32 - doFn moqPassByMapFn_doFn - doReturnFn moqPassByMapFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqPassByMapFn_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 *moqPassByMapFn_resultsByParams - 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 = &moqPassByMapFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqPassByMapFn_paramsKey]*moqPassByMapFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqPassByMapFn_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 *moqPassByMapFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqPassByMapFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqPassByMapFn_recorder) repeat(repeaters ...moq.Repeater) *moqPassByMapFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 map[string]testmoqs.Results - } - sequence uint32 - doFn moqPassByMapFn_doFn - doReturnFn moqPassByMapFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqPassByMapFn) prettyParams(params moqPassByMapFn_params) string { +func (*moqPassByMapFn_adaptor) PrettyParams(params moqPassByMapFn_params) string { return fmt.Sprintf("PassByMapFn(%#v)", params.p) } -func (m *moqPassByMapFn) paramsKey(params moqPassByMapFn_params, anyParams uint64) moqPassByMapFn_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqPassByMapFn_adaptor) ParamsKey(params moqPassByMapFn_params, anyParams uint64) moqPassByMapFn_paramsKey { + a.moq.moq.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.p, anyParams) return moqPassByMapFn_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -5741,39 +3198,37 @@ func (m *moqPassByMapFn) paramsKey(params moqPassByMapFn_params, anyParams uint6 } // Reset resets the state of the moq -func (m *moqPassByMapFn) Reset() { m.resultsByParams = nil } +func (m *moqPassByMapFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqPassByMapFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqPassByReferenceFn holds the state of a moq of the PassByReferenceFn type type moqPassByReferenceFn struct { - scene *moq.Scene - config moq.Config - moq *moqPassByReferenceFn_mock + moq *impl.Moq[ + *moqPassByReferenceFn_adaptor, + moqPassByReferenceFn_params, + moqPassByReferenceFn_paramsKey, + moqPassByReferenceFn_results, + ] - resultsByParams []moqPassByReferenceFn_resultsByParams - - runtime struct { - parameterIndexing struct { - p moq.ParamIndexing - } - } + runtime moqPassByReferenceFn_runtime } -// moqPassByReferenceFn_mock isolates the mock interface of the +// moqPassByReferenceFn_runtime holds runtime configuration for the // PassByReferenceFn type -type moqPassByReferenceFn_mock struct { +type moqPassByReferenceFn_runtime struct { + parameterIndexing moqPassByReferenceFn_paramIndexing +} + +// moqPassByReferenceFn_adaptor adapts moqPassByReferenceFn as needed by the +// runtime +type moqPassByReferenceFn_adaptor struct { moq *moqPassByReferenceFn } @@ -5787,12 +3242,15 @@ type moqPassByReferenceFn_paramsKey struct { hashes struct{ p hash.Hash } } -// moqPassByReferenceFn_resultsByParams contains the results for a given set of -// parameters for the PassByReferenceFn type -type moqPassByReferenceFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqPassByReferenceFn_paramsKey]*moqPassByReferenceFn_results +// moqPassByReferenceFn_results holds the results of the PassByReferenceFn type +type moqPassByReferenceFn_results struct { + result1 *testmoqs.Results +} + +// moqPassByReferenceFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByReferenceFn type +type moqPassByReferenceFn_paramIndexing struct { + p moq.ParamIndexing } // moqPassByReferenceFn_doFn defines the type of function needed when calling @@ -5803,58 +3261,39 @@ type moqPassByReferenceFn_doFn func(p *testmoqs.Params) // calling doReturnResults for the PassByReferenceFn type type moqPassByReferenceFn_doReturnFn func(p *testmoqs.Params) *testmoqs.Results -// moqPassByReferenceFn_results holds the results of the PassByReferenceFn type -type moqPassByReferenceFn_results struct { - params moqPassByReferenceFn_params - results []struct { - values *struct { - result1 *testmoqs.Results - } - sequence uint32 - doFn moqPassByReferenceFn_doFn - doReturnFn moqPassByReferenceFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqPassByReferenceFn_fnRecorder routes recorded function calls to the +// moqPassByReferenceFn_recorder routes recorded function calls to the // moqPassByReferenceFn moq -type moqPassByReferenceFn_fnRecorder struct { - params moqPassByReferenceFn_params - anyParams uint64 - sequence bool - results *moqPassByReferenceFn_results - moq *moqPassByReferenceFn +type moqPassByReferenceFn_recorder struct { + recorder *impl.Recorder[ + *moqPassByReferenceFn_adaptor, + moqPassByReferenceFn_params, + moqPassByReferenceFn_paramsKey, + moqPassByReferenceFn_results, + ] } // moqPassByReferenceFn_anyParams isolates the any params functions of the // PassByReferenceFn type type moqPassByReferenceFn_anyParams struct { - recorder *moqPassByReferenceFn_fnRecorder + recorder *moqPassByReferenceFn_recorder } // newMoqPassByReferenceFn creates a new moq of the PassByReferenceFn type func newMoqPassByReferenceFn(scene *moq.Scene, config *moq.Config) *moqPassByReferenceFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqPassByReferenceFn_adaptor{} m := &moqPassByReferenceFn{ - scene: scene, - config: *config, - moq: &moqPassByReferenceFn_mock{}, - - runtime: struct { - parameterIndexing struct { - p moq.ParamIndexing - } - }{parameterIndexing: struct { - p moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqPassByReferenceFn_adaptor, + moqPassByReferenceFn_params, + moqPassByReferenceFn_paramsKey, + moqPassByReferenceFn_results, + ](scene, adaptor1, config), + + runtime: moqPassByReferenceFn_runtime{parameterIndexing: moqPassByReferenceFn_paramIndexing{ p: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -5863,258 +3302,101 @@ func newMoqPassByReferenceFn(scene *moq.Scene, config *moq.Config) *moqPassByRef // mock returns the moq implementation of the PassByReferenceFn type func (m *moqPassByReferenceFn) mock() testmoqs.PassByReferenceFn { return func(p *testmoqs.Params) *testmoqs.Results { - m.scene.T.Helper() - moq := &moqPassByReferenceFn_mock{moq: m} - return moq.fn(p) + m.moq.Scene.T.Helper() + params := moqPassByReferenceFn_params{ + p: p, + } + + var result1 *testmoqs.Results + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + } + return result1 } } -func (m *moqPassByReferenceFn_mock) fn(p *testmoqs.Params) (result1 *testmoqs.Results) { - m.moq.scene.T.Helper() - params := moqPassByReferenceFn_params{ - p: p, - } - var results *moqPassByReferenceFn_results - 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(p) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) - } - return -} - -func (m *moqPassByReferenceFn) onCall(p *testmoqs.Params) *moqPassByReferenceFn_fnRecorder { - return &moqPassByReferenceFn_fnRecorder{ - params: moqPassByReferenceFn_params{ - p: p, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, +func (m *moqPassByReferenceFn) onCall(p *testmoqs.Params) *moqPassByReferenceFn_recorder { + return &moqPassByReferenceFn_recorder{ + recorder: m.moq.OnCall(moqPassByReferenceFn_params{ + p: p, + }), } } -func (r *moqPassByReferenceFn_fnRecorder) any() *moqPassByReferenceFn_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(r.params)) +func (r *moqPassByReferenceFn_recorder) any() *moqPassByReferenceFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqPassByReferenceFn_anyParams{recorder: r} } -func (a *moqPassByReferenceFn_anyParams) p() *moqPassByReferenceFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqPassByReferenceFn_anyParams) p() *moqPassByReferenceFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqPassByReferenceFn_fnRecorder) seq() *moqPassByReferenceFn_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(r.params)) +func (r *moqPassByReferenceFn_recorder) seq() *moqPassByReferenceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqPassByReferenceFn_fnRecorder) noSeq() *moqPassByReferenceFn_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(r.params)) +func (r *moqPassByReferenceFn_recorder) noSeq() *moqPassByReferenceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqPassByReferenceFn_fnRecorder) returnResults(result1 *testmoqs.Results) *moqPassByReferenceFn_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 *testmoqs.Results - } - sequence uint32 - doFn moqPassByReferenceFn_doFn - doReturnFn moqPassByReferenceFn_doReturnFn - }{ - values: &struct { - result1 *testmoqs.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqPassByReferenceFn_recorder) returnResults(result1 *testmoqs.Results) *moqPassByReferenceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqPassByReferenceFn_results{ + result1: result1, }) return r } -func (r *moqPassByReferenceFn_fnRecorder) andDo(fn moqPassByReferenceFn_doFn) *moqPassByReferenceFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqPassByReferenceFn_recorder) andDo(fn moqPassByReferenceFn_doFn) *moqPassByReferenceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqPassByReferenceFn_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqPassByReferenceFn_fnRecorder) doReturnResults(fn moqPassByReferenceFn_doReturnFn) *moqPassByReferenceFn_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 *testmoqs.Results +func (r *moqPassByReferenceFn_recorder) doReturnResults(fn moqPassByReferenceFn_doReturnFn) *moqPassByReferenceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqPassByReferenceFn_params) *moqPassByReferenceFn_results { + result1 := fn(params.p) + return &moqPassByReferenceFn_results{ + result1: result1, } - sequence uint32 - doFn moqPassByReferenceFn_doFn - doReturnFn moqPassByReferenceFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqPassByReferenceFn_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 *moqPassByReferenceFn_resultsByParams - 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 = &moqPassByReferenceFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqPassByReferenceFn_paramsKey]*moqPassByReferenceFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqPassByReferenceFn_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 *moqPassByReferenceFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqPassByReferenceFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqPassByReferenceFn_recorder) repeat(repeaters ...moq.Repeater) *moqPassByReferenceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 *testmoqs.Results - } - sequence uint32 - doFn moqPassByReferenceFn_doFn - doReturnFn moqPassByReferenceFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqPassByReferenceFn) prettyParams(params moqPassByReferenceFn_params) string { +func (*moqPassByReferenceFn_adaptor) PrettyParams(params moqPassByReferenceFn_params) string { return fmt.Sprintf("PassByReferenceFn(%#v)", params.p) } -func (m *moqPassByReferenceFn) paramsKey(params moqPassByReferenceFn_params, anyParams uint64) moqPassByReferenceFn_paramsKey { - m.scene.T.Helper() - var pUsed *testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.p == moq.ParamIndexByValue { - pUsed = params.p - } else { - pUsedHash = hash.DeepHash(params.p) - } - } +func (a *moqPassByReferenceFn_adaptor) ParamsKey(params moqPassByReferenceFn_params, anyParams uint64) moqPassByReferenceFn_paramsKey { + a.moq.moq.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.p, 1, a.moq.runtime.parameterIndexing.p, anyParams) return moqPassByReferenceFn_paramsKey{ params: struct{ p *testmoqs.Params }{ p: pUsed, @@ -6126,38 +3408,36 @@ func (m *moqPassByReferenceFn) paramsKey(params moqPassByReferenceFn_params, any } // Reset resets the state of the moq -func (m *moqPassByReferenceFn) Reset() { m.resultsByParams = nil } +func (m *moqPassByReferenceFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqPassByReferenceFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqPassBySliceFn holds the state of a moq of the PassBySliceFn type type moqPassBySliceFn struct { - scene *moq.Scene - config moq.Config - moq *moqPassBySliceFn_mock + moq *impl.Moq[ + *moqPassBySliceFn_adaptor, + moqPassBySliceFn_params, + moqPassBySliceFn_paramsKey, + moqPassBySliceFn_results, + ] - resultsByParams []moqPassBySliceFn_resultsByParams + runtime moqPassBySliceFn_runtime +} - runtime struct { - parameterIndexing struct { - p moq.ParamIndexing - } - } +// moqPassBySliceFn_runtime holds runtime configuration for the PassBySliceFn +// type +type moqPassBySliceFn_runtime struct { + parameterIndexing moqPassBySliceFn_paramIndexing } -// moqPassBySliceFn_mock isolates the mock interface of the PassBySliceFn type -type moqPassBySliceFn_mock struct { +// moqPassBySliceFn_adaptor adapts moqPassBySliceFn as needed by the runtime +type moqPassBySliceFn_adaptor struct { moq *moqPassBySliceFn } @@ -6171,12 +3451,15 @@ type moqPassBySliceFn_paramsKey struct { hashes struct{ p hash.Hash } } -// moqPassBySliceFn_resultsByParams contains the results for a given set of -// parameters for the PassBySliceFn type -type moqPassBySliceFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqPassBySliceFn_paramsKey]*moqPassBySliceFn_results +// moqPassBySliceFn_results holds the results of the PassBySliceFn type +type moqPassBySliceFn_results struct { + result1 []testmoqs.Results +} + +// moqPassBySliceFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassBySliceFn type +type moqPassBySliceFn_paramIndexing struct { + p moq.ParamIndexing } // moqPassBySliceFn_doFn defines the type of function needed when calling andDo @@ -6187,58 +3470,39 @@ type moqPassBySliceFn_doFn func(p []testmoqs.Params) // doReturnResults for the PassBySliceFn type type moqPassBySliceFn_doReturnFn func(p []testmoqs.Params) []testmoqs.Results -// moqPassBySliceFn_results holds the results of the PassBySliceFn type -type moqPassBySliceFn_results struct { - params moqPassBySliceFn_params - results []struct { - values *struct { - result1 []testmoqs.Results - } - sequence uint32 - doFn moqPassBySliceFn_doFn - doReturnFn moqPassBySliceFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqPassBySliceFn_fnRecorder routes recorded function calls to the +// moqPassBySliceFn_recorder routes recorded function calls to the // moqPassBySliceFn moq -type moqPassBySliceFn_fnRecorder struct { - params moqPassBySliceFn_params - anyParams uint64 - sequence bool - results *moqPassBySliceFn_results - moq *moqPassBySliceFn +type moqPassBySliceFn_recorder struct { + recorder *impl.Recorder[ + *moqPassBySliceFn_adaptor, + moqPassBySliceFn_params, + moqPassBySliceFn_paramsKey, + moqPassBySliceFn_results, + ] } // moqPassBySliceFn_anyParams isolates the any params functions of the // PassBySliceFn type type moqPassBySliceFn_anyParams struct { - recorder *moqPassBySliceFn_fnRecorder + recorder *moqPassBySliceFn_recorder } // newMoqPassBySliceFn creates a new moq of the PassBySliceFn type func newMoqPassBySliceFn(scene *moq.Scene, config *moq.Config) *moqPassBySliceFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqPassBySliceFn_adaptor{} m := &moqPassBySliceFn{ - scene: scene, - config: *config, - moq: &moqPassBySliceFn_mock{}, - - runtime: struct { - parameterIndexing struct { - p moq.ParamIndexing - } - }{parameterIndexing: struct { - p moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqPassBySliceFn_adaptor, + moqPassBySliceFn_params, + moqPassBySliceFn_paramsKey, + moqPassBySliceFn_results, + ](scene, adaptor1, config), + + runtime: moqPassBySliceFn_runtime{parameterIndexing: moqPassBySliceFn_paramIndexing{ p: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -6247,256 +3511,101 @@ func newMoqPassBySliceFn(scene *moq.Scene, config *moq.Config) *moqPassBySliceFn // mock returns the moq implementation of the PassBySliceFn type func (m *moqPassBySliceFn) mock() testmoqs.PassBySliceFn { return func(p []testmoqs.Params) []testmoqs.Results { - m.scene.T.Helper() - moq := &moqPassBySliceFn_mock{moq: m} - return moq.fn(p) - } -} - -func (m *moqPassBySliceFn_mock) fn(p []testmoqs.Params) (result1 []testmoqs.Results) { - m.moq.scene.T.Helper() - params := moqPassBySliceFn_params{ - p: p, - } - var results *moqPassBySliceFn_results - 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 + m.moq.Scene.T.Helper() + params := moqPassBySliceFn_params{ + p: p, } - 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)) + var result1 []testmoqs.Results + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } + return result1 } - - if result.doFn != nil { - result.doFn(p) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) - } - return } -func (m *moqPassBySliceFn) onCall(p []testmoqs.Params) *moqPassBySliceFn_fnRecorder { - return &moqPassBySliceFn_fnRecorder{ - params: moqPassBySliceFn_params{ +func (m *moqPassBySliceFn) onCall(p []testmoqs.Params) *moqPassBySliceFn_recorder { + return &moqPassBySliceFn_recorder{ + recorder: m.moq.OnCall(moqPassBySliceFn_params{ p: p, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqPassBySliceFn_fnRecorder) any() *moqPassBySliceFn_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(r.params)) +func (r *moqPassBySliceFn_recorder) any() *moqPassBySliceFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqPassBySliceFn_anyParams{recorder: r} } -func (a *moqPassBySliceFn_anyParams) p() *moqPassBySliceFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqPassBySliceFn_anyParams) p() *moqPassBySliceFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqPassBySliceFn_fnRecorder) seq() *moqPassBySliceFn_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(r.params)) +func (r *moqPassBySliceFn_recorder) seq() *moqPassBySliceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqPassBySliceFn_fnRecorder) noSeq() *moqPassBySliceFn_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(r.params)) +func (r *moqPassBySliceFn_recorder) noSeq() *moqPassBySliceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqPassBySliceFn_fnRecorder) returnResults(result1 []testmoqs.Results) *moqPassBySliceFn_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 []testmoqs.Results - } - sequence uint32 - doFn moqPassBySliceFn_doFn - doReturnFn moqPassBySliceFn_doReturnFn - }{ - values: &struct { - result1 []testmoqs.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqPassBySliceFn_recorder) returnResults(result1 []testmoqs.Results) *moqPassBySliceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqPassBySliceFn_results{ + result1: result1, }) return r } -func (r *moqPassBySliceFn_fnRecorder) andDo(fn moqPassBySliceFn_doFn) *moqPassBySliceFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqPassBySliceFn_recorder) andDo(fn moqPassBySliceFn_doFn) *moqPassBySliceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqPassBySliceFn_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqPassBySliceFn_fnRecorder) doReturnResults(fn moqPassBySliceFn_doReturnFn) *moqPassBySliceFn_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 []testmoqs.Results +func (r *moqPassBySliceFn_recorder) doReturnResults(fn moqPassBySliceFn_doReturnFn) *moqPassBySliceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqPassBySliceFn_params) *moqPassBySliceFn_results { + result1 := fn(params.p) + return &moqPassBySliceFn_results{ + result1: result1, } - sequence uint32 - doFn moqPassBySliceFn_doFn - doReturnFn moqPassBySliceFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqPassBySliceFn_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 *moqPassBySliceFn_resultsByParams - 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 = &moqPassBySliceFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqPassBySliceFn_paramsKey]*moqPassBySliceFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqPassBySliceFn_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 *moqPassBySliceFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqPassBySliceFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqPassBySliceFn_recorder) repeat(repeaters ...moq.Repeater) *moqPassBySliceFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 []testmoqs.Results - } - sequence uint32 - doFn moqPassBySliceFn_doFn - doReturnFn moqPassBySliceFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqPassBySliceFn) prettyParams(params moqPassBySliceFn_params) string { +func (*moqPassBySliceFn_adaptor) PrettyParams(params moqPassBySliceFn_params) string { return fmt.Sprintf("PassBySliceFn(%#v)", params.p) } -func (m *moqPassBySliceFn) paramsKey(params moqPassBySliceFn_params, anyParams uint64) moqPassBySliceFn_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqPassBySliceFn_adaptor) ParamsKey(params moqPassBySliceFn_params, anyParams uint64) moqPassBySliceFn_paramsKey { + a.moq.moq.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.p, anyParams) return moqPassBySliceFn_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -6506,38 +3615,36 @@ func (m *moqPassBySliceFn) paramsKey(params moqPassBySliceFn_params, anyParams u } // Reset resets the state of the moq -func (m *moqPassBySliceFn) Reset() { m.resultsByParams = nil } +func (m *moqPassBySliceFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqPassBySliceFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqPassByValueFn holds the state of a moq of the PassByValueFn type type moqPassByValueFn struct { - scene *moq.Scene - config moq.Config - moq *moqPassByValueFn_mock + moq *impl.Moq[ + *moqPassByValueFn_adaptor, + moqPassByValueFn_params, + moqPassByValueFn_paramsKey, + moqPassByValueFn_results, + ] - resultsByParams []moqPassByValueFn_resultsByParams + runtime moqPassByValueFn_runtime +} - runtime struct { - parameterIndexing struct { - p moq.ParamIndexing - } - } +// moqPassByValueFn_runtime holds runtime configuration for the PassByValueFn +// type +type moqPassByValueFn_runtime struct { + parameterIndexing moqPassByValueFn_paramIndexing } -// moqPassByValueFn_mock isolates the mock interface of the PassByValueFn type -type moqPassByValueFn_mock struct { +// moqPassByValueFn_adaptor adapts moqPassByValueFn as needed by the runtime +type moqPassByValueFn_adaptor struct { moq *moqPassByValueFn } @@ -6551,12 +3658,15 @@ type moqPassByValueFn_paramsKey struct { hashes struct{ p hash.Hash } } -// moqPassByValueFn_resultsByParams contains the results for a given set of -// parameters for the PassByValueFn type -type moqPassByValueFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqPassByValueFn_paramsKey]*moqPassByValueFn_results +// moqPassByValueFn_results holds the results of the PassByValueFn type +type moqPassByValueFn_results struct { + result1 testmoqs.Results +} + +// moqPassByValueFn_paramIndexing holds the parameter indexing runtime +// configuration for the PassByValueFn type +type moqPassByValueFn_paramIndexing struct { + p moq.ParamIndexing } // moqPassByValueFn_doFn defines the type of function needed when calling andDo @@ -6567,58 +3677,39 @@ type moqPassByValueFn_doFn func(p testmoqs.Params) // doReturnResults for the PassByValueFn type type moqPassByValueFn_doReturnFn func(p testmoqs.Params) testmoqs.Results -// moqPassByValueFn_results holds the results of the PassByValueFn type -type moqPassByValueFn_results struct { - params moqPassByValueFn_params - results []struct { - values *struct { - result1 testmoqs.Results - } - sequence uint32 - doFn moqPassByValueFn_doFn - doReturnFn moqPassByValueFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqPassByValueFn_fnRecorder routes recorded function calls to the +// moqPassByValueFn_recorder routes recorded function calls to the // moqPassByValueFn moq -type moqPassByValueFn_fnRecorder struct { - params moqPassByValueFn_params - anyParams uint64 - sequence bool - results *moqPassByValueFn_results - moq *moqPassByValueFn +type moqPassByValueFn_recorder struct { + recorder *impl.Recorder[ + *moqPassByValueFn_adaptor, + moqPassByValueFn_params, + moqPassByValueFn_paramsKey, + moqPassByValueFn_results, + ] } // moqPassByValueFn_anyParams isolates the any params functions of the // PassByValueFn type type moqPassByValueFn_anyParams struct { - recorder *moqPassByValueFn_fnRecorder + recorder *moqPassByValueFn_recorder } // newMoqPassByValueFn creates a new moq of the PassByValueFn type func newMoqPassByValueFn(scene *moq.Scene, config *moq.Config) *moqPassByValueFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqPassByValueFn_adaptor{} m := &moqPassByValueFn{ - scene: scene, - config: *config, - moq: &moqPassByValueFn_mock{}, - - runtime: struct { - parameterIndexing struct { - p moq.ParamIndexing - } - }{parameterIndexing: struct { - p moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqPassByValueFn_adaptor, + moqPassByValueFn_params, + moqPassByValueFn_paramsKey, + moqPassByValueFn_results, + ](scene, adaptor1, config), + + runtime: moqPassByValueFn_runtime{parameterIndexing: moqPassByValueFn_paramIndexing{ p: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -6627,258 +3718,101 @@ func newMoqPassByValueFn(scene *moq.Scene, config *moq.Config) *moqPassByValueFn // mock returns the moq implementation of the PassByValueFn type func (m *moqPassByValueFn) mock() testmoqs.PassByValueFn { return func(p testmoqs.Params) testmoqs.Results { - m.scene.T.Helper() - moq := &moqPassByValueFn_mock{moq: m} - return moq.fn(p) - } -} - -func (m *moqPassByValueFn_mock) fn(p testmoqs.Params) (result1 testmoqs.Results) { - m.moq.scene.T.Helper() - params := moqPassByValueFn_params{ - p: p, - } - var results *moqPassByValueFn_results - 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 + m.moq.Scene.T.Helper() + params := moqPassByValueFn_params{ + p: p, } - 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)) + var result1 testmoqs.Results + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } + return result1 } - - if result.doFn != nil { - result.doFn(p) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) - } - return } -func (m *moqPassByValueFn) onCall(p testmoqs.Params) *moqPassByValueFn_fnRecorder { - return &moqPassByValueFn_fnRecorder{ - params: moqPassByValueFn_params{ +func (m *moqPassByValueFn) onCall(p testmoqs.Params) *moqPassByValueFn_recorder { + return &moqPassByValueFn_recorder{ + recorder: m.moq.OnCall(moqPassByValueFn_params{ p: p, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqPassByValueFn_fnRecorder) any() *moqPassByValueFn_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(r.params)) +func (r *moqPassByValueFn_recorder) any() *moqPassByValueFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqPassByValueFn_anyParams{recorder: r} } -func (a *moqPassByValueFn_anyParams) p() *moqPassByValueFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqPassByValueFn_anyParams) p() *moqPassByValueFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqPassByValueFn_fnRecorder) seq() *moqPassByValueFn_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(r.params)) +func (r *moqPassByValueFn_recorder) seq() *moqPassByValueFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqPassByValueFn_fnRecorder) noSeq() *moqPassByValueFn_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(r.params)) +func (r *moqPassByValueFn_recorder) noSeq() *moqPassByValueFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqPassByValueFn_fnRecorder) returnResults(result1 testmoqs.Results) *moqPassByValueFn_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 testmoqs.Results - } - sequence uint32 - doFn moqPassByValueFn_doFn - doReturnFn moqPassByValueFn_doReturnFn - }{ - values: &struct { - result1 testmoqs.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqPassByValueFn_recorder) returnResults(result1 testmoqs.Results) *moqPassByValueFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqPassByValueFn_results{ + result1: result1, }) return r } -func (r *moqPassByValueFn_fnRecorder) andDo(fn moqPassByValueFn_doFn) *moqPassByValueFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqPassByValueFn_recorder) andDo(fn moqPassByValueFn_doFn) *moqPassByValueFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqPassByValueFn_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqPassByValueFn_fnRecorder) doReturnResults(fn moqPassByValueFn_doReturnFn) *moqPassByValueFn_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 testmoqs.Results +func (r *moqPassByValueFn_recorder) doReturnResults(fn moqPassByValueFn_doReturnFn) *moqPassByValueFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqPassByValueFn_params) *moqPassByValueFn_results { + result1 := fn(params.p) + return &moqPassByValueFn_results{ + result1: result1, } - sequence uint32 - doFn moqPassByValueFn_doFn - doReturnFn moqPassByValueFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqPassByValueFn_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 *moqPassByValueFn_resultsByParams - 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 = &moqPassByValueFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqPassByValueFn_paramsKey]*moqPassByValueFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqPassByValueFn_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 *moqPassByValueFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqPassByValueFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqPassByValueFn_recorder) repeat(repeaters ...moq.Repeater) *moqPassByValueFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 testmoqs.Results - } - sequence uint32 - doFn moqPassByValueFn_doFn - doReturnFn moqPassByValueFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqPassByValueFn) prettyParams(params moqPassByValueFn_params) string { +func (*moqPassByValueFn_adaptor) PrettyParams(params moqPassByValueFn_params) string { return fmt.Sprintf("PassByValueFn(%#v)", params.p) } -func (m *moqPassByValueFn) paramsKey(params moqPassByValueFn_params, anyParams uint64) moqPassByValueFn_paramsKey { - m.scene.T.Helper() - var pUsed testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.p == moq.ParamIndexByValue { - pUsed = params.p - } else { - pUsedHash = hash.DeepHash(params.p) - } - } +func (a *moqPassByValueFn_adaptor) ParamsKey(params moqPassByValueFn_params, anyParams uint64) moqPassByValueFn_paramsKey { + a.moq.moq.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.p, 1, a.moq.runtime.parameterIndexing.p, anyParams) return moqPassByValueFn_paramsKey{ params: struct{ p testmoqs.Params }{ p: pUsed, @@ -6890,39 +3824,37 @@ func (m *moqPassByValueFn) paramsKey(params moqPassByValueFn_params, anyParams u } // Reset resets the state of the moq -func (m *moqPassByValueFn) Reset() { m.resultsByParams = nil } +func (m *moqPassByValueFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqPassByValueFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqInterfaceParamFn holds the state of a moq of the InterfaceParamFn type type moqInterfaceParamFn struct { - scene *moq.Scene - config moq.Config - moq *moqInterfaceParamFn_mock + moq *impl.Moq[ + *moqInterfaceParamFn_adaptor, + moqInterfaceParamFn_params, + moqInterfaceParamFn_paramsKey, + moqInterfaceParamFn_results, + ] - resultsByParams []moqInterfaceParamFn_resultsByParams + runtime moqInterfaceParamFn_runtime +} - runtime struct { - parameterIndexing struct { - w moq.ParamIndexing - } - } +// moqInterfaceParamFn_runtime holds runtime configuration for the +// InterfaceParamFn type +type moqInterfaceParamFn_runtime struct { + parameterIndexing moqInterfaceParamFn_paramIndexing } -// moqInterfaceParamFn_mock isolates the mock interface of the InterfaceParamFn -// type -type moqInterfaceParamFn_mock struct { +// moqInterfaceParamFn_adaptor adapts moqInterfaceParamFn as needed by the +// runtime +type moqInterfaceParamFn_adaptor struct { moq *moqInterfaceParamFn } @@ -6936,12 +3868,16 @@ type moqInterfaceParamFn_paramsKey struct { hashes struct{ w hash.Hash } } -// moqInterfaceParamFn_resultsByParams contains the results for a given set of -// parameters for the InterfaceParamFn type -type moqInterfaceParamFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqInterfaceParamFn_paramsKey]*moqInterfaceParamFn_results +// moqInterfaceParamFn_results holds the results of the InterfaceParamFn type +type moqInterfaceParamFn_results struct { + sResult string + err error +} + +// moqInterfaceParamFn_paramIndexing holds the parameter indexing runtime +// configuration for the InterfaceParamFn type +type moqInterfaceParamFn_paramIndexing struct { + w moq.ParamIndexing } // moqInterfaceParamFn_doFn defines the type of function needed when calling @@ -6952,59 +3888,39 @@ type moqInterfaceParamFn_doFn func(w io.Writer) // calling doReturnResults for the InterfaceParamFn type type moqInterfaceParamFn_doReturnFn func(w io.Writer) (sResult string, err error) -// moqInterfaceParamFn_results holds the results of the InterfaceParamFn type -type moqInterfaceParamFn_results struct { - params moqInterfaceParamFn_params - results []struct { - values *struct { - sResult string - err error - } - sequence uint32 - doFn moqInterfaceParamFn_doFn - doReturnFn moqInterfaceParamFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqInterfaceParamFn_fnRecorder routes recorded function calls to the +// moqInterfaceParamFn_recorder routes recorded function calls to the // moqInterfaceParamFn moq -type moqInterfaceParamFn_fnRecorder struct { - params moqInterfaceParamFn_params - anyParams uint64 - sequence bool - results *moqInterfaceParamFn_results - moq *moqInterfaceParamFn +type moqInterfaceParamFn_recorder struct { + recorder *impl.Recorder[ + *moqInterfaceParamFn_adaptor, + moqInterfaceParamFn_params, + moqInterfaceParamFn_paramsKey, + moqInterfaceParamFn_results, + ] } // moqInterfaceParamFn_anyParams isolates the any params functions of the // InterfaceParamFn type type moqInterfaceParamFn_anyParams struct { - recorder *moqInterfaceParamFn_fnRecorder + recorder *moqInterfaceParamFn_recorder } // newMoqInterfaceParamFn creates a new moq of the InterfaceParamFn type func newMoqInterfaceParamFn(scene *moq.Scene, config *moq.Config) *moqInterfaceParamFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqInterfaceParamFn_adaptor{} m := &moqInterfaceParamFn{ - scene: scene, - config: *config, - moq: &moqInterfaceParamFn_mock{}, - - runtime: struct { - parameterIndexing struct { - w moq.ParamIndexing - } - }{parameterIndexing: struct { - w moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqInterfaceParamFn_adaptor, + moqInterfaceParamFn_params, + moqInterfaceParamFn_paramsKey, + moqInterfaceParamFn_results, + ](scene, adaptor1, config), + + runtime: moqInterfaceParamFn_runtime{parameterIndexing: moqInterfaceParamFn_paramIndexing{ w: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -7012,265 +3928,106 @@ func newMoqInterfaceParamFn(scene *moq.Scene, config *moq.Config) *moqInterfaceP // mock returns the moq implementation of the InterfaceParamFn type func (m *moqInterfaceParamFn) mock() testmoqs.InterfaceParamFn { - return func(w io.Writer) (_ string, _ error) { - m.scene.T.Helper() - moq := &moqInterfaceParamFn_mock{moq: m} - return moq.fn(w) - } -} - -func (m *moqInterfaceParamFn_mock) fn(w io.Writer) (sResult string, err error) { - m.moq.scene.T.Helper() - params := moqInterfaceParamFn_params{ - w: w, - } - var results *moqInterfaceParamFn_results - 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 + return func(w io.Writer) (string, error) { + m.moq.Scene.T.Helper() + params := moqInterfaceParamFn_params{ + w: w, } - 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)) + var result1 string + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } + return result1, result2 } - - 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 *moqInterfaceParamFn) onCall(w io.Writer) *moqInterfaceParamFn_fnRecorder { - return &moqInterfaceParamFn_fnRecorder{ - params: moqInterfaceParamFn_params{ +func (m *moqInterfaceParamFn) onCall(w io.Writer) *moqInterfaceParamFn_recorder { + return &moqInterfaceParamFn_recorder{ + recorder: m.moq.OnCall(moqInterfaceParamFn_params{ w: w, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqInterfaceParamFn_fnRecorder) any() *moqInterfaceParamFn_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(r.params)) +func (r *moqInterfaceParamFn_recorder) any() *moqInterfaceParamFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqInterfaceParamFn_anyParams{recorder: r} } -func (a *moqInterfaceParamFn_anyParams) w() *moqInterfaceParamFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqInterfaceParamFn_anyParams) w() *moqInterfaceParamFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqInterfaceParamFn_fnRecorder) seq() *moqInterfaceParamFn_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(r.params)) +func (r *moqInterfaceParamFn_recorder) seq() *moqInterfaceParamFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqInterfaceParamFn_fnRecorder) noSeq() *moqInterfaceParamFn_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(r.params)) +func (r *moqInterfaceParamFn_recorder) noSeq() *moqInterfaceParamFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqInterfaceParamFn_fnRecorder) returnResults(sResult string, err error) *moqInterfaceParamFn_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 moqInterfaceParamFn_doFn - doReturnFn moqInterfaceParamFn_doReturnFn - }{ - values: &struct { - sResult string - err error - }{ - sResult: sResult, - err: err, - }, - sequence: sequence, +func (r *moqInterfaceParamFn_recorder) returnResults(sResult string, err error) *moqInterfaceParamFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqInterfaceParamFn_results{ + sResult: sResult, + err: err, }) return r } -func (r *moqInterfaceParamFn_fnRecorder) andDo(fn moqInterfaceParamFn_doFn) *moqInterfaceParamFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqInterfaceParamFn_recorder) andDo(fn moqInterfaceParamFn_doFn) *moqInterfaceParamFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqInterfaceParamFn_params) { + fn(params.w) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqInterfaceParamFn_fnRecorder) doReturnResults(fn moqInterfaceParamFn_doReturnFn) *moqInterfaceParamFn_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 +func (r *moqInterfaceParamFn_recorder) doReturnResults(fn moqInterfaceParamFn_doReturnFn) *moqInterfaceParamFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqInterfaceParamFn_params) *moqInterfaceParamFn_results { + sResult, err := fn(params.w) + return &moqInterfaceParamFn_results{ + sResult: sResult, + err: err, } - sequence uint32 - doFn moqInterfaceParamFn_doFn - doReturnFn moqInterfaceParamFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqInterfaceParamFn_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 *moqInterfaceParamFn_resultsByParams - 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 = &moqInterfaceParamFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqInterfaceParamFn_paramsKey]*moqInterfaceParamFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqInterfaceParamFn_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 *moqInterfaceParamFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqInterfaceParamFn_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 moqInterfaceParamFn_doFn - doReturnFn moqInterfaceParamFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqInterfaceParamFn_recorder) repeat(repeaters ...moq.Repeater) *moqInterfaceParamFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqInterfaceParamFn) prettyParams(params moqInterfaceParamFn_params) string { +func (*moqInterfaceParamFn_adaptor) PrettyParams(params moqInterfaceParamFn_params) string { return fmt.Sprintf("InterfaceParamFn(%#v)", params.w) } -func (m *moqInterfaceParamFn) paramsKey(params moqInterfaceParamFn_params, anyParams uint64) moqInterfaceParamFn_paramsKey { - m.scene.T.Helper() - var wUsed io.Writer - var wUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.w == moq.ParamIndexByValue { - wUsed = params.w - } else { - wUsedHash = hash.DeepHash(params.w) - } - } +func (a *moqInterfaceParamFn_adaptor) ParamsKey(params moqInterfaceParamFn_params, anyParams uint64) moqInterfaceParamFn_paramsKey { + a.moq.moq.Scene.T.Helper() + wUsed, wUsedHash := impl.ParamKey( + params.w, 1, a.moq.runtime.parameterIndexing.w, anyParams) return moqInterfaceParamFn_paramsKey{ params: struct{ w io.Writer }{ w: wUsed, @@ -7282,40 +4039,37 @@ func (m *moqInterfaceParamFn) paramsKey(params moqInterfaceParamFn_params, anyPa } // Reset resets the state of the moq -func (m *moqInterfaceParamFn) Reset() { m.resultsByParams = nil } +func (m *moqInterfaceParamFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqInterfaceParamFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqInterfaceResultFn holds the state of a moq of the InterfaceResultFn type type moqInterfaceResultFn struct { - scene *moq.Scene - config moq.Config - moq *moqInterfaceResultFn_mock + moq *impl.Moq[ + *moqInterfaceResultFn_adaptor, + moqInterfaceResultFn_params, + moqInterfaceResultFn_paramsKey, + moqInterfaceResultFn_results, + ] - resultsByParams []moqInterfaceResultFn_resultsByParams - - runtime struct { - parameterIndexing struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - } + runtime moqInterfaceResultFn_runtime } -// moqInterfaceResultFn_mock isolates the mock interface of the +// moqInterfaceResultFn_runtime holds runtime configuration for the // InterfaceResultFn type -type moqInterfaceResultFn_mock struct { +type moqInterfaceResultFn_runtime struct { + parameterIndexing moqInterfaceResultFn_paramIndexing +} + +// moqInterfaceResultFn_adaptor adapts moqInterfaceResultFn as needed by the +// runtime +type moqInterfaceResultFn_adaptor struct { moq *moqInterfaceResultFn } @@ -7338,12 +4092,14 @@ type moqInterfaceResultFn_paramsKey struct { } } -// moqInterfaceResultFn_resultsByParams contains the results for a given set of -// parameters for the InterfaceResultFn type -type moqInterfaceResultFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqInterfaceResultFn_paramsKey]*moqInterfaceResultFn_results +// moqInterfaceResultFn_results holds the results of the InterfaceResultFn type +type moqInterfaceResultFn_results struct{ result1 io.Reader } + +// moqInterfaceResultFn_paramIndexing holds the parameter indexing runtime +// configuration for the InterfaceResultFn type +type moqInterfaceResultFn_paramIndexing struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing } // moqInterfaceResultFn_doFn defines the type of function needed when calling @@ -7354,59 +4110,40 @@ type moqInterfaceResultFn_doFn func(sParam string, bParam bool) // calling doReturnResults for the InterfaceResultFn type type moqInterfaceResultFn_doReturnFn func(sParam string, bParam bool) (r io.Reader) -// moqInterfaceResultFn_results holds the results of the InterfaceResultFn type -type moqInterfaceResultFn_results struct { - params moqInterfaceResultFn_params - results []struct { - values *struct{ result1 io.Reader } - sequence uint32 - doFn moqInterfaceResultFn_doFn - doReturnFn moqInterfaceResultFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqInterfaceResultFn_fnRecorder routes recorded function calls to the +// moqInterfaceResultFn_recorder routes recorded function calls to the // moqInterfaceResultFn moq -type moqInterfaceResultFn_fnRecorder struct { - params moqInterfaceResultFn_params - anyParams uint64 - sequence bool - results *moqInterfaceResultFn_results - moq *moqInterfaceResultFn +type moqInterfaceResultFn_recorder struct { + recorder *impl.Recorder[ + *moqInterfaceResultFn_adaptor, + moqInterfaceResultFn_params, + moqInterfaceResultFn_paramsKey, + moqInterfaceResultFn_results, + ] } // moqInterfaceResultFn_anyParams isolates the any params functions of the // InterfaceResultFn type type moqInterfaceResultFn_anyParams struct { - recorder *moqInterfaceResultFn_fnRecorder + recorder *moqInterfaceResultFn_recorder } // newMoqInterfaceResultFn creates a new moq of the InterfaceResultFn type func newMoqInterfaceResultFn(scene *moq.Scene, config *moq.Config) *moqInterfaceResultFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqInterfaceResultFn_adaptor{} m := &moqInterfaceResultFn{ - scene: scene, - config: *config, - moq: &moqInterfaceResultFn_mock{}, - - runtime: struct { - parameterIndexing struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - }{parameterIndexing: struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqInterfaceResultFn_adaptor, + moqInterfaceResultFn_params, + moqInterfaceResultFn_paramsKey, + moqInterfaceResultFn_results, + ](scene, adaptor1, config), + + runtime: moqInterfaceResultFn_runtime{parameterIndexing: moqInterfaceResultFn_paramIndexing{ sParam: moq.ParamIndexByValue, bParam: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -7414,267 +4151,111 @@ func newMoqInterfaceResultFn(scene *moq.Scene, config *moq.Config) *moqInterface // mock returns the moq implementation of the InterfaceResultFn type func (m *moqInterfaceResultFn) mock() testmoqs.InterfaceResultFn { - return func(sParam string, bParam bool) (_ io.Reader) { - m.scene.T.Helper() - moq := &moqInterfaceResultFn_mock{moq: m} - return moq.fn(sParam, bParam) - } -} - -func (m *moqInterfaceResultFn_mock) fn(sParam string, bParam bool) (result1 io.Reader) { - m.moq.scene.T.Helper() - params := moqInterfaceResultFn_params{ - sParam: sParam, - bParam: bParam, - } - var results *moqInterfaceResultFn_results - 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 + return func(sParam string, bParam bool) io.Reader { + m.moq.Scene.T.Helper() + params := moqInterfaceResultFn_params{ + sParam: sParam, + bParam: bParam, } - 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)) + var result1 io.Reader + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } + return result1 } - - 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 *moqInterfaceResultFn) onCall(sParam string, bParam bool) *moqInterfaceResultFn_fnRecorder { - return &moqInterfaceResultFn_fnRecorder{ - params: moqInterfaceResultFn_params{ +func (m *moqInterfaceResultFn) onCall(sParam string, bParam bool) *moqInterfaceResultFn_recorder { + return &moqInterfaceResultFn_recorder{ + recorder: m.moq.OnCall(moqInterfaceResultFn_params{ sParam: sParam, bParam: bParam, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqInterfaceResultFn_fnRecorder) any() *moqInterfaceResultFn_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(r.params)) +func (r *moqInterfaceResultFn_recorder) any() *moqInterfaceResultFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqInterfaceResultFn_anyParams{recorder: r} } -func (a *moqInterfaceResultFn_anyParams) sParam() *moqInterfaceResultFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqInterfaceResultFn_anyParams) sParam() *moqInterfaceResultFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqInterfaceResultFn_anyParams) bParam() *moqInterfaceResultFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqInterfaceResultFn_anyParams) bParam() *moqInterfaceResultFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqInterfaceResultFn_fnRecorder) seq() *moqInterfaceResultFn_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(r.params)) +func (r *moqInterfaceResultFn_recorder) seq() *moqInterfaceResultFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqInterfaceResultFn_fnRecorder) noSeq() *moqInterfaceResultFn_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(r.params)) +func (r *moqInterfaceResultFn_recorder) noSeq() *moqInterfaceResultFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqInterfaceResultFn_fnRecorder) returnResults(result1 io.Reader) *moqInterfaceResultFn_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 io.Reader } - sequence uint32 - doFn moqInterfaceResultFn_doFn - doReturnFn moqInterfaceResultFn_doReturnFn - }{ - values: &struct{ result1 io.Reader }{ - result1: result1, - }, - sequence: sequence, +func (r *moqInterfaceResultFn_recorder) returnResults(result1 io.Reader) *moqInterfaceResultFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqInterfaceResultFn_results{ + result1: result1, }) return r } -func (r *moqInterfaceResultFn_fnRecorder) andDo(fn moqInterfaceResultFn_doFn) *moqInterfaceResultFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqInterfaceResultFn_recorder) andDo(fn moqInterfaceResultFn_doFn) *moqInterfaceResultFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqInterfaceResultFn_params) { + fn(params.sParam, params.bParam) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn - return r -} - -func (r *moqInterfaceResultFn_fnRecorder) doReturnResults(fn moqInterfaceResultFn_doReturnFn) *moqInterfaceResultFn_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 io.Reader } - sequence uint32 - doFn moqInterfaceResultFn_doFn - doReturnFn moqInterfaceResultFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqInterfaceResultFn_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 *moqInterfaceResultFn_resultsByParams - 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 = &moqInterfaceResultFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqInterfaceResultFn_paramsKey]*moqInterfaceResultFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqInterfaceResultFn_results{ - params: r.params, - results: nil, - index: 0, - repeat: &moq.RepeatVal{}, +func (r *moqInterfaceResultFn_recorder) doReturnResults(fn moqInterfaceResultFn_doReturnFn) *moqInterfaceResultFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqInterfaceResultFn_params) *moqInterfaceResultFn_results { + result1 := fn(params.sParam, params.bParam) + return &moqInterfaceResultFn_results{ + result1: result1, } - results.results[paramsKey] = r.results - } - - r.results.repeat.Increment(r.moq.scene.T) + }) + return r } -func (r *moqInterfaceResultFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqInterfaceResultFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqInterfaceResultFn_recorder) repeat(repeaters ...moq.Repeater) *moqInterfaceResultFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 io.Reader } - sequence uint32 - doFn moqInterfaceResultFn_doFn - doReturnFn moqInterfaceResultFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqInterfaceResultFn) prettyParams(params moqInterfaceResultFn_params) string { +func (*moqInterfaceResultFn_adaptor) PrettyParams(params moqInterfaceResultFn_params) string { return fmt.Sprintf("InterfaceResultFn(%#v, %#v)", params.sParam, params.bParam) } -func (m *moqInterfaceResultFn) paramsKey(params moqInterfaceResultFn_params, anyParams uint64) moqInterfaceResultFn_paramsKey { - m.scene.T.Helper() - var sParamUsed string - var sParamUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.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.bParam == moq.ParamIndexByValue { - bParamUsed = params.bParam - } else { - bParamUsedHash = hash.DeepHash(params.bParam) - } - } +func (a *moqInterfaceResultFn_adaptor) ParamsKey(params moqInterfaceResultFn_params, anyParams uint64) moqInterfaceResultFn_paramsKey { + a.moq.moq.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.sParam, 1, a.moq.runtime.parameterIndexing.sParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.bParam, 2, a.moq.runtime.parameterIndexing.bParam, anyParams) return moqInterfaceResultFn_paramsKey{ params: struct { sParam string @@ -7694,40 +4275,36 @@ func (m *moqInterfaceResultFn) paramsKey(params moqInterfaceResultFn_params, any } // Reset resets the state of the moq -func (m *moqInterfaceResultFn) Reset() { m.resultsByParams = nil } +func (m *moqInterfaceResultFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqInterfaceResultFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // moqGenericParamsFn holds the state of a moq of the GenericParamsFn type type moqGenericParamsFn[S, B any] struct { - scene *moq.Scene - config moq.Config - moq *moqGenericParamsFn_mock[S, B] + moq *impl.Moq[ + *moqGenericParamsFn_adaptor[S, B], + moqGenericParamsFn_params[S, B], + moqGenericParamsFn_paramsKey[S, B], + moqGenericParamsFn_results[S, B]] - resultsByParams []moqGenericParamsFn_resultsByParams[S, B] + runtime moqGenericParamsFn_runtime +} - runtime struct { - parameterIndexing struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - } +// moqGenericParamsFn_runtime holds runtime configuration for the +// GenericParamsFn type +type moqGenericParamsFn_runtime struct { + parameterIndexing moqGenericParamsFn_paramIndexing } -// moqGenericParamsFn_mock isolates the mock interface of the GenericParamsFn -// type -type moqGenericParamsFn_mock[S, B any] struct { +// moqGenericParamsFn_adaptor adapts moqGenericParamsFn as needed by the +// runtime +type moqGenericParamsFn_adaptor[S, B any] struct { moq *moqGenericParamsFn[S, B] } @@ -7747,12 +4324,17 @@ type moqGenericParamsFn_paramsKey[S, B any] 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[moqGenericParamsFn_paramsKey[S, B]]*moqGenericParamsFn_results[S, B] +// moqGenericParamsFn_results holds the results of the GenericParamsFn type +type moqGenericParamsFn_results[S, B any] struct { + result1 string + result2 error +} + +// moqGenericParamsFn_paramIndexing holds the parameter indexing runtime +// configuration for the GenericParamsFn type +type moqGenericParamsFn_paramIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } // moqGenericParamsFn_doFn defines the type of function needed when calling @@ -7763,62 +4345,38 @@ type moqGenericParamsFn_doFn[S, B any] func(S, B) // calling doReturnResults for the GenericParamsFn type type moqGenericParamsFn_doReturnFn[S, B any] func(S, B) (string, error) -// 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 { - result1 string - result2 error - } - sequence uint32 - doFn moqGenericParamsFn_doFn[S, B] - doReturnFn moqGenericParamsFn_doReturnFn[S, B] - } - index uint32 - repeat *moq.RepeatVal -} - -// moqGenericParamsFn_fnRecorder routes recorded function calls to the +// moqGenericParamsFn_recorder 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 *moqGenericParamsFn_results[S, B] - moq *moqGenericParamsFn[S, B] +type moqGenericParamsFn_recorder[S, B any] struct { + recorder *impl.Recorder[ + *moqGenericParamsFn_adaptor[S, B], + moqGenericParamsFn_params[S, B], + moqGenericParamsFn_paramsKey[S, B], + moqGenericParamsFn_results[S, B]] } // moqGenericParamsFn_anyParams isolates the any params functions of the // GenericParamsFn type type moqGenericParamsFn_anyParams[S, B any] struct { - recorder *moqGenericParamsFn_fnRecorder[S, B] + recorder *moqGenericParamsFn_recorder[S, B] } // 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{} - } + adaptor1 := &moqGenericParamsFn_adaptor[S, B]{} 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 - }{ + moq: impl.NewMoq[ + *moqGenericParamsFn_adaptor[S, B], + moqGenericParamsFn_params[S, B], + moqGenericParamsFn_paramsKey[S, B], + moqGenericParamsFn_results[S, B]](scene, adaptor1, config), + + runtime: moqGenericParamsFn_runtime{parameterIndexing: moqGenericParamsFn_paramIndexing{ param1: moq.ParamIndexByHash, param2: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -7827,276 +4385,114 @@ func newMoqGenericParamsFn[S, B any](scene *moq.Scene, config *moq.Config) *moqG // 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) - } -} - -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 - } - - 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 + m.moq.Scene.T.Helper() + params := moqGenericParamsFn_params[S, B]{ + param1: param1, + param2: param2, } - 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)) + var result1 string + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } + return result1, result2 } - - 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 *moqGenericParamsFn[S, B]) onCall(param1 S, param2 B) *moqGenericParamsFn_fnRecorder[S, B] { - return &moqGenericParamsFn_fnRecorder[S, B]{ - params: moqGenericParamsFn_params[S, B]{ +func (m *moqGenericParamsFn[S, B]) onCall(param1 S, param2 B) *moqGenericParamsFn_recorder[S, B] { + return &moqGenericParamsFn_recorder[S, B]{ + recorder: m.moq.OnCall(moqGenericParamsFn_params[S, B]{ param1: param1, param2: param2, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -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)) +func (r *moqGenericParamsFn_recorder[S, B]) any() *moqGenericParamsFn_anyParams[S, B] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqGenericParamsFn_anyParams[S, B]{recorder: r} } -func (a *moqGenericParamsFn_anyParams[S, B]) param1() *moqGenericParamsFn_fnRecorder[S, B] { - a.recorder.anyParams |= 1 << 0 +func (a *moqGenericParamsFn_anyParams[S, B]) param1() *moqGenericParamsFn_recorder[S, B] { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqGenericParamsFn_anyParams[S, B]) param2() *moqGenericParamsFn_fnRecorder[S, B] { - a.recorder.anyParams |= 1 << 1 +func (a *moqGenericParamsFn_anyParams[S, B]) param2() *moqGenericParamsFn_recorder[S, B] { + a.recorder.recorder.AnyParam(2) return a.recorder } -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)) +func (r *moqGenericParamsFn_recorder[S, B]) seq() *moqGenericParamsFn_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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)) +func (r *moqGenericParamsFn_recorder[S, B]) noSeq() *moqGenericParamsFn_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqGenericParamsFn_fnRecorder[S, B]) returnResults(result1 string, result2 error) *moqGenericParamsFn_fnRecorder[S, B] { - 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 moqGenericParamsFn_doFn[S, B] - doReturnFn moqGenericParamsFn_doReturnFn[S, B] - }{ - values: &struct { - result1 string - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqGenericParamsFn_recorder[S, B]) returnResults(result1 string, result2 error) *moqGenericParamsFn_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqGenericParamsFn_results[S, B]{ + result1: result1, + result2: result2, }) return r } -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") +func (r *moqGenericParamsFn_recorder[S, B]) andDo(fn moqGenericParamsFn_doFn[S, B]) *moqGenericParamsFn_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqGenericParamsFn_params[S, B]) { + fn(params.param1, params.param2) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqGenericParamsFn_fnRecorder[S, B]) doReturnResults(fn moqGenericParamsFn_doReturnFn[S, B]) *moqGenericParamsFn_fnRecorder[S, B] { - 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 +func (r *moqGenericParamsFn_recorder[S, B]) doReturnResults(fn moqGenericParamsFn_doReturnFn[S, B]) *moqGenericParamsFn_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqGenericParamsFn_params[S, B]) *moqGenericParamsFn_results[S, B] { + result1, result2 := fn(params.param1, params.param2) + return &moqGenericParamsFn_results[S, B]{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqGenericParamsFn_doFn[S, B] - doReturnFn moqGenericParamsFn_doReturnFn[S, B] - }{sequence: sequence, doReturnFn: fn}) + }) return r } -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 - } - - 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 - } - } - - paramsKey := r.moq.paramsKey(r.params, r.anyParams) - - 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 - } - - r.results.repeat.Increment(r.moq.scene.T) -} - -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 - } - 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) +func (r *moqGenericParamsFn_recorder[S, B]) repeat(repeaters ...moq.Repeater) *moqGenericParamsFn_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqGenericParamsFn[S, B]) prettyParams(params moqGenericParamsFn_params[S, B]) string { +func (*moqGenericParamsFn_adaptor[S, B]) PrettyParams(params moqGenericParamsFn_params[S, B]) string { return fmt.Sprintf("GenericParamsFn(%#v, %#v)", params.param1, params.param2) } -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) - } +func (a *moqGenericParamsFn_adaptor[S, B]) ParamsKey(params moqGenericParamsFn_params[S, B], anyParams uint64) moqGenericParamsFn_paramsKey[S, B] { + a.moq.moq.Scene.T.Helper() + param1UsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.param1, "param1", 1, a.moq.runtime.parameterIndexing.param1, anyParams) + param2UsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.param2, "param2", 2, a.moq.runtime.parameterIndexing.param2, anyParams) return moqGenericParamsFn_paramsKey[S, B]{ params: struct{}{}, hashes: struct { @@ -8110,41 +4506,37 @@ func (m *moqGenericParamsFn[S, B]) paramsKey(params moqGenericParamsFn_params[S, } // Reset resets the state of the moq -func (m *moqGenericParamsFn[S, B]) Reset() { m.resultsByParams = nil } +func (m *moqGenericParamsFn[S, B]) Reset() { + m.moq.Reset() +} // 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // 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] + moq *impl.Moq[ + *moqPartialGenericParamsFn_adaptor[S], + moqPartialGenericParamsFn_params[S], + moqPartialGenericParamsFn_paramsKey[S], + moqPartialGenericParamsFn_results[S]] - resultsByParams []moqPartialGenericParamsFn_resultsByParams[S] - - runtime struct { - parameterIndexing struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - } + runtime moqPartialGenericParamsFn_runtime } -// moqPartialGenericParamsFn_mock isolates the mock interface of the +// moqPartialGenericParamsFn_runtime holds runtime configuration for the // PartialGenericParamsFn type -type moqPartialGenericParamsFn_mock[S any] struct { +type moqPartialGenericParamsFn_runtime struct { + parameterIndexing moqPartialGenericParamsFn_paramIndexing +} + +// moqPartialGenericParamsFn_adaptor adapts moqPartialGenericParamsFn as needed +// by the runtime +type moqPartialGenericParamsFn_adaptor[S any] struct { moq *moqPartialGenericParamsFn[S] } @@ -8165,12 +4557,18 @@ type moqPartialGenericParamsFn_paramsKey[S any] 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[moqPartialGenericParamsFn_paramsKey[S]]*moqPartialGenericParamsFn_results[S] +// moqPartialGenericParamsFn_results holds the results of the +// PartialGenericParamsFn type +type moqPartialGenericParamsFn_results[S any] struct { + result1 string + result2 error +} + +// moqPartialGenericParamsFn_paramIndexing holds the parameter indexing runtime +// configuration for the PartialGenericParamsFn type +type moqPartialGenericParamsFn_paramIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } // moqPartialGenericParamsFn_doFn defines the type of function needed when @@ -8181,64 +4579,39 @@ type moqPartialGenericParamsFn_doFn[S any] func(S, bool) // when calling doReturnResults for the PartialGenericParamsFn type type moqPartialGenericParamsFn_doReturnFn[S any] func(S, bool) (string, error) -// moqPartialGenericParamsFn_results holds the results of the -// PartialGenericParamsFn type -type moqPartialGenericParamsFn_results[S any] struct { - params moqPartialGenericParamsFn_params[S] - results []struct { - values *struct { - result1 string - result2 error - } - sequence uint32 - doFn moqPartialGenericParamsFn_doFn[S] - doReturnFn moqPartialGenericParamsFn_doReturnFn[S] - } - index uint32 - repeat *moq.RepeatVal -} - -// moqPartialGenericParamsFn_fnRecorder routes recorded function calls to the +// moqPartialGenericParamsFn_recorder routes recorded function calls to the // moqPartialGenericParamsFn moq -type moqPartialGenericParamsFn_fnRecorder[S any] struct { - params moqPartialGenericParamsFn_params[S] - anyParams uint64 - sequence bool - results *moqPartialGenericParamsFn_results[S] - moq *moqPartialGenericParamsFn[S] +type moqPartialGenericParamsFn_recorder[S any] struct { + recorder *impl.Recorder[ + *moqPartialGenericParamsFn_adaptor[S], + moqPartialGenericParamsFn_params[S], + moqPartialGenericParamsFn_paramsKey[S], + moqPartialGenericParamsFn_results[S]] } // moqPartialGenericParamsFn_anyParams isolates the any params functions of the // PartialGenericParamsFn type type moqPartialGenericParamsFn_anyParams[S any] struct { - recorder *moqPartialGenericParamsFn_fnRecorder[S] + recorder *moqPartialGenericParamsFn_recorder[S] } // 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{} - } + adaptor1 := &moqPartialGenericParamsFn_adaptor[S]{} 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 - }{ + moq: impl.NewMoq[ + *moqPartialGenericParamsFn_adaptor[S], + moqPartialGenericParamsFn_params[S], + moqPartialGenericParamsFn_paramsKey[S], + moqPartialGenericParamsFn_results[S]](scene, adaptor1, config), + + runtime: moqPartialGenericParamsFn_runtime{parameterIndexing: moqPartialGenericParamsFn_paramIndexing{ param1: moq.ParamIndexByHash, param2: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -8247,278 +4620,114 @@ func newMoqPartialGenericParamsFn[S any](scene *moq.Scene, config *moq.Config) * // 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) - } -} - -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 - } - - 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 + m.moq.Scene.T.Helper() + params := moqPartialGenericParamsFn_params[S]{ + param1: param1, + param2: param2, } - 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)) + var result1 string + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } + return result1, result2 } - - 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 *moqPartialGenericParamsFn[S]) onCall(param1 S, param2 bool) *moqPartialGenericParamsFn_fnRecorder[S] { - return &moqPartialGenericParamsFn_fnRecorder[S]{ - params: moqPartialGenericParamsFn_params[S]{ +func (m *moqPartialGenericParamsFn[S]) onCall(param1 S, param2 bool) *moqPartialGenericParamsFn_recorder[S] { + return &moqPartialGenericParamsFn_recorder[S]{ + recorder: m.moq.OnCall(moqPartialGenericParamsFn_params[S]{ param1: param1, param2: param2, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -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)) +func (r *moqPartialGenericParamsFn_recorder[S]) any() *moqPartialGenericParamsFn_anyParams[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqPartialGenericParamsFn_anyParams[S]{recorder: r} } -func (a *moqPartialGenericParamsFn_anyParams[S]) param1() *moqPartialGenericParamsFn_fnRecorder[S] { - a.recorder.anyParams |= 1 << 0 +func (a *moqPartialGenericParamsFn_anyParams[S]) param1() *moqPartialGenericParamsFn_recorder[S] { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqPartialGenericParamsFn_anyParams[S]) param2() *moqPartialGenericParamsFn_fnRecorder[S] { - a.recorder.anyParams |= 1 << 1 +func (a *moqPartialGenericParamsFn_anyParams[S]) param2() *moqPartialGenericParamsFn_recorder[S] { + a.recorder.recorder.AnyParam(2) return a.recorder } -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)) +func (r *moqPartialGenericParamsFn_recorder[S]) seq() *moqPartialGenericParamsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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)) +func (r *moqPartialGenericParamsFn_recorder[S]) noSeq() *moqPartialGenericParamsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqPartialGenericParamsFn_fnRecorder[S]) returnResults(result1 string, result2 error) *moqPartialGenericParamsFn_fnRecorder[S] { - 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 moqPartialGenericParamsFn_doFn[S] - doReturnFn moqPartialGenericParamsFn_doReturnFn[S] - }{ - values: &struct { - result1 string - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqPartialGenericParamsFn_recorder[S]) returnResults(result1 string, result2 error) *moqPartialGenericParamsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqPartialGenericParamsFn_results[S]{ + result1: result1, + result2: result2, }) return r } -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") +func (r *moqPartialGenericParamsFn_recorder[S]) andDo(fn moqPartialGenericParamsFn_doFn[S]) *moqPartialGenericParamsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqPartialGenericParamsFn_params[S]) { + fn(params.param1, params.param2) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqPartialGenericParamsFn_fnRecorder[S]) doReturnResults(fn moqPartialGenericParamsFn_doReturnFn[S]) *moqPartialGenericParamsFn_fnRecorder[S] { - 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 +func (r *moqPartialGenericParamsFn_recorder[S]) doReturnResults(fn moqPartialGenericParamsFn_doReturnFn[S]) *moqPartialGenericParamsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqPartialGenericParamsFn_params[S]) *moqPartialGenericParamsFn_results[S] { + result1, result2 := fn(params.param1, params.param2) + return &moqPartialGenericParamsFn_results[S]{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqPartialGenericParamsFn_doFn[S] - doReturnFn moqPartialGenericParamsFn_doReturnFn[S] - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqPartialGenericParamsFn_fnRecorder[S]) 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 *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 - } - } - - paramsKey := r.moq.paramsKey(r.params, r.anyParams) - - 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{}, - } - results.results[paramsKey] = r.results - } - - r.results.repeat.Increment(r.moq.scene.T) -} - -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(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqPartialGenericParamsFn_recorder[S]) repeat(repeaters ...moq.Repeater) *moqPartialGenericParamsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqPartialGenericParamsFn[S]) prettyParams(params moqPartialGenericParamsFn_params[S]) string { +func (*moqPartialGenericParamsFn_adaptor[S]) PrettyParams(params moqPartialGenericParamsFn_params[S]) string { return fmt.Sprintf("PartialGenericParamsFn(%#v, %#v)", params.param1, params.param2) } -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) - } - 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) - } - } +func (a *moqPartialGenericParamsFn_adaptor[S]) ParamsKey(params moqPartialGenericParamsFn_params[S], anyParams uint64) moqPartialGenericParamsFn_paramsKey[S] { + a.moq.moq.Scene.T.Helper() + param1UsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.param1, "param1", 1, a.moq.runtime.parameterIndexing.param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.param2, 2, a.moq.runtime.parameterIndexing.param2, anyParams) return moqPartialGenericParamsFn_paramsKey[S]{ params: struct{ param2 bool }{ param2: param2Used, @@ -8534,40 +4743,36 @@ func (m *moqPartialGenericParamsFn[S]) paramsKey(params moqPartialGenericParamsF } // Reset resets the state of the moq -func (m *moqPartialGenericParamsFn[S]) Reset() { m.resultsByParams = nil } +func (m *moqPartialGenericParamsFn[S]) Reset() { + m.moq.Reset() +} // 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // 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] + moq *impl.Moq[ + *moqGenericResultsFn_adaptor[S, E], + moqGenericResultsFn_params[S, E], + moqGenericResultsFn_paramsKey[S, E], + moqGenericResultsFn_results[S, E]] - resultsByParams []moqGenericResultsFn_resultsByParams[S, E] + runtime moqGenericResultsFn_runtime +} - runtime struct { - parameterIndexing struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - } +// moqGenericResultsFn_runtime holds runtime configuration for the +// GenericResultsFn type +type moqGenericResultsFn_runtime struct { + parameterIndexing moqGenericResultsFn_paramIndexing } -// moqGenericResultsFn_mock isolates the mock interface of the GenericResultsFn -// type -type moqGenericResultsFn_mock[S ~string, E error] struct { +// moqGenericResultsFn_adaptor adapts moqGenericResultsFn as needed by the +// runtime +type moqGenericResultsFn_adaptor[S ~string, E error] struct { moq *moqGenericResultsFn[S, E] } @@ -8590,12 +4795,17 @@ type moqGenericResultsFn_paramsKey[S ~string, E error] 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[moqGenericResultsFn_paramsKey[S, E]]*moqGenericResultsFn_results[S, E] +// moqGenericResultsFn_results holds the results of the GenericResultsFn type +type moqGenericResultsFn_results[S ~string, E error] struct { + result1 S + result2 E +} + +// moqGenericResultsFn_paramIndexing holds the parameter indexing runtime +// configuration for the GenericResultsFn type +type moqGenericResultsFn_paramIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } // moqGenericResultsFn_doFn defines the type of function needed when calling @@ -8606,62 +4816,38 @@ type moqGenericResultsFn_doFn[S ~string, E error] func(string, bool) // calling doReturnResults for the GenericResultsFn type type moqGenericResultsFn_doReturnFn[S ~string, E error] func(string, bool) (S, E) -// 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 { - result1 S - result2 E - } - sequence uint32 - doFn moqGenericResultsFn_doFn[S, E] - doReturnFn moqGenericResultsFn_doReturnFn[S, E] - } - index uint32 - repeat *moq.RepeatVal -} - -// moqGenericResultsFn_fnRecorder routes recorded function calls to the +// moqGenericResultsFn_recorder 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 *moqGenericResultsFn_results[S, E] - moq *moqGenericResultsFn[S, E] +type moqGenericResultsFn_recorder[S ~string, E error] struct { + recorder *impl.Recorder[ + *moqGenericResultsFn_adaptor[S, E], + moqGenericResultsFn_params[S, E], + moqGenericResultsFn_paramsKey[S, E], + moqGenericResultsFn_results[S, E]] } // moqGenericResultsFn_anyParams isolates the any params functions of the // GenericResultsFn type type moqGenericResultsFn_anyParams[S ~string, E error] struct { - recorder *moqGenericResultsFn_fnRecorder[S, E] + recorder *moqGenericResultsFn_recorder[S, E] } // 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{} - } + adaptor1 := &moqGenericResultsFn_adaptor[S, E]{} m := &moqGenericResultsFn[S, E]{ - scene: scene, - config: *config, - moq: &moqGenericResultsFn_mock[S, E]{}, - - runtime: struct { - parameterIndexing struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - }{parameterIndexing: struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqGenericResultsFn_adaptor[S, E], + moqGenericResultsFn_params[S, E], + moqGenericResultsFn_paramsKey[S, E], + moqGenericResultsFn_results[S, E]](scene, adaptor1, config), + + runtime: moqGenericResultsFn_runtime{parameterIndexing: moqGenericResultsFn_paramIndexing{ param1: moq.ParamIndexByValue, param2: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -8670,280 +4856,114 @@ func newMoqGenericResultsFn[S ~string, E error](scene *moq.Scene, config *moq.Co // 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) - } -} - -func (m *moqGenericResultsFn_mock[S, E]) fn(param1 string, param2 bool) (result1 S, result2 E) { - m.moq.scene.T.Helper() - params := moqGenericResultsFn_params[S, E]{ - param1: param1, - param2: param2, - } - 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 { - break - } - } - if results == nil { - if m.moq.config.Expectation == moq.Strict { - m.moq.scene.T.Fatalf("Unexpected call to %s", m.moq.prettyParams(params)) + m.moq.Scene.T.Helper() + params := moqGenericResultsFn_params[S, E]{ + param1: param1, + param2: param2, } - 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 + var result1 S + var result2 E + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - i = results.repeat.ResultCount - 1 + return result1, result2 } +} - 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)) - } +func (m *moqGenericResultsFn[S, E]) onCall(param1 string, param2 bool) *moqGenericResultsFn_recorder[S, E] { + return &moqGenericResultsFn_recorder[S, E]{ + recorder: m.moq.OnCall(moqGenericResultsFn_params[S, E]{ + param1: param1, + param2: param2, + }), } +} - if result.doFn != nil { - result.doFn(param1, param2) +func (r *moqGenericResultsFn_recorder[S, E]) any() *moqGenericResultsFn_anyParams[S, E] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { + return nil } + return &moqGenericResultsFn_anyParams[S, E]{recorder: r} +} - 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 *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, - } -} - -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} -} - -func (a *moqGenericResultsFn_anyParams[S, E]) param1() *moqGenericResultsFn_fnRecorder[S, E] { - a.recorder.anyParams |= 1 << 0 +func (a *moqGenericResultsFn_anyParams[S, E]) param1() *moqGenericResultsFn_recorder[S, E] { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqGenericResultsFn_anyParams[S, E]) param2() *moqGenericResultsFn_fnRecorder[S, E] { - a.recorder.anyParams |= 1 << 1 +func (a *moqGenericResultsFn_anyParams[S, E]) param2() *moqGenericResultsFn_recorder[S, E] { + a.recorder.recorder.AnyParam(2) return a.recorder } -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)) +func (r *moqGenericResultsFn_recorder[S, E]) seq() *moqGenericResultsFn_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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)) +func (r *moqGenericResultsFn_recorder[S, E]) noSeq() *moqGenericResultsFn_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqGenericResultsFn_fnRecorder[S, E]) returnResults(result1 S, result2 E) *moqGenericResultsFn_fnRecorder[S, E] { - 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 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, +func (r *moqGenericResultsFn_recorder[S, E]) returnResults(result1 S, result2 E) *moqGenericResultsFn_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqGenericResultsFn_results[S, E]{ + result1: result1, + result2: result2, }) return r } -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") +func (r *moqGenericResultsFn_recorder[S, E]) andDo(fn moqGenericResultsFn_doFn[S, E]) *moqGenericResultsFn_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqGenericResultsFn_params[S, E]) { + fn(params.param1, params.param2) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqGenericResultsFn_fnRecorder[S, E]) doReturnResults(fn moqGenericResultsFn_doReturnFn[S, E]) *moqGenericResultsFn_fnRecorder[S, E] { - 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 S - result2 E +func (r *moqGenericResultsFn_recorder[S, E]) doReturnResults(fn moqGenericResultsFn_doReturnFn[S, E]) *moqGenericResultsFn_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqGenericResultsFn_params[S, E]) *moqGenericResultsFn_results[S, E] { + result1, result2 := fn(params.param1, params.param2) + return &moqGenericResultsFn_results[S, E]{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqGenericResultsFn_doFn[S, E] - doReturnFn moqGenericResultsFn_doReturnFn[S, E] - }{sequence: sequence, doReturnFn: fn}) + }) return r } -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 - } - - 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 { - results = &moqGenericResultsFn_resultsByParams[S, E]{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqGenericResultsFn_paramsKey[S, E]]*moqGenericResultsFn_results[S, E]{}, - } - 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(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 - } - - r.results.repeat.Increment(r.moq.scene.T) -} - -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 - } - 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) +func (r *moqGenericResultsFn_recorder[S, E]) repeat(repeaters ...moq.Repeater) *moqGenericResultsFn_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqGenericResultsFn[S, E]) prettyParams(params moqGenericResultsFn_params[S, E]) string { +func (*moqGenericResultsFn_adaptor[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) - } - } - 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) - } - } +func (a *moqGenericResultsFn_adaptor[S, E]) ParamsKey(params moqGenericResultsFn_params[S, E], anyParams uint64) moqGenericResultsFn_paramsKey[S, E] { + a.moq.moq.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.param1, 1, a.moq.runtime.parameterIndexing.param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.param2, 2, a.moq.runtime.parameterIndexing.param2, anyParams) return moqGenericResultsFn_paramsKey[S, E]{ params: struct { param1 string @@ -8963,41 +4983,37 @@ func (m *moqGenericResultsFn[S, E]) paramsKey(params moqGenericResultsFn_params[ } // Reset resets the state of the moq -func (m *moqGenericResultsFn[S, E]) Reset() { m.resultsByParams = nil } +func (m *moqGenericResultsFn[S, E]) Reset() { + m.moq.Reset() +} // 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // 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] + moq *impl.Moq[ + *moqPartialGenericResultsFn_adaptor[S], + moqPartialGenericResultsFn_params[S], + moqPartialGenericResultsFn_paramsKey[S], + moqPartialGenericResultsFn_results[S]] - runtime struct { - parameterIndexing struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - } + runtime moqPartialGenericResultsFn_runtime } -// moqPartialGenericResultsFn_mock isolates the mock interface of the +// moqPartialGenericResultsFn_runtime holds runtime configuration for the // PartialGenericResultsFn type -type moqPartialGenericResultsFn_mock[S ~string] struct { +type moqPartialGenericResultsFn_runtime struct { + parameterIndexing moqPartialGenericResultsFn_paramIndexing +} + +// moqPartialGenericResultsFn_adaptor adapts moqPartialGenericResultsFn as +// needed by the runtime +type moqPartialGenericResultsFn_adaptor[S ~string] struct { moq *moqPartialGenericResultsFn[S] } @@ -9021,12 +5037,18 @@ type moqPartialGenericResultsFn_paramsKey[S ~string] struct { } } -// 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] +// moqPartialGenericResultsFn_results holds the results of the +// PartialGenericResultsFn type +type moqPartialGenericResultsFn_results[S ~string] struct { + result1 S + result2 error +} + +// moqPartialGenericResultsFn_paramIndexing holds the parameter indexing +// runtime configuration for the PartialGenericResultsFn type +type moqPartialGenericResultsFn_paramIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } // moqPartialGenericResultsFn_doFn defines the type of function needed when @@ -9037,64 +5059,39 @@ type moqPartialGenericResultsFn_doFn[S ~string] func(string, bool) // 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 -} - -// moqPartialGenericResultsFn_fnRecorder routes recorded function calls to the +// moqPartialGenericResultsFn_recorder 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] +type moqPartialGenericResultsFn_recorder[S ~string] struct { + recorder *impl.Recorder[ + *moqPartialGenericResultsFn_adaptor[S], + moqPartialGenericResultsFn_params[S], + moqPartialGenericResultsFn_paramsKey[S], + moqPartialGenericResultsFn_results[S]] } // moqPartialGenericResultsFn_anyParams isolates the any params functions of // the PartialGenericResultsFn type type moqPartialGenericResultsFn_anyParams[S ~string] struct { - recorder *moqPartialGenericResultsFn_fnRecorder[S] + recorder *moqPartialGenericResultsFn_recorder[S] } // 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{} - } + adaptor1 := &moqPartialGenericResultsFn_adaptor[S]{} m := &moqPartialGenericResultsFn[S]{ - scene: scene, - config: *config, - moq: &moqPartialGenericResultsFn_mock[S]{}, - - runtime: struct { - parameterIndexing struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - }{parameterIndexing: struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqPartialGenericResultsFn_adaptor[S], + moqPartialGenericResultsFn_params[S], + moqPartialGenericResultsFn_paramsKey[S], + moqPartialGenericResultsFn_results[S]](scene, adaptor1, config), + + runtime: moqPartialGenericResultsFn_runtime{parameterIndexing: moqPartialGenericResultsFn_paramIndexing{ param1: moq.ParamIndexByValue, param2: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -9103,280 +5100,114 @@ func newMoqPartialGenericResultsFn[S ~string](scene *moq.Scene, config *moq.Conf // 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) - } -} - -func (m *moqPartialGenericResultsFn_mock[S]) fn(param1 string, param2 bool) (result1 S, result2 error) { - m.moq.scene.T.Helper() - 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 { - 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 + m.moq.Scene.T.Helper() + params := moqPartialGenericResultsFn_params[S]{ + param1: param1, + param2: param2, } - 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)) + var result1 S + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } + return result1, result2 } - - 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 *moqPartialGenericResultsFn[S]) onCall(param1 string, param2 bool) *moqPartialGenericResultsFn_fnRecorder[S] { - return &moqPartialGenericResultsFn_fnRecorder[S]{ - params: moqPartialGenericResultsFn_params[S]{ +func (m *moqPartialGenericResultsFn[S]) onCall(param1 string, param2 bool) *moqPartialGenericResultsFn_recorder[S] { + return &moqPartialGenericResultsFn_recorder[S]{ + recorder: m.moq.OnCall(moqPartialGenericResultsFn_params[S]{ param1: param1, param2: param2, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -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(r.params)) +func (r *moqPartialGenericResultsFn_recorder[S]) any() *moqPartialGenericResultsFn_anyParams[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqPartialGenericResultsFn_anyParams[S]{recorder: r} } -func (a *moqPartialGenericResultsFn_anyParams[S]) param1() *moqPartialGenericResultsFn_fnRecorder[S] { - a.recorder.anyParams |= 1 << 0 +func (a *moqPartialGenericResultsFn_anyParams[S]) param1() *moqPartialGenericResultsFn_recorder[S] { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqPartialGenericResultsFn_anyParams[S]) param2() *moqPartialGenericResultsFn_fnRecorder[S] { - a.recorder.anyParams |= 1 << 1 +func (a *moqPartialGenericResultsFn_anyParams[S]) param2() *moqPartialGenericResultsFn_recorder[S] { + a.recorder.recorder.AnyParam(2) return a.recorder } -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(r.params)) +func (r *moqPartialGenericResultsFn_recorder[S]) seq() *moqPartialGenericResultsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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(r.params)) +func (r *moqPartialGenericResultsFn_recorder[S]) noSeq() *moqPartialGenericResultsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqPartialGenericResultsFn_fnRecorder[S]) returnResults(result1 S, result2 error) *moqPartialGenericResultsFn_fnRecorder[S] { - 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 S - result2 error - } - sequence uint32 - doFn moqPartialGenericResultsFn_doFn[S] - doReturnFn moqPartialGenericResultsFn_doReturnFn[S] - }{ - values: &struct { - result1 S - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqPartialGenericResultsFn_recorder[S]) returnResults(result1 S, result2 error) *moqPartialGenericResultsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqPartialGenericResultsFn_results[S]{ + result1: result1, + result2: result2, }) return r } -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") +func (r *moqPartialGenericResultsFn_recorder[S]) andDo(fn moqPartialGenericResultsFn_doFn[S]) *moqPartialGenericResultsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqPartialGenericResultsFn_params[S]) { + fn(params.param1, params.param2) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqPartialGenericResultsFn_fnRecorder[S]) doReturnResults(fn moqPartialGenericResultsFn_doReturnFn[S]) *moqPartialGenericResultsFn_fnRecorder[S] { - 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 S - result2 error +func (r *moqPartialGenericResultsFn_recorder[S]) doReturnResults(fn moqPartialGenericResultsFn_doReturnFn[S]) *moqPartialGenericResultsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqPartialGenericResultsFn_params[S]) *moqPartialGenericResultsFn_results[S] { + result1, result2 := fn(params.param1, params.param2) + return &moqPartialGenericResultsFn_results[S]{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqPartialGenericResultsFn_doFn[S] - doReturnFn moqPartialGenericResultsFn_doReturnFn[S] - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqPartialGenericResultsFn_fnRecorder[S]) 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 *moqPartialGenericResultsFn_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 = &moqPartialGenericResultsFn_resultsByParams[S]{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqPartialGenericResultsFn_paramsKey[S]]*moqPartialGenericResultsFn_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 - } - } - - paramsKey := r.moq.paramsKey(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqPartialGenericResultsFn_results[S]{ - 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 *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") - 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 S - result2 error - } - sequence uint32 - doFn moqPartialGenericResultsFn_doFn[S] - doReturnFn moqPartialGenericResultsFn_doReturnFn[S] - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqPartialGenericResultsFn_recorder[S]) repeat(repeaters ...moq.Repeater) *moqPartialGenericResultsFn_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqPartialGenericResultsFn[S]) prettyParams(params moqPartialGenericResultsFn_params[S]) string { +func (*moqPartialGenericResultsFn_adaptor[S]) PrettyParams(params moqPartialGenericResultsFn_params[S]) string { return fmt.Sprintf("PartialGenericResultsFn(%#v, %#v)", params.param1, params.param2) } -func (m *moqPartialGenericResultsFn[S]) paramsKey(params moqPartialGenericResultsFn_params[S], anyParams uint64) moqPartialGenericResultsFn_paramsKey[S] { - 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) - } - } - 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) - } - } +func (a *moqPartialGenericResultsFn_adaptor[S]) ParamsKey(params moqPartialGenericResultsFn_params[S], anyParams uint64) moqPartialGenericResultsFn_paramsKey[S] { + a.moq.moq.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.param1, 1, a.moq.runtime.parameterIndexing.param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.param2, 2, a.moq.runtime.parameterIndexing.param2, anyParams) return moqPartialGenericResultsFn_paramsKey[S]{ params: struct { param1 string @@ -9396,40 +5227,37 @@ func (m *moqPartialGenericResultsFn[S]) paramsKey(params moqPartialGenericResult } // Reset resets the state of the moq -func (m *moqPartialGenericResultsFn[S]) Reset() { m.resultsByParams = nil } +func (m *moqPartialGenericResultsFn[S]) Reset() { + m.moq.Reset() +} // 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // 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] + moq *impl.Moq[ + *moqGenericInterfaceParamFn_adaptor[W], + moqGenericInterfaceParamFn_params[W], + moqGenericInterfaceParamFn_paramsKey[W], + moqGenericInterfaceParamFn_results[W]] - resultsByParams []moqGenericInterfaceParamFn_resultsByParams[W] - - runtime struct { - parameterIndexing struct { - w moq.ParamIndexing - } - } + runtime moqGenericInterfaceParamFn_runtime } -// moqGenericInterfaceParamFn_mock isolates the mock interface of the +// moqGenericInterfaceParamFn_runtime holds runtime configuration for the // GenericInterfaceParamFn type -type moqGenericInterfaceParamFn_mock[W testmoqs.MyWriter] struct { +type moqGenericInterfaceParamFn_runtime struct { + parameterIndexing moqGenericInterfaceParamFn_paramIndexing +} + +// moqGenericInterfaceParamFn_adaptor adapts moqGenericInterfaceParamFn as +// needed by the runtime +type moqGenericInterfaceParamFn_adaptor[W testmoqs.MyWriter] struct { moq *moqGenericInterfaceParamFn[W] } @@ -9444,12 +5272,17 @@ type moqGenericInterfaceParamFn_paramsKey[W testmoqs.MyWriter] 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_results holds the results of the +// GenericInterfaceParamFn type +type moqGenericInterfaceParamFn_results[W testmoqs.MyWriter] struct { + sResult string + err error +} + +// moqGenericInterfaceParamFn_paramIndexing holds the parameter indexing +// runtime configuration for the GenericInterfaceParamFn type +type moqGenericInterfaceParamFn_paramIndexing struct { + w moq.ParamIndexing } // moqGenericInterfaceParamFn_doFn defines the type of function needed when @@ -9460,61 +5293,38 @@ type moqGenericInterfaceParamFn_doFn[W testmoqs.MyWriter] func(w W) // 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_recorder 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] +type moqGenericInterfaceParamFn_recorder[W testmoqs.MyWriter] struct { + recorder *impl.Recorder[ + *moqGenericInterfaceParamFn_adaptor[W], + moqGenericInterfaceParamFn_params[W], + moqGenericInterfaceParamFn_paramsKey[W], + moqGenericInterfaceParamFn_results[W]] } // moqGenericInterfaceParamFn_anyParams isolates the any params functions of // the GenericInterfaceParamFn type type moqGenericInterfaceParamFn_anyParams[W testmoqs.MyWriter] struct { - recorder *moqGenericInterfaceParamFn_fnRecorder[W] + recorder *moqGenericInterfaceParamFn_recorder[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{} - } + adaptor1 := &moqGenericInterfaceParamFn_adaptor[W]{} m := &moqGenericInterfaceParamFn[W]{ - scene: scene, - config: *config, - moq: &moqGenericInterfaceParamFn_mock[W]{}, - - runtime: struct { - parameterIndexing struct { - w moq.ParamIndexing - } - }{parameterIndexing: struct { - w moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqGenericInterfaceParamFn_adaptor[W], + moqGenericInterfaceParamFn_params[W], + moqGenericInterfaceParamFn_paramsKey[W], + moqGenericInterfaceParamFn_results[W]](scene, adaptor1, config), + + runtime: moqGenericInterfaceParamFn_runtime{parameterIndexing: moqGenericInterfaceParamFn_paramIndexing{ w: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -9522,263 +5332,106 @@ func newMoqGenericInterfaceParamFn[W testmoqs.MyWriter](scene *moq.Scene, config // 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 + return func(w W) (string, error) { + m.moq.Scene.T.Helper() + params := moqGenericInterfaceParamFn_params[W]{ + w: w, } - 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)) + var result1 string + var result2 error + if result := m.moq.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } + return result1, result2 } - - 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]{ +func (m *moqGenericInterfaceParamFn[W]) onCall(w W) *moqGenericInterfaceParamFn_recorder[W] { + return &moqGenericInterfaceParamFn_recorder[W]{ + recorder: m.moq.OnCall(moqGenericInterfaceParamFn_params[W]{ w: w, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -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(r.params)) +func (r *moqGenericInterfaceParamFn_recorder[W]) any() *moqGenericInterfaceParamFn_anyParams[W] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqGenericInterfaceParamFn_anyParams[W]{recorder: r} } -func (a *moqGenericInterfaceParamFn_anyParams[W]) w() *moqGenericInterfaceParamFn_fnRecorder[W] { - a.recorder.anyParams |= 1 << 0 +func (a *moqGenericInterfaceParamFn_anyParams[W]) w() *moqGenericInterfaceParamFn_recorder[W] { + a.recorder.recorder.AnyParam(1) return a.recorder } -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(r.params)) +func (r *moqGenericInterfaceParamFn_recorder[W]) seq() *moqGenericInterfaceParamFn_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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(r.params)) +func (r *moqGenericInterfaceParamFn_recorder[W]) noSeq() *moqGenericInterfaceParamFn_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqGenericInterfaceParamFn_fnRecorder[W]) returnResults(sResult string, err error) *moqGenericInterfaceParamFn_fnRecorder[W] { - 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 moqGenericInterfaceParamFn_doFn[W] - doReturnFn moqGenericInterfaceParamFn_doReturnFn[W] - }{ - values: &struct { - sResult string - err error - }{ - sResult: sResult, - err: err, - }, - sequence: sequence, +func (r *moqGenericInterfaceParamFn_recorder[W]) returnResults(sResult string, err error) *moqGenericInterfaceParamFn_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqGenericInterfaceParamFn_results[W]{ + sResult: sResult, + err: err, }) return r } -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") +func (r *moqGenericInterfaceParamFn_recorder[W]) andDo(fn moqGenericInterfaceParamFn_doFn[W]) *moqGenericInterfaceParamFn_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqGenericInterfaceParamFn_params[W]) { + fn(params.w) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqGenericInterfaceParamFn_fnRecorder[W]) doReturnResults(fn moqGenericInterfaceParamFn_doReturnFn[W]) *moqGenericInterfaceParamFn_fnRecorder[W] { - 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 +func (r *moqGenericInterfaceParamFn_recorder[W]) doReturnResults(fn moqGenericInterfaceParamFn_doReturnFn[W]) *moqGenericInterfaceParamFn_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqGenericInterfaceParamFn_params[W]) *moqGenericInterfaceParamFn_results[W] { + sResult, err := fn(params.w) + return &moqGenericInterfaceParamFn_results[W]{ + sResult: sResult, + err: err, } - sequence uint32 - doFn moqGenericInterfaceParamFn_doFn[W] - doReturnFn moqGenericInterfaceParamFn_doReturnFn[W] - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqGenericInterfaceParamFn_fnRecorder[W]) 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 *moqGenericInterfaceParamFn_resultsByParams[W] - 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 = &moqGenericInterfaceParamFn_resultsByParams[W]{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqGenericInterfaceParamFn_paramsKey[W]]*moqGenericInterfaceParamFn_results[W]{}, - } - 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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqGenericInterfaceParamFn_results[W]{ - 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 *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") - 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 moqGenericInterfaceParamFn_doFn[W] - doReturnFn moqGenericInterfaceParamFn_doReturnFn[W] - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqGenericInterfaceParamFn_recorder[W]) repeat(repeaters ...moq.Repeater) *moqGenericInterfaceParamFn_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqGenericInterfaceParamFn[W]) prettyParams(params moqGenericInterfaceParamFn_params[W]) string { +func (*moqGenericInterfaceParamFn_adaptor[W]) PrettyParams(params moqGenericInterfaceParamFn_params[W]) string { return fmt.Sprintf("GenericInterfaceParamFn(%#v)", params.w) } -func (m *moqGenericInterfaceParamFn[W]) paramsKey(params moqGenericInterfaceParamFn_params[W], anyParams uint64) moqGenericInterfaceParamFn_paramsKey[W] { - m.scene.T.Helper() - var wUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - 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) - } +func (a *moqGenericInterfaceParamFn_adaptor[W]) ParamsKey(params moqGenericInterfaceParamFn_params[W], anyParams uint64) moqGenericInterfaceParamFn_paramsKey[W] { + a.moq.moq.Scene.T.Helper() + wUsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.w, "w", 1, a.moq.runtime.parameterIndexing.w, anyParams) return moqGenericInterfaceParamFn_paramsKey[W]{ params: struct{}{}, hashes: struct{ w hash.Hash }{ @@ -9788,41 +5441,37 @@ func (m *moqGenericInterfaceParamFn[W]) paramsKey(params moqGenericInterfacePara } // Reset resets the state of the moq -func (m *moqGenericInterfaceParamFn[W]) Reset() { m.resultsByParams = nil } +func (m *moqGenericInterfaceParamFn[W]) Reset() { + m.moq.Reset() +} // 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // 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] + moq *impl.Moq[ + *moqGenericInterfaceResultFn_adaptor[R], + moqGenericInterfaceResultFn_params[R], + moqGenericInterfaceResultFn_paramsKey[R], + moqGenericInterfaceResultFn_results[R]] - runtime struct { - parameterIndexing struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - } + runtime moqGenericInterfaceResultFn_runtime } -// moqGenericInterfaceResultFn_mock isolates the mock interface of the +// moqGenericInterfaceResultFn_runtime holds runtime configuration for the // GenericInterfaceResultFn type -type moqGenericInterfaceResultFn_mock[R testmoqs.MyReader] struct { +type moqGenericInterfaceResultFn_runtime struct { + parameterIndexing moqGenericInterfaceResultFn_paramIndexing +} + +// moqGenericInterfaceResultFn_adaptor adapts moqGenericInterfaceResultFn as +// needed by the runtime +type moqGenericInterfaceResultFn_adaptor[R testmoqs.MyReader] struct { moq *moqGenericInterfaceResultFn[R] } @@ -9846,12 +5495,15 @@ type moqGenericInterfaceResultFn_paramsKey[R testmoqs.MyReader] struct { } } -// 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_results holds the results of the +// GenericInterfaceResultFn type +type moqGenericInterfaceResultFn_results[R testmoqs.MyReader] struct{ result1 R } + +// moqGenericInterfaceResultFn_paramIndexing holds the parameter indexing +// runtime configuration for the GenericInterfaceResultFn type +type moqGenericInterfaceResultFn_paramIndexing struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing } // moqGenericInterfaceResultFn_doFn defines the type of function needed when @@ -9862,61 +5514,39 @@ type moqGenericInterfaceResultFn_doFn[R testmoqs.MyReader] func(sParam string, b // 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_recorder 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] +type moqGenericInterfaceResultFn_recorder[R testmoqs.MyReader] struct { + recorder *impl.Recorder[ + *moqGenericInterfaceResultFn_adaptor[R], + moqGenericInterfaceResultFn_params[R], + moqGenericInterfaceResultFn_paramsKey[R], + moqGenericInterfaceResultFn_results[R]] } // moqGenericInterfaceResultFn_anyParams isolates the any params functions of // the GenericInterfaceResultFn type type moqGenericInterfaceResultFn_anyParams[R testmoqs.MyReader] struct { - recorder *moqGenericInterfaceResultFn_fnRecorder[R] + recorder *moqGenericInterfaceResultFn_recorder[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{} - } + adaptor1 := &moqGenericInterfaceResultFn_adaptor[R]{} 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 - }{ + moq: impl.NewMoq[ + *moqGenericInterfaceResultFn_adaptor[R], + moqGenericInterfaceResultFn_params[R], + moqGenericInterfaceResultFn_paramsKey[R], + moqGenericInterfaceResultFn_results[R]](scene, adaptor1, config), + + runtime: moqGenericInterfaceResultFn_runtime{parameterIndexing: moqGenericInterfaceResultFn_paramIndexing{ sParam: moq.ParamIndexByValue, bParam: moq.ParamIndexByValue, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -9924,267 +5554,111 @@ func newMoqGenericInterfaceResultFn[R testmoqs.MyReader](scene *moq.Scene, confi // 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 + return func(sParam string, bParam bool) R { + m.moq.Scene.T.Helper() + params := moqGenericInterfaceResultFn_params[R]{ + sParam: sParam, + bParam: bParam, } - 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)) + var result1 R + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } + return result1 } - - 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]{ +func (m *moqGenericInterfaceResultFn[R]) onCall(sParam string, bParam bool) *moqGenericInterfaceResultFn_recorder[R] { + return &moqGenericInterfaceResultFn_recorder[R]{ + recorder: m.moq.OnCall(moqGenericInterfaceResultFn_params[R]{ sParam: sParam, bParam: bParam, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -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(r.params)) +func (r *moqGenericInterfaceResultFn_recorder[R]) any() *moqGenericInterfaceResultFn_anyParams[R] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqGenericInterfaceResultFn_anyParams[R]{recorder: r} } -func (a *moqGenericInterfaceResultFn_anyParams[R]) sParam() *moqGenericInterfaceResultFn_fnRecorder[R] { - a.recorder.anyParams |= 1 << 0 +func (a *moqGenericInterfaceResultFn_anyParams[R]) sParam() *moqGenericInterfaceResultFn_recorder[R] { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqGenericInterfaceResultFn_anyParams[R]) bParam() *moqGenericInterfaceResultFn_fnRecorder[R] { - a.recorder.anyParams |= 1 << 1 +func (a *moqGenericInterfaceResultFn_anyParams[R]) bParam() *moqGenericInterfaceResultFn_recorder[R] { + a.recorder.recorder.AnyParam(2) return a.recorder } -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(r.params)) +func (r *moqGenericInterfaceResultFn_recorder[R]) seq() *moqGenericInterfaceResultFn_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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(r.params)) +func (r *moqGenericInterfaceResultFn_recorder[R]) noSeq() *moqGenericInterfaceResultFn_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqGenericInterfaceResultFn_fnRecorder[R]) returnResults(result1 R) *moqGenericInterfaceResultFn_fnRecorder[R] { - 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 R } - sequence uint32 - doFn moqGenericInterfaceResultFn_doFn[R] - doReturnFn moqGenericInterfaceResultFn_doReturnFn[R] - }{ - values: &struct{ result1 R }{ - result1: result1, - }, - sequence: sequence, +func (r *moqGenericInterfaceResultFn_recorder[R]) returnResults(result1 R) *moqGenericInterfaceResultFn_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqGenericInterfaceResultFn_results[R]{ + result1: result1, }) return r } -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") +func (r *moqGenericInterfaceResultFn_recorder[R]) andDo(fn moqGenericInterfaceResultFn_doFn[R]) *moqGenericInterfaceResultFn_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqGenericInterfaceResultFn_params[R]) { + fn(params.sParam, params.bParam) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqGenericInterfaceResultFn_fnRecorder[R]) doReturnResults(fn moqGenericInterfaceResultFn_doReturnFn[R]) *moqGenericInterfaceResultFn_fnRecorder[R] { - 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 R } - sequence uint32 - doFn moqGenericInterfaceResultFn_doFn[R] - doReturnFn moqGenericInterfaceResultFn_doReturnFn[R] - }{sequence: sequence, doReturnFn: fn}) +func (r *moqGenericInterfaceResultFn_recorder[R]) doReturnResults(fn moqGenericInterfaceResultFn_doReturnFn[R]) *moqGenericInterfaceResultFn_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqGenericInterfaceResultFn_params[R]) *moqGenericInterfaceResultFn_results[R] { + result1 := fn(params.sParam, params.bParam) + return &moqGenericInterfaceResultFn_results[R]{ + result1: result1, + } + }) return r } -func (r *moqGenericInterfaceResultFn_fnRecorder[R]) 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 *moqGenericInterfaceResultFn_resultsByParams[R] - 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 = &moqGenericInterfaceResultFn_resultsByParams[R]{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqGenericInterfaceResultFn_paramsKey[R]]*moqGenericInterfaceResultFn_results[R]{}, - } - 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 - } +func (r *moqGenericInterfaceResultFn_recorder[R]) repeat(repeaters ...moq.Repeater) *moqGenericInterfaceResultFn_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } + return r +} - paramsKey := r.moq.paramsKey(r.params, r.anyParams) +func (*moqGenericInterfaceResultFn_adaptor[R]) PrettyParams(params moqGenericInterfaceResultFn_params[R]) string { + return fmt.Sprintf("GenericInterfaceResultFn(%#v, %#v)", params.sParam, params.bParam) +} - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqGenericInterfaceResultFn_results[R]{ - 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 *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") - 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 R } - sequence uint32 - doFn moqGenericInterfaceResultFn_doFn[R] - doReturnFn moqGenericInterfaceResultFn_doReturnFn[R] - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } - return r -} - -func (m *moqGenericInterfaceResultFn[R]) prettyParams(params moqGenericInterfaceResultFn_params[R]) string { - return fmt.Sprintf("GenericInterfaceResultFn(%#v, %#v)", params.sParam, params.bParam) -} - -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.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.bParam == moq.ParamIndexByValue { - bParamUsed = params.bParam - } else { - bParamUsedHash = hash.DeepHash(params.bParam) - } - } +func (a *moqGenericInterfaceResultFn_adaptor[R]) ParamsKey(params moqGenericInterfaceResultFn_params[R], anyParams uint64) moqGenericInterfaceResultFn_paramsKey[R] { + a.moq.moq.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.sParam, 1, a.moq.runtime.parameterIndexing.sParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.bParam, 2, a.moq.runtime.parameterIndexing.bParam, anyParams) return moqGenericInterfaceResultFn_paramsKey[R]{ params: struct { sParam string @@ -10204,19 +5678,14 @@ func (m *moqGenericInterfaceResultFn[R]) paramsKey(params moqGenericInterfaceRes } // Reset resets the state of the moq -func (m *moqGenericInterfaceResultFn[R]) Reset() { m.resultsByParams = nil } +func (m *moqGenericInterfaceResultFn[R]) Reset() { + m.moq.Reset() +} // 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } // The following type assertion assures that testmoqs.Usual is mocked @@ -10225,112 +5694,139 @@ 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_PassByArray []moqUsual_PassByArray_resultsByParams - resultsByParams_PassByChan []moqUsual_PassByChan_resultsByParams - resultsByParams_PassByEllipsis []moqUsual_PassByEllipsis_resultsByParams - resultsByParams_PassByMap []moqUsual_PassByMap_resultsByParams - resultsByParams_PassByReference []moqUsual_PassByReference_resultsByParams - resultsByParams_PassBySlice []moqUsual_PassBySlice_resultsByParams - resultsByParams_PassByValue []moqUsual_PassByValue_resultsByParams - resultsByParams_InterfaceParam []moqUsual_InterfaceParam_resultsByParams - resultsByParams_InterfaceResult []moqUsual_InterfaceResult_resultsByParams - resultsByParams_FnParam []moqUsual_FnParam_resultsByParams - resultsByParams_Other []moqUsual_Other_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{} - PassByArray struct { - p moq.ParamIndexing - } - PassByChan struct { - p moq.ParamIndexing - } - PassByEllipsis struct { - p moq.ParamIndexing - } - PassByMap struct { - p moq.ParamIndexing - } - PassByReference struct { - p moq.ParamIndexing - } - PassBySlice struct { - p moq.ParamIndexing - } - PassByValue struct { - p moq.ParamIndexing - } - InterfaceParam struct { - w moq.ParamIndexing - } - InterfaceResult struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - FnParam struct { - fn moq.ParamIndexing - } - Other struct { - param1 moq.ParamIndexing - } - } - } - // moqUsual_mock isolates the mock interface of the Usual type -} - + moq *moqUsual_mock + + moq_Usual *impl.Moq[ + *moqUsual_Usual_adaptor, + moqUsual_Usual_params, + moqUsual_Usual_paramsKey, + moqUsual_Usual_results, + ] + moq_NoNames *impl.Moq[ + *moqUsual_NoNames_adaptor, + moqUsual_NoNames_params, + moqUsual_NoNames_paramsKey, + moqUsual_NoNames_results, + ] + moq_NoResults *impl.Moq[ + *moqUsual_NoResults_adaptor, + moqUsual_NoResults_params, + moqUsual_NoResults_paramsKey, + moqUsual_NoResults_results, + ] + moq_NoParams *impl.Moq[ + *moqUsual_NoParams_adaptor, + moqUsual_NoParams_params, + moqUsual_NoParams_paramsKey, + moqUsual_NoParams_results, + ] + moq_Nothing *impl.Moq[ + *moqUsual_Nothing_adaptor, + moqUsual_Nothing_params, + moqUsual_Nothing_paramsKey, + moqUsual_Nothing_results, + ] + moq_Variadic *impl.Moq[ + *moqUsual_Variadic_adaptor, + moqUsual_Variadic_params, + moqUsual_Variadic_paramsKey, + moqUsual_Variadic_results, + ] + moq_RepeatedIds *impl.Moq[ + *moqUsual_RepeatedIds_adaptor, + moqUsual_RepeatedIds_params, + moqUsual_RepeatedIds_paramsKey, + moqUsual_RepeatedIds_results, + ] + moq_Times *impl.Moq[ + *moqUsual_Times_adaptor, + moqUsual_Times_params, + moqUsual_Times_paramsKey, + moqUsual_Times_results, + ] + moq_DifficultParamNames *impl.Moq[ + *moqUsual_DifficultParamNames_adaptor, + moqUsual_DifficultParamNames_params, + moqUsual_DifficultParamNames_paramsKey, + moqUsual_DifficultParamNames_results, + ] + moq_DifficultResultNames *impl.Moq[ + *moqUsual_DifficultResultNames_adaptor, + moqUsual_DifficultResultNames_params, + moqUsual_DifficultResultNames_paramsKey, + moqUsual_DifficultResultNames_results, + ] + moq_PassByArray *impl.Moq[ + *moqUsual_PassByArray_adaptor, + moqUsual_PassByArray_params, + moqUsual_PassByArray_paramsKey, + moqUsual_PassByArray_results, + ] + moq_PassByChan *impl.Moq[ + *moqUsual_PassByChan_adaptor, + moqUsual_PassByChan_params, + moqUsual_PassByChan_paramsKey, + moqUsual_PassByChan_results, + ] + moq_PassByEllipsis *impl.Moq[ + *moqUsual_PassByEllipsis_adaptor, + moqUsual_PassByEllipsis_params, + moqUsual_PassByEllipsis_paramsKey, + moqUsual_PassByEllipsis_results, + ] + moq_PassByMap *impl.Moq[ + *moqUsual_PassByMap_adaptor, + moqUsual_PassByMap_params, + moqUsual_PassByMap_paramsKey, + moqUsual_PassByMap_results, + ] + moq_PassByReference *impl.Moq[ + *moqUsual_PassByReference_adaptor, + moqUsual_PassByReference_params, + moqUsual_PassByReference_paramsKey, + moqUsual_PassByReference_results, + ] + moq_PassBySlice *impl.Moq[ + *moqUsual_PassBySlice_adaptor, + moqUsual_PassBySlice_params, + moqUsual_PassBySlice_paramsKey, + moqUsual_PassBySlice_results, + ] + moq_PassByValue *impl.Moq[ + *moqUsual_PassByValue_adaptor, + moqUsual_PassByValue_params, + moqUsual_PassByValue_paramsKey, + moqUsual_PassByValue_results, + ] + moq_InterfaceParam *impl.Moq[ + *moqUsual_InterfaceParam_adaptor, + moqUsual_InterfaceParam_params, + moqUsual_InterfaceParam_paramsKey, + moqUsual_InterfaceParam_results, + ] + moq_InterfaceResult *impl.Moq[ + *moqUsual_InterfaceResult_adaptor, + moqUsual_InterfaceResult_params, + moqUsual_InterfaceResult_paramsKey, + moqUsual_InterfaceResult_results, + ] + moq_FnParam *impl.Moq[ + *moqUsual_FnParam_adaptor, + moqUsual_FnParam_params, + moqUsual_FnParam_paramsKey, + moqUsual_FnParam_results, + ] + moq_Other *impl.Moq[ + *moqUsual_Other_adaptor, + moqUsual_Other_params, + moqUsual_Other_paramsKey, + moqUsual_Other_results, + ] + + runtime moqUsual_runtime +} + +// moqUsual_mock isolates the mock interface of the Usual type type moqUsual_mock struct { moq *moqUsual } @@ -10340,6 +5836,38 @@ type moqUsual_recorder struct { moq *moqUsual } +// moqUsual_runtime holds runtime configuration for the Usual type +type moqUsual_runtime struct { + parameterIndexing struct { + Usual moqUsual_Usual_paramIndexing + NoNames moqUsual_NoNames_paramIndexing + NoResults moqUsual_NoResults_paramIndexing + NoParams moqUsual_NoParams_paramIndexing + Nothing moqUsual_Nothing_paramIndexing + Variadic moqUsual_Variadic_paramIndexing + RepeatedIds moqUsual_RepeatedIds_paramIndexing + Times moqUsual_Times_paramIndexing + DifficultParamNames moqUsual_DifficultParamNames_paramIndexing + DifficultResultNames moqUsual_DifficultResultNames_paramIndexing + PassByArray moqUsual_PassByArray_paramIndexing + PassByChan moqUsual_PassByChan_paramIndexing + PassByEllipsis moqUsual_PassByEllipsis_paramIndexing + PassByMap moqUsual_PassByMap_paramIndexing + PassByReference moqUsual_PassByReference_paramIndexing + PassBySlice moqUsual_PassBySlice_paramIndexing + PassByValue moqUsual_PassByValue_paramIndexing + InterfaceParam moqUsual_InterfaceParam_paramIndexing + InterfaceResult moqUsual_InterfaceResult_paramIndexing + FnParam moqUsual_FnParam_paramIndexing + Other moqUsual_Other_paramIndexing + } +} + +// moqUsual_Usual_adaptor adapts moqUsual as needed by the runtime +type moqUsual_Usual_adaptor struct { + moq *moqUsual +} + // moqUsual_Usual_params holds the params of the Usual type type moqUsual_Usual_params struct { sParam string @@ -10358,12 +5886,17 @@ type moqUsual_Usual_paramsKey struct { } } -// 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_results holds the results of the Usual type +type moqUsual_Usual_results struct { + sResult string + err error +} + +// moqUsual_Usual_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_Usual_paramIndexing struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing } // moqUsual_Usual_doFn defines the type of function needed when calling andDo @@ -10374,34 +5907,24 @@ type moqUsual_Usual_doFn func(sParam string, bParam bool) // 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_recorder routes recorded function calls to the moqUsual moq +type moqUsual_Usual_recorder struct { + recorder *impl.Recorder[ + *moqUsual_Usual_adaptor, + moqUsual_Usual_params, + moqUsual_Usual_paramsKey, + moqUsual_Usual_results, + ] } // moqUsual_Usual_anyParams isolates the any params functions of the Usual type type moqUsual_Usual_anyParams struct { - recorder *moqUsual_Usual_fnRecorder + recorder *moqUsual_Usual_recorder +} + +// moqUsual_NoNames_adaptor adapts moqUsual as needed by the runtime +type moqUsual_NoNames_adaptor struct { + moq *moqUsual } // moqUsual_NoNames_params holds the params of the Usual type @@ -10422,12 +5945,17 @@ type moqUsual_NoNames_paramsKey struct { } } -// 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_results holds the results of the Usual type +type moqUsual_NoNames_results struct { + result1 string + result2 error +} + +// moqUsual_NoNames_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_NoNames_paramIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } // moqUsual_NoNames_doFn defines the type of function needed when calling andDo @@ -10438,36 +5966,25 @@ type moqUsual_NoNames_doFn func(string, bool) // 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_recorder routes recorded function calls to the moqUsual moq +type moqUsual_NoNames_recorder struct { + recorder *impl.Recorder[ + *moqUsual_NoNames_adaptor, + moqUsual_NoNames_params, + moqUsual_NoNames_paramsKey, + moqUsual_NoNames_results, + ] } // moqUsual_NoNames_anyParams isolates the any params functions of the Usual // type type moqUsual_NoNames_anyParams struct { - recorder *moqUsual_NoNames_fnRecorder + recorder *moqUsual_NoNames_recorder +} + +// moqUsual_NoResults_adaptor adapts moqUsual as needed by the runtime +type moqUsual_NoResults_adaptor struct { + moq *moqUsual } // moqUsual_NoResults_params holds the params of the Usual type @@ -10488,12 +6005,14 @@ type moqUsual_NoResults_paramsKey struct { } } -// 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_results holds the results of the Usual type +type moqUsual_NoResults_results struct{} + +// moqUsual_NoResults_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_NoResults_paramIndexing struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing } // moqUsual_NoResults_doFn defines the type of function needed when calling @@ -10504,33 +6023,26 @@ type moqUsual_NoResults_doFn func(sParam string, bParam bool) // 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 +// moqUsual_NoResults_recorder 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 +type moqUsual_NoResults_recorder struct { + recorder *impl.Recorder[ + *moqUsual_NoResults_adaptor, + moqUsual_NoResults_params, + moqUsual_NoResults_paramsKey, + moqUsual_NoResults_results, + ] } // moqUsual_NoResults_anyParams isolates the any params functions of the Usual // type type moqUsual_NoResults_anyParams struct { - recorder *moqUsual_NoResults_fnRecorder + recorder *moqUsual_NoResults_recorder +} + +// moqUsual_NoParams_adaptor adapts moqUsual as needed by the runtime +type moqUsual_NoParams_adaptor struct { + moq *moqUsual } // moqUsual_NoParams_params holds the params of the Usual type @@ -10542,14 +6054,16 @@ type moqUsual_NoParams_paramsKey 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_results holds the results of the Usual type +type moqUsual_NoParams_results struct { + sResult string + err error } +// moqUsual_NoParams_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_NoParams_paramIndexing struct{} + // moqUsual_NoParams_doFn defines the type of function needed when calling // andDo for the Usual type type moqUsual_NoParams_doFn func() @@ -10558,36 +6072,26 @@ type moqUsual_NoParams_doFn func() // 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 +// moqUsual_NoParams_recorder 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 +type moqUsual_NoParams_recorder struct { + recorder *impl.Recorder[ + *moqUsual_NoParams_adaptor, + moqUsual_NoParams_params, + moqUsual_NoParams_paramsKey, + moqUsual_NoParams_results, + ] } // moqUsual_NoParams_anyParams isolates the any params functions of the Usual // type type moqUsual_NoParams_anyParams struct { - recorder *moqUsual_NoParams_fnRecorder + recorder *moqUsual_NoParams_recorder +} + +// moqUsual_Nothing_adaptor adapts moqUsual as needed by the runtime +type moqUsual_Nothing_adaptor struct { + moq *moqUsual } // moqUsual_Nothing_params holds the params of the Usual type @@ -10599,13 +6103,12 @@ type moqUsual_Nothing_paramsKey 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_results holds the results of the Usual type +type moqUsual_Nothing_results struct{} + +// moqUsual_Nothing_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_Nothing_paramIndexing struct{} // moqUsual_Nothing_doFn defines the type of function needed when calling andDo // for the Usual type @@ -10615,33 +6118,25 @@ type moqUsual_Nothing_doFn func() // 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_recorder routes recorded function calls to the moqUsual moq +type moqUsual_Nothing_recorder struct { + recorder *impl.Recorder[ + *moqUsual_Nothing_adaptor, + moqUsual_Nothing_params, + moqUsual_Nothing_paramsKey, + moqUsual_Nothing_results, + ] } // moqUsual_Nothing_anyParams isolates the any params functions of the Usual // type type moqUsual_Nothing_anyParams struct { - recorder *moqUsual_Nothing_fnRecorder + recorder *moqUsual_Nothing_recorder +} + +// moqUsual_Variadic_adaptor adapts moqUsual as needed by the runtime +type moqUsual_Variadic_adaptor struct { + moq *moqUsual } // moqUsual_Variadic_params holds the params of the Usual type @@ -10659,12 +6154,17 @@ type moqUsual_Variadic_paramsKey struct { } } -// 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_results holds the results of the Usual type +type moqUsual_Variadic_results struct { + sResult string + err error +} + +// moqUsual_Variadic_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_Variadic_paramIndexing struct { + other moq.ParamIndexing + args moq.ParamIndexing } // moqUsual_Variadic_doFn defines the type of function needed when calling @@ -10675,36 +6175,26 @@ type moqUsual_Variadic_doFn func(other bool, args ...string) // 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 +// moqUsual_Variadic_recorder 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 +type moqUsual_Variadic_recorder struct { + recorder *impl.Recorder[ + *moqUsual_Variadic_adaptor, + moqUsual_Variadic_params, + moqUsual_Variadic_paramsKey, + moqUsual_Variadic_results, + ] } // moqUsual_Variadic_anyParams isolates the any params functions of the Usual // type type moqUsual_Variadic_anyParams struct { - recorder *moqUsual_Variadic_fnRecorder + recorder *moqUsual_Variadic_recorder +} + +// moqUsual_RepeatedIds_adaptor adapts moqUsual as needed by the runtime +type moqUsual_RepeatedIds_adaptor struct { + moq *moqUsual } // moqUsual_RepeatedIds_params holds the params of the Usual type @@ -10725,12 +6215,17 @@ type moqUsual_RepeatedIds_paramsKey struct { } } -// 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_results holds the results of the Usual type +type moqUsual_RepeatedIds_results struct { + sResult1, sResult2 string + err error +} + +// moqUsual_RepeatedIds_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_RepeatedIds_paramIndexing struct { + sParam1, sParam2 moq.ParamIndexing + bParam moq.ParamIndexing } // moqUsual_RepeatedIds_doFn defines the type of function needed when calling @@ -10741,36 +6236,26 @@ type moqUsual_RepeatedIds_doFn func(sParam1, sParam2 string, bParam bool) // 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_recorder routes recorded function calls to the moqUsual +// moq +type moqUsual_RepeatedIds_recorder struct { + recorder *impl.Recorder[ + *moqUsual_RepeatedIds_adaptor, + moqUsual_RepeatedIds_params, + moqUsual_RepeatedIds_paramsKey, + moqUsual_RepeatedIds_results, + ] } // moqUsual_RepeatedIds_anyParams isolates the any params functions of the // Usual type type moqUsual_RepeatedIds_anyParams struct { - recorder *moqUsual_RepeatedIds_fnRecorder + recorder *moqUsual_RepeatedIds_recorder +} + +// moqUsual_Times_adaptor adapts moqUsual as needed by the runtime +type moqUsual_Times_adaptor struct { + moq *moqUsual } // moqUsual_Times_params holds the params of the Usual type @@ -10791,12 +6276,17 @@ type moqUsual_Times_paramsKey struct { } } -// 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_results holds the results of the Usual type +type moqUsual_Times_results struct { + sResult string + err error +} + +// moqUsual_Times_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_Times_paramIndexing struct { + sParam moq.ParamIndexing + times moq.ParamIndexing } // moqUsual_Times_doFn defines the type of function needed when calling andDo @@ -10807,34 +6297,25 @@ type moqUsual_Times_doFn func(sParam string, times bool) // 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_recorder routes recorded function calls to the moqUsual moq +type moqUsual_Times_recorder struct { + recorder *impl.Recorder[ + *moqUsual_Times_adaptor, + moqUsual_Times_params, + moqUsual_Times_paramsKey, + moqUsual_Times_results, + ] } // moqUsual_Times_anyParams isolates the any params functions of the Usual type type moqUsual_Times_anyParams struct { - recorder *moqUsual_Times_fnRecorder + recorder *moqUsual_Times_recorder +} + +// moqUsual_DifficultParamNames_adaptor adapts moqUsual as needed by the +// runtime +type moqUsual_DifficultParamNames_adaptor struct { + moq *moqUsual } // moqUsual_DifficultParamNames_params holds the params of the Usual type @@ -10862,12 +6343,16 @@ type moqUsual_DifficultParamNames_paramsKey struct { } } -// 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_results holds the results of the Usual type +type moqUsual_DifficultParamNames_results struct{} + +// moqUsual_DifficultParamNames_paramIndexing holds the parameter indexing +// runtime configuration for the Usual type +type moqUsual_DifficultParamNames_paramIndexing struct { + param1, param2 moq.ParamIndexing + param3 moq.ParamIndexing + param, param5, param6 moq.ParamIndexing + param7, param8, param9 moq.ParamIndexing } // moqUsual_DifficultParamNames_doFn defines the type of function needed when @@ -10878,33 +6363,27 @@ type moqUsual_DifficultParamNames_doFn func(m, r bool, sequence string, param, p // 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_recorder routes recorded function calls to the +// moqUsual moq +type moqUsual_DifficultParamNames_recorder struct { + recorder *impl.Recorder[ + *moqUsual_DifficultParamNames_adaptor, + moqUsual_DifficultParamNames_params, + moqUsual_DifficultParamNames_paramsKey, + moqUsual_DifficultParamNames_results, + ] } // moqUsual_DifficultParamNames_anyParams isolates the any params functions of // the Usual type type moqUsual_DifficultParamNames_anyParams struct { - recorder *moqUsual_DifficultParamNames_fnRecorder + recorder *moqUsual_DifficultParamNames_recorder +} + +// moqUsual_DifficultResultNames_adaptor adapts moqUsual as needed by the +// runtime +type moqUsual_DifficultResultNames_adaptor struct { + moq *moqUsual } // moqUsual_DifficultResultNames_params holds the params of the Usual type @@ -10917,14 +6396,18 @@ type moqUsual_DifficultResultNames_paramsKey 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_results holds the results of the Usual type +type moqUsual_DifficultResultNames_results struct { + result1, result2 string + result3 error + param, result5, result6 int + result7, result8, result9 float32 } +// moqUsual_DifficultResultNames_paramIndexing holds the parameter indexing +// runtime configuration for the Usual type +type moqUsual_DifficultResultNames_paramIndexing struct{} + // moqUsual_DifficultResultNames_doFn defines the type of function needed when // calling andDo for the Usual type type moqUsual_DifficultResultNames_doFn func() @@ -10933,38 +6416,26 @@ type moqUsual_DifficultResultNames_doFn func() // 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_recorder routes recorded function calls to the +// moqUsual moq +type moqUsual_DifficultResultNames_recorder struct { + recorder *impl.Recorder[ + *moqUsual_DifficultResultNames_adaptor, + moqUsual_DifficultResultNames_params, + moqUsual_DifficultResultNames_paramsKey, + moqUsual_DifficultResultNames_results, + ] } // moqUsual_DifficultResultNames_anyParams isolates the any params functions of // the Usual type type moqUsual_DifficultResultNames_anyParams struct { - recorder *moqUsual_DifficultResultNames_fnRecorder + recorder *moqUsual_DifficultResultNames_recorder +} + +// moqUsual_PassByArray_adaptor adapts moqUsual as needed by the runtime +type moqUsual_PassByArray_adaptor struct { + moq *moqUsual } // moqUsual_PassByArray_params holds the params of the Usual type @@ -10976,12 +6447,15 @@ type moqUsual_PassByArray_paramsKey struct { hashes struct{ p hash.Hash } } -// moqUsual_PassByArray_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_PassByArray_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_PassByArray_paramsKey]*moqUsual_PassByArray_results +// moqUsual_PassByArray_results holds the results of the Usual type +type moqUsual_PassByArray_results struct { + result1 [3]testmoqs.Results +} + +// moqUsual_PassByArray_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_PassByArray_paramIndexing struct { + p moq.ParamIndexing } // moqUsual_PassByArray_doFn defines the type of function needed when calling @@ -10992,35 +6466,26 @@ type moqUsual_PassByArray_doFn func(p [3]testmoqs.Params) // calling doReturnResults for the Usual type type moqUsual_PassByArray_doReturnFn func(p [3]testmoqs.Params) [3]testmoqs.Results -// moqUsual_PassByArray_results holds the results of the Usual type -type moqUsual_PassByArray_results struct { - params moqUsual_PassByArray_params - results []struct { - values *struct { - result1 [3]testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByArray_doFn - doReturnFn moqUsual_PassByArray_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsual_PassByArray_fnRecorder routes recorded function calls to the -// moqUsual moq -type moqUsual_PassByArray_fnRecorder struct { - params moqUsual_PassByArray_params - anyParams uint64 - sequence bool - results *moqUsual_PassByArray_results - moq *moqUsual +// moqUsual_PassByArray_recorder routes recorded function calls to the moqUsual +// moq +type moqUsual_PassByArray_recorder struct { + recorder *impl.Recorder[ + *moqUsual_PassByArray_adaptor, + moqUsual_PassByArray_params, + moqUsual_PassByArray_paramsKey, + moqUsual_PassByArray_results, + ] } // moqUsual_PassByArray_anyParams isolates the any params functions of the // Usual type type moqUsual_PassByArray_anyParams struct { - recorder *moqUsual_PassByArray_fnRecorder + recorder *moqUsual_PassByArray_recorder +} + +// moqUsual_PassByChan_adaptor adapts moqUsual as needed by the runtime +type moqUsual_PassByChan_adaptor struct { + moq *moqUsual } // moqUsual_PassByChan_params holds the params of the Usual type @@ -11032,12 +6497,15 @@ type moqUsual_PassByChan_paramsKey struct { hashes struct{ p hash.Hash } } -// moqUsual_PassByChan_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_PassByChan_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_PassByChan_paramsKey]*moqUsual_PassByChan_results +// moqUsual_PassByChan_results holds the results of the Usual type +type moqUsual_PassByChan_results struct { + result1 chan testmoqs.Results +} + +// moqUsual_PassByChan_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_PassByChan_paramIndexing struct { + p moq.ParamIndexing } // moqUsual_PassByChan_doFn defines the type of function needed when calling @@ -11048,35 +6516,26 @@ type moqUsual_PassByChan_doFn func(p chan testmoqs.Params) // calling doReturnResults for the Usual type type moqUsual_PassByChan_doReturnFn func(p chan testmoqs.Params) chan testmoqs.Results -// moqUsual_PassByChan_results holds the results of the Usual type -type moqUsual_PassByChan_results struct { - params moqUsual_PassByChan_params - results []struct { - values *struct { - result1 chan testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByChan_doFn - doReturnFn moqUsual_PassByChan_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsual_PassByChan_fnRecorder routes recorded function calls to the -// moqUsual moq -type moqUsual_PassByChan_fnRecorder struct { - params moqUsual_PassByChan_params - anyParams uint64 - sequence bool - results *moqUsual_PassByChan_results - moq *moqUsual +// moqUsual_PassByChan_recorder routes recorded function calls to the moqUsual +// moq +type moqUsual_PassByChan_recorder struct { + recorder *impl.Recorder[ + *moqUsual_PassByChan_adaptor, + moqUsual_PassByChan_params, + moqUsual_PassByChan_paramsKey, + moqUsual_PassByChan_results, + ] } // moqUsual_PassByChan_anyParams isolates the any params functions of the Usual // type type moqUsual_PassByChan_anyParams struct { - recorder *moqUsual_PassByChan_fnRecorder + recorder *moqUsual_PassByChan_recorder +} + +// moqUsual_PassByEllipsis_adaptor adapts moqUsual as needed by the runtime +type moqUsual_PassByEllipsis_adaptor struct { + moq *moqUsual } // moqUsual_PassByEllipsis_params holds the params of the Usual type @@ -11088,12 +6547,16 @@ type moqUsual_PassByEllipsis_paramsKey struct { hashes struct{ p hash.Hash } } -// moqUsual_PassByEllipsis_resultsByParams contains the results for a given set -// of parameters for the Usual type -type moqUsual_PassByEllipsis_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_PassByEllipsis_paramsKey]*moqUsual_PassByEllipsis_results +// moqUsual_PassByEllipsis_results holds the results of the Usual type +type moqUsual_PassByEllipsis_results struct { + result1 string + result2 error +} + +// moqUsual_PassByEllipsis_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_PassByEllipsis_paramIndexing struct { + p moq.ParamIndexing } // moqUsual_PassByEllipsis_doFn defines the type of function needed when @@ -11104,36 +6567,26 @@ type moqUsual_PassByEllipsis_doFn func(p ...testmoqs.Params) // calling doReturnResults for the Usual type type moqUsual_PassByEllipsis_doReturnFn func(p ...testmoqs.Params) (string, error) -// moqUsual_PassByEllipsis_results holds the results of the Usual type -type moqUsual_PassByEllipsis_results struct { - params moqUsual_PassByEllipsis_params - results []struct { - values *struct { - result1 string - result2 error - } - sequence uint32 - doFn moqUsual_PassByEllipsis_doFn - doReturnFn moqUsual_PassByEllipsis_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsual_PassByEllipsis_fnRecorder routes recorded function calls to the +// moqUsual_PassByEllipsis_recorder routes recorded function calls to the // moqUsual moq -type moqUsual_PassByEllipsis_fnRecorder struct { - params moqUsual_PassByEllipsis_params - anyParams uint64 - sequence bool - results *moqUsual_PassByEllipsis_results - moq *moqUsual +type moqUsual_PassByEllipsis_recorder struct { + recorder *impl.Recorder[ + *moqUsual_PassByEllipsis_adaptor, + moqUsual_PassByEllipsis_params, + moqUsual_PassByEllipsis_paramsKey, + moqUsual_PassByEllipsis_results, + ] } // moqUsual_PassByEllipsis_anyParams isolates the any params functions of the // Usual type type moqUsual_PassByEllipsis_anyParams struct { - recorder *moqUsual_PassByEllipsis_fnRecorder + recorder *moqUsual_PassByEllipsis_recorder +} + +// moqUsual_PassByMap_adaptor adapts moqUsual as needed by the runtime +type moqUsual_PassByMap_adaptor struct { + moq *moqUsual } // moqUsual_PassByMap_params holds the params of the Usual type @@ -11145,12 +6598,15 @@ type moqUsual_PassByMap_paramsKey struct { hashes struct{ p hash.Hash } } -// moqUsual_PassByMap_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_PassByMap_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_PassByMap_paramsKey]*moqUsual_PassByMap_results +// moqUsual_PassByMap_results holds the results of the Usual type +type moqUsual_PassByMap_results struct { + result1 map[string]testmoqs.Results +} + +// moqUsual_PassByMap_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_PassByMap_paramIndexing struct { + p moq.ParamIndexing } // moqUsual_PassByMap_doFn defines the type of function needed when calling @@ -11161,35 +6617,26 @@ type moqUsual_PassByMap_doFn func(p map[string]testmoqs.Params) // calling doReturnResults for the Usual type type moqUsual_PassByMap_doReturnFn func(p map[string]testmoqs.Params) map[string]testmoqs.Results -// moqUsual_PassByMap_results holds the results of the Usual type -type moqUsual_PassByMap_results struct { - params moqUsual_PassByMap_params - results []struct { - values *struct { - result1 map[string]testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByMap_doFn - doReturnFn moqUsual_PassByMap_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsual_PassByMap_fnRecorder routes recorded function calls to the moqUsual +// moqUsual_PassByMap_recorder routes recorded function calls to the moqUsual // moq -type moqUsual_PassByMap_fnRecorder struct { - params moqUsual_PassByMap_params - anyParams uint64 - sequence bool - results *moqUsual_PassByMap_results - moq *moqUsual +type moqUsual_PassByMap_recorder struct { + recorder *impl.Recorder[ + *moqUsual_PassByMap_adaptor, + moqUsual_PassByMap_params, + moqUsual_PassByMap_paramsKey, + moqUsual_PassByMap_results, + ] } // moqUsual_PassByMap_anyParams isolates the any params functions of the Usual // type type moqUsual_PassByMap_anyParams struct { - recorder *moqUsual_PassByMap_fnRecorder + recorder *moqUsual_PassByMap_recorder +} + +// moqUsual_PassByReference_adaptor adapts moqUsual as needed by the runtime +type moqUsual_PassByReference_adaptor struct { + moq *moqUsual } // moqUsual_PassByReference_params holds the params of the Usual type @@ -11202,12 +6649,15 @@ type moqUsual_PassByReference_paramsKey struct { 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_results holds the results of the Usual type +type moqUsual_PassByReference_results struct { + result1 *testmoqs.Results +} + +// moqUsual_PassByReference_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_PassByReference_paramIndexing struct { + p moq.ParamIndexing } // moqUsual_PassByReference_doFn defines the type of function needed when @@ -11218,35 +6668,26 @@ type moqUsual_PassByReference_doFn func(p *testmoqs.Params) // calling doReturnResults for the Usual type type moqUsual_PassByReference_doReturnFn func(p *testmoqs.Params) *testmoqs.Results -// moqUsual_PassByReference_results holds the results of the Usual type -type moqUsual_PassByReference_results struct { - params moqUsual_PassByReference_params - results []struct { - values *struct { - result1 *testmoqs.Results - } - 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_PassByReference_recorder 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 +type moqUsual_PassByReference_recorder struct { + recorder *impl.Recorder[ + *moqUsual_PassByReference_adaptor, + moqUsual_PassByReference_params, + moqUsual_PassByReference_paramsKey, + moqUsual_PassByReference_results, + ] } // moqUsual_PassByReference_anyParams isolates the any params functions of the // Usual type type moqUsual_PassByReference_anyParams struct { - recorder *moqUsual_PassByReference_fnRecorder + recorder *moqUsual_PassByReference_recorder +} + +// moqUsual_PassBySlice_adaptor adapts moqUsual as needed by the runtime +type moqUsual_PassBySlice_adaptor struct { + moq *moqUsual } // moqUsual_PassBySlice_params holds the params of the Usual type @@ -11258,12 +6699,15 @@ type moqUsual_PassBySlice_paramsKey struct { hashes struct{ p hash.Hash } } -// moqUsual_PassBySlice_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_PassBySlice_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_PassBySlice_paramsKey]*moqUsual_PassBySlice_results +// moqUsual_PassBySlice_results holds the results of the Usual type +type moqUsual_PassBySlice_results struct { + result1 []testmoqs.Results +} + +// moqUsual_PassBySlice_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_PassBySlice_paramIndexing struct { + p moq.ParamIndexing } // moqUsual_PassBySlice_doFn defines the type of function needed when calling @@ -11274,35 +6718,26 @@ type moqUsual_PassBySlice_doFn func(p []testmoqs.Params) // calling doReturnResults for the Usual type type moqUsual_PassBySlice_doReturnFn func(p []testmoqs.Params) []testmoqs.Results -// moqUsual_PassBySlice_results holds the results of the Usual type -type moqUsual_PassBySlice_results struct { - params moqUsual_PassBySlice_params - results []struct { - values *struct { - result1 []testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassBySlice_doFn - doReturnFn moqUsual_PassBySlice_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsual_PassBySlice_fnRecorder routes recorded function calls to the -// moqUsual moq -type moqUsual_PassBySlice_fnRecorder struct { - params moqUsual_PassBySlice_params - anyParams uint64 - sequence bool - results *moqUsual_PassBySlice_results - moq *moqUsual +// moqUsual_PassBySlice_recorder routes recorded function calls to the moqUsual +// moq +type moqUsual_PassBySlice_recorder struct { + recorder *impl.Recorder[ + *moqUsual_PassBySlice_adaptor, + moqUsual_PassBySlice_params, + moqUsual_PassBySlice_paramsKey, + moqUsual_PassBySlice_results, + ] } // moqUsual_PassBySlice_anyParams isolates the any params functions of the // Usual type type moqUsual_PassBySlice_anyParams struct { - recorder *moqUsual_PassBySlice_fnRecorder + recorder *moqUsual_PassBySlice_recorder +} + +// moqUsual_PassByValue_adaptor adapts moqUsual as needed by the runtime +type moqUsual_PassByValue_adaptor struct { + moq *moqUsual } // moqUsual_PassByValue_params holds the params of the Usual type @@ -11314,12 +6749,15 @@ type moqUsual_PassByValue_paramsKey struct { hashes struct{ p hash.Hash } } -// moqUsual_PassByValue_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_PassByValue_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_PassByValue_paramsKey]*moqUsual_PassByValue_results +// moqUsual_PassByValue_results holds the results of the Usual type +type moqUsual_PassByValue_results struct { + result1 testmoqs.Results +} + +// moqUsual_PassByValue_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_PassByValue_paramIndexing struct { + p moq.ParamIndexing } // moqUsual_PassByValue_doFn defines the type of function needed when calling @@ -11330,35 +6768,26 @@ type moqUsual_PassByValue_doFn func(p testmoqs.Params) // calling doReturnResults for the Usual type type moqUsual_PassByValue_doReturnFn func(p testmoqs.Params) testmoqs.Results -// moqUsual_PassByValue_results holds the results of the Usual type -type moqUsual_PassByValue_results struct { - params moqUsual_PassByValue_params - results []struct { - values *struct { - result1 testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByValue_doFn - doReturnFn moqUsual_PassByValue_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsual_PassByValue_fnRecorder routes recorded function calls to the -// moqUsual moq -type moqUsual_PassByValue_fnRecorder struct { - params moqUsual_PassByValue_params - anyParams uint64 - sequence bool - results *moqUsual_PassByValue_results - moq *moqUsual +// moqUsual_PassByValue_recorder routes recorded function calls to the moqUsual +// moq +type moqUsual_PassByValue_recorder struct { + recorder *impl.Recorder[ + *moqUsual_PassByValue_adaptor, + moqUsual_PassByValue_params, + moqUsual_PassByValue_paramsKey, + moqUsual_PassByValue_results, + ] } // moqUsual_PassByValue_anyParams isolates the any params functions of the // Usual type type moqUsual_PassByValue_anyParams struct { - recorder *moqUsual_PassByValue_fnRecorder + recorder *moqUsual_PassByValue_recorder +} + +// moqUsual_InterfaceParam_adaptor adapts moqUsual as needed by the runtime +type moqUsual_InterfaceParam_adaptor struct { + moq *moqUsual } // moqUsual_InterfaceParam_params holds the params of the Usual type @@ -11370,12 +6799,16 @@ type moqUsual_InterfaceParam_paramsKey struct { 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_results holds the results of the Usual type +type moqUsual_InterfaceParam_results struct { + sResult string + err error +} + +// moqUsual_InterfaceParam_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_InterfaceParam_paramIndexing struct { + w moq.ParamIndexing } // moqUsual_InterfaceParam_doFn defines the type of function needed when @@ -11386,36 +6819,26 @@ type moqUsual_InterfaceParam_doFn func(w io.Writer) // 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_InterfaceParam_recorder 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 +type moqUsual_InterfaceParam_recorder struct { + recorder *impl.Recorder[ + *moqUsual_InterfaceParam_adaptor, + moqUsual_InterfaceParam_params, + moqUsual_InterfaceParam_paramsKey, + moqUsual_InterfaceParam_results, + ] } // moqUsual_InterfaceParam_anyParams isolates the any params functions of the // Usual type type moqUsual_InterfaceParam_anyParams struct { - recorder *moqUsual_InterfaceParam_fnRecorder + recorder *moqUsual_InterfaceParam_recorder +} + +// moqUsual_InterfaceResult_adaptor adapts moqUsual as needed by the runtime +type moqUsual_InterfaceResult_adaptor struct { + moq *moqUsual } // moqUsual_InterfaceResult_params holds the params of the Usual type @@ -11437,12 +6860,14 @@ type moqUsual_InterfaceResult_paramsKey struct { } } -// 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_results holds the results of the Usual type +type moqUsual_InterfaceResult_results struct{ result1 io.Reader } + +// moqUsual_InterfaceResult_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_InterfaceResult_paramIndexing struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing } // moqUsual_InterfaceResult_doFn defines the type of function needed when @@ -11453,33 +6878,26 @@ type moqUsual_InterfaceResult_doFn func(sParam string, bParam bool) // 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_InterfaceResult_recorder 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 +type moqUsual_InterfaceResult_recorder struct { + recorder *impl.Recorder[ + *moqUsual_InterfaceResult_adaptor, + moqUsual_InterfaceResult_params, + moqUsual_InterfaceResult_paramsKey, + moqUsual_InterfaceResult_results, + ] } // moqUsual_InterfaceResult_anyParams isolates the any params functions of the // Usual type type moqUsual_InterfaceResult_anyParams struct { - recorder *moqUsual_InterfaceResult_fnRecorder + recorder *moqUsual_InterfaceResult_recorder +} + +// moqUsual_FnParam_adaptor adapts moqUsual as needed by the runtime +type moqUsual_FnParam_adaptor struct { + moq *moqUsual } // moqUsual_FnParam_params holds the params of the Usual type @@ -11491,12 +6909,13 @@ type moqUsual_FnParam_paramsKey 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_results holds the results of the Usual type +type moqUsual_FnParam_results struct{} + +// moqUsual_FnParam_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_FnParam_paramIndexing struct { + fn moq.ParamIndexing } // moqUsual_FnParam_doFn defines the type of function needed when calling andDo @@ -11507,33 +6926,25 @@ type moqUsual_FnParam_doFn func(fn func()) // 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_recorder routes recorded function calls to the moqUsual moq +type moqUsual_FnParam_recorder struct { + recorder *impl.Recorder[ + *moqUsual_FnParam_adaptor, + moqUsual_FnParam_params, + moqUsual_FnParam_paramsKey, + moqUsual_FnParam_results, + ] } // moqUsual_FnParam_anyParams isolates the any params functions of the Usual // type type moqUsual_FnParam_anyParams struct { - recorder *moqUsual_FnParam_fnRecorder + recorder *moqUsual_FnParam_recorder +} + +// moqUsual_Other_adaptor adapts moqUsual as needed by the runtime +type moqUsual_Other_adaptor struct { + moq *moqUsual } // moqUsual_Other_params holds the params of the Usual type @@ -11545,12 +6956,15 @@ type moqUsual_Other_paramsKey struct { hashes struct{ param1 hash.Hash } } -// moqUsual_Other_resultsByParams contains the results for a given set of -// parameters for the Usual type -type moqUsual_Other_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUsual_Other_paramsKey]*moqUsual_Other_results +// moqUsual_Other_results holds the results of the Usual type +type moqUsual_Other_results struct { + result1 other.Results +} + +// moqUsual_Other_paramIndexing holds the parameter indexing runtime +// configuration for the Usual type +type moqUsual_Other_paramIndexing struct { + param1 moq.ParamIndexing } // moqUsual_Other_doFn defines the type of function needed when calling andDo @@ -11561,253 +6975,225 @@ type moqUsual_Other_doFn func(other.Params) // doReturnResults for the Usual type type moqUsual_Other_doReturnFn func(other.Params) other.Results -// moqUsual_Other_results holds the results of the Usual type -type moqUsual_Other_results struct { - params moqUsual_Other_params - results []struct { - values *struct { - result1 other.Results - } - sequence uint32 - doFn moqUsual_Other_doFn - doReturnFn moqUsual_Other_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqUsual_Other_fnRecorder routes recorded function calls to the moqUsual moq -type moqUsual_Other_fnRecorder struct { - params moqUsual_Other_params - anyParams uint64 - sequence bool - results *moqUsual_Other_results - moq *moqUsual +// moqUsual_Other_recorder routes recorded function calls to the moqUsual moq +type moqUsual_Other_recorder struct { + recorder *impl.Recorder[ + *moqUsual_Other_adaptor, + moqUsual_Other_params, + moqUsual_Other_paramsKey, + moqUsual_Other_results, + ] } // moqUsual_Other_anyParams isolates the any params functions of the Usual type type moqUsual_Other_anyParams struct { - recorder *moqUsual_Other_fnRecorder + recorder *moqUsual_Other_recorder } // newMoqUsual creates a new moq of the Usual type func newMoqUsual(scene *moq.Scene, config *moq.Config) *moqUsual { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqUsual_Usual_adaptor{} + adaptor2 := &moqUsual_NoNames_adaptor{} + adaptor3 := &moqUsual_NoResults_adaptor{} + adaptor4 := &moqUsual_NoParams_adaptor{} + adaptor5 := &moqUsual_Nothing_adaptor{} + adaptor6 := &moqUsual_Variadic_adaptor{} + adaptor7 := &moqUsual_RepeatedIds_adaptor{} + adaptor8 := &moqUsual_Times_adaptor{} + adaptor9 := &moqUsual_DifficultParamNames_adaptor{} + adaptor10 := &moqUsual_DifficultResultNames_adaptor{} + adaptor11 := &moqUsual_PassByArray_adaptor{} + adaptor12 := &moqUsual_PassByChan_adaptor{} + adaptor13 := &moqUsual_PassByEllipsis_adaptor{} + adaptor14 := &moqUsual_PassByMap_adaptor{} + adaptor15 := &moqUsual_PassByReference_adaptor{} + adaptor16 := &moqUsual_PassBySlice_adaptor{} + adaptor17 := &moqUsual_PassByValue_adaptor{} + adaptor18 := &moqUsual_InterfaceParam_adaptor{} + adaptor19 := &moqUsual_InterfaceResult_adaptor{} + adaptor20 := &moqUsual_FnParam_adaptor{} + adaptor21 := &moqUsual_Other_adaptor{} 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{} - PassByArray struct { - p moq.ParamIndexing - } - PassByChan struct { - p moq.ParamIndexing - } - PassByEllipsis struct { - p moq.ParamIndexing - } - PassByMap struct { - p moq.ParamIndexing - } - PassByReference struct { - p moq.ParamIndexing - } - PassBySlice struct { - p moq.ParamIndexing - } - PassByValue struct { - p moq.ParamIndexing - } - InterfaceParam struct { - w moq.ParamIndexing - } - InterfaceResult struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - FnParam struct { - fn moq.ParamIndexing - } - Other struct { - param1 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{} - PassByArray struct { - p moq.ParamIndexing - } - PassByChan struct { - p moq.ParamIndexing - } - PassByEllipsis struct { - p moq.ParamIndexing - } - PassByMap struct { - p moq.ParamIndexing - } - PassByReference struct { - p moq.ParamIndexing - } - PassBySlice struct { - p moq.ParamIndexing - } - PassByValue struct { - p moq.ParamIndexing - } - InterfaceParam struct { - w moq.ParamIndexing - } - InterfaceResult struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - } - FnParam struct { - fn moq.ParamIndexing - } - Other struct { - param1 moq.ParamIndexing - } + moq: &moqUsual_mock{}, + + moq_Usual: impl.NewMoq[ + *moqUsual_Usual_adaptor, + moqUsual_Usual_params, + moqUsual_Usual_paramsKey, + moqUsual_Usual_results, + ](scene, adaptor1, config), + moq_NoNames: impl.NewMoq[ + *moqUsual_NoNames_adaptor, + moqUsual_NoNames_params, + moqUsual_NoNames_paramsKey, + moqUsual_NoNames_results, + ](scene, adaptor2, config), + moq_NoResults: impl.NewMoq[ + *moqUsual_NoResults_adaptor, + moqUsual_NoResults_params, + moqUsual_NoResults_paramsKey, + moqUsual_NoResults_results, + ](scene, adaptor3, config), + moq_NoParams: impl.NewMoq[ + *moqUsual_NoParams_adaptor, + moqUsual_NoParams_params, + moqUsual_NoParams_paramsKey, + moqUsual_NoParams_results, + ](scene, adaptor4, config), + moq_Nothing: impl.NewMoq[ + *moqUsual_Nothing_adaptor, + moqUsual_Nothing_params, + moqUsual_Nothing_paramsKey, + moqUsual_Nothing_results, + ](scene, adaptor5, config), + moq_Variadic: impl.NewMoq[ + *moqUsual_Variadic_adaptor, + moqUsual_Variadic_params, + moqUsual_Variadic_paramsKey, + moqUsual_Variadic_results, + ](scene, adaptor6, config), + moq_RepeatedIds: impl.NewMoq[ + *moqUsual_RepeatedIds_adaptor, + moqUsual_RepeatedIds_params, + moqUsual_RepeatedIds_paramsKey, + moqUsual_RepeatedIds_results, + ](scene, adaptor7, config), + moq_Times: impl.NewMoq[ + *moqUsual_Times_adaptor, + moqUsual_Times_params, + moqUsual_Times_paramsKey, + moqUsual_Times_results, + ](scene, adaptor8, config), + moq_DifficultParamNames: impl.NewMoq[ + *moqUsual_DifficultParamNames_adaptor, + moqUsual_DifficultParamNames_params, + moqUsual_DifficultParamNames_paramsKey, + moqUsual_DifficultParamNames_results, + ](scene, adaptor9, config), + moq_DifficultResultNames: impl.NewMoq[ + *moqUsual_DifficultResultNames_adaptor, + moqUsual_DifficultResultNames_params, + moqUsual_DifficultResultNames_paramsKey, + moqUsual_DifficultResultNames_results, + ](scene, adaptor10, config), + moq_PassByArray: impl.NewMoq[ + *moqUsual_PassByArray_adaptor, + moqUsual_PassByArray_params, + moqUsual_PassByArray_paramsKey, + moqUsual_PassByArray_results, + ](scene, adaptor11, config), + moq_PassByChan: impl.NewMoq[ + *moqUsual_PassByChan_adaptor, + moqUsual_PassByChan_params, + moqUsual_PassByChan_paramsKey, + moqUsual_PassByChan_results, + ](scene, adaptor12, config), + moq_PassByEllipsis: impl.NewMoq[ + *moqUsual_PassByEllipsis_adaptor, + moqUsual_PassByEllipsis_params, + moqUsual_PassByEllipsis_paramsKey, + moqUsual_PassByEllipsis_results, + ](scene, adaptor13, config), + moq_PassByMap: impl.NewMoq[ + *moqUsual_PassByMap_adaptor, + moqUsual_PassByMap_params, + moqUsual_PassByMap_paramsKey, + moqUsual_PassByMap_results, + ](scene, adaptor14, config), + moq_PassByReference: impl.NewMoq[ + *moqUsual_PassByReference_adaptor, + moqUsual_PassByReference_params, + moqUsual_PassByReference_paramsKey, + moqUsual_PassByReference_results, + ](scene, adaptor15, config), + moq_PassBySlice: impl.NewMoq[ + *moqUsual_PassBySlice_adaptor, + moqUsual_PassBySlice_params, + moqUsual_PassBySlice_paramsKey, + moqUsual_PassBySlice_results, + ](scene, adaptor16, config), + moq_PassByValue: impl.NewMoq[ + *moqUsual_PassByValue_adaptor, + moqUsual_PassByValue_params, + moqUsual_PassByValue_paramsKey, + moqUsual_PassByValue_results, + ](scene, adaptor17, config), + moq_InterfaceParam: impl.NewMoq[ + *moqUsual_InterfaceParam_adaptor, + moqUsual_InterfaceParam_params, + moqUsual_InterfaceParam_paramsKey, + moqUsual_InterfaceParam_results, + ](scene, adaptor18, config), + moq_InterfaceResult: impl.NewMoq[ + *moqUsual_InterfaceResult_adaptor, + moqUsual_InterfaceResult_params, + moqUsual_InterfaceResult_paramsKey, + moqUsual_InterfaceResult_results, + ](scene, adaptor19, config), + moq_FnParam: impl.NewMoq[ + *moqUsual_FnParam_adaptor, + moqUsual_FnParam_params, + moqUsual_FnParam_paramsKey, + moqUsual_FnParam_results, + ](scene, adaptor20, config), + moq_Other: impl.NewMoq[ + *moqUsual_Other_adaptor, + moqUsual_Other_params, + moqUsual_Other_paramsKey, + moqUsual_Other_results, + ](scene, adaptor21, config), + + runtime: moqUsual_runtime{parameterIndexing: struct { + Usual moqUsual_Usual_paramIndexing + NoNames moqUsual_NoNames_paramIndexing + NoResults moqUsual_NoResults_paramIndexing + NoParams moqUsual_NoParams_paramIndexing + Nothing moqUsual_Nothing_paramIndexing + Variadic moqUsual_Variadic_paramIndexing + RepeatedIds moqUsual_RepeatedIds_paramIndexing + Times moqUsual_Times_paramIndexing + DifficultParamNames moqUsual_DifficultParamNames_paramIndexing + DifficultResultNames moqUsual_DifficultResultNames_paramIndexing + PassByArray moqUsual_PassByArray_paramIndexing + PassByChan moqUsual_PassByChan_paramIndexing + PassByEllipsis moqUsual_PassByEllipsis_paramIndexing + PassByMap moqUsual_PassByMap_paramIndexing + PassByReference moqUsual_PassByReference_paramIndexing + PassBySlice moqUsual_PassBySlice_paramIndexing + PassByValue moqUsual_PassByValue_paramIndexing + InterfaceParam moqUsual_InterfaceParam_paramIndexing + InterfaceResult moqUsual_InterfaceResult_paramIndexing + FnParam moqUsual_FnParam_paramIndexing + Other moqUsual_Other_paramIndexing }{ - Usual: struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - }{ + Usual: moqUsual_Usual_paramIndexing{ sParam: moq.ParamIndexByValue, bParam: moq.ParamIndexByValue, }, - NoNames: struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - }{ + NoNames: moqUsual_NoNames_paramIndexing{ param1: moq.ParamIndexByValue, param2: moq.ParamIndexByValue, }, - NoResults: struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - }{ + NoResults: moqUsual_NoResults_paramIndexing{ sParam: moq.ParamIndexByValue, bParam: moq.ParamIndexByValue, }, - NoParams: struct{}{}, - Nothing: struct{}{}, - Variadic: struct { - other moq.ParamIndexing - args moq.ParamIndexing - }{ + NoParams: moqUsual_NoParams_paramIndexing{}, + Nothing: moqUsual_Nothing_paramIndexing{}, + Variadic: moqUsual_Variadic_paramIndexing{ other: moq.ParamIndexByValue, args: moq.ParamIndexByHash, }, - RepeatedIds: struct { - sParam1 moq.ParamIndexing - sParam2 moq.ParamIndexing - bParam moq.ParamIndexing - }{ + RepeatedIds: moqUsual_RepeatedIds_paramIndexing{ sParam1: moq.ParamIndexByValue, sParam2: moq.ParamIndexByValue, bParam: moq.ParamIndexByValue, }, - Times: struct { - sParam moq.ParamIndexing - times moq.ParamIndexing - }{ + Times: moqUsual_Times_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 - }{ + DifficultParamNames: moqUsual_DifficultParamNames_paramIndexing{ param1: moq.ParamIndexByValue, param2: moq.ParamIndexByValue, param3: moq.ParamIndexByValue, @@ -11818,68 +7204,67 @@ func newMoqUsual(scene *moq.Scene, config *moq.Config) *moqUsual { param8: moq.ParamIndexByValue, param9: moq.ParamIndexByValue, }, - DifficultResultNames: struct{}{}, - PassByArray: struct { - p moq.ParamIndexing - }{ + DifficultResultNames: moqUsual_DifficultResultNames_paramIndexing{}, + PassByArray: moqUsual_PassByArray_paramIndexing{ p: moq.ParamIndexByValue, }, - PassByChan: struct { - p moq.ParamIndexing - }{ + PassByChan: moqUsual_PassByChan_paramIndexing{ p: moq.ParamIndexByValue, }, - PassByEllipsis: struct { - p moq.ParamIndexing - }{ + PassByEllipsis: moqUsual_PassByEllipsis_paramIndexing{ p: moq.ParamIndexByHash, }, - PassByMap: struct { - p moq.ParamIndexing - }{ + PassByMap: moqUsual_PassByMap_paramIndexing{ p: moq.ParamIndexByHash, }, - PassByReference: struct { - p moq.ParamIndexing - }{ + PassByReference: moqUsual_PassByReference_paramIndexing{ p: moq.ParamIndexByHash, }, - PassBySlice: struct { - p moq.ParamIndexing - }{ + PassBySlice: moqUsual_PassBySlice_paramIndexing{ p: moq.ParamIndexByHash, }, - PassByValue: struct { - p moq.ParamIndexing - }{ + PassByValue: moqUsual_PassByValue_paramIndexing{ p: moq.ParamIndexByValue, }, - InterfaceParam: struct { - w moq.ParamIndexing - }{ + InterfaceParam: moqUsual_InterfaceParam_paramIndexing{ w: moq.ParamIndexByHash, }, - InterfaceResult: struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - }{ + InterfaceResult: moqUsual_InterfaceResult_paramIndexing{ sParam: moq.ParamIndexByValue, bParam: moq.ParamIndexByValue, }, - FnParam: struct { - fn moq.ParamIndexing - }{ + FnParam: moqUsual_FnParam_paramIndexing{ fn: moq.ParamIndexByHash, }, - Other: struct { - param1 moq.ParamIndexing - }{ + Other: moqUsual_Other_paramIndexing{ param1: moq.ParamIndexByValue, }, }}, } m.moq.moq = m + adaptor1.moq = m + adaptor2.moq = m + adaptor3.moq = m + adaptor4.moq = m + adaptor5.moq = m + adaptor6.moq = m + adaptor7.moq = m + adaptor8.moq = m + adaptor9.moq = m + adaptor10.moq = m + adaptor11.moq = m + adaptor12.moq = m + adaptor13.moq = m + adaptor14.moq = m + adaptor15.moq = m + adaptor16.moq = m + adaptor17.moq = m + adaptor18.moq = m + adaptor19.moq = m + adaptor20.moq = m + adaptor21.moq = m + scene.AddMoq(m) return m } @@ -11887,436 +7272,121 @@ func newMoqUsual(scene *moq.Scene, config *moq.Config) *moqUsual { // 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() +func (m *moqUsual_mock) Usual(sParam string, bParam bool) (string, error) { + m.moq.moq_Usual.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)) - } + var result1 string + var result2 error + if result := m.moq.moq_Usual.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } - - 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 + return result1, result2 } -func (m *moqUsual_mock) NoNames(param1 string, param2 bool) (result1 string, result2 error) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) NoNames(param1 string, param2 bool) (string, error) { + m.moq.moq_NoNames.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)) - } + var result1 string + var result2 error + if result := m.moq.moq_NoNames.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - - 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 + return result1, result2 } func (m *moqUsual_mock) NoResults(sParam string, bParam bool) { - m.moq.scene.T.Helper() + m.moq.moq_NoResults.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 + m.moq.moq_NoResults.Function(params) } -func (m *moqUsual_mock) NoParams() (sResult string, err error) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) NoParams() (string, error) { + m.moq.moq_NoParams.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 + var result1 string + var result2 error + if result := m.moq.moq_NoParams.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } - - 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 + return result1, result2 } func (m *moqUsual_mock) Nothing() { - m.moq.scene.T.Helper() + m.moq.moq_Nothing.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 + m.moq.moq_Nothing.Function(params) } -func (m *moqUsual_mock) Variadic(other bool, args ...string) (sResult string, err error) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) Variadic(other bool, args ...string) (string, error) { + m.moq.moq_Variadic.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...) + var result1 string + var result2 error + if result := m.moq.moq_Variadic.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } - - if result.values != nil { - sResult = result.values.sResult - err = result.values.err - } - if result.doReturnFn != nil { - sResult, err = result.doReturnFn(other, args...) - } - return + return result1, result2 } -func (m *moqUsual_mock) RepeatedIds(sParam1, sParam2 string, bParam bool) (sResult1, sResult2 string, err error) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) RepeatedIds(sParam1, sParam2 string, bParam bool) (string, string, error) { + m.moq.moq_RepeatedIds.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 + var result1 string + var result2 string + var result3 error + if result := m.moq.moq_RepeatedIds.Function(params); result != nil { + result1 = result.sResult1 + result2 = result.sResult2 + result3 = result.err } - - 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 + return result1, result2, result3 } -func (m *moqUsual_mock) Times(sParam string, times bool) (sResult string, err error) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) Times(sParam string, times bool) (string, error) { + m.moq.moq_Times.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 + var result1 string + var result2 error + if result := m.moq.moq_Times.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } - if result.doReturnFn != nil { - sResult, err = result.doReturnFn(sParam, times) - } - return + return result1, result2 } func (m *moqUsual_mock) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) { - m.moq.scene.T.Helper() + m.moq.moq_DifficultParamNames.Scene.T.Helper() params := moqUsual_DifficultParamNames_params{ param1: param1, param2: param2, @@ -12328,691 +7398,179 @@ func (m *moqUsual_mock) DifficultParamNames(param1, param2 bool, param3 string, 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 + m.moq.moq_DifficultParamNames.Function(params) } -func (m *moqUsual_mock) DifficultResultNames() (result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) DifficultResultNames() (string, string, error, int, int, int, float32, float32, float32) { + m.moq.moq_DifficultResultNames.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) PassByArray(p [3]testmoqs.Params) (result1 [3]testmoqs.Results) { - m.moq.scene.T.Helper() + var result1 string + var result2 string + var result3 error + var result4 int + var result5 int + var result6 int + var result7 float32 + var result8 float32 + var result9 float32 + if result := m.moq.moq_DifficultResultNames.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 + result3 = result.result3 + result4 = result.param + result5 = result.result5 + result6 = result.result6 + result7 = result.result7 + result8 = result.result8 + result9 = result.result9 + } + return result1, result2, result3, result4, result5, result6, result7, result8, result9 +} + +func (m *moqUsual_mock) PassByArray(p [3]testmoqs.Params) [3]testmoqs.Results { + m.moq.moq_PassByArray.Scene.T.Helper() params := moqUsual_PassByArray_params{ p: p, } - var results *moqUsual_PassByArray_results - for _, resultsByParams := range m.moq.resultsByParams_PassByArray { - paramsKey := m.moq.paramsKey_PassByArray(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_PassByArray(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_PassByArray(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_PassByArray(params)) - } - } - if result.doFn != nil { - result.doFn(p) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) + var result1 [3]testmoqs.Results + if result := m.moq.moq_PassByArray.Function(params); result != nil { + result1 = result.result1 } - return + return result1 } -func (m *moqUsual_mock) PassByChan(p chan testmoqs.Params) (result1 chan testmoqs.Results) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) PassByChan(p chan testmoqs.Params) chan testmoqs.Results { + m.moq.moq_PassByChan.Scene.T.Helper() params := moqUsual_PassByChan_params{ p: p, } - var results *moqUsual_PassByChan_results - for _, resultsByParams := range m.moq.resultsByParams_PassByChan { - paramsKey := m.moq.paramsKey_PassByChan(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_PassByChan(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_PassByChan(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_PassByChan(params)) - } - } - if result.doFn != nil { - result.doFn(p) + var result1 chan testmoqs.Results + if result := m.moq.moq_PassByChan.Function(params); result != nil { + result1 = result.result1 } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) - } - return + return result1 } -func (m *moqUsual_mock) PassByEllipsis(p ...testmoqs.Params) (result1 string, result2 error) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) PassByEllipsis(p ...testmoqs.Params) (string, error) { + m.moq.moq_PassByEllipsis.Scene.T.Helper() params := moqUsual_PassByEllipsis_params{ p: p, } - var results *moqUsual_PassByEllipsis_results - for _, resultsByParams := range m.moq.resultsByParams_PassByEllipsis { - paramsKey := m.moq.paramsKey_PassByEllipsis(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_PassByEllipsis(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_PassByEllipsis(params)) - } - return - } - i = results.repeat.ResultCount - 1 + var result1 string + var result2 error + if result := m.moq.moq_PassByEllipsis.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - - 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_PassByEllipsis(params)) - } - } - - if result.doFn != nil { - result.doFn(p...) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(p...) - } - return + return result1, result2 } -func (m *moqUsual_mock) PassByMap(p map[string]testmoqs.Params) (result1 map[string]testmoqs.Results) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) PassByMap(p map[string]testmoqs.Params) map[string]testmoqs.Results { + m.moq.moq_PassByMap.Scene.T.Helper() params := moqUsual_PassByMap_params{ p: p, } - var results *moqUsual_PassByMap_results - for _, resultsByParams := range m.moq.resultsByParams_PassByMap { - paramsKey := m.moq.paramsKey_PassByMap(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_PassByMap(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_PassByMap(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_PassByMap(params)) - } - } - - if result.doFn != nil { - result.doFn(p) - } - - if result.values != nil { - result1 = result.values.result1 + var result1 map[string]testmoqs.Results + if result := m.moq.moq_PassByMap.Function(params); result != nil { + result1 = result.result1 } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) - } - return + return result1 } -func (m *moqUsual_mock) PassByReference(p *testmoqs.Params) (result1 *testmoqs.Results) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) PassByReference(p *testmoqs.Params) *testmoqs.Results { + m.moq.moq_PassByReference.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 { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) + var result1 *testmoqs.Results + if result := m.moq.moq_PassByReference.Function(params); result != nil { + result1 = result.result1 } - return + return result1 } -func (m *moqUsual_mock) PassBySlice(p []testmoqs.Params) (result1 []testmoqs.Results) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) PassBySlice(p []testmoqs.Params) []testmoqs.Results { + m.moq.moq_PassBySlice.Scene.T.Helper() params := moqUsual_PassBySlice_params{ p: p, } - var results *moqUsual_PassBySlice_results - for _, resultsByParams := range m.moq.resultsByParams_PassBySlice { - paramsKey := m.moq.paramsKey_PassBySlice(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_PassBySlice(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_PassBySlice(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_PassBySlice(params)) - } - } - - if result.doFn != nil { - result.doFn(p) - } - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) + var result1 []testmoqs.Results + if result := m.moq.moq_PassBySlice.Function(params); result != nil { + result1 = result.result1 } - return + return result1 } -func (m *moqUsual_mock) PassByValue(p testmoqs.Params) (result1 testmoqs.Results) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) PassByValue(p testmoqs.Params) testmoqs.Results { + m.moq.moq_PassByValue.Scene.T.Helper() params := moqUsual_PassByValue_params{ p: p, } - var results *moqUsual_PassByValue_results - for _, resultsByParams := range m.moq.resultsByParams_PassByValue { - paramsKey := m.moq.paramsKey_PassByValue(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_PassByValue(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_PassByValue(params)) - } - return - } - i = results.repeat.ResultCount - 1 + var result1 testmoqs.Results + if result := m.moq.moq_PassByValue.Function(params); result != nil { + result1 = result.result1 } - - 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_PassByValue(params)) - } - } - - if result.doFn != nil { - result.doFn(p) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(p) - } - return + return result1 } -func (m *moqUsual_mock) InterfaceParam(w io.Writer) (sResult string, err error) { - m.moq.scene.T.Helper() +func (m *moqUsual_mock) InterfaceParam(w io.Writer) (string, error) { + m.moq.moq_InterfaceParam.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 -} - -func (m *moqUsual_mock) Other(param1 other.Params) (result1 other.Results) { - m.moq.scene.T.Helper() - params := moqUsual_Other_params{ - param1: param1, - } - var results *moqUsual_Other_results - for _, resultsByParams := range m.moq.resultsByParams_Other { - paramsKey := m.moq.paramsKey_Other(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_Other(params)) - } - return + var result1 string + var result2 error + if result := m.moq.moq_InterfaceParam.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } + return result1, result2 +} - 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_Other(params)) - } - return - } - i = results.repeat.ResultCount - 1 +func (m *moqUsual_mock) InterfaceResult(sParam string, bParam bool) io.Reader { + m.moq.moq_InterfaceResult.Scene.T.Helper() + params := moqUsual_InterfaceResult_params{ + sParam: sParam, + bParam: bParam, } - 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_Other(params)) - } + var result1 io.Reader + if result := m.moq.moq_InterfaceResult.Function(params); result != nil { + result1 = result.result1 } + return result1 +} - if result.doFn != nil { - result.doFn(param1) +func (m *moqUsual_mock) FnParam(fn func()) { + m.moq.moq_FnParam.Scene.T.Helper() + params := moqUsual_FnParam_params{ + fn: fn, } - if result.values != nil { - result1 = result.values.result1 + m.moq.moq_FnParam.Function(params) +} + +func (m *moqUsual_mock) Other(param1 other.Params) other.Results { + m.moq.moq_Other.Scene.T.Helper() + params := moqUsual_Other_params{ + param1: param1, } - if result.doReturnFn != nil { - result1 = result.doReturnFn(param1) + + var result1 other.Results + if result := m.moq.moq_Other.Function(params); result != nil { + result1 = result.result1 } - return + return result1 } // onCall returns the recorder implementation of the Usual type @@ -13022,219 +7580,98 @@ func (m *moqUsual) onCall() *moqUsual_recorder { } } -func (m *moqUsual_recorder) Usual(sParam string, bParam bool) *moqUsual_Usual_fnRecorder { - return &moqUsual_Usual_fnRecorder{ - params: moqUsual_Usual_params{ +func (m *moqUsual_recorder) Usual(sParam string, bParam bool) *moqUsual_Usual_recorder { + return &moqUsual_Usual_recorder{ + recorder: m.moq.moq_Usual.OnCall(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)) +func (r *moqUsual_Usual_recorder) any() *moqUsual_Usual_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_Usual_anyParams{recorder: r} } -func (a *moqUsual_Usual_anyParams) sParam() *moqUsual_Usual_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_Usual_anyParams) sParam() *moqUsual_Usual_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqUsual_Usual_anyParams) bParam() *moqUsual_Usual_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqUsual_Usual_anyParams) bParam() *moqUsual_Usual_recorder { + a.recorder.recorder.AnyParam(2) 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)) +func (r *moqUsual_Usual_recorder) seq() *moqUsual_Usual_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { 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)) +func (r *moqUsual_Usual_recorder) noSeq() *moqUsual_Usual_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { 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, +func (r *moqUsual_Usual_recorder) returnResults(sResult string, err error) *moqUsual_Usual_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_Usual_results{ + sResult: sResult, + err: err, }) 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") +func (r *moqUsual_Usual_recorder) andDo(fn moqUsual_Usual_doFn) *moqUsual_Usual_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_Usual_params) { + fn(params.sParam, params.bParam) + }, false) { 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 +func (r *moqUsual_Usual_recorder) doReturnResults(fn moqUsual_Usual_doReturnFn) *moqUsual_Usual_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_Usual_params) *moqUsual_Usual_results { + sResult, err := fn(params.sParam, params.bParam) + return &moqUsual_Usual_results{ + sResult: sResult, + err: err, } - 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) +func (r *moqUsual_Usual_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_Usual_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqUsual) prettyParams_Usual(params moqUsual_Usual_params) string { +func (*moqUsual_Usual_adaptor) PrettyParams(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) - } - } +func (a *moqUsual_Usual_adaptor) ParamsKey(params moqUsual_Usual_params, anyParams uint64) moqUsual_Usual_paramsKey { + a.moq.moq_Usual.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.sParam, 1, a.moq.runtime.parameterIndexing.Usual.sParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.bParam, 2, a.moq.runtime.parameterIndexing.Usual.bParam, anyParams) return moqUsual_Usual_paramsKey{ params: struct { sParam string @@ -13253,219 +7690,98 @@ func (m *moqUsual) paramsKey_Usual(params moqUsual_Usual_params, anyParams uint6 } } -func (m *moqUsual_recorder) NoNames(param1 string, param2 bool) *moqUsual_NoNames_fnRecorder { - return &moqUsual_NoNames_fnRecorder{ - params: moqUsual_NoNames_params{ +func (m *moqUsual_recorder) NoNames(param1 string, param2 bool) *moqUsual_NoNames_recorder { + return &moqUsual_NoNames_recorder{ + recorder: m.moq.moq_NoNames.OnCall(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)) +func (r *moqUsual_NoNames_recorder) any() *moqUsual_NoNames_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_NoNames_anyParams{recorder: r} } -func (a *moqUsual_NoNames_anyParams) param1() *moqUsual_NoNames_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_NoNames_anyParams) param1() *moqUsual_NoNames_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqUsual_NoNames_anyParams) param2() *moqUsual_NoNames_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqUsual_NoNames_anyParams) param2() *moqUsual_NoNames_recorder { + a.recorder.recorder.AnyParam(2) 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)) +func (r *moqUsual_NoNames_recorder) seq() *moqUsual_NoNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { 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)) +func (r *moqUsual_NoNames_recorder) noSeq() *moqUsual_NoNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { 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, +func (r *moqUsual_NoNames_recorder) returnResults(result1 string, result2 error) *moqUsual_NoNames_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_NoNames_results{ + result1: result1, + result2: result2, }) 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") +func (r *moqUsual_NoNames_recorder) andDo(fn moqUsual_NoNames_doFn) *moqUsual_NoNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_NoNames_params) { + fn(params.param1, params.param2) + }, false) { 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 +func (r *moqUsual_NoNames_recorder) doReturnResults(fn moqUsual_NoNames_doReturnFn) *moqUsual_NoNames_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_NoNames_params) *moqUsual_NoNames_results { + result1, result2 := fn(params.param1, params.param2) + return &moqUsual_NoNames_results{ + result1: result1, + result2: result2, } - 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) +func (r *moqUsual_NoNames_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_NoNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqUsual) prettyParams_NoNames(params moqUsual_NoNames_params) string { +func (*moqUsual_NoNames_adaptor) PrettyParams(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) - } - } +func (a *moqUsual_NoNames_adaptor) ParamsKey(params moqUsual_NoNames_params, anyParams uint64) moqUsual_NoNames_paramsKey { + a.moq.moq_NoNames.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.param1, 1, a.moq.runtime.parameterIndexing.NoNames.param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.param2, 2, a.moq.runtime.parameterIndexing.NoNames.param2, anyParams) return moqUsual_NoNames_paramsKey{ params: struct { param1 string @@ -13484,204 +7800,92 @@ func (m *moqUsual) paramsKey_NoNames(params moqUsual_NoNames_params, anyParams u } } -func (m *moqUsual_recorder) NoResults(sParam string, bParam bool) *moqUsual_NoResults_fnRecorder { - return &moqUsual_NoResults_fnRecorder{ - params: moqUsual_NoResults_params{ +func (m *moqUsual_recorder) NoResults(sParam string, bParam bool) *moqUsual_NoResults_recorder { + return &moqUsual_NoResults_recorder{ + recorder: m.moq.moq_NoResults.OnCall(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)) +func (r *moqUsual_NoResults_recorder) any() *moqUsual_NoResults_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_NoResults_anyParams{recorder: r} } -func (a *moqUsual_NoResults_anyParams) sParam() *moqUsual_NoResults_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_NoResults_anyParams) sParam() *moqUsual_NoResults_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqUsual_NoResults_anyParams) bParam() *moqUsual_NoResults_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqUsual_NoResults_anyParams) bParam() *moqUsual_NoResults_recorder { + a.recorder.recorder.AnyParam(2) 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)) +func (r *moqUsual_NoResults_recorder) seq() *moqUsual_NoResults_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { 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)) +func (r *moqUsual_NoResults_recorder) noSeq() *moqUsual_NoResults_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { 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, - }) +func (r *moqUsual_NoResults_recorder) returnResults() *moqUsual_NoResults_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_NoResults_results{}) 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") +func (r *moqUsual_NoResults_recorder) andDo(fn moqUsual_NoResults_doFn) *moqUsual_NoResults_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_NoResults_params) { + fn(params.sParam, params.bParam) + }, false) { 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}) +func (r *moqUsual_NoResults_recorder) doReturnResults(fn moqUsual_NoResults_doReturnFn) *moqUsual_NoResults_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_NoResults_params) *moqUsual_NoResults_results { + fn(params.sParam, params.bParam) + return &moqUsual_NoResults_results{} + }) 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") +func (r *moqUsual_NoResults_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_NoResults_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { +func (*moqUsual_NoResults_adaptor) PrettyParams(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) - } - } +func (a *moqUsual_NoResults_adaptor) ParamsKey(params moqUsual_NoResults_params, anyParams uint64) moqUsual_NoResults_paramsKey { + a.moq.moq_NoResults.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.sParam, 1, a.moq.runtime.parameterIndexing.NoResults.sParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.bParam, 2, a.moq.runtime.parameterIndexing.NoResults.bParam, anyParams) return moqUsual_NoResults_paramsKey{ params: struct { sParam string @@ -13700,578 +7904,254 @@ func (m *moqUsual) paramsKey_NoResults(params moqUsual_NoResults_params, anyPara } } -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 (m *moqUsual_recorder) NoParams() *moqUsual_NoParams_recorder { + return &moqUsual_NoParams_recorder{ + recorder: m.moq.moq_NoParams.OnCall(moqUsual_NoParams_params{}), } } -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)) +func (r *moqUsual_NoParams_recorder) any() *moqUsual_NoParams_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { 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)) +func (r *moqUsual_NoParams_recorder) seq() *moqUsual_NoParams_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { 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)) +func (r *moqUsual_NoParams_recorder) noSeq() *moqUsual_NoParams_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { 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, +func (r *moqUsual_NoParams_recorder) returnResults(sResult string, err error) *moqUsual_NoParams_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_NoParams_results{ + sResult: sResult, + err: err, }) 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") +func (r *moqUsual_NoParams_recorder) andDo(fn moqUsual_NoParams_doFn) *moqUsual_NoParams_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_NoParams_params) { + fn() + }, false) { 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 +func (r *moqUsual_NoParams_recorder) doReturnResults(fn moqUsual_NoParams_doReturnFn) *moqUsual_NoParams_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_NoParams_params) *moqUsual_NoParams_results { + sResult, err := fn() + return &moqUsual_NoParams_results{ + sResult: sResult, + err: err, } - 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) +func (r *moqUsual_NoParams_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_NoParams_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqUsual) prettyParams_NoParams(params moqUsual_NoParams_params) string { +func (*moqUsual_NoParams_adaptor) PrettyParams(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() +func (a *moqUsual_NoParams_adaptor) ParamsKey(params moqUsual_NoParams_params, anyParams uint64) moqUsual_NoParams_paramsKey { + a.moq.moq_NoParams.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 (m *moqUsual_recorder) Nothing() *moqUsual_Nothing_recorder { + return &moqUsual_Nothing_recorder{ + recorder: m.moq.moq_Nothing.OnCall(moqUsual_Nothing_params{}), } } -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)) +func (r *moqUsual_Nothing_recorder) any() *moqUsual_Nothing_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { 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)) +func (r *moqUsual_Nothing_recorder) seq() *moqUsual_Nothing_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { 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)) +func (r *moqUsual_Nothing_recorder) noSeq() *moqUsual_Nothing_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { 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, - }) +func (r *moqUsual_Nothing_recorder) returnResults() *moqUsual_Nothing_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_Nothing_results{}) 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") +func (r *moqUsual_Nothing_recorder) andDo(fn moqUsual_Nothing_doFn) *moqUsual_Nothing_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_Nothing_params) { + fn() + }, false) { 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}) +func (r *moqUsual_Nothing_recorder) doReturnResults(fn moqUsual_Nothing_doReturnFn) *moqUsual_Nothing_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_Nothing_params) *moqUsual_Nothing_results { + fn() + return &moqUsual_Nothing_results{} + }) 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") +func (r *moqUsual_Nothing_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_Nothing_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { +func (*moqUsual_Nothing_adaptor) PrettyParams(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() +func (a *moqUsual_Nothing_adaptor) ParamsKey(params moqUsual_Nothing_params, anyParams uint64) moqUsual_Nothing_paramsKey { + a.moq.moq_Nothing.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{ +func (m *moqUsual_recorder) Variadic(other bool, args ...string) *moqUsual_Variadic_recorder { + return &moqUsual_Variadic_recorder{ + recorder: m.moq.moq_Variadic.OnCall(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)) +func (r *moqUsual_Variadic_recorder) any() *moqUsual_Variadic_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_Variadic_anyParams{recorder: r} } -func (a *moqUsual_Variadic_anyParams) other() *moqUsual_Variadic_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_Variadic_anyParams) other() *moqUsual_Variadic_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqUsual_Variadic_anyParams) args() *moqUsual_Variadic_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqUsual_Variadic_anyParams) args() *moqUsual_Variadic_recorder { + a.recorder.recorder.AnyParam(2) 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)) +func (r *moqUsual_Variadic_recorder) seq() *moqUsual_Variadic_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { 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)) +func (r *moqUsual_Variadic_recorder) noSeq() *moqUsual_Variadic_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { 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, +func (r *moqUsual_Variadic_recorder) returnResults(sResult string, err error) *moqUsual_Variadic_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_Variadic_results{ + sResult: sResult, + err: err, }) 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") +func (r *moqUsual_Variadic_recorder) andDo(fn moqUsual_Variadic_doFn) *moqUsual_Variadic_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_Variadic_params) { + fn(params.other, params.args...) + }, false) { 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 +func (r *moqUsual_Variadic_recorder) doReturnResults(fn moqUsual_Variadic_doReturnFn) *moqUsual_Variadic_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_Variadic_params) *moqUsual_Variadic_results { + sResult, err := fn(params.other, params.args...) + return &moqUsual_Variadic_results{ + sResult: sResult, + err: err, } - 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) +func (r *moqUsual_Variadic_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_Variadic_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqUsual) prettyParams_Variadic(params moqUsual_Variadic_params) string { +func (*moqUsual_Variadic_adaptor) PrettyParams(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) - } +func (a *moqUsual_Variadic_adaptor) ParamsKey(params moqUsual_Variadic_params, anyParams uint64) moqUsual_Variadic_paramsKey { + a.moq.moq_Variadic.Scene.T.Helper() + otherUsed, otherUsedHash := impl.ParamKey( + params.other, 1, a.moq.runtime.parameterIndexing.Variadic.other, anyParams) + argsUsedHash := impl.HashOnlyParamKey(a.moq.moq_Variadic.Scene.T, + params.args, "args", 2, a.moq.runtime.parameterIndexing.Variadic.args, anyParams) return moqUsual_Variadic_paramsKey{ params: struct{ other bool }{ other: otherUsed, @@ -14286,235 +8166,108 @@ func (m *moqUsual) paramsKey_Variadic(params moqUsual_Variadic_params, anyParams } } -func (m *moqUsual_recorder) RepeatedIds(sParam1, sParam2 string, bParam bool) *moqUsual_RepeatedIds_fnRecorder { - return &moqUsual_RepeatedIds_fnRecorder{ - params: moqUsual_RepeatedIds_params{ +func (m *moqUsual_recorder) RepeatedIds(sParam1, sParam2 string, bParam bool) *moqUsual_RepeatedIds_recorder { + return &moqUsual_RepeatedIds_recorder{ + recorder: m.moq.moq_RepeatedIds.OnCall(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)) +func (r *moqUsual_RepeatedIds_recorder) any() *moqUsual_RepeatedIds_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_RepeatedIds_anyParams{recorder: r} } -func (a *moqUsual_RepeatedIds_anyParams) sParam1() *moqUsual_RepeatedIds_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_RepeatedIds_anyParams) sParam1() *moqUsual_RepeatedIds_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqUsual_RepeatedIds_anyParams) sParam2() *moqUsual_RepeatedIds_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqUsual_RepeatedIds_anyParams) sParam2() *moqUsual_RepeatedIds_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (a *moqUsual_RepeatedIds_anyParams) bParam() *moqUsual_RepeatedIds_fnRecorder { - a.recorder.anyParams |= 1 << 2 +func (a *moqUsual_RepeatedIds_anyParams) bParam() *moqUsual_RepeatedIds_recorder { + a.recorder.recorder.AnyParam(3) 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)) +func (r *moqUsual_RepeatedIds_recorder) seq() *moqUsual_RepeatedIds_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { 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)) +func (r *moqUsual_RepeatedIds_recorder) noSeq() *moqUsual_RepeatedIds_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { 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, +func (r *moqUsual_RepeatedIds_recorder) returnResults(sResult1, sResult2 string, err error) *moqUsual_RepeatedIds_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_RepeatedIds_results{ + sResult1: sResult1, + sResult2: sResult2, + err: err, }) 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") +func (r *moqUsual_RepeatedIds_recorder) andDo(fn moqUsual_RepeatedIds_doFn) *moqUsual_RepeatedIds_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_RepeatedIds_params) { + fn(params.sParam1, params.sParam2, params.bParam) + }, false) { 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 +func (r *moqUsual_RepeatedIds_recorder) doReturnResults(fn moqUsual_RepeatedIds_doReturnFn) *moqUsual_RepeatedIds_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_RepeatedIds_params) *moqUsual_RepeatedIds_results { + sResult1, sResult2, err := fn(params.sParam1, params.sParam2, params.bParam) + return &moqUsual_RepeatedIds_results{ + sResult1: sResult1, + sResult2: sResult2, + err: err, } - 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) +func (r *moqUsual_RepeatedIds_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_RepeatedIds_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqUsual) prettyParams_RepeatedIds(params moqUsual_RepeatedIds_params) string { +func (*moqUsual_RepeatedIds_adaptor) PrettyParams(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) - } - } +func (a *moqUsual_RepeatedIds_adaptor) ParamsKey(params moqUsual_RepeatedIds_params, anyParams uint64) moqUsual_RepeatedIds_paramsKey { + a.moq.moq_RepeatedIds.Scene.T.Helper() + sParam1Used, sParam1UsedHash := impl.ParamKey( + params.sParam1, 1, a.moq.runtime.parameterIndexing.RepeatedIds.sParam1, anyParams) + sParam2Used, sParam2UsedHash := impl.ParamKey( + params.sParam2, 2, a.moq.runtime.parameterIndexing.RepeatedIds.sParam2, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.bParam, 3, a.moq.runtime.parameterIndexing.RepeatedIds.bParam, anyParams) return moqUsual_RepeatedIds_paramsKey{ params: struct { sParam1, sParam2 string @@ -14535,219 +8288,98 @@ func (m *moqUsual) paramsKey_RepeatedIds(params moqUsual_RepeatedIds_params, any } } -func (m *moqUsual_recorder) Times(sParam string, times bool) *moqUsual_Times_fnRecorder { - return &moqUsual_Times_fnRecorder{ - params: moqUsual_Times_params{ +func (m *moqUsual_recorder) Times(sParam string, times bool) *moqUsual_Times_recorder { + return &moqUsual_Times_recorder{ + recorder: m.moq.moq_Times.OnCall(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)) +func (r *moqUsual_Times_recorder) any() *moqUsual_Times_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_Times_anyParams{recorder: r} } -func (a *moqUsual_Times_anyParams) sParam() *moqUsual_Times_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_Times_anyParams) sParam() *moqUsual_Times_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqUsual_Times_anyParams) times() *moqUsual_Times_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqUsual_Times_anyParams) times() *moqUsual_Times_recorder { + a.recorder.recorder.AnyParam(2) 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)) +func (r *moqUsual_Times_recorder) seq() *moqUsual_Times_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { 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)) +func (r *moqUsual_Times_recorder) noSeq() *moqUsual_Times_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { 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, +func (r *moqUsual_Times_recorder) returnResults(sResult string, err error) *moqUsual_Times_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_Times_results{ + sResult: sResult, + err: err, }) 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") +func (r *moqUsual_Times_recorder) andDo(fn moqUsual_Times_doFn) *moqUsual_Times_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_Times_params) { + fn(params.sParam, params.times) + }, false) { 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(), - } +func (r *moqUsual_Times_recorder) doReturnResults(fn moqUsual_Times_doReturnFn) *moqUsual_Times_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_Times_params) *moqUsual_Times_results { + sResult, err := fn(params.sParam, params.times) + return &moqUsual_Times_results{ + sResult: sResult, + err: err, } - r.results.results = append(r.results.results, last) + }) + return r +} + +func (r *moqUsual_Times_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_Times_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqUsual) prettyParams_Times(params moqUsual_Times_params) string { +func (*moqUsual_Times_adaptor) PrettyParams(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) - } - } +func (a *moqUsual_Times_adaptor) ParamsKey(params moqUsual_Times_params, anyParams uint64) moqUsual_Times_paramsKey { + a.moq.moq_Times.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.sParam, 1, a.moq.runtime.parameterIndexing.Times.sParam, anyParams) + timesUsed, timesUsedHash := impl.ParamKey( + params.times, 2, a.moq.runtime.parameterIndexing.Times.times, anyParams) return moqUsual_Times_paramsKey{ params: struct { sParam string @@ -14766,9 +8398,9 @@ func (m *moqUsual) paramsKey_Times(params moqUsual_Times_params, anyParams uint6 } } -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{ +func (m *moqUsual_recorder) DifficultParamNames(param1, param2 bool, param3 string, param, param5, param6 int, param7, param8, param9 float32) *moqUsual_DifficultParamNames_recorder { + return &moqUsual_DifficultParamNames_recorder{ + recorder: m.moq.moq_DifficultParamNames.OnCall(moqUsual_DifficultParamNames_params{ param1: param1, param2: param2, param3: param3, @@ -14778,297 +8410,136 @@ func (m *moqUsual_recorder) DifficultParamNames(param1, param2 bool, param3 stri 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)) +func (r *moqUsual_DifficultParamNames_recorder) any() *moqUsual_DifficultParamNames_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_DifficultParamNames_anyParams{recorder: r} } -func (a *moqUsual_DifficultParamNames_anyParams) param1() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_DifficultParamNames_anyParams) param1() *moqUsual_DifficultParamNames_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqUsual_DifficultParamNames_anyParams) param2() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqUsual_DifficultParamNames_anyParams) param2() *moqUsual_DifficultParamNames_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (a *moqUsual_DifficultParamNames_anyParams) param3() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 2 +func (a *moqUsual_DifficultParamNames_anyParams) param3() *moqUsual_DifficultParamNames_recorder { + a.recorder.recorder.AnyParam(3) return a.recorder } -func (a *moqUsual_DifficultParamNames_anyParams) param() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 3 +func (a *moqUsual_DifficultParamNames_anyParams) param() *moqUsual_DifficultParamNames_recorder { + a.recorder.recorder.AnyParam(4) return a.recorder } -func (a *moqUsual_DifficultParamNames_anyParams) param5() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 4 +func (a *moqUsual_DifficultParamNames_anyParams) param5() *moqUsual_DifficultParamNames_recorder { + a.recorder.recorder.AnyParam(5) return a.recorder } -func (a *moqUsual_DifficultParamNames_anyParams) param6() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 5 +func (a *moqUsual_DifficultParamNames_anyParams) param6() *moqUsual_DifficultParamNames_recorder { + a.recorder.recorder.AnyParam(6) return a.recorder } -func (a *moqUsual_DifficultParamNames_anyParams) param7() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 6 +func (a *moqUsual_DifficultParamNames_anyParams) param7() *moqUsual_DifficultParamNames_recorder { + a.recorder.recorder.AnyParam(7) return a.recorder } -func (a *moqUsual_DifficultParamNames_anyParams) param8() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 7 +func (a *moqUsual_DifficultParamNames_anyParams) param8() *moqUsual_DifficultParamNames_recorder { + a.recorder.recorder.AnyParam(8) return a.recorder } -func (a *moqUsual_DifficultParamNames_anyParams) param9() *moqUsual_DifficultParamNames_fnRecorder { - a.recorder.anyParams |= 1 << 8 +func (a *moqUsual_DifficultParamNames_anyParams) param9() *moqUsual_DifficultParamNames_recorder { + a.recorder.recorder.AnyParam(9) 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)) +func (r *moqUsual_DifficultParamNames_recorder) seq() *moqUsual_DifficultParamNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { 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)) +func (r *moqUsual_DifficultParamNames_recorder) noSeq() *moqUsual_DifficultParamNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { 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, - }) +func (r *moqUsual_DifficultParamNames_recorder) returnResults() *moqUsual_DifficultParamNames_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_DifficultParamNames_results{}) 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") +func (r *moqUsual_DifficultParamNames_recorder) andDo(fn moqUsual_DifficultParamNames_doFn) *moqUsual_DifficultParamNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_DifficultParamNames_params) { + fn(params.param1, params.param2, params.param3, params.param, params.param5, params.param6, params.param7, params.param8, params.param9) + }, false) { 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}) +func (r *moqUsual_DifficultParamNames_recorder) doReturnResults(fn moqUsual_DifficultParamNames_doReturnFn) *moqUsual_DifficultParamNames_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_DifficultParamNames_params) *moqUsual_DifficultParamNames_results { + fn(params.param1, params.param2, params.param3, params.param, params.param5, params.param6, params.param7, params.param8, params.param9) + return &moqUsual_DifficultParamNames_results{} + }) 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") +func (r *moqUsual_DifficultParamNames_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_DifficultParamNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { +func (*moqUsual_DifficultParamNames_adaptor) PrettyParams(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) - } - } +func (a *moqUsual_DifficultParamNames_adaptor) ParamsKey(params moqUsual_DifficultParamNames_params, anyParams uint64) moqUsual_DifficultParamNames_paramsKey { + a.moq.moq_DifficultParamNames.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.param1, 1, a.moq.runtime.parameterIndexing.DifficultParamNames.param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.param2, 2, a.moq.runtime.parameterIndexing.DifficultParamNames.param2, anyParams) + param3Used, param3UsedHash := impl.ParamKey( + params.param3, 3, a.moq.runtime.parameterIndexing.DifficultParamNames.param3, anyParams) + paramUsed, paramUsedHash := impl.ParamKey( + params.param, 4, a.moq.runtime.parameterIndexing.DifficultParamNames.param, anyParams) + param5Used, param5UsedHash := impl.ParamKey( + params.param5, 5, a.moq.runtime.parameterIndexing.DifficultParamNames.param5, anyParams) + param6Used, param6UsedHash := impl.ParamKey( + params.param6, 6, a.moq.runtime.parameterIndexing.DifficultParamNames.param6, anyParams) + param7Used, param7UsedHash := impl.ParamKey( + params.param7, 7, a.moq.runtime.parameterIndexing.DifficultParamNames.param7, anyParams) + param8Used, param8UsedHash := impl.ParamKey( + params.param8, 8, a.moq.runtime.parameterIndexing.DifficultParamNames.param8, anyParams) + param9Used, param9UsedHash := impl.ParamKey( + params.param9, 9, a.moq.runtime.parameterIndexing.DifficultParamNames.param9, anyParams) return moqUsual_DifficultParamNames_paramsKey{ params: struct { param1, param2 bool @@ -15105,69 +8576,67 @@ func (m *moqUsual) paramsKey_DifficultParamNames(params moqUsual_DifficultParamN } } -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 (m *moqUsual_recorder) DifficultResultNames() *moqUsual_DifficultResultNames_recorder { + return &moqUsual_DifficultResultNames_recorder{ + recorder: m.moq.moq_DifficultResultNames.OnCall(moqUsual_DifficultResultNames_params{}), } } -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)) +func (r *moqUsual_DifficultResultNames_recorder) any() *moqUsual_DifficultResultNames_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { 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)) +func (r *moqUsual_DifficultResultNames_recorder) seq() *moqUsual_DifficultResultNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { 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)) +func (r *moqUsual_DifficultResultNames_recorder) noSeq() *moqUsual_DifficultResultNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { 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() +func (r *moqUsual_DifficultResultNames_recorder) returnResults(result1, result2 string, result3 error, param, result5, result6 int, result7, result8, result9 float32) *moqUsual_DifficultResultNames_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_DifficultResultNames_results{ + result1: result1, + result2: result2, + result3: result3, + param: param, + result5: result5, + result6: result6, + result7: result7, + result8: result8, + result9: result9, + }) + return r +} - var sequence uint32 - if r.sequence { - sequence = r.moq.scene.NextRecorderSequence() +func (r *moqUsual_DifficultResultNames_recorder) andDo(fn moqUsual_DifficultResultNames_doFn) *moqUsual_DifficultResultNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_DifficultResultNames_params) { + fn() + }, false) { + return nil } + return r +} - 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 - }{ +func (r *moqUsual_DifficultResultNames_recorder) doReturnResults(fn moqUsual_DifficultResultNames_doReturnFn) *moqUsual_DifficultResultNames_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_DifficultResultNames_params) *moqUsual_DifficultResultNames_results { + result1, result2, result3, param, result5, result6, result7, result8, result9 := fn() + return &moqUsual_DifficultResultNames_results{ result1: result1, result2: result2, result3: result3, @@ -15177,330 +8646,113 @@ func (r *moqUsual_DifficultResultNames_fnRecorder) returnResults(result1, result 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") +func (r *moqUsual_DifficultResultNames_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_DifficultResultNames_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { +func (*moqUsual_DifficultResultNames_adaptor) PrettyParams(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() +func (a *moqUsual_DifficultResultNames_adaptor) ParamsKey(params moqUsual_DifficultResultNames_params, anyParams uint64) moqUsual_DifficultResultNames_paramsKey { + a.moq.moq_DifficultResultNames.Scene.T.Helper() return moqUsual_DifficultResultNames_paramsKey{ params: struct{}{}, hashes: struct{}{}, } } -func (m *moqUsual_recorder) PassByArray(p [3]testmoqs.Params) *moqUsual_PassByArray_fnRecorder { - return &moqUsual_PassByArray_fnRecorder{ - params: moqUsual_PassByArray_params{ +func (m *moqUsual_recorder) PassByArray(p [3]testmoqs.Params) *moqUsual_PassByArray_recorder { + return &moqUsual_PassByArray_recorder{ + recorder: m.moq.moq_PassByArray.OnCall(moqUsual_PassByArray_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqUsual_PassByArray_fnRecorder) any() *moqUsual_PassByArray_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_PassByArray(r.params)) +func (r *moqUsual_PassByArray_recorder) any() *moqUsual_PassByArray_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_PassByArray_anyParams{recorder: r} } -func (a *moqUsual_PassByArray_anyParams) p() *moqUsual_PassByArray_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_PassByArray_anyParams) p() *moqUsual_PassByArray_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqUsual_PassByArray_fnRecorder) seq() *moqUsual_PassByArray_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_PassByArray(r.params)) +func (r *moqUsual_PassByArray_recorder) seq() *moqUsual_PassByArray_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqUsual_PassByArray_fnRecorder) noSeq() *moqUsual_PassByArray_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_PassByArray(r.params)) +func (r *moqUsual_PassByArray_recorder) noSeq() *moqUsual_PassByArray_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUsual_PassByArray_fnRecorder) returnResults(result1 [3]testmoqs.Results) *moqUsual_PassByArray_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 [3]testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByArray_doFn - doReturnFn moqUsual_PassByArray_doReturnFn - }{ - values: &struct { - result1 [3]testmoqs.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqUsual_PassByArray_recorder) returnResults(result1 [3]testmoqs.Results) *moqUsual_PassByArray_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_PassByArray_results{ + result1: result1, }) return r } -func (r *moqUsual_PassByArray_fnRecorder) andDo(fn moqUsual_PassByArray_doFn) *moqUsual_PassByArray_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqUsual_PassByArray_recorder) andDo(fn moqUsual_PassByArray_doFn) *moqUsual_PassByArray_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_PassByArray_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqUsual_PassByArray_fnRecorder) doReturnResults(fn moqUsual_PassByArray_doReturnFn) *moqUsual_PassByArray_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 [3]testmoqs.Results +func (r *moqUsual_PassByArray_recorder) doReturnResults(fn moqUsual_PassByArray_doReturnFn) *moqUsual_PassByArray_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_PassByArray_params) *moqUsual_PassByArray_results { + result1 := fn(params.p) + return &moqUsual_PassByArray_results{ + result1: result1, } - sequence uint32 - doFn moqUsual_PassByArray_doFn - doReturnFn moqUsual_PassByArray_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqUsual_PassByArray_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_PassByArray_resultsByParams - for n, res := range r.moq.resultsByParams_PassByArray { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqUsual_PassByArray_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_PassByArray_paramsKey]*moqUsual_PassByArray_results{}, - } - r.moq.resultsByParams_PassByArray = append(r.moq.resultsByParams_PassByArray, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_PassByArray) { - copy(r.moq.resultsByParams_PassByArray[insertAt+1:], r.moq.resultsByParams_PassByArray[insertAt:0]) - r.moq.resultsByParams_PassByArray[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_PassByArray(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_PassByArray_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_PassByArray_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByArray_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqUsual_PassByArray_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByArray_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 [3]testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByArray_doFn - doReturnFn moqUsual_PassByArray_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqUsual) prettyParams_PassByArray(params moqUsual_PassByArray_params) string { +func (*moqUsual_PassByArray_adaptor) PrettyParams(params moqUsual_PassByArray_params) string { return fmt.Sprintf("PassByArray(%#v)", params.p) } -func (m *moqUsual) paramsKey_PassByArray(params moqUsual_PassByArray_params, anyParams uint64) moqUsual_PassByArray_paramsKey { - m.scene.T.Helper() - var pUsed [3]testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.PassByArray.p == moq.ParamIndexByValue { - pUsed = params.p - } else { - pUsedHash = hash.DeepHash(params.p) - } - } +func (a *moqUsual_PassByArray_adaptor) ParamsKey(params moqUsual_PassByArray_params, anyParams uint64) moqUsual_PassByArray_paramsKey { + a.moq.moq_PassByArray.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.p, 1, a.moq.runtime.parameterIndexing.PassByArray.p, anyParams) return moqUsual_PassByArray_paramsKey{ params: struct{ p [3]testmoqs.Params }{ p: pUsed, @@ -15511,199 +8763,88 @@ func (m *moqUsual) paramsKey_PassByArray(params moqUsual_PassByArray_params, any } } -func (m *moqUsual_recorder) PassByChan(p chan testmoqs.Params) *moqUsual_PassByChan_fnRecorder { - return &moqUsual_PassByChan_fnRecorder{ - params: moqUsual_PassByChan_params{ +func (m *moqUsual_recorder) PassByChan(p chan testmoqs.Params) *moqUsual_PassByChan_recorder { + return &moqUsual_PassByChan_recorder{ + recorder: m.moq.moq_PassByChan.OnCall(moqUsual_PassByChan_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqUsual_PassByChan_fnRecorder) any() *moqUsual_PassByChan_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_PassByChan(r.params)) +func (r *moqUsual_PassByChan_recorder) any() *moqUsual_PassByChan_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_PassByChan_anyParams{recorder: r} } -func (a *moqUsual_PassByChan_anyParams) p() *moqUsual_PassByChan_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_PassByChan_anyParams) p() *moqUsual_PassByChan_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqUsual_PassByChan_fnRecorder) seq() *moqUsual_PassByChan_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_PassByChan(r.params)) +func (r *moqUsual_PassByChan_recorder) seq() *moqUsual_PassByChan_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqUsual_PassByChan_fnRecorder) noSeq() *moqUsual_PassByChan_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_PassByChan(r.params)) +func (r *moqUsual_PassByChan_recorder) noSeq() *moqUsual_PassByChan_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUsual_PassByChan_fnRecorder) returnResults(result1 chan testmoqs.Results) *moqUsual_PassByChan_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 chan testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByChan_doFn - doReturnFn moqUsual_PassByChan_doReturnFn - }{ - values: &struct { - result1 chan testmoqs.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqUsual_PassByChan_recorder) returnResults(result1 chan testmoqs.Results) *moqUsual_PassByChan_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_PassByChan_results{ + result1: result1, }) return r } -func (r *moqUsual_PassByChan_fnRecorder) andDo(fn moqUsual_PassByChan_doFn) *moqUsual_PassByChan_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqUsual_PassByChan_recorder) andDo(fn moqUsual_PassByChan_doFn) *moqUsual_PassByChan_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_PassByChan_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqUsual_PassByChan_fnRecorder) doReturnResults(fn moqUsual_PassByChan_doReturnFn) *moqUsual_PassByChan_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 chan testmoqs.Results +func (r *moqUsual_PassByChan_recorder) doReturnResults(fn moqUsual_PassByChan_doReturnFn) *moqUsual_PassByChan_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_PassByChan_params) *moqUsual_PassByChan_results { + result1 := fn(params.p) + return &moqUsual_PassByChan_results{ + result1: result1, } - sequence uint32 - doFn moqUsual_PassByChan_doFn - doReturnFn moqUsual_PassByChan_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqUsual_PassByChan_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_PassByChan_resultsByParams - for n, res := range r.moq.resultsByParams_PassByChan { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqUsual_PassByChan_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_PassByChan_paramsKey]*moqUsual_PassByChan_results{}, - } - r.moq.resultsByParams_PassByChan = append(r.moq.resultsByParams_PassByChan, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_PassByChan) { - copy(r.moq.resultsByParams_PassByChan[insertAt+1:], r.moq.resultsByParams_PassByChan[insertAt:0]) - r.moq.resultsByParams_PassByChan[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_PassByChan(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_PassByChan_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_PassByChan_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByChan_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqUsual_PassByChan_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByChan_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 chan testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByChan_doFn - doReturnFn moqUsual_PassByChan_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqUsual) prettyParams_PassByChan(params moqUsual_PassByChan_params) string { +func (*moqUsual_PassByChan_adaptor) PrettyParams(params moqUsual_PassByChan_params) string { return fmt.Sprintf("PassByChan(%#v)", params.p) } -func (m *moqUsual) paramsKey_PassByChan(params moqUsual_PassByChan_params, anyParams uint64) moqUsual_PassByChan_paramsKey { - m.scene.T.Helper() - var pUsed chan testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.PassByChan.p == moq.ParamIndexByValue { - pUsed = params.p - } else { - pUsedHash = hash.DeepHash(params.p) - } - } +func (a *moqUsual_PassByChan_adaptor) ParamsKey(params moqUsual_PassByChan_params, anyParams uint64) moqUsual_PassByChan_paramsKey { + a.moq.moq_PassByChan.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.p, 1, a.moq.runtime.parameterIndexing.PassByChan.p, anyParams) return moqUsual_PassByChan_paramsKey{ params: struct{ p chan testmoqs.Params }{ p: pUsed, @@ -15714,202 +8855,90 @@ func (m *moqUsual) paramsKey_PassByChan(params moqUsual_PassByChan_params, anyPa } } -func (m *moqUsual_recorder) PassByEllipsis(p ...testmoqs.Params) *moqUsual_PassByEllipsis_fnRecorder { - return &moqUsual_PassByEllipsis_fnRecorder{ - params: moqUsual_PassByEllipsis_params{ +func (m *moqUsual_recorder) PassByEllipsis(p ...testmoqs.Params) *moqUsual_PassByEllipsis_recorder { + return &moqUsual_PassByEllipsis_recorder{ + recorder: m.moq.moq_PassByEllipsis.OnCall(moqUsual_PassByEllipsis_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqUsual_PassByEllipsis_fnRecorder) any() *moqUsual_PassByEllipsis_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_PassByEllipsis(r.params)) +func (r *moqUsual_PassByEllipsis_recorder) any() *moqUsual_PassByEllipsis_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_PassByEllipsis_anyParams{recorder: r} } -func (a *moqUsual_PassByEllipsis_anyParams) p() *moqUsual_PassByEllipsis_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_PassByEllipsis_anyParams) p() *moqUsual_PassByEllipsis_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqUsual_PassByEllipsis_fnRecorder) seq() *moqUsual_PassByEllipsis_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_PassByEllipsis(r.params)) +func (r *moqUsual_PassByEllipsis_recorder) seq() *moqUsual_PassByEllipsis_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqUsual_PassByEllipsis_fnRecorder) noSeq() *moqUsual_PassByEllipsis_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_PassByEllipsis(r.params)) +func (r *moqUsual_PassByEllipsis_recorder) noSeq() *moqUsual_PassByEllipsis_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUsual_PassByEllipsis_fnRecorder) returnResults(result1 string, result2 error) *moqUsual_PassByEllipsis_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_PassByEllipsis_doFn - doReturnFn moqUsual_PassByEllipsis_doReturnFn - }{ - values: &struct { - result1 string - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqUsual_PassByEllipsis_recorder) returnResults(result1 string, result2 error) *moqUsual_PassByEllipsis_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_PassByEllipsis_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqUsual_PassByEllipsis_fnRecorder) andDo(fn moqUsual_PassByEllipsis_doFn) *moqUsual_PassByEllipsis_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqUsual_PassByEllipsis_recorder) andDo(fn moqUsual_PassByEllipsis_doFn) *moqUsual_PassByEllipsis_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_PassByEllipsis_params) { + fn(params.p...) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqUsual_PassByEllipsis_fnRecorder) doReturnResults(fn moqUsual_PassByEllipsis_doReturnFn) *moqUsual_PassByEllipsis_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 +func (r *moqUsual_PassByEllipsis_recorder) doReturnResults(fn moqUsual_PassByEllipsis_doReturnFn) *moqUsual_PassByEllipsis_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_PassByEllipsis_params) *moqUsual_PassByEllipsis_results { + result1, result2 := fn(params.p...) + return &moqUsual_PassByEllipsis_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqUsual_PassByEllipsis_doFn - doReturnFn moqUsual_PassByEllipsis_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqUsual_PassByEllipsis_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_PassByEllipsis_resultsByParams - for n, res := range r.moq.resultsByParams_PassByEllipsis { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqUsual_PassByEllipsis_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_PassByEllipsis_paramsKey]*moqUsual_PassByEllipsis_results{}, - } - r.moq.resultsByParams_PassByEllipsis = append(r.moq.resultsByParams_PassByEllipsis, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_PassByEllipsis) { - copy(r.moq.resultsByParams_PassByEllipsis[insertAt+1:], r.moq.resultsByParams_PassByEllipsis[insertAt:0]) - r.moq.resultsByParams_PassByEllipsis[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_PassByEllipsis(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_PassByEllipsis_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_PassByEllipsis_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByEllipsis_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_PassByEllipsis_doFn - doReturnFn moqUsual_PassByEllipsis_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqUsual_PassByEllipsis_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByEllipsis_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqUsual) prettyParams_PassByEllipsis(params moqUsual_PassByEllipsis_params) string { +func (*moqUsual_PassByEllipsis_adaptor) PrettyParams(params moqUsual_PassByEllipsis_params) string { return fmt.Sprintf("PassByEllipsis(%#v)", params.p) } -func (m *moqUsual) paramsKey_PassByEllipsis(params moqUsual_PassByEllipsis_params, anyParams uint64) moqUsual_PassByEllipsis_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.PassByEllipsis.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter of the PassByEllipsis function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqUsual_PassByEllipsis_adaptor) ParamsKey(params moqUsual_PassByEllipsis_params, anyParams uint64) moqUsual_PassByEllipsis_paramsKey { + a.moq.moq_PassByEllipsis.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq_PassByEllipsis.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.PassByEllipsis.p, anyParams) return moqUsual_PassByEllipsis_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -15918,197 +8947,88 @@ func (m *moqUsual) paramsKey_PassByEllipsis(params moqUsual_PassByEllipsis_param } } -func (m *moqUsual_recorder) PassByMap(p map[string]testmoqs.Params) *moqUsual_PassByMap_fnRecorder { - return &moqUsual_PassByMap_fnRecorder{ - params: moqUsual_PassByMap_params{ +func (m *moqUsual_recorder) PassByMap(p map[string]testmoqs.Params) *moqUsual_PassByMap_recorder { + return &moqUsual_PassByMap_recorder{ + recorder: m.moq.moq_PassByMap.OnCall(moqUsual_PassByMap_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqUsual_PassByMap_fnRecorder) any() *moqUsual_PassByMap_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_PassByMap(r.params)) +func (r *moqUsual_PassByMap_recorder) any() *moqUsual_PassByMap_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_PassByMap_anyParams{recorder: r} } -func (a *moqUsual_PassByMap_anyParams) p() *moqUsual_PassByMap_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_PassByMap_anyParams) p() *moqUsual_PassByMap_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqUsual_PassByMap_fnRecorder) seq() *moqUsual_PassByMap_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_PassByMap(r.params)) +func (r *moqUsual_PassByMap_recorder) seq() *moqUsual_PassByMap_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqUsual_PassByMap_fnRecorder) noSeq() *moqUsual_PassByMap_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_PassByMap(r.params)) +func (r *moqUsual_PassByMap_recorder) noSeq() *moqUsual_PassByMap_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUsual_PassByMap_fnRecorder) returnResults(result1 map[string]testmoqs.Results) *moqUsual_PassByMap_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 map[string]testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByMap_doFn - doReturnFn moqUsual_PassByMap_doReturnFn - }{ - values: &struct { - result1 map[string]testmoqs.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqUsual_PassByMap_recorder) returnResults(result1 map[string]testmoqs.Results) *moqUsual_PassByMap_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_PassByMap_results{ + result1: result1, }) return r } -func (r *moqUsual_PassByMap_fnRecorder) andDo(fn moqUsual_PassByMap_doFn) *moqUsual_PassByMap_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqUsual_PassByMap_recorder) andDo(fn moqUsual_PassByMap_doFn) *moqUsual_PassByMap_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_PassByMap_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqUsual_PassByMap_fnRecorder) doReturnResults(fn moqUsual_PassByMap_doReturnFn) *moqUsual_PassByMap_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 map[string]testmoqs.Results +func (r *moqUsual_PassByMap_recorder) doReturnResults(fn moqUsual_PassByMap_doReturnFn) *moqUsual_PassByMap_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_PassByMap_params) *moqUsual_PassByMap_results { + result1 := fn(params.p) + return &moqUsual_PassByMap_results{ + result1: result1, } - sequence uint32 - doFn moqUsual_PassByMap_doFn - doReturnFn moqUsual_PassByMap_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqUsual_PassByMap_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_PassByMap_resultsByParams - for n, res := range r.moq.resultsByParams_PassByMap { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqUsual_PassByMap_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_PassByMap_paramsKey]*moqUsual_PassByMap_results{}, - } - r.moq.resultsByParams_PassByMap = append(r.moq.resultsByParams_PassByMap, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_PassByMap) { - copy(r.moq.resultsByParams_PassByMap[insertAt+1:], r.moq.resultsByParams_PassByMap[insertAt:0]) - r.moq.resultsByParams_PassByMap[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_PassByMap(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_PassByMap_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_PassByMap_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByMap_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqUsual_PassByMap_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByMap_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 map[string]testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByMap_doFn - doReturnFn moqUsual_PassByMap_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqUsual) prettyParams_PassByMap(params moqUsual_PassByMap_params) string { +func (*moqUsual_PassByMap_adaptor) PrettyParams(params moqUsual_PassByMap_params) string { return fmt.Sprintf("PassByMap(%#v)", params.p) } -func (m *moqUsual) paramsKey_PassByMap(params moqUsual_PassByMap_params, anyParams uint64) moqUsual_PassByMap_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.PassByMap.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter of the PassByMap function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqUsual_PassByMap_adaptor) ParamsKey(params moqUsual_PassByMap_params, anyParams uint64) moqUsual_PassByMap_paramsKey { + a.moq.moq_PassByMap.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq_PassByMap.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.PassByMap.p, anyParams) return moqUsual_PassByMap_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -16117,199 +9037,88 @@ func (m *moqUsual) paramsKey_PassByMap(params moqUsual_PassByMap_params, anyPara } } -func (m *moqUsual_recorder) PassByReference(p *testmoqs.Params) *moqUsual_PassByReference_fnRecorder { - return &moqUsual_PassByReference_fnRecorder{ - params: moqUsual_PassByReference_params{ +func (m *moqUsual_recorder) PassByReference(p *testmoqs.Params) *moqUsual_PassByReference_recorder { + return &moqUsual_PassByReference_recorder{ + recorder: m.moq.moq_PassByReference.OnCall(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)) +func (r *moqUsual_PassByReference_recorder) any() *moqUsual_PassByReference_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_PassByReference_anyParams{recorder: r} } -func (a *moqUsual_PassByReference_anyParams) p() *moqUsual_PassByReference_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_PassByReference_anyParams) p() *moqUsual_PassByReference_recorder { + a.recorder.recorder.AnyParam(1) 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(result1 *testmoqs.Results) *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 { - result1 *testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByReference_doFn - doReturnFn moqUsual_PassByReference_doReturnFn - }{ - values: &struct { - result1 *testmoqs.Results - }{ - result1: result1, - }, - 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") +func (r *moqUsual_PassByReference_recorder) seq() *moqUsual_PassByReference_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { 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 { - result1 *testmoqs.Results - } - 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 +func (r *moqUsual_PassByReference_recorder) noSeq() *moqUsual_PassByReference_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { + return nil } + return r +} - r.results.repeat.Increment(r.moq.scene.T) +func (r *moqUsual_PassByReference_recorder) returnResults(result1 *testmoqs.Results) *moqUsual_PassByReference_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_PassByReference_results{ + result1: result1, + }) + return r } -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") +func (r *moqUsual_PassByReference_recorder) andDo(fn moqUsual_PassByReference_doFn) *moqUsual_PassByReference_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_PassByReference_params) { + fn(params.p) + }, false) { 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 *testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByReference_doFn - doReturnFn moqUsual_PassByReference_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } + return r +} + +func (r *moqUsual_PassByReference_recorder) doReturnResults(fn moqUsual_PassByReference_doReturnFn) *moqUsual_PassByReference_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_PassByReference_params) *moqUsual_PassByReference_results { + result1 := fn(params.p) + return &moqUsual_PassByReference_results{ + result1: result1, } - r.results.results = append(r.results.results, last) + }) + return r +} + +func (r *moqUsual_PassByReference_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByReference_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqUsual) prettyParams_PassByReference(params moqUsual_PassByReference_params) string { +func (*moqUsual_PassByReference_adaptor) PrettyParams(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.Params - 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) - } - } +func (a *moqUsual_PassByReference_adaptor) ParamsKey(params moqUsual_PassByReference_params, anyParams uint64) moqUsual_PassByReference_paramsKey { + a.moq.moq_PassByReference.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.p, 1, a.moq.runtime.parameterIndexing.PassByReference.p, anyParams) return moqUsual_PassByReference_paramsKey{ params: struct{ p *testmoqs.Params }{ p: pUsed, @@ -16320,197 +9129,88 @@ func (m *moqUsual) paramsKey_PassByReference(params moqUsual_PassByReference_par } } -func (m *moqUsual_recorder) PassBySlice(p []testmoqs.Params) *moqUsual_PassBySlice_fnRecorder { - return &moqUsual_PassBySlice_fnRecorder{ - params: moqUsual_PassBySlice_params{ +func (m *moqUsual_recorder) PassBySlice(p []testmoqs.Params) *moqUsual_PassBySlice_recorder { + return &moqUsual_PassBySlice_recorder{ + recorder: m.moq.moq_PassBySlice.OnCall(moqUsual_PassBySlice_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqUsual_PassBySlice_fnRecorder) any() *moqUsual_PassBySlice_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_PassBySlice(r.params)) +func (r *moqUsual_PassBySlice_recorder) any() *moqUsual_PassBySlice_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_PassBySlice_anyParams{recorder: r} } -func (a *moqUsual_PassBySlice_anyParams) p() *moqUsual_PassBySlice_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_PassBySlice_anyParams) p() *moqUsual_PassBySlice_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqUsual_PassBySlice_fnRecorder) seq() *moqUsual_PassBySlice_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_PassBySlice(r.params)) +func (r *moqUsual_PassBySlice_recorder) seq() *moqUsual_PassBySlice_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqUsual_PassBySlice_fnRecorder) noSeq() *moqUsual_PassBySlice_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_PassBySlice(r.params)) +func (r *moqUsual_PassBySlice_recorder) noSeq() *moqUsual_PassBySlice_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUsual_PassBySlice_fnRecorder) returnResults(result1 []testmoqs.Results) *moqUsual_PassBySlice_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 []testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassBySlice_doFn - doReturnFn moqUsual_PassBySlice_doReturnFn - }{ - values: &struct { - result1 []testmoqs.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqUsual_PassBySlice_recorder) returnResults(result1 []testmoqs.Results) *moqUsual_PassBySlice_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_PassBySlice_results{ + result1: result1, }) return r } -func (r *moqUsual_PassBySlice_fnRecorder) andDo(fn moqUsual_PassBySlice_doFn) *moqUsual_PassBySlice_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqUsual_PassBySlice_recorder) andDo(fn moqUsual_PassBySlice_doFn) *moqUsual_PassBySlice_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_PassBySlice_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqUsual_PassBySlice_fnRecorder) doReturnResults(fn moqUsual_PassBySlice_doReturnFn) *moqUsual_PassBySlice_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 []testmoqs.Results +func (r *moqUsual_PassBySlice_recorder) doReturnResults(fn moqUsual_PassBySlice_doReturnFn) *moqUsual_PassBySlice_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_PassBySlice_params) *moqUsual_PassBySlice_results { + result1 := fn(params.p) + return &moqUsual_PassBySlice_results{ + result1: result1, } - sequence uint32 - doFn moqUsual_PassBySlice_doFn - doReturnFn moqUsual_PassBySlice_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqUsual_PassBySlice_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_PassBySlice_resultsByParams - for n, res := range r.moq.resultsByParams_PassBySlice { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqUsual_PassBySlice_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_PassBySlice_paramsKey]*moqUsual_PassBySlice_results{}, - } - r.moq.resultsByParams_PassBySlice = append(r.moq.resultsByParams_PassBySlice, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_PassBySlice) { - copy(r.moq.resultsByParams_PassBySlice[insertAt+1:], r.moq.resultsByParams_PassBySlice[insertAt:0]) - r.moq.resultsByParams_PassBySlice[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_PassBySlice(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_PassBySlice_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_PassBySlice_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassBySlice_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqUsual_PassBySlice_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassBySlice_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 []testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassBySlice_doFn - doReturnFn moqUsual_PassBySlice_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqUsual) prettyParams_PassBySlice(params moqUsual_PassBySlice_params) string { +func (*moqUsual_PassBySlice_adaptor) PrettyParams(params moqUsual_PassBySlice_params) string { return fmt.Sprintf("PassBySlice(%#v)", params.p) } -func (m *moqUsual) paramsKey_PassBySlice(params moqUsual_PassBySlice_params, anyParams uint64) moqUsual_PassBySlice_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.PassBySlice.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter of the PassBySlice function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqUsual_PassBySlice_adaptor) ParamsKey(params moqUsual_PassBySlice_params, anyParams uint64) moqUsual_PassBySlice_paramsKey { + a.moq.moq_PassBySlice.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq_PassBySlice.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.PassBySlice.p, anyParams) return moqUsual_PassBySlice_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -16519,199 +9219,88 @@ func (m *moqUsual) paramsKey_PassBySlice(params moqUsual_PassBySlice_params, any } } -func (m *moqUsual_recorder) PassByValue(p testmoqs.Params) *moqUsual_PassByValue_fnRecorder { - return &moqUsual_PassByValue_fnRecorder{ - params: moqUsual_PassByValue_params{ +func (m *moqUsual_recorder) PassByValue(p testmoqs.Params) *moqUsual_PassByValue_recorder { + return &moqUsual_PassByValue_recorder{ + recorder: m.moq.moq_PassByValue.OnCall(moqUsual_PassByValue_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqUsual_PassByValue_fnRecorder) any() *moqUsual_PassByValue_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_PassByValue(r.params)) +func (r *moqUsual_PassByValue_recorder) any() *moqUsual_PassByValue_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_PassByValue_anyParams{recorder: r} } -func (a *moqUsual_PassByValue_anyParams) p() *moqUsual_PassByValue_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_PassByValue_anyParams) p() *moqUsual_PassByValue_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqUsual_PassByValue_fnRecorder) seq() *moqUsual_PassByValue_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_PassByValue(r.params)) +func (r *moqUsual_PassByValue_recorder) seq() *moqUsual_PassByValue_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqUsual_PassByValue_fnRecorder) noSeq() *moqUsual_PassByValue_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_PassByValue(r.params)) +func (r *moqUsual_PassByValue_recorder) noSeq() *moqUsual_PassByValue_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUsual_PassByValue_fnRecorder) returnResults(result1 testmoqs.Results) *moqUsual_PassByValue_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 testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByValue_doFn - doReturnFn moqUsual_PassByValue_doReturnFn - }{ - values: &struct { - result1 testmoqs.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqUsual_PassByValue_recorder) returnResults(result1 testmoqs.Results) *moqUsual_PassByValue_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_PassByValue_results{ + result1: result1, }) return r } -func (r *moqUsual_PassByValue_fnRecorder) andDo(fn moqUsual_PassByValue_doFn) *moqUsual_PassByValue_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqUsual_PassByValue_recorder) andDo(fn moqUsual_PassByValue_doFn) *moqUsual_PassByValue_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_PassByValue_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqUsual_PassByValue_fnRecorder) doReturnResults(fn moqUsual_PassByValue_doReturnFn) *moqUsual_PassByValue_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 testmoqs.Results +func (r *moqUsual_PassByValue_recorder) doReturnResults(fn moqUsual_PassByValue_doReturnFn) *moqUsual_PassByValue_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_PassByValue_params) *moqUsual_PassByValue_results { + result1 := fn(params.p) + return &moqUsual_PassByValue_results{ + result1: result1, } - sequence uint32 - doFn moqUsual_PassByValue_doFn - doReturnFn moqUsual_PassByValue_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqUsual_PassByValue_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_PassByValue_resultsByParams - for n, res := range r.moq.resultsByParams_PassByValue { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqUsual_PassByValue_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_PassByValue_paramsKey]*moqUsual_PassByValue_results{}, - } - r.moq.resultsByParams_PassByValue = append(r.moq.resultsByParams_PassByValue, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_PassByValue) { - copy(r.moq.resultsByParams_PassByValue[insertAt+1:], r.moq.resultsByParams_PassByValue[insertAt:0]) - r.moq.resultsByParams_PassByValue[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_PassByValue(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_PassByValue_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_PassByValue_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByValue_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqUsual_PassByValue_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_PassByValue_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 testmoqs.Results - } - sequence uint32 - doFn moqUsual_PassByValue_doFn - doReturnFn moqUsual_PassByValue_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqUsual) prettyParams_PassByValue(params moqUsual_PassByValue_params) string { +func (*moqUsual_PassByValue_adaptor) PrettyParams(params moqUsual_PassByValue_params) string { return fmt.Sprintf("PassByValue(%#v)", params.p) } -func (m *moqUsual) paramsKey_PassByValue(params moqUsual_PassByValue_params, anyParams uint64) moqUsual_PassByValue_paramsKey { - m.scene.T.Helper() - var pUsed testmoqs.Params - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.PassByValue.p == moq.ParamIndexByValue { - pUsed = params.p - } else { - pUsedHash = hash.DeepHash(params.p) - } - } +func (a *moqUsual_PassByValue_adaptor) ParamsKey(params moqUsual_PassByValue_params, anyParams uint64) moqUsual_PassByValue_paramsKey { + a.moq.moq_PassByValue.Scene.T.Helper() + pUsed, pUsedHash := impl.ParamKey( + params.p, 1, a.moq.runtime.parameterIndexing.PassByValue.p, anyParams) return moqUsual_PassByValue_paramsKey{ params: struct{ p testmoqs.Params }{ p: pUsed, @@ -16722,204 +9311,90 @@ func (m *moqUsual) paramsKey_PassByValue(params moqUsual_PassByValue_params, any } } -func (m *moqUsual_recorder) InterfaceParam(w io.Writer) *moqUsual_InterfaceParam_fnRecorder { - return &moqUsual_InterfaceParam_fnRecorder{ - params: moqUsual_InterfaceParam_params{ +func (m *moqUsual_recorder) InterfaceParam(w io.Writer) *moqUsual_InterfaceParam_recorder { + return &moqUsual_InterfaceParam_recorder{ + recorder: m.moq.moq_InterfaceParam.OnCall(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_InterfaceParam(r.params)) +func (r *moqUsual_InterfaceParam_recorder) any() *moqUsual_InterfaceParam_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_InterfaceParam_anyParams{recorder: r} } -func (a *moqUsual_InterfaceParam_anyParams) w() *moqUsual_InterfaceParam_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_InterfaceParam_anyParams) w() *moqUsual_InterfaceParam_recorder { + a.recorder.recorder.AnyParam(1) 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_InterfaceParam(r.params)) +func (r *moqUsual_InterfaceParam_recorder) seq() *moqUsual_InterfaceParam_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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_InterfaceParam(r.params)) +func (r *moqUsual_InterfaceParam_recorder) noSeq() *moqUsual_InterfaceParam_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUsual_InterfaceParam_fnRecorder) returnResults(sResult string, err error) *moqUsual_InterfaceParam_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_InterfaceParam_doFn - doReturnFn moqUsual_InterfaceParam_doReturnFn - }{ - values: &struct { - sResult string - err error - }{ - sResult: sResult, - err: err, - }, - sequence: sequence, +func (r *moqUsual_InterfaceParam_recorder) returnResults(sResult string, err error) *moqUsual_InterfaceParam_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_InterfaceParam_results{ + sResult: sResult, + err: err, }) return r } -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") +func (r *moqUsual_InterfaceParam_recorder) andDo(fn moqUsual_InterfaceParam_doFn) *moqUsual_InterfaceParam_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_InterfaceParam_params) { + fn(params.w) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqUsual_InterfaceParam_fnRecorder) doReturnResults(fn moqUsual_InterfaceParam_doReturnFn) *moqUsual_InterfaceParam_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 +func (r *moqUsual_InterfaceParam_recorder) doReturnResults(fn moqUsual_InterfaceParam_doReturnFn) *moqUsual_InterfaceParam_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_InterfaceParam_params) *moqUsual_InterfaceParam_results { + sResult, err := fn(params.w) + return &moqUsual_InterfaceParam_results{ + sResult: sResult, + err: err, } - sequence uint32 - doFn moqUsual_InterfaceParam_doFn - doReturnFn moqUsual_InterfaceParam_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqUsual_InterfaceParam_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_InterfaceParam_resultsByParams - for n, res := range r.moq.resultsByParams_InterfaceParam { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqUsual_InterfaceParam_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_InterfaceParam_paramsKey]*moqUsual_InterfaceParam_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_InterfaceParam(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_InterfaceParam_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_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") - 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_InterfaceParam_doFn - doReturnFn moqUsual_InterfaceParam_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqUsual_InterfaceParam_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_InterfaceParam_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqUsual) prettyParams_InterfaceParam(params moqUsual_InterfaceParam_params) string { +func (*moqUsual_InterfaceParam_adaptor) PrettyParams(params moqUsual_InterfaceParam_params) string { return fmt.Sprintf("InterfaceParam(%#v)", params.w) } -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) - } - } +func (a *moqUsual_InterfaceParam_adaptor) ParamsKey(params moqUsual_InterfaceParam_params, anyParams uint64) moqUsual_InterfaceParam_paramsKey { + a.moq.moq_InterfaceParam.Scene.T.Helper() + wUsed, wUsedHash := impl.ParamKey( + params.w, 1, a.moq.runtime.parameterIndexing.InterfaceParam.w, anyParams) return moqUsual_InterfaceParam_paramsKey{ params: struct{ w io.Writer }{ w: wUsed, @@ -16930,206 +9405,96 @@ func (m *moqUsual) paramsKey_InterfaceParam(params moqUsual_InterfaceParam_param } } -func (m *moqUsual_recorder) InterfaceResult(sParam string, bParam bool) *moqUsual_InterfaceResult_fnRecorder { - return &moqUsual_InterfaceResult_fnRecorder{ - params: moqUsual_InterfaceResult_params{ +func (m *moqUsual_recorder) InterfaceResult(sParam string, bParam bool) *moqUsual_InterfaceResult_recorder { + return &moqUsual_InterfaceResult_recorder{ + recorder: m.moq.moq_InterfaceResult.OnCall(moqUsual_InterfaceResult_params{ sParam: sParam, bParam: bParam, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -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_InterfaceResult(r.params)) +func (r *moqUsual_InterfaceResult_recorder) any() *moqUsual_InterfaceResult_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_InterfaceResult_anyParams{recorder: r} } -func (a *moqUsual_InterfaceResult_anyParams) sParam() *moqUsual_InterfaceResult_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_InterfaceResult_anyParams) sParam() *moqUsual_InterfaceResult_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqUsual_InterfaceResult_anyParams) bParam() *moqUsual_InterfaceResult_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqUsual_InterfaceResult_anyParams) bParam() *moqUsual_InterfaceResult_recorder { + a.recorder.recorder.AnyParam(2) 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_InterfaceResult(r.params)) +func (r *moqUsual_InterfaceResult_recorder) seq() *moqUsual_InterfaceResult_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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_InterfaceResult(r.params)) +func (r *moqUsual_InterfaceResult_recorder) noSeq() *moqUsual_InterfaceResult_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUsual_InterfaceResult_fnRecorder) returnResults(result1 io.Reader) *moqUsual_InterfaceResult_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 io.Reader } - sequence uint32 - doFn moqUsual_InterfaceResult_doFn - doReturnFn moqUsual_InterfaceResult_doReturnFn - }{ - values: &struct{ result1 io.Reader }{ - result1: result1, - }, - sequence: sequence, +func (r *moqUsual_InterfaceResult_recorder) returnResults(result1 io.Reader) *moqUsual_InterfaceResult_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_InterfaceResult_results{ + result1: result1, }) return r } -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") +func (r *moqUsual_InterfaceResult_recorder) andDo(fn moqUsual_InterfaceResult_doFn) *moqUsual_InterfaceResult_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_InterfaceResult_params) { + fn(params.sParam, params.bParam) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn - return r -} - -func (r *moqUsual_InterfaceResult_fnRecorder) doReturnResults(fn moqUsual_InterfaceResult_doReturnFn) *moqUsual_InterfaceResult_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 io.Reader } - sequence uint32 - doFn moqUsual_InterfaceResult_doFn - doReturnFn moqUsual_InterfaceResult_doReturnFn - }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqUsual_InterfaceResult_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_InterfaceResult_resultsByParams - for n, res := range r.moq.resultsByParams_InterfaceResult { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqUsual_InterfaceResult_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_InterfaceResult_paramsKey]*moqUsual_InterfaceResult_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_InterfaceResult(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_InterfaceResult_results{ - params: r.params, - results: nil, - index: 0, - repeat: &moq.RepeatVal{}, +func (r *moqUsual_InterfaceResult_recorder) doReturnResults(fn moqUsual_InterfaceResult_doReturnFn) *moqUsual_InterfaceResult_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_InterfaceResult_params) *moqUsual_InterfaceResult_results { + result1 := fn(params.sParam, params.bParam) + return &moqUsual_InterfaceResult_results{ + result1: result1, } - results.results[paramsKey] = r.results - } - - r.results.repeat.Increment(r.moq.scene.T) + }) + return r } -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") +func (r *moqUsual_InterfaceResult_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_InterfaceResult_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 io.Reader } - sequence uint32 - doFn moqUsual_InterfaceResult_doFn - doReturnFn moqUsual_InterfaceResult_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqUsual) prettyParams_InterfaceResult(params moqUsual_InterfaceResult_params) string { +func (*moqUsual_InterfaceResult_adaptor) PrettyParams(params moqUsual_InterfaceResult_params) string { return fmt.Sprintf("InterfaceResult(%#v, %#v)", params.sParam, params.bParam) } -func (m *moqUsual) paramsKey_InterfaceResult(params moqUsual_InterfaceResult_params, anyParams uint64) moqUsual_InterfaceResult_paramsKey { - m.scene.T.Helper() - 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) - } - } +func (a *moqUsual_InterfaceResult_adaptor) ParamsKey(params moqUsual_InterfaceResult_params, anyParams uint64) moqUsual_InterfaceResult_paramsKey { + a.moq.moq_InterfaceResult.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.sParam, 1, a.moq.runtime.parameterIndexing.InterfaceResult.sParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.bParam, 2, a.moq.runtime.parameterIndexing.InterfaceResult.bParam, anyParams) return moqUsual_InterfaceResult_paramsKey{ params: struct { sParam string @@ -17148,187 +9513,84 @@ func (m *moqUsual) paramsKey_InterfaceResult(params moqUsual_InterfaceResult_par } } -func (m *moqUsual_recorder) FnParam(fn func()) *moqUsual_FnParam_fnRecorder { - return &moqUsual_FnParam_fnRecorder{ - params: moqUsual_FnParam_params{ +func (m *moqUsual_recorder) FnParam(fn func()) *moqUsual_FnParam_recorder { + return &moqUsual_FnParam_recorder{ + recorder: m.moq.moq_FnParam.OnCall(moqUsual_FnParam_params{ fn: fn, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -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_FnParam(r.params)) +func (r *moqUsual_FnParam_recorder) any() *moqUsual_FnParam_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_FnParam_anyParams{recorder: r} } -func (a *moqUsual_FnParam_anyParams) fn() *moqUsual_FnParam_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_FnParam_anyParams) fn() *moqUsual_FnParam_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -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_FnParam(r.params)) +func (r *moqUsual_FnParam_recorder) seq() *moqUsual_FnParam_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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_FnParam(r.params)) +func (r *moqUsual_FnParam_recorder) noSeq() *moqUsual_FnParam_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUsual_FnParam_fnRecorder) returnResults() *moqUsual_FnParam_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_FnParam_doFn - doReturnFn moqUsual_FnParam_doReturnFn - }{ - values: &struct{}{}, - sequence: sequence, - }) +func (r *moqUsual_FnParam_recorder) returnResults() *moqUsual_FnParam_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_FnParam_results{}) return r } -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") +func (r *moqUsual_FnParam_recorder) andDo(fn moqUsual_FnParam_doFn) *moqUsual_FnParam_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_FnParam_params) { + fn(params.fn) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqUsual_FnParam_fnRecorder) doReturnResults(fn moqUsual_FnParam_doReturnFn) *moqUsual_FnParam_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_FnParam_doFn - doReturnFn moqUsual_FnParam_doReturnFn - }{sequence: sequence, doReturnFn: fn}) +func (r *moqUsual_FnParam_recorder) doReturnResults(fn moqUsual_FnParam_doReturnFn) *moqUsual_FnParam_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_FnParam_params) *moqUsual_FnParam_results { + fn(params.fn) + return &moqUsual_FnParam_results{} + }) return r } -func (r *moqUsual_FnParam_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_FnParam_resultsByParams - for n, res := range r.moq.resultsByParams_FnParam { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqUsual_FnParam_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_FnParam_paramsKey]*moqUsual_FnParam_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_FnParam(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_FnParam_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_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") +func (r *moqUsual_FnParam_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_FnParam_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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_FnParam_doFn - doReturnFn moqUsual_FnParam_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqUsual) prettyParams_FnParam(params moqUsual_FnParam_params) string { +func (*moqUsual_FnParam_adaptor) PrettyParams(params moqUsual_FnParam_params) string { return fmt.Sprintf("FnParam(%#v)", moq.FnString(params.fn)) } -func (m *moqUsual) paramsKey_FnParam(params moqUsual_FnParam_params, anyParams uint64) moqUsual_FnParam_paramsKey { - m.scene.T.Helper() - var fnUsedHash 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") - } - fnUsedHash = hash.DeepHash(params.fn) - } +func (a *moqUsual_FnParam_adaptor) ParamsKey(params moqUsual_FnParam_params, anyParams uint64) moqUsual_FnParam_paramsKey { + a.moq.moq_FnParam.Scene.T.Helper() + fnUsedHash := impl.HashOnlyParamKey(a.moq.moq_FnParam.Scene.T, + params.fn, "fn", 1, a.moq.runtime.parameterIndexing.FnParam.fn, anyParams) return moqUsual_FnParam_paramsKey{ params: struct{}{}, hashes: struct{ fn hash.Hash }{ @@ -17337,430 +9599,167 @@ func (m *moqUsual) paramsKey_FnParam(params moqUsual_FnParam_params, anyParams u } } -func (m *moqUsual_recorder) Other(param1 other.Params) *moqUsual_Other_fnRecorder { - return &moqUsual_Other_fnRecorder{ - params: moqUsual_Other_params{ +func (m *moqUsual_recorder) Other(param1 other.Params) *moqUsual_Other_recorder { + return &moqUsual_Other_recorder{ + recorder: m.moq.moq_Other.OnCall(moqUsual_Other_params{ param1: param1, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqUsual_Other_fnRecorder) any() *moqUsual_Other_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_Other(r.params)) +func (r *moqUsual_Other_recorder) any() *moqUsual_Other_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUsual_Other_anyParams{recorder: r} } -func (a *moqUsual_Other_anyParams) param1() *moqUsual_Other_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqUsual_Other_anyParams) param1() *moqUsual_Other_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqUsual_Other_fnRecorder) seq() *moqUsual_Other_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_Other(r.params)) +func (r *moqUsual_Other_recorder) seq() *moqUsual_Other_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqUsual_Other_fnRecorder) noSeq() *moqUsual_Other_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_Other(r.params)) +func (r *moqUsual_Other_recorder) noSeq() *moqUsual_Other_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUsual_Other_fnRecorder) returnResults(result1 other.Results) *moqUsual_Other_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 other.Results - } - sequence uint32 - doFn moqUsual_Other_doFn - doReturnFn moqUsual_Other_doReturnFn - }{ - values: &struct { - result1 other.Results - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqUsual_Other_recorder) returnResults(result1 other.Results) *moqUsual_Other_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUsual_Other_results{ + result1: result1, }) return r } -func (r *moqUsual_Other_fnRecorder) andDo(fn moqUsual_Other_doFn) *moqUsual_Other_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqUsual_Other_recorder) andDo(fn moqUsual_Other_doFn) *moqUsual_Other_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUsual_Other_params) { + fn(params.param1) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqUsual_Other_fnRecorder) doReturnResults(fn moqUsual_Other_doReturnFn) *moqUsual_Other_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 other.Results +func (r *moqUsual_Other_recorder) doReturnResults(fn moqUsual_Other_doReturnFn) *moqUsual_Other_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUsual_Other_params) *moqUsual_Other_results { + result1 := fn(params.param1) + return &moqUsual_Other_results{ + result1: result1, } - sequence uint32 - doFn moqUsual_Other_doFn - doReturnFn moqUsual_Other_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqUsual_Other_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_Other_resultsByParams - for n, res := range r.moq.resultsByParams_Other { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqUsual_Other_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUsual_Other_paramsKey]*moqUsual_Other_results{}, - } - r.moq.resultsByParams_Other = append(r.moq.resultsByParams_Other, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Other) { - copy(r.moq.resultsByParams_Other[insertAt+1:], r.moq.resultsByParams_Other[insertAt:0]) - r.moq.resultsByParams_Other[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Other(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUsual_Other_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_Other_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUsual_Other_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqUsual_Other_recorder) repeat(repeaters ...moq.Repeater) *moqUsual_Other_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 other.Results - } - sequence uint32 - doFn moqUsual_Other_doFn - doReturnFn moqUsual_Other_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqUsual) prettyParams_Other(params moqUsual_Other_params) string { +func (*moqUsual_Other_adaptor) PrettyParams(params moqUsual_Other_params) string { return fmt.Sprintf("Other(%#v)", params.param1) } -func (m *moqUsual) paramsKey_Other(params moqUsual_Other_params, anyParams uint64) moqUsual_Other_paramsKey { - m.scene.T.Helper() - var param1Used other.Params - var param1UsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Other.param1 == moq.ParamIndexByValue { - param1Used = params.param1 - } else { - param1UsedHash = hash.DeepHash(params.param1) - } - } +func (a *moqUsual_Other_adaptor) ParamsKey(params moqUsual_Other_params, anyParams uint64) moqUsual_Other_paramsKey { + a.moq.moq_Other.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.param1, 1, a.moq.runtime.parameterIndexing.Other.param1, anyParams) return moqUsual_Other_paramsKey{ params: struct{ param1 other.Params }{ param1: param1Used, }, - hashes: struct{ param1 hash.Hash }{ - param1: param1UsedHash, - }, - } -} - -// 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_PassByArray = nil - m.resultsByParams_PassByChan = nil - m.resultsByParams_PassByEllipsis = nil - m.resultsByParams_PassByMap = nil - m.resultsByParams_PassByReference = nil - m.resultsByParams_PassBySlice = nil - m.resultsByParams_PassByValue = nil - m.resultsByParams_InterfaceParam = nil - m.resultsByParams_InterfaceResult = nil - m.resultsByParams_FnParam = nil - m.resultsByParams_Other = 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)) - } - } - } - 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_PassByArray { - 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_PassByArray(results.params)) - } - } - } - for _, res := range m.resultsByParams_PassByChan { - 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_PassByChan(results.params)) - } - } - } - for _, res := range m.resultsByParams_PassByEllipsis { - 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_PassByEllipsis(results.params)) - } - } - } - for _, res := range m.resultsByParams_PassByMap { - 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_PassByMap(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_PassBySlice { - 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_PassBySlice(results.params)) - } - } - } - for _, res := range m.resultsByParams_PassByValue { - 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_PassByValue(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)) - } - } - } - for _, res := range m.resultsByParams_Other { - 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_Other(results.params)) - } - } + hashes: struct{ param1 hash.Hash }{ + param1: param1UsedHash, + }, } } +// Reset resets the state of the moq +func (m *moqUsual) Reset() { + m.moq_Usual.Reset() + m.moq_NoNames.Reset() + m.moq_NoResults.Reset() + m.moq_NoParams.Reset() + m.moq_Nothing.Reset() + m.moq_Variadic.Reset() + m.moq_RepeatedIds.Reset() + m.moq_Times.Reset() + m.moq_DifficultParamNames.Reset() + m.moq_DifficultResultNames.Reset() + m.moq_PassByArray.Reset() + m.moq_PassByChan.Reset() + m.moq_PassByEllipsis.Reset() + m.moq_PassByMap.Reset() + m.moq_PassByReference.Reset() + m.moq_PassBySlice.Reset() + m.moq_PassByValue.Reset() + m.moq_InterfaceParam.Reset() + m.moq_InterfaceResult.Reset() + m.moq_FnParam.Reset() + m.moq_Other.Reset() +} + +// AssertExpectationsMet asserts that all expectations have been met +func (m *moqUsual) AssertExpectationsMet() { + m.moq_Usual.Scene.T.Helper() + m.moq_Usual.AssertExpectationsMet() + m.moq_NoNames.AssertExpectationsMet() + m.moq_NoResults.AssertExpectationsMet() + m.moq_NoParams.AssertExpectationsMet() + m.moq_Nothing.AssertExpectationsMet() + m.moq_Variadic.AssertExpectationsMet() + m.moq_RepeatedIds.AssertExpectationsMet() + m.moq_Times.AssertExpectationsMet() + m.moq_DifficultParamNames.AssertExpectationsMet() + m.moq_DifficultResultNames.AssertExpectationsMet() + m.moq_PassByArray.AssertExpectationsMet() + m.moq_PassByChan.AssertExpectationsMet() + m.moq_PassByEllipsis.AssertExpectationsMet() + m.moq_PassByMap.AssertExpectationsMet() + m.moq_PassByReference.AssertExpectationsMet() + m.moq_PassBySlice.AssertExpectationsMet() + m.moq_PassByValue.AssertExpectationsMet() + m.moq_InterfaceParam.AssertExpectationsMet() + m.moq_InterfaceResult.AssertExpectationsMet() + m.moq_FnParam.AssertExpectationsMet() + m.moq_Other.AssertExpectationsMet() +} + // The following type assertion assures that testmoqs.GenericParams is mocked // completely var _ testmoqs.GenericParams[any, any] = (*moqGenericParams_mock[any, any])(nil) // 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] - - 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 + moq *moqGenericParams_mock[S, B] + + moq_Usual *impl.Moq[ + *moqGenericParams_Usual_adaptor[S, B], + moqGenericParams_Usual_params[S, B], + moqGenericParams_Usual_paramsKey[S, B], + moqGenericParams_Usual_results[S, B]] + + runtime moqGenericParams_runtime } +// moqGenericParams_mock isolates the mock interface of the GenericParams type type moqGenericParams_mock[S, B any] struct { moq *moqGenericParams[S, B] } @@ -17771,6 +9770,20 @@ type moqGenericParams_recorder[S, B any] struct { moq *moqGenericParams[S, B] } +// moqGenericParams_runtime holds runtime configuration for the GenericParams +// type +type moqGenericParams_runtime struct { + parameterIndexing struct { + Usual moqGenericParams_Usual_paramIndexing + } +} + +// moqGenericParams_Usual_adaptor adapts moqGenericParams as needed by the +// runtime +type moqGenericParams_Usual_adaptor[S, B any] struct { + moq *moqGenericParams[S, B] +} + // moqGenericParams_Usual_params holds the params of the GenericParams type type moqGenericParams_Usual_params[S, B any] struct { param1 S @@ -17787,12 +9800,17 @@ type moqGenericParams_Usual_paramsKey[S, B any] 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_results holds the results of the GenericParams type +type moqGenericParams_Usual_results[S, B any] struct { + result1 string + result2 error +} + +// moqGenericParams_Usual_paramIndexing holds the parameter indexing runtime +// configuration for the GenericParams type +type moqGenericParams_Usual_paramIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } // moqGenericParams_Usual_doFn defines the type of function needed when calling @@ -17803,65 +9821,38 @@ type moqGenericParams_Usual_doFn[S, B any] func(S, B) // 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 { - result1 string - result2 error - } - sequence uint32 - doFn moqGenericParams_Usual_doFn[S, B] - doReturnFn moqGenericParams_Usual_doReturnFn[S, B] - } - index uint32 - repeat *moq.RepeatVal -} - -// moqGenericParams_Usual_fnRecorder routes recorded function calls to the +// moqGenericParams_Usual_recorder 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] +type moqGenericParams_Usual_recorder[S, B any] struct { + recorder *impl.Recorder[ + *moqGenericParams_Usual_adaptor[S, B], + moqGenericParams_Usual_params[S, B], + moqGenericParams_Usual_paramsKey[S, B], + moqGenericParams_Usual_results[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] + recorder *moqGenericParams_Usual_recorder[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{} - } + adaptor1 := &moqGenericParams_Usual_adaptor[S, B]{} m := &moqGenericParams[S, B]{ - scene: scene, - config: *config, - moq: &moqGenericParams_mock[S, B]{}, - - runtime: struct { - parameterIndexing struct { - Usual struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - } - }{parameterIndexing: struct { - Usual struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } + moq: &moqGenericParams_mock[S, B]{}, + + moq_Usual: impl.NewMoq[ + *moqGenericParams_Usual_adaptor[S, B], + moqGenericParams_Usual_params[S, B], + moqGenericParams_Usual_paramsKey[S, B], + moqGenericParams_Usual_results[S, B]](scene, adaptor1, config), + + runtime: moqGenericParams_runtime{parameterIndexing: struct { + Usual moqGenericParams_Usual_paramIndexing }{ - Usual: struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - }{ + Usual: moqGenericParams_Usual_paramIndexing{ param1: moq.ParamIndexByHash, param2: moq.ParamIndexByHash, }, @@ -17869,6 +9860,8 @@ func newMoqGenericParams[S, B any](scene *moq.Scene, config *moq.Config) *moqGen } m.moq.moq = m + adaptor1.moq = m + scene.AddMoq(m) return m } @@ -17876,59 +9869,20 @@ func newMoqGenericParams[S, B any](scene *moq.Scene, config *moq.Config) *moqGen // 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() +func (m *moqGenericParams_mock[S, B]) Usual(param1 S, param2 B) (string, error) { + m.moq.moq_Usual.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 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 + var result1 string + var result2 error + if result := m.moq.moq_Usual.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(param1, param2) - } - return + return result1, result2 } // onCall returns the recorder implementation of the GenericParams type @@ -17938,215 +9892,98 @@ func (m *moqGenericParams[S, B]) onCall() *moqGenericParams_recorder[S, B] { } } -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]{ +func (m *moqGenericParams_recorder[S, B]) Usual(param1 S, param2 B) *moqGenericParams_Usual_recorder[S, B] { + return &moqGenericParams_Usual_recorder[S, B]{ + recorder: m.moq.moq_Usual.OnCall(moqGenericParams_Usual_params[S, B]{ param1: param1, param2: param2, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -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_Usual(r.params)) +func (r *moqGenericParams_Usual_recorder[S, B]) any() *moqGenericParams_Usual_anyParams[S, B] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqGenericParams_Usual_anyParams[S, B]{recorder: r} } -func (a *moqGenericParams_Usual_anyParams[S, B]) param1() *moqGenericParams_Usual_fnRecorder[S, B] { - a.recorder.anyParams |= 1 << 0 +func (a *moqGenericParams_Usual_anyParams[S, B]) param1() *moqGenericParams_Usual_recorder[S, B] { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqGenericParams_Usual_anyParams[S, B]) param2() *moqGenericParams_Usual_fnRecorder[S, B] { - a.recorder.anyParams |= 1 << 1 +func (a *moqGenericParams_Usual_anyParams[S, B]) param2() *moqGenericParams_Usual_recorder[S, B] { + a.recorder.recorder.AnyParam(2) return a.recorder } -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_Usual(r.params)) +func (r *moqGenericParams_Usual_recorder[S, B]) seq() *moqGenericParams_Usual_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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_Usual(r.params)) +func (r *moqGenericParams_Usual_recorder[S, B]) noSeq() *moqGenericParams_Usual_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqGenericParams_Usual_fnRecorder[S, B]) returnResults(result1 string, result2 error) *moqGenericParams_Usual_fnRecorder[S, B] { - 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 moqGenericParams_Usual_doFn[S, B] - doReturnFn moqGenericParams_Usual_doReturnFn[S, B] - }{ - values: &struct { - result1 string - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqGenericParams_Usual_recorder[S, B]) returnResults(result1 string, result2 error) *moqGenericParams_Usual_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqGenericParams_Usual_results[S, B]{ + result1: result1, + result2: result2, }) return r } -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") +func (r *moqGenericParams_Usual_recorder[S, B]) andDo(fn moqGenericParams_Usual_doFn[S, B]) *moqGenericParams_Usual_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqGenericParams_Usual_params[S, B]) { + fn(params.param1, params.param2) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -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() - - 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 +func (r *moqGenericParams_Usual_recorder[S, B]) doReturnResults(fn moqGenericParams_Usual_doReturnFn[S, B]) *moqGenericParams_Usual_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqGenericParams_Usual_params[S, B]) *moqGenericParams_Usual_results[S, B] { + result1, result2 := fn(params.param1, params.param2) + return &moqGenericParams_Usual_results[S, B]{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqGenericParams_Usual_doFn[S, B] - doReturnFn moqGenericParams_Usual_doReturnFn[S, B] - }{sequence: sequence, doReturnFn: fn}) + }) return r } -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) - return - } - - anyCount := bits.OnesCount64(r.anyParams) - insertAt := -1 - var results *moqGenericParams_Usual_resultsByParams[S, B] - 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 = &moqGenericParams_Usual_resultsByParams[S, B]{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqGenericParams_Usual_paramsKey[S, B]]*moqGenericParams_Usual_results[S, B]{}, - } - 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 = &moqGenericParams_Usual_results[S, B]{ - 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 *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") - 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 moqGenericParams_Usual_doFn[S, B] - doReturnFn moqGenericParams_Usual_doReturnFn[S, B] - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqGenericParams_Usual_recorder[S, B]) repeat(repeaters ...moq.Repeater) *moqGenericParams_Usual_recorder[S, B] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqGenericParams[S, B]) prettyParams_Usual(params moqGenericParams_Usual_params[S, B]) string { +func (*moqGenericParams_Usual_adaptor[S, B]) PrettyParams(params moqGenericParams_Usual_params[S, B]) string { return fmt.Sprintf("Usual(%#v, %#v)", params.param1, params.param2) } -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 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 param2UsedHash hash.Hash - if anyParams&(1<<1) == 0 { - 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) - } +func (a *moqGenericParams_Usual_adaptor[S, B]) ParamsKey(params moqGenericParams_Usual_params[S, B], anyParams uint64) moqGenericParams_Usual_paramsKey[S, B] { + a.moq.moq_Usual.Scene.T.Helper() + param1UsedHash := impl.HashOnlyParamKey(a.moq.moq_Usual.Scene.T, + params.param1, "param1", 1, a.moq.runtime.parameterIndexing.Usual.param1, anyParams) + param2UsedHash := impl.HashOnlyParamKey(a.moq.moq_Usual.Scene.T, + params.param2, "param2", 2, a.moq.runtime.parameterIndexing.Usual.param2, anyParams) return moqGenericParams_Usual_paramsKey[S, B]{ params: struct{}{}, hashes: struct { @@ -18160,19 +9997,14 @@ func (m *moqGenericParams[S, B]) paramsKey_Usual(params moqGenericParams_Usual_p } // Reset resets the state of the moq -func (m *moqGenericParams[S, B]) Reset() { m.resultsByParams_Usual = nil } +func (m *moqGenericParams[S, B]) Reset() { + m.moq_Usual.Reset() +} // 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)) - } - } - } + m.moq_Usual.Scene.T.Helper() + m.moq_Usual.AssertExpectationsMet() } // The following type assertion assures that testmoqs.PartialGenericParams is @@ -18182,23 +10014,18 @@ var _ testmoqs.PartialGenericParams[any] = (*moqPartialGenericParams_mock[any])( // 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] - - resultsByParams_Usual []moqPartialGenericParams_Usual_resultsByParams[S] - - runtime struct { - parameterIndexing struct { - Usual struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - } - } - } - // moqPartialGenericParams_mock isolates the mock interface of the + moq *moqPartialGenericParams_mock[S] + + moq_Usual *impl.Moq[ + *moqPartialGenericParams_Usual_adaptor[S], + moqPartialGenericParams_Usual_params[S], + moqPartialGenericParams_Usual_paramsKey[S], + moqPartialGenericParams_Usual_results[S]] + + runtime moqPartialGenericParams_runtime } +// moqPartialGenericParams_mock isolates the mock interface of the // PartialGenericParams type type moqPartialGenericParams_mock[S any] struct { moq *moqPartialGenericParams[S] @@ -18210,6 +10037,20 @@ type moqPartialGenericParams_recorder[S any] struct { moq *moqPartialGenericParams[S] } +// moqPartialGenericParams_runtime holds runtime configuration for the +// PartialGenericParams type +type moqPartialGenericParams_runtime struct { + parameterIndexing struct { + Usual moqPartialGenericParams_Usual_paramIndexing + } +} + +// moqPartialGenericParams_Usual_adaptor adapts moqPartialGenericParams as +// needed by the runtime +type moqPartialGenericParams_Usual_adaptor[S any] struct { + moq *moqPartialGenericParams[S] +} + // moqPartialGenericParams_Usual_params holds the params of the // PartialGenericParams type type moqPartialGenericParams_Usual_params[S any] struct { @@ -18227,12 +10068,18 @@ type moqPartialGenericParams_Usual_paramsKey[S any] struct { } } -// 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_results holds the results of the +// PartialGenericParams type +type moqPartialGenericParams_Usual_results[S any] struct { + result1 string + result2 error +} + +// moqPartialGenericParams_Usual_paramIndexing holds the parameter indexing +// runtime configuration for the PartialGenericParams type +type moqPartialGenericParams_Usual_paramIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } // moqPartialGenericParams_Usual_doFn defines the type of function needed when @@ -18243,67 +10090,39 @@ type moqPartialGenericParams_Usual_doFn[S any] func(S, bool) // 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 - } - sequence uint32 - doFn moqPartialGenericParams_Usual_doFn[S] - doReturnFn moqPartialGenericParams_Usual_doReturnFn[S] - } - index uint32 - repeat *moq.RepeatVal -} - -// 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] +// moqPartialGenericParams_Usual_recorder routes recorded function calls to the +// moqPartialGenericParams moq +type moqPartialGenericParams_Usual_recorder[S any] struct { + recorder *impl.Recorder[ + *moqPartialGenericParams_Usual_adaptor[S], + moqPartialGenericParams_Usual_params[S], + moqPartialGenericParams_Usual_paramsKey[S], + moqPartialGenericParams_Usual_results[S]] } // moqPartialGenericParams_Usual_anyParams isolates the any params functions of // the PartialGenericParams type type moqPartialGenericParams_Usual_anyParams[S any] struct { - recorder *moqPartialGenericParams_Usual_fnRecorder[S] + recorder *moqPartialGenericParams_Usual_recorder[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{} - } + adaptor1 := &moqPartialGenericParams_Usual_adaptor[S]{} 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 - } + moq: &moqPartialGenericParams_mock[S]{}, + + moq_Usual: impl.NewMoq[ + *moqPartialGenericParams_Usual_adaptor[S], + moqPartialGenericParams_Usual_params[S], + moqPartialGenericParams_Usual_paramsKey[S], + moqPartialGenericParams_Usual_results[S]](scene, adaptor1, config), + + runtime: moqPartialGenericParams_runtime{parameterIndexing: struct { + Usual moqPartialGenericParams_Usual_paramIndexing }{ - Usual: struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - }{ + Usual: moqPartialGenericParams_Usual_paramIndexing{ param1: moq.ParamIndexByHash, param2: moq.ParamIndexByValue, }, @@ -18311,6 +10130,8 @@ func newMoqPartialGenericParams[S any](scene *moq.Scene, config *moq.Config) *mo } m.moq.moq = m + adaptor1.moq = m + scene.AddMoq(m) return m } @@ -18318,59 +10139,20 @@ func newMoqPartialGenericParams[S any](scene *moq.Scene, config *moq.Config) *mo // 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() +func (m *moqPartialGenericParams_mock[S]) Usual(param1 S, param2 bool) (string, error) { + m.moq.moq_Usual.Scene.T.Helper() params := moqPartialGenericParams_Usual_params[S]{ param1: param1, param2: param2, } - 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 - } - } - 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) + var result1 string + var result2 error + if result := m.moq.moq_Usual.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - return + return result1, result2 } // onCall returns the recorder implementation of the PartialGenericParams type @@ -18380,217 +10162,98 @@ func (m *moqPartialGenericParams[S]) onCall() *moqPartialGenericParams_recorder[ } } -func (m *moqPartialGenericParams_recorder[S]) Usual(param1 S, param2 bool) *moqPartialGenericParams_Usual_fnRecorder[S] { - return &moqPartialGenericParams_Usual_fnRecorder[S]{ - params: moqPartialGenericParams_Usual_params[S]{ +func (m *moqPartialGenericParams_recorder[S]) Usual(param1 S, param2 bool) *moqPartialGenericParams_Usual_recorder[S] { + return &moqPartialGenericParams_Usual_recorder[S]{ + recorder: m.moq.moq_Usual.OnCall(moqPartialGenericParams_Usual_params[S]{ param1: param1, param2: param2, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -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_Usual(r.params)) +func (r *moqPartialGenericParams_Usual_recorder[S]) any() *moqPartialGenericParams_Usual_anyParams[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqPartialGenericParams_Usual_anyParams[S]{recorder: r} } -func (a *moqPartialGenericParams_Usual_anyParams[S]) param1() *moqPartialGenericParams_Usual_fnRecorder[S] { - a.recorder.anyParams |= 1 << 0 +func (a *moqPartialGenericParams_Usual_anyParams[S]) param1() *moqPartialGenericParams_Usual_recorder[S] { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqPartialGenericParams_Usual_anyParams[S]) param2() *moqPartialGenericParams_Usual_fnRecorder[S] { - a.recorder.anyParams |= 1 << 1 +func (a *moqPartialGenericParams_Usual_anyParams[S]) param2() *moqPartialGenericParams_Usual_recorder[S] { + a.recorder.recorder.AnyParam(2) 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_Usual(r.params)) +func (r *moqPartialGenericParams_Usual_recorder[S]) seq() *moqPartialGenericParams_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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_Usual(r.params)) +func (r *moqPartialGenericParams_Usual_recorder[S]) noSeq() *moqPartialGenericParams_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqPartialGenericParams_Usual_fnRecorder[S]) returnResults(result1 string, result2 error) *moqPartialGenericParams_Usual_fnRecorder[S] { - 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 moqPartialGenericParams_Usual_doFn[S] - doReturnFn moqPartialGenericParams_Usual_doReturnFn[S] - }{ - values: &struct { - result1 string - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqPartialGenericParams_Usual_recorder[S]) returnResults(result1 string, result2 error) *moqPartialGenericParams_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqPartialGenericParams_Usual_results[S]{ + result1: result1, + result2: result2, }) return r } -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") +func (r *moqPartialGenericParams_Usual_recorder[S]) andDo(fn moqPartialGenericParams_Usual_doFn[S]) *moqPartialGenericParams_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqPartialGenericParams_Usual_params[S]) { + fn(params.param1, params.param2) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqPartialGenericParams_Usual_fnRecorder[S]) doReturnResults(fn moqPartialGenericParams_Usual_doReturnFn[S]) *moqPartialGenericParams_Usual_fnRecorder[S] { - 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 +func (r *moqPartialGenericParams_Usual_recorder[S]) doReturnResults(fn moqPartialGenericParams_Usual_doReturnFn[S]) *moqPartialGenericParams_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqPartialGenericParams_Usual_params[S]) *moqPartialGenericParams_Usual_results[S] { + result1, result2 := fn(params.param1, params.param2) + return &moqPartialGenericParams_Usual_results[S]{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqPartialGenericParams_Usual_doFn[S] - doReturnFn moqPartialGenericParams_Usual_doReturnFn[S] - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqPartialGenericParams_Usual_fnRecorder[S]) 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 *moqPartialGenericParams_Usual_resultsByParams[S] - 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 = &moqPartialGenericParams_Usual_resultsByParams[S]{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqPartialGenericParams_Usual_paramsKey[S]]*moqPartialGenericParams_Usual_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 - } - } - - paramsKey := r.moq.paramsKey_Usual(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqPartialGenericParams_Usual_results[S]{ - 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 *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") - 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 moqPartialGenericParams_Usual_doFn[S] - doReturnFn moqPartialGenericParams_Usual_doReturnFn[S] - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqPartialGenericParams_Usual_recorder[S]) repeat(repeaters ...moq.Repeater) *moqPartialGenericParams_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqPartialGenericParams[S]) prettyParams_Usual(params moqPartialGenericParams_Usual_params[S]) string { +func (*moqPartialGenericParams_Usual_adaptor[S]) PrettyParams(params moqPartialGenericParams_Usual_params[S]) string { return fmt.Sprintf("Usual(%#v, %#v)", params.param1, params.param2) } -func (m *moqPartialGenericParams[S]) paramsKey_Usual(params moqPartialGenericParams_Usual_params[S], anyParams uint64) moqPartialGenericParams_Usual_paramsKey[S] { - m.scene.T.Helper() - 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) - } - } +func (a *moqPartialGenericParams_Usual_adaptor[S]) ParamsKey(params moqPartialGenericParams_Usual_params[S], anyParams uint64) moqPartialGenericParams_Usual_paramsKey[S] { + a.moq.moq_Usual.Scene.T.Helper() + param1UsedHash := impl.HashOnlyParamKey(a.moq.moq_Usual.Scene.T, + params.param1, "param1", 1, a.moq.runtime.parameterIndexing.Usual.param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.param2, 2, a.moq.runtime.parameterIndexing.Usual.param2, anyParams) return moqPartialGenericParams_Usual_paramsKey[S]{ params: struct{ param2 bool }{ param2: param2Used, @@ -18606,19 +10269,14 @@ func (m *moqPartialGenericParams[S]) paramsKey_Usual(params moqPartialGenericPar } // Reset resets the state of the moq -func (m *moqPartialGenericParams[S]) Reset() { m.resultsByParams_Usual = nil } +func (m *moqPartialGenericParams[S]) Reset() { + m.moq_Usual.Reset() +} // 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)) - } - } - } + m.moq_Usual.Scene.T.Helper() + m.moq_Usual.AssertExpectationsMet() } // The following type assertion assures that testmoqs.GenericResults is mocked @@ -18627,23 +10285,18 @@ var _ testmoqs.GenericResults[string, error] = (*moqGenericResults_mock[string, // 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 + moq *moqGenericResults_mock[S, E] + + moq_Usual *impl.Moq[ + *moqGenericResults_Usual_adaptor[S, E], + moqGenericResults_Usual_params[S, E], + moqGenericResults_Usual_paramsKey[S, E], + moqGenericResults_Usual_results[S, E]] + + runtime moqGenericResults_runtime } +// moqGenericResults_mock isolates the mock interface of the GenericResults // type type moqGenericResults_mock[S ~string, E error] struct { moq *moqGenericResults[S, E] @@ -18655,6 +10308,20 @@ type moqGenericResults_recorder[S ~string, E error] struct { moq *moqGenericResults[S, E] } +// moqGenericResults_runtime holds runtime configuration for the GenericResults +// type +type moqGenericResults_runtime struct { + parameterIndexing struct { + Usual moqGenericResults_Usual_paramIndexing + } +} + +// moqGenericResults_Usual_adaptor adapts moqGenericResults as needed by the +// runtime +type moqGenericResults_Usual_adaptor[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 @@ -18674,12 +10341,17 @@ type moqGenericResults_Usual_paramsKey[S ~string, E error] struct { } } -// 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_results holds the results of the GenericResults type +type moqGenericResults_Usual_results[S ~string, E error] struct { + result1 S + result2 E +} + +// moqGenericResults_Usual_paramIndexing holds the parameter indexing runtime +// configuration for the GenericResults type +type moqGenericResults_Usual_paramIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } // moqGenericResults_Usual_doFn defines the type of function needed when @@ -18690,65 +10362,38 @@ type moqGenericResults_Usual_doFn[S ~string, E error] func(string, bool) // 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_Usual_recorder 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] +type moqGenericResults_Usual_recorder[S ~string, E error] struct { + recorder *impl.Recorder[ + *moqGenericResults_Usual_adaptor[S, E], + moqGenericResults_Usual_params[S, E], + moqGenericResults_Usual_paramsKey[S, E], + moqGenericResults_Usual_results[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] + recorder *moqGenericResults_Usual_recorder[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{} - } + adaptor1 := &moqGenericResults_Usual_adaptor[S, E]{} 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 - } + moq: &moqGenericResults_mock[S, E]{}, + + moq_Usual: impl.NewMoq[ + *moqGenericResults_Usual_adaptor[S, E], + moqGenericResults_Usual_params[S, E], + moqGenericResults_Usual_paramsKey[S, E], + moqGenericResults_Usual_results[S, E]](scene, adaptor1, config), + + runtime: moqGenericResults_runtime{parameterIndexing: struct { + Usual moqGenericResults_Usual_paramIndexing }{ - Usual: struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - }{ + Usual: moqGenericResults_Usual_paramIndexing{ param1: moq.ParamIndexByValue, param2: moq.ParamIndexByValue, }, @@ -18756,6 +10401,8 @@ func newMoqGenericResults[S ~string, E error](scene *moq.Scene, config *moq.Conf } m.moq.moq = m + adaptor1.moq = m + scene.AddMoq(m) return m } @@ -18763,59 +10410,20 @@ func newMoqGenericResults[S ~string, E error](scene *moq.Scene, config *moq.Conf // 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() +func (m *moqGenericResults_mock[S, E]) Usual(param1 string, param2 bool) (S, E) { + m.moq.moq_Usual.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) + var result1 S + var result2 E + if result := m.moq.moq_Usual.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - return + return result1, result2 } // onCall returns the recorder implementation of the GenericResults type @@ -18825,219 +10433,98 @@ func (m *moqGenericResults[S, E]) onCall() *moqGenericResults_recorder[S, E] { } } -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]{ +func (m *moqGenericResults_recorder[S, E]) Usual(param1 string, param2 bool) *moqGenericResults_Usual_recorder[S, E] { + return &moqGenericResults_Usual_recorder[S, E]{ + recorder: m.moq.moq_Usual.OnCall(moqGenericResults_Usual_params[S, E]{ param1: param1, param2: param2, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -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_Usual(r.params)) +func (r *moqGenericResults_Usual_recorder[S, E]) any() *moqGenericResults_Usual_anyParams[S, E] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqGenericResults_Usual_anyParams[S, E]{recorder: r} } -func (a *moqGenericResults_Usual_anyParams[S, E]) param1() *moqGenericResults_Usual_fnRecorder[S, E] { - a.recorder.anyParams |= 1 << 0 +func (a *moqGenericResults_Usual_anyParams[S, E]) param1() *moqGenericResults_Usual_recorder[S, E] { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqGenericResults_Usual_anyParams[S, E]) param2() *moqGenericResults_Usual_fnRecorder[S, E] { - a.recorder.anyParams |= 1 << 1 +func (a *moqGenericResults_Usual_anyParams[S, E]) param2() *moqGenericResults_Usual_recorder[S, E] { + a.recorder.recorder.AnyParam(2) 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_Usual(r.params)) +func (r *moqGenericResults_Usual_recorder[S, E]) seq() *moqGenericResults_Usual_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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_Usual(r.params)) +func (r *moqGenericResults_Usual_recorder[S, E]) noSeq() *moqGenericResults_Usual_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqGenericResults_Usual_fnRecorder[S, E]) returnResults(result1 S, result2 E) *moqGenericResults_Usual_fnRecorder[S, E] { - 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 S - result2 E - } - sequence uint32 - doFn moqGenericResults_Usual_doFn[S, E] - doReturnFn moqGenericResults_Usual_doReturnFn[S, E] - }{ - values: &struct { - result1 S - result2 E - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqGenericResults_Usual_recorder[S, E]) returnResults(result1 S, result2 E) *moqGenericResults_Usual_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqGenericResults_Usual_results[S, E]{ + result1: result1, + result2: result2, }) return r } -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") +func (r *moqGenericResults_Usual_recorder[S, E]) andDo(fn moqGenericResults_Usual_doFn[S, E]) *moqGenericResults_Usual_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqGenericResults_Usual_params[S, E]) { + fn(params.param1, params.param2) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -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() - - var sequence uint32 - if r.sequence { - sequence = r.moq.scene.NextRecorderSequence() - } - - r.results.results = append(r.results.results, struct { - values *struct { - result1 S - result2 E +func (r *moqGenericResults_Usual_recorder[S, E]) doReturnResults(fn moqGenericResults_Usual_doReturnFn[S, E]) *moqGenericResults_Usual_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqGenericResults_Usual_params[S, E]) *moqGenericResults_Usual_results[S, E] { + result1, result2 := fn(params.param1, params.param2) + return &moqGenericResults_Usual_results[S, E]{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqGenericResults_Usual_doFn[S, E] - doReturnFn moqGenericResults_Usual_doReturnFn[S, E] - }{sequence: sequence, doReturnFn: fn}) + }) return r } -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) - return - } - - anyCount := bits.OnesCount64(r.anyParams) - insertAt := -1 - var results *moqGenericResults_Usual_resultsByParams[S, E] - 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 = &moqGenericResults_Usual_resultsByParams[S, E]{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqGenericResults_Usual_paramsKey[S, E]]*moqGenericResults_Usual_results[S, E]{}, - } - 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 = &moqGenericResults_Usual_results[S, E]{ - 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 *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") - 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 S - result2 E - } - sequence uint32 - doFn moqGenericResults_Usual_doFn[S, E] - doReturnFn moqGenericResults_Usual_doReturnFn[S, E] - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqGenericResults_Usual_recorder[S, E]) repeat(repeaters ...moq.Repeater) *moqGenericResults_Usual_recorder[S, E] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqGenericResults[S, E]) prettyParams_Usual(params moqGenericResults_Usual_params[S, E]) string { +func (*moqGenericResults_Usual_adaptor[S, E]) PrettyParams(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) - } - } +func (a *moqGenericResults_Usual_adaptor[S, E]) ParamsKey(params moqGenericResults_Usual_params[S, E], anyParams uint64) moqGenericResults_Usual_paramsKey[S, E] { + a.moq.moq_Usual.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.param1, 1, a.moq.runtime.parameterIndexing.Usual.param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.param2, 2, a.moq.runtime.parameterIndexing.Usual.param2, anyParams) return moqGenericResults_Usual_paramsKey[S, E]{ params: struct { param1 string @@ -19057,19 +10544,14 @@ func (m *moqGenericResults[S, E]) paramsKey_Usual(params moqGenericResults_Usual } // Reset resets the state of the moq -func (m *moqGenericResults[S, E]) Reset() { m.resultsByParams_Usual = nil } +func (m *moqGenericResults[S, E]) Reset() { + m.moq_Usual.Reset() +} // 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)) - } - } - } + m.moq_Usual.Scene.T.Helper() + m.moq_Usual.AssertExpectationsMet() } // The following type assertion assures that testmoqs.PartialGenericResults is @@ -19079,23 +10561,18 @@ var _ testmoqs.PartialGenericResults[string] = (*moqPartialGenericResults_mock[s // 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 + moq *moqPartialGenericResults_mock[S] + + moq_Usual *impl.Moq[ + *moqPartialGenericResults_Usual_adaptor[S], + moqPartialGenericResults_Usual_params[S], + moqPartialGenericResults_Usual_paramsKey[S], + moqPartialGenericResults_Usual_results[S]] + + runtime moqPartialGenericResults_runtime } +// moqPartialGenericResults_mock isolates the mock interface of the // PartialGenericResults type type moqPartialGenericResults_mock[S ~string] struct { moq *moqPartialGenericResults[S] @@ -19107,6 +10584,20 @@ type moqPartialGenericResults_recorder[S ~string] struct { moq *moqPartialGenericResults[S] } +// moqPartialGenericResults_runtime holds runtime configuration for the +// PartialGenericResults type +type moqPartialGenericResults_runtime struct { + parameterIndexing struct { + Usual moqPartialGenericResults_Usual_paramIndexing + } +} + +// moqPartialGenericResults_Usual_adaptor adapts moqPartialGenericResults as +// needed by the runtime +type moqPartialGenericResults_Usual_adaptor[S ~string] struct { + moq *moqPartialGenericResults[S] +} + // moqPartialGenericResults_Usual_params holds the params of the // PartialGenericResults type type moqPartialGenericResults_Usual_params[S ~string] struct { @@ -19127,12 +10618,18 @@ type moqPartialGenericResults_Usual_paramsKey[S ~string] struct { } } -// 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_results holds the results of the +// PartialGenericResults type +type moqPartialGenericResults_Usual_results[S ~string] struct { + result1 S + result2 error +} + +// moqPartialGenericResults_Usual_paramIndexing holds the parameter indexing +// runtime configuration for the PartialGenericResults type +type moqPartialGenericResults_Usual_paramIndexing struct { + param1 moq.ParamIndexing + param2 moq.ParamIndexing } // moqPartialGenericResults_Usual_doFn defines the type of function needed when @@ -19140,70 +10637,42 @@ type moqPartialGenericResults_Usual_resultsByParams[S ~string] struct { 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 -} +// needed when calling doReturnResults for the PartialGenericResults type +type moqPartialGenericResults_Usual_doReturnFn[S ~string] func(string, bool) (S, error) -// moqPartialGenericResults_Usual_fnRecorder routes recorded function calls to +// moqPartialGenericResults_Usual_recorder 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] +type moqPartialGenericResults_Usual_recorder[S ~string] struct { + recorder *impl.Recorder[ + *moqPartialGenericResults_Usual_adaptor[S], + moqPartialGenericResults_Usual_params[S], + moqPartialGenericResults_Usual_paramsKey[S], + moqPartialGenericResults_Usual_results[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] + recorder *moqPartialGenericResults_Usual_recorder[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{} - } + adaptor1 := &moqPartialGenericResults_Usual_adaptor[S]{} 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 - } + moq: &moqPartialGenericResults_mock[S]{}, + + moq_Usual: impl.NewMoq[ + *moqPartialGenericResults_Usual_adaptor[S], + moqPartialGenericResults_Usual_params[S], + moqPartialGenericResults_Usual_paramsKey[S], + moqPartialGenericResults_Usual_results[S]](scene, adaptor1, config), + + runtime: moqPartialGenericResults_runtime{parameterIndexing: struct { + Usual moqPartialGenericResults_Usual_paramIndexing }{ - Usual: struct { - param1 moq.ParamIndexing - param2 moq.ParamIndexing - }{ + Usual: moqPartialGenericResults_Usual_paramIndexing{ param1: moq.ParamIndexByValue, param2: moq.ParamIndexByValue, }, @@ -19211,6 +10680,8 @@ func newMoqPartialGenericResults[S ~string](scene *moq.Scene, config *moq.Config } m.moq.moq = m + adaptor1.moq = m + scene.AddMoq(m) return m } @@ -19218,59 +10689,20 @@ func newMoqPartialGenericResults[S ~string](scene *moq.Scene, config *moq.Config // 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() +func (m *moqPartialGenericResults_mock[S]) Usual(param1 string, param2 bool) (S, error) { + m.moq.moq_Usual.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) + var result1 S + var result2 error + if result := m.moq.moq_Usual.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(param1, param2) - } - return + return result1, result2 } // onCall returns the recorder implementation of the PartialGenericResults type @@ -19280,219 +10712,98 @@ func (m *moqPartialGenericResults[S]) onCall() *moqPartialGenericResults_recorde } } -func (m *moqPartialGenericResults_recorder[S]) Usual(param1 string, param2 bool) *moqPartialGenericResults_Usual_fnRecorder[S] { - return &moqPartialGenericResults_Usual_fnRecorder[S]{ - params: moqPartialGenericResults_Usual_params[S]{ +func (m *moqPartialGenericResults_recorder[S]) Usual(param1 string, param2 bool) *moqPartialGenericResults_Usual_recorder[S] { + return &moqPartialGenericResults_Usual_recorder[S]{ + recorder: m.moq.moq_Usual.OnCall(moqPartialGenericResults_Usual_params[S]{ param1: param1, param2: param2, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -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_Usual(r.params)) +func (r *moqPartialGenericResults_Usual_recorder[S]) any() *moqPartialGenericResults_Usual_anyParams[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqPartialGenericResults_Usual_anyParams[S]{recorder: r} } -func (a *moqPartialGenericResults_Usual_anyParams[S]) param1() *moqPartialGenericResults_Usual_fnRecorder[S] { - a.recorder.anyParams |= 1 << 0 +func (a *moqPartialGenericResults_Usual_anyParams[S]) param1() *moqPartialGenericResults_Usual_recorder[S] { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqPartialGenericResults_Usual_anyParams[S]) param2() *moqPartialGenericResults_Usual_fnRecorder[S] { - a.recorder.anyParams |= 1 << 1 +func (a *moqPartialGenericResults_Usual_anyParams[S]) param2() *moqPartialGenericResults_Usual_recorder[S] { + a.recorder.recorder.AnyParam(2) 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_Usual(r.params)) +func (r *moqPartialGenericResults_Usual_recorder[S]) seq() *moqPartialGenericResults_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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_Usual(r.params)) +func (r *moqPartialGenericResults_Usual_recorder[S]) noSeq() *moqPartialGenericResults_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqPartialGenericResults_Usual_fnRecorder[S]) returnResults(result1 S, result2 error) *moqPartialGenericResults_Usual_fnRecorder[S] { - 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 S - result2 error - } - sequence uint32 - doFn moqPartialGenericResults_Usual_doFn[S] - doReturnFn moqPartialGenericResults_Usual_doReturnFn[S] - }{ - values: &struct { - result1 S - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqPartialGenericResults_Usual_recorder[S]) returnResults(result1 S, result2 error) *moqPartialGenericResults_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqPartialGenericResults_Usual_results[S]{ + result1: result1, + result2: result2, }) return r } -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") +func (r *moqPartialGenericResults_Usual_recorder[S]) andDo(fn moqPartialGenericResults_Usual_doFn[S]) *moqPartialGenericResults_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqPartialGenericResults_Usual_params[S]) { + fn(params.param1, params.param2) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqPartialGenericResults_Usual_fnRecorder[S]) doReturnResults(fn moqPartialGenericResults_Usual_doReturnFn[S]) *moqPartialGenericResults_Usual_fnRecorder[S] { - 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 S - result2 error +func (r *moqPartialGenericResults_Usual_recorder[S]) doReturnResults(fn moqPartialGenericResults_Usual_doReturnFn[S]) *moqPartialGenericResults_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqPartialGenericResults_Usual_params[S]) *moqPartialGenericResults_Usual_results[S] { + result1, result2 := fn(params.param1, params.param2) + return &moqPartialGenericResults_Usual_results[S]{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqPartialGenericResults_Usual_doFn[S] - doReturnFn moqPartialGenericResults_Usual_doReturnFn[S] - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqPartialGenericResults_Usual_fnRecorder[S]) 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 *moqPartialGenericResults_Usual_resultsByParams[S] - 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 = &moqPartialGenericResults_Usual_resultsByParams[S]{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqPartialGenericResults_Usual_paramsKey[S]]*moqPartialGenericResults_Usual_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 - } - } - - paramsKey := r.moq.paramsKey_Usual(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqPartialGenericResults_Usual_results[S]{ - 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 *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") - 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 S - result2 error - } - sequence uint32 - doFn moqPartialGenericResults_Usual_doFn[S] - doReturnFn moqPartialGenericResults_Usual_doReturnFn[S] - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqPartialGenericResults_Usual_recorder[S]) repeat(repeaters ...moq.Repeater) *moqPartialGenericResults_Usual_recorder[S] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqPartialGenericResults[S]) prettyParams_Usual(params moqPartialGenericResults_Usual_params[S]) string { +func (*moqPartialGenericResults_Usual_adaptor[S]) PrettyParams(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) - } - } +func (a *moqPartialGenericResults_Usual_adaptor[S]) ParamsKey(params moqPartialGenericResults_Usual_params[S], anyParams uint64) moqPartialGenericResults_Usual_paramsKey[S] { + a.moq.moq_Usual.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.param1, 1, a.moq.runtime.parameterIndexing.Usual.param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.param2, 2, a.moq.runtime.parameterIndexing.Usual.param2, anyParams) return moqPartialGenericResults_Usual_paramsKey[S]{ params: struct { param1 string @@ -19512,19 +10823,14 @@ func (m *moqPartialGenericResults[S]) paramsKey_Usual(params moqPartialGenericRe } // Reset resets the state of the moq -func (m *moqPartialGenericResults[S]) Reset() { m.resultsByParams_Usual = nil } +func (m *moqPartialGenericResults[S]) Reset() { + m.moq_Usual.Reset() +} // 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)) - } - } - } + m.moq_Usual.Scene.T.Helper() + m.moq_Usual.AssertExpectationsMet() } // The following type assertion assures that testmoqs.GenericInterfaceParam is @@ -19534,22 +10840,18 @@ var _ testmoqs.GenericInterfaceParam[testmoqs.MyWriter] = (*moqGenericInterfaceP // 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] + moq *moqGenericInterfaceParam_mock[W] - resultsByParams_Usual []moqGenericInterfaceParam_Usual_resultsByParams[W] + moq_Usual *impl.Moq[ + *moqGenericInterfaceParam_Usual_adaptor[W], + moqGenericInterfaceParam_Usual_params[W], + moqGenericInterfaceParam_Usual_paramsKey[W], + moqGenericInterfaceParam_Usual_results[W]] - runtime struct { - parameterIndexing struct { - Usual struct { - w moq.ParamIndexing - } - } - } - // moqGenericInterfaceParam_mock isolates the mock interface of the + runtime moqGenericInterfaceParam_runtime } +// moqGenericInterfaceParam_mock isolates the mock interface of the // GenericInterfaceParam type type moqGenericInterfaceParam_mock[W testmoqs.MyWriter] struct { moq *moqGenericInterfaceParam[W] @@ -19561,6 +10863,20 @@ type moqGenericInterfaceParam_recorder[W testmoqs.MyWriter] struct { moq *moqGenericInterfaceParam[W] } +// moqGenericInterfaceParam_runtime holds runtime configuration for the +// GenericInterfaceParam type +type moqGenericInterfaceParam_runtime struct { + parameterIndexing struct { + Usual moqGenericInterfaceParam_Usual_paramIndexing + } +} + +// moqGenericInterfaceParam_Usual_adaptor adapts moqGenericInterfaceParam as +// needed by the runtime +type moqGenericInterfaceParam_Usual_adaptor[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 } @@ -19572,12 +10888,17 @@ type moqGenericInterfaceParam_Usual_paramsKey[W testmoqs.MyWriter] 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_results holds the results of the +// GenericInterfaceParam type +type moqGenericInterfaceParam_Usual_results[W testmoqs.MyWriter] struct { + sResult string + err error +} + +// moqGenericInterfaceParam_Usual_paramIndexing holds the parameter indexing +// runtime configuration for the GenericInterfaceParam type +type moqGenericInterfaceParam_Usual_paramIndexing struct { + w moq.ParamIndexing } // moqGenericInterfaceParam_Usual_doFn defines the type of function needed when @@ -19588,70 +10909,47 @@ type moqGenericInterfaceParam_Usual_doFn[W testmoqs.MyWriter] func(w W) // 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 +// moqGenericInterfaceParam_Usual_recorder 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] +type moqGenericInterfaceParam_Usual_recorder[W testmoqs.MyWriter] struct { + recorder *impl.Recorder[ + *moqGenericInterfaceParam_Usual_adaptor[W], + moqGenericInterfaceParam_Usual_params[W], + moqGenericInterfaceParam_Usual_paramsKey[W], + moqGenericInterfaceParam_Usual_results[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] + recorder *moqGenericInterfaceParam_Usual_recorder[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{} - } + adaptor1 := &moqGenericInterfaceParam_Usual_adaptor[W]{} 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 - } + moq: &moqGenericInterfaceParam_mock[W]{}, + + moq_Usual: impl.NewMoq[ + *moqGenericInterfaceParam_Usual_adaptor[W], + moqGenericInterfaceParam_Usual_params[W], + moqGenericInterfaceParam_Usual_paramsKey[W], + moqGenericInterfaceParam_Usual_results[W]](scene, adaptor1, config), + + runtime: moqGenericInterfaceParam_runtime{parameterIndexing: struct { + Usual moqGenericInterfaceParam_Usual_paramIndexing }{ - Usual: struct { - w moq.ParamIndexing - }{ + Usual: moqGenericInterfaceParam_Usual_paramIndexing{ w: moq.ParamIndexByHash, }, }}, } m.moq.moq = m + adaptor1.moq = m + scene.AddMoq(m) return m } @@ -19659,58 +10957,19 @@ func newMoqGenericInterfaceParam[W testmoqs.MyWriter](scene *moq.Scene, config * // 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() +func (m *moqGenericInterfaceParam_mock[W]) Usual(w W) (string, error) { + m.moq.moq_Usual.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) - } - if result.values != nil { - sResult = result.values.sResult - err = result.values.err - } - if result.doReturnFn != nil { - sResult, err = result.doReturnFn(w) + var result1 string + var result2 error + if result := m.moq.moq_Usual.Function(params); result != nil { + result1 = result.sResult + result2 = result.err } - return + return result1, result2 } // onCall returns the recorder implementation of the GenericInterfaceParam type @@ -19720,202 +10979,90 @@ func (m *moqGenericInterfaceParam[W]) onCall() *moqGenericInterfaceParam_recorde } } -func (m *moqGenericInterfaceParam_recorder[W]) Usual(w W) *moqGenericInterfaceParam_Usual_fnRecorder[W] { - return &moqGenericInterfaceParam_Usual_fnRecorder[W]{ - params: moqGenericInterfaceParam_Usual_params[W]{ +func (m *moqGenericInterfaceParam_recorder[W]) Usual(w W) *moqGenericInterfaceParam_Usual_recorder[W] { + return &moqGenericInterfaceParam_Usual_recorder[W]{ + recorder: m.moq.moq_Usual.OnCall(moqGenericInterfaceParam_Usual_params[W]{ w: w, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -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_Usual(r.params)) +func (r *moqGenericInterfaceParam_Usual_recorder[W]) any() *moqGenericInterfaceParam_Usual_anyParams[W] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqGenericInterfaceParam_Usual_anyParams[W]{recorder: r} } -func (a *moqGenericInterfaceParam_Usual_anyParams[W]) w() *moqGenericInterfaceParam_Usual_fnRecorder[W] { - a.recorder.anyParams |= 1 << 0 +func (a *moqGenericInterfaceParam_Usual_anyParams[W]) w() *moqGenericInterfaceParam_Usual_recorder[W] { + a.recorder.recorder.AnyParam(1) return a.recorder } -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_Usual(r.params)) +func (r *moqGenericInterfaceParam_Usual_recorder[W]) seq() *moqGenericInterfaceParam_Usual_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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_Usual(r.params)) +func (r *moqGenericInterfaceParam_Usual_recorder[W]) noSeq() *moqGenericInterfaceParam_Usual_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqGenericInterfaceParam_Usual_fnRecorder[W]) returnResults(sResult string, err error) *moqGenericInterfaceParam_Usual_fnRecorder[W] { - 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 moqGenericInterfaceParam_Usual_doFn[W] - doReturnFn moqGenericInterfaceParam_Usual_doReturnFn[W] - }{ - values: &struct { - sResult string - err error - }{ - sResult: sResult, - err: err, - }, - sequence: sequence, +func (r *moqGenericInterfaceParam_Usual_recorder[W]) returnResults(sResult string, err error) *moqGenericInterfaceParam_Usual_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqGenericInterfaceParam_Usual_results[W]{ + sResult: sResult, + err: err, }) return r } -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") +func (r *moqGenericInterfaceParam_Usual_recorder[W]) andDo(fn moqGenericInterfaceParam_Usual_doFn[W]) *moqGenericInterfaceParam_Usual_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqGenericInterfaceParam_Usual_params[W]) { + fn(params.w) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqGenericInterfaceParam_Usual_fnRecorder[W]) doReturnResults(fn moqGenericInterfaceParam_Usual_doReturnFn[W]) *moqGenericInterfaceParam_Usual_fnRecorder[W] { - 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 +func (r *moqGenericInterfaceParam_Usual_recorder[W]) doReturnResults(fn moqGenericInterfaceParam_Usual_doReturnFn[W]) *moqGenericInterfaceParam_Usual_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqGenericInterfaceParam_Usual_params[W]) *moqGenericInterfaceParam_Usual_results[W] { + sResult, err := fn(params.w) + return &moqGenericInterfaceParam_Usual_results[W]{ + sResult: sResult, + err: err, } - sequence uint32 - doFn moqGenericInterfaceParam_Usual_doFn[W] - doReturnFn moqGenericInterfaceParam_Usual_doReturnFn[W] - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqGenericInterfaceParam_Usual_fnRecorder[W]) 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 *moqGenericInterfaceParam_Usual_resultsByParams[W] - 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 = &moqGenericInterfaceParam_Usual_resultsByParams[W]{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqGenericInterfaceParam_Usual_paramsKey[W]]*moqGenericInterfaceParam_Usual_results[W]{}, - } - 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 = &moqGenericInterfaceParam_Usual_results[W]{ - 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 *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") - 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 moqGenericInterfaceParam_Usual_doFn[W] - doReturnFn moqGenericInterfaceParam_Usual_doReturnFn[W] - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) +func (r *moqGenericInterfaceParam_Usual_recorder[W]) repeat(repeaters ...moq.Repeater) *moqGenericInterfaceParam_Usual_recorder[W] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { + return nil } return r } -func (m *moqGenericInterfaceParam[W]) prettyParams_Usual(params moqGenericInterfaceParam_Usual_params[W]) string { +func (*moqGenericInterfaceParam_Usual_adaptor[W]) PrettyParams(params moqGenericInterfaceParam_Usual_params[W]) string { return fmt.Sprintf("Usual(%#v)", params.w) } -func (m *moqGenericInterfaceParam[W]) paramsKey_Usual(params moqGenericInterfaceParam_Usual_params[W], anyParams uint64) moqGenericInterfaceParam_Usual_paramsKey[W] { - m.scene.T.Helper() - var wUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - 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) - } +func (a *moqGenericInterfaceParam_Usual_adaptor[W]) ParamsKey(params moqGenericInterfaceParam_Usual_params[W], anyParams uint64) moqGenericInterfaceParam_Usual_paramsKey[W] { + a.moq.moq_Usual.Scene.T.Helper() + wUsedHash := impl.HashOnlyParamKey(a.moq.moq_Usual.Scene.T, + params.w, "w", 1, a.moq.runtime.parameterIndexing.Usual.w, anyParams) return moqGenericInterfaceParam_Usual_paramsKey[W]{ params: struct{}{}, hashes: struct{ w hash.Hash }{ @@ -19925,19 +11072,14 @@ func (m *moqGenericInterfaceParam[W]) paramsKey_Usual(params moqGenericInterface } // Reset resets the state of the moq -func (m *moqGenericInterfaceParam[W]) Reset() { m.resultsByParams_Usual = nil } +func (m *moqGenericInterfaceParam[W]) Reset() { + m.moq_Usual.Reset() +} // 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)) - } - } - } + m.moq_Usual.Scene.T.Helper() + m.moq_Usual.AssertExpectationsMet() } // The following type assertion assures that testmoqs.GenericInterfaceResult is @@ -19947,23 +11089,18 @@ var _ testmoqs.GenericInterfaceResult[testmoqs.MyReader] = (*moqGenericInterface // 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 + moq *moqGenericInterfaceResult_mock[R] + + moq_Usual *impl.Moq[ + *moqGenericInterfaceResult_Usual_adaptor[R], + moqGenericInterfaceResult_Usual_params[R], + moqGenericInterfaceResult_Usual_paramsKey[R], + moqGenericInterfaceResult_Usual_results[R]] + + runtime moqGenericInterfaceResult_runtime } +// moqGenericInterfaceResult_mock isolates the mock interface of the // GenericInterfaceResult type type moqGenericInterfaceResult_mock[R testmoqs.MyReader] struct { moq *moqGenericInterfaceResult[R] @@ -19975,6 +11112,20 @@ type moqGenericInterfaceResult_recorder[R testmoqs.MyReader] struct { moq *moqGenericInterfaceResult[R] } +// moqGenericInterfaceResult_runtime holds runtime configuration for the +// GenericInterfaceResult type +type moqGenericInterfaceResult_runtime struct { + parameterIndexing struct { + Usual moqGenericInterfaceResult_Usual_paramIndexing + } +} + +// moqGenericInterfaceResult_Usual_adaptor adapts moqGenericInterfaceResult as +// needed by the runtime +type moqGenericInterfaceResult_Usual_adaptor[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 { @@ -19995,12 +11146,15 @@ type moqGenericInterfaceResult_Usual_paramsKey[R testmoqs.MyReader] struct { } } -// 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_results holds the results of the +// GenericInterfaceResult type +type moqGenericInterfaceResult_Usual_results[R testmoqs.MyReader] struct{ result1 R } + +// moqGenericInterfaceResult_Usual_paramIndexing holds the parameter indexing +// runtime configuration for the GenericInterfaceResult type +type moqGenericInterfaceResult_Usual_paramIndexing struct { + sParam moq.ParamIndexing + bParam moq.ParamIndexing } // moqGenericInterfaceResult_Usual_doFn defines the type of function needed @@ -20011,64 +11165,39 @@ type moqGenericInterfaceResult_Usual_doFn[R testmoqs.MyReader] func(sParam strin // 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 +// moqGenericInterfaceResult_Usual_recorder 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] +type moqGenericInterfaceResult_Usual_recorder[R testmoqs.MyReader] struct { + recorder *impl.Recorder[ + *moqGenericInterfaceResult_Usual_adaptor[R], + moqGenericInterfaceResult_Usual_params[R], + moqGenericInterfaceResult_Usual_paramsKey[R], + moqGenericInterfaceResult_Usual_results[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] + recorder *moqGenericInterfaceResult_Usual_recorder[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{} - } + adaptor1 := &moqGenericInterfaceResult_Usual_adaptor[R]{} 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 - } + moq: &moqGenericInterfaceResult_mock[R]{}, + + moq_Usual: impl.NewMoq[ + *moqGenericInterfaceResult_Usual_adaptor[R], + moqGenericInterfaceResult_Usual_params[R], + moqGenericInterfaceResult_Usual_paramsKey[R], + moqGenericInterfaceResult_Usual_results[R]](scene, adaptor1, config), + + runtime: moqGenericInterfaceResult_runtime{parameterIndexing: struct { + Usual moqGenericInterfaceResult_Usual_paramIndexing }{ - Usual: struct { - sParam moq.ParamIndexing - bParam moq.ParamIndexing - }{ + Usual: moqGenericInterfaceResult_Usual_paramIndexing{ sParam: moq.ParamIndexByValue, bParam: moq.ParamIndexByValue, }, @@ -20076,6 +11205,8 @@ func newMoqGenericInterfaceResult[R testmoqs.MyReader](scene *moq.Scene, config } m.moq.moq = m + adaptor1.moq = m + scene.AddMoq(m) return m } @@ -20083,58 +11214,18 @@ func newMoqGenericInterfaceResult[R testmoqs.MyReader](scene *moq.Scene, config // 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() +func (m *moqGenericInterfaceResult_mock[R]) Usual(sParam string, bParam bool) R { + m.moq.moq_Usual.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)) - } - } - - if result.doFn != nil { - result.doFn(sParam, bParam) - } - if result.values != nil { - result1 = result.values.result1 + var result1 R + if result := m.moq.moq_Usual.Function(params); result != nil { + result1 = result.result1 } - if result.doReturnFn != nil { - result1 = result.doReturnFn(sParam, bParam) - } - return + return result1 } // onCall returns the recorder implementation of the GenericInterfaceResult @@ -20145,206 +11236,96 @@ func (m *moqGenericInterfaceResult[R]) onCall() *moqGenericInterfaceResult_recor } } -func (m *moqGenericInterfaceResult_recorder[R]) Usual(sParam string, bParam bool) *moqGenericInterfaceResult_Usual_fnRecorder[R] { - return &moqGenericInterfaceResult_Usual_fnRecorder[R]{ - params: moqGenericInterfaceResult_Usual_params[R]{ +func (m *moqGenericInterfaceResult_recorder[R]) Usual(sParam string, bParam bool) *moqGenericInterfaceResult_Usual_recorder[R] { + return &moqGenericInterfaceResult_Usual_recorder[R]{ + recorder: m.moq.moq_Usual.OnCall(moqGenericInterfaceResult_Usual_params[R]{ sParam: sParam, bParam: bParam, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -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_Usual(r.params)) +func (r *moqGenericInterfaceResult_Usual_recorder[R]) any() *moqGenericInterfaceResult_Usual_anyParams[R] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqGenericInterfaceResult_Usual_anyParams[R]{recorder: r} } -func (a *moqGenericInterfaceResult_Usual_anyParams[R]) sParam() *moqGenericInterfaceResult_Usual_fnRecorder[R] { - a.recorder.anyParams |= 1 << 0 +func (a *moqGenericInterfaceResult_Usual_anyParams[R]) sParam() *moqGenericInterfaceResult_Usual_recorder[R] { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqGenericInterfaceResult_Usual_anyParams[R]) bParam() *moqGenericInterfaceResult_Usual_fnRecorder[R] { - a.recorder.anyParams |= 1 << 1 +func (a *moqGenericInterfaceResult_Usual_anyParams[R]) bParam() *moqGenericInterfaceResult_Usual_recorder[R] { + a.recorder.recorder.AnyParam(2) 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_Usual(r.params)) +func (r *moqGenericInterfaceResult_Usual_recorder[R]) seq() *moqGenericInterfaceResult_Usual_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -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_Usual(r.params)) +func (r *moqGenericInterfaceResult_Usual_recorder[R]) noSeq() *moqGenericInterfaceResult_Usual_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqGenericInterfaceResult_Usual_fnRecorder[R]) returnResults(result1 R) *moqGenericInterfaceResult_Usual_fnRecorder[R] { - 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 R } - sequence uint32 - doFn moqGenericInterfaceResult_Usual_doFn[R] - doReturnFn moqGenericInterfaceResult_Usual_doReturnFn[R] - }{ - values: &struct{ result1 R }{ - result1: result1, - }, - sequence: sequence, +func (r *moqGenericInterfaceResult_Usual_recorder[R]) returnResults(result1 R) *moqGenericInterfaceResult_Usual_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqGenericInterfaceResult_Usual_results[R]{ + result1: result1, }) return r } -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") +func (r *moqGenericInterfaceResult_Usual_recorder[R]) andDo(fn moqGenericInterfaceResult_Usual_doFn[R]) *moqGenericInterfaceResult_Usual_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqGenericInterfaceResult_Usual_params[R]) { + fn(params.sParam, params.bParam) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn - return r -} - -func (r *moqGenericInterfaceResult_Usual_fnRecorder[R]) doReturnResults(fn moqGenericInterfaceResult_Usual_doReturnFn[R]) *moqGenericInterfaceResult_Usual_fnRecorder[R] { - 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 R } - sequence uint32 - doFn moqGenericInterfaceResult_Usual_doFn[R] - doReturnFn moqGenericInterfaceResult_Usual_doReturnFn[R] - }{sequence: sequence, doReturnFn: fn}) return r } -func (r *moqGenericInterfaceResult_Usual_fnRecorder[R]) 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 *moqGenericInterfaceResult_Usual_resultsByParams[R] - 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 = &moqGenericInterfaceResult_Usual_resultsByParams[R]{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqGenericInterfaceResult_Usual_paramsKey[R]]*moqGenericInterfaceResult_Usual_results[R]{}, - } - 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 = &moqGenericInterfaceResult_Usual_results[R]{ - params: r.params, - results: nil, - index: 0, - repeat: &moq.RepeatVal{}, +func (r *moqGenericInterfaceResult_Usual_recorder[R]) doReturnResults(fn moqGenericInterfaceResult_Usual_doReturnFn[R]) *moqGenericInterfaceResult_Usual_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqGenericInterfaceResult_Usual_params[R]) *moqGenericInterfaceResult_Usual_results[R] { + result1 := fn(params.sParam, params.bParam) + return &moqGenericInterfaceResult_Usual_results[R]{ + result1: result1, } - results.results[paramsKey] = r.results - } - - r.results.repeat.Increment(r.moq.scene.T) + }) + return r } -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") +func (r *moqGenericInterfaceResult_Usual_recorder[R]) repeat(repeaters ...moq.Repeater) *moqGenericInterfaceResult_Usual_recorder[R] { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 R } - sequence uint32 - doFn moqGenericInterfaceResult_Usual_doFn[R] - doReturnFn moqGenericInterfaceResult_Usual_doReturnFn[R] - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqGenericInterfaceResult[R]) prettyParams_Usual(params moqGenericInterfaceResult_Usual_params[R]) string { +func (*moqGenericInterfaceResult_Usual_adaptor[R]) PrettyParams(params moqGenericInterfaceResult_Usual_params[R]) string { return fmt.Sprintf("Usual(%#v, %#v)", params.sParam, params.bParam) } -func (m *moqGenericInterfaceResult[R]) paramsKey_Usual(params moqGenericInterfaceResult_Usual_params[R], anyParams uint64) moqGenericInterfaceResult_Usual_paramsKey[R] { - 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) - } - } +func (a *moqGenericInterfaceResult_Usual_adaptor[R]) ParamsKey(params moqGenericInterfaceResult_Usual_params[R], anyParams uint64) moqGenericInterfaceResult_Usual_paramsKey[R] { + a.moq.moq_Usual.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.sParam, 1, a.moq.runtime.parameterIndexing.Usual.sParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.bParam, 2, a.moq.runtime.parameterIndexing.Usual.bParam, anyParams) return moqGenericInterfaceResult_Usual_paramsKey[R]{ params: struct { sParam string @@ -20364,37 +11345,37 @@ func (m *moqGenericInterfaceResult[R]) paramsKey_Usual(params moqGenericInterfac } // Reset resets the state of the moq -func (m *moqGenericInterfaceResult[R]) Reset() { m.resultsByParams_Usual = nil } +func (m *moqGenericInterfaceResult[R]) Reset() { + m.moq_Usual.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqGenericInterfaceResult[R]) 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)) - } - } - } + m.moq_Usual.Scene.T.Helper() + m.moq_Usual.AssertExpectationsMet() } // moqUnsafePointerFn holds the state of a moq of the UnsafePointerFn type type moqUnsafePointerFn struct { - scene *moq.Scene - config moq.Config - moq *moqUnsafePointerFn_mock + moq *impl.Moq[ + *moqUnsafePointerFn_adaptor, + moqUnsafePointerFn_params, + moqUnsafePointerFn_paramsKey, + moqUnsafePointerFn_results, + ] - resultsByParams []moqUnsafePointerFn_resultsByParams + runtime moqUnsafePointerFn_runtime +} - runtime struct { - parameterIndexing struct{} - } +// moqUnsafePointerFn_runtime holds runtime configuration for the +// UnsafePointerFn type +type moqUnsafePointerFn_runtime struct { + parameterIndexing moqUnsafePointerFn_paramIndexing } -// moqUnsafePointerFn_mock isolates the mock interface of the UnsafePointerFn -// type -type moqUnsafePointerFn_mock struct { +// moqUnsafePointerFn_adaptor adapts moqUnsafePointerFn as needed by the +// runtime +type moqUnsafePointerFn_adaptor struct { moq *moqUnsafePointerFn } @@ -20408,14 +11389,15 @@ type moqUnsafePointerFn_paramsKey struct { hashes struct{} } -// moqUnsafePointerFn_resultsByParams contains the results for a given set of -// parameters for the UnsafePointerFn type -type moqUnsafePointerFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqUnsafePointerFn_paramsKey]*moqUnsafePointerFn_results +// moqUnsafePointerFn_results holds the results of the UnsafePointerFn type +type moqUnsafePointerFn_results struct { + result1 unsafe.Pointer } +// moqUnsafePointerFn_paramIndexing holds the parameter indexing runtime +// configuration for the UnsafePointerFn type +type moqUnsafePointerFn_paramIndexing struct{} + // moqUnsafePointerFn_doFn defines the type of function needed when calling // andDo for the UnsafePointerFn type type moqUnsafePointerFn_doFn func() @@ -20424,52 +11406,37 @@ type moqUnsafePointerFn_doFn func() // calling doReturnResults for the UnsafePointerFn type type moqUnsafePointerFn_doReturnFn func() unsafe.Pointer -// moqUnsafePointerFn_results holds the results of the UnsafePointerFn type -type moqUnsafePointerFn_results struct { - params moqUnsafePointerFn_params - results []struct { - values *struct { - result1 unsafe.Pointer - } - sequence uint32 - doFn moqUnsafePointerFn_doFn - doReturnFn moqUnsafePointerFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqUnsafePointerFn_fnRecorder routes recorded function calls to the +// moqUnsafePointerFn_recorder routes recorded function calls to the // moqUnsafePointerFn moq -type moqUnsafePointerFn_fnRecorder struct { - params moqUnsafePointerFn_params - anyParams uint64 - sequence bool - results *moqUnsafePointerFn_results - moq *moqUnsafePointerFn +type moqUnsafePointerFn_recorder struct { + recorder *impl.Recorder[ + *moqUnsafePointerFn_adaptor, + moqUnsafePointerFn_params, + moqUnsafePointerFn_paramsKey, + moqUnsafePointerFn_results, + ] } // moqUnsafePointerFn_anyParams isolates the any params functions of the // UnsafePointerFn type type moqUnsafePointerFn_anyParams struct { - recorder *moqUnsafePointerFn_fnRecorder + recorder *moqUnsafePointerFn_recorder } // newMoqUnsafePointerFn creates a new moq of the UnsafePointerFn type func newMoqUnsafePointerFn(scene *moq.Scene, config *moq.Config) *moqUnsafePointerFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqUnsafePointerFn_adaptor{} m := &moqUnsafePointerFn{ - scene: scene, - config: *config, - moq: &moqUnsafePointerFn_mock{}, + moq: impl.NewMoq[ + *moqUnsafePointerFn_adaptor, + moqUnsafePointerFn_params, + moqUnsafePointerFn_paramsKey, + moqUnsafePointerFn_results, + ](scene, adaptor1, config), - runtime: struct { - parameterIndexing struct{} - }{parameterIndexing: struct{}{}}, + runtime: moqUnsafePointerFn_runtime{parameterIndexing: moqUnsafePointerFn_paramIndexing{}}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -20477,237 +11444,91 @@ func newMoqUnsafePointerFn(scene *moq.Scene, config *moq.Config) *moqUnsafePoint // mock returns the moq implementation of the UnsafePointerFn type func (m *moqUnsafePointerFn) mock() testmoqs.UnsafePointerFn { - return func() unsafe.Pointer { m.scene.T.Helper(); moq := &moqUnsafePointerFn_mock{moq: m}; return moq.fn() } -} - -func (m *moqUnsafePointerFn_mock) fn() (result1 unsafe.Pointer) { - m.moq.scene.T.Helper() - params := moqUnsafePointerFn_params{} - var results *moqUnsafePointerFn_results - 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 - } + return func() unsafe.Pointer { + m.moq.Scene.T.Helper() + params := moqUnsafePointerFn_params{} - 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 + var result1 unsafe.Pointer + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } - 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() - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn() + return result1 } - return } -func (m *moqUnsafePointerFn) onCall() *moqUnsafePointerFn_fnRecorder { - return &moqUnsafePointerFn_fnRecorder{ - params: moqUnsafePointerFn_params{}, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, +func (m *moqUnsafePointerFn) onCall() *moqUnsafePointerFn_recorder { + return &moqUnsafePointerFn_recorder{ + recorder: m.moq.OnCall(moqUnsafePointerFn_params{}), } } -func (r *moqUnsafePointerFn_fnRecorder) any() *moqUnsafePointerFn_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(r.params)) +func (r *moqUnsafePointerFn_recorder) any() *moqUnsafePointerFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqUnsafePointerFn_anyParams{recorder: r} } -func (r *moqUnsafePointerFn_fnRecorder) seq() *moqUnsafePointerFn_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(r.params)) +func (r *moqUnsafePointerFn_recorder) seq() *moqUnsafePointerFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqUnsafePointerFn_fnRecorder) noSeq() *moqUnsafePointerFn_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(r.params)) +func (r *moqUnsafePointerFn_recorder) noSeq() *moqUnsafePointerFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqUnsafePointerFn_fnRecorder) returnResults(result1 unsafe.Pointer) *moqUnsafePointerFn_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 unsafe.Pointer - } - sequence uint32 - doFn moqUnsafePointerFn_doFn - doReturnFn moqUnsafePointerFn_doReturnFn - }{ - values: &struct { - result1 unsafe.Pointer - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqUnsafePointerFn_recorder) returnResults(result1 unsafe.Pointer) *moqUnsafePointerFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqUnsafePointerFn_results{ + result1: result1, }) return r } -func (r *moqUnsafePointerFn_fnRecorder) andDo(fn moqUnsafePointerFn_doFn) *moqUnsafePointerFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqUnsafePointerFn_recorder) andDo(fn moqUnsafePointerFn_doFn) *moqUnsafePointerFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqUnsafePointerFn_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqUnsafePointerFn_fnRecorder) doReturnResults(fn moqUnsafePointerFn_doReturnFn) *moqUnsafePointerFn_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 unsafe.Pointer +func (r *moqUnsafePointerFn_recorder) doReturnResults(fn moqUnsafePointerFn_doReturnFn) *moqUnsafePointerFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqUnsafePointerFn_params) *moqUnsafePointerFn_results { + result1 := fn() + return &moqUnsafePointerFn_results{ + result1: result1, } - sequence uint32 - doFn moqUnsafePointerFn_doFn - doReturnFn moqUnsafePointerFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqUnsafePointerFn_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 *moqUnsafePointerFn_resultsByParams - 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 = &moqUnsafePointerFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqUnsafePointerFn_paramsKey]*moqUnsafePointerFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqUnsafePointerFn_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 *moqUnsafePointerFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqUnsafePointerFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqUnsafePointerFn_recorder) repeat(repeaters ...moq.Repeater) *moqUnsafePointerFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 unsafe.Pointer - } - sequence uint32 - doFn moqUnsafePointerFn_doFn - doReturnFn moqUnsafePointerFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqUnsafePointerFn) prettyParams(params moqUnsafePointerFn_params) string { +func (*moqUnsafePointerFn_adaptor) PrettyParams(params moqUnsafePointerFn_params) string { return fmt.Sprintf("UnsafePointerFn()") } -func (m *moqUnsafePointerFn) paramsKey(params moqUnsafePointerFn_params, anyParams uint64) moqUnsafePointerFn_paramsKey { - m.scene.T.Helper() +func (a *moqUnsafePointerFn_adaptor) ParamsKey(params moqUnsafePointerFn_params, anyParams uint64) moqUnsafePointerFn_paramsKey { + a.moq.moq.Scene.T.Helper() return moqUnsafePointerFn_paramsKey{ params: struct{}{}, hashes: struct{}{}, @@ -20715,17 +11536,12 @@ func (m *moqUnsafePointerFn) paramsKey(params moqUnsafePointerFn_params, anyPara } // Reset resets the state of the moq -func (m *moqUnsafePointerFn) Reset() { m.resultsByParams = nil } +func (m *moqUnsafePointerFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqUnsafePointerFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/generator/testmoqs/testmoqs_test.go b/generator/testmoqs/testmoqs_test.go index e40e7cc..0dca9d7 100644 --- a/generator/testmoqs/testmoqs_test.go +++ b/generator/testmoqs/testmoqs_test.go @@ -417,12 +417,10 @@ func TestRepeaters(t *testing.T) { tMoq.onCall().Helper().returnResults().repeat(moq.AnyTimes()) - msg := fmt.Sprintf("%s or %s must be called before calling %s", + tMoq.onCall().Fatalf("%s or %s must be called before calling %s", export("returnResults", entry), export("doReturnResults", entry), - export("repeat", entry)) - - tMoq.onCall().Fatalf(msg).returnResults() + export("repeat", entry)).returnResults() rec := entry.newRecorder([]string{"Hi", "you"}, true) @@ -626,12 +624,9 @@ func TestAnyValues(t *testing.T) { drrFn = titler.String(drrFn) } - msg := fmt.Sprintf( - "Any functions must be called before %s or %s calls, recording %%s", - rrFn, drrFn) bParams := entry.prettyParams([]string{"Hi", "you"}, true) - tMoq.onCall().Fatalf(msg, bParams).returnResults() - fmtMsg := fmt.Sprintf(msg, bParams) + tMoq.onCall().Fatalf("Any functions must be called before %s or %s calls, recording %s", + rrFn, drrFn, bParams).returnResults() // ACT rec.anySParam() @@ -643,8 +638,8 @@ func TestAnyValues(t *testing.T) { scene.AssertExpectationsMet() moqScene.AssertExpectationsMet() if !config.noParams && !config.opaqueParams { - if !strings.Contains(fmtMsg, "Hi") { - t.Errorf("got: %s, want to contain Hi", fmtMsg) + if !strings.Contains(bParams, "Hi") { + t.Errorf("got: %s, want to contain Hi", bParams) } } }) @@ -997,13 +992,12 @@ func TestSequences(t *testing.T) { rec := entry.newRecorder([]string{"Hello", "there"}, false) rec.returnResults(result.sResults, result.err) - msg := fmt.Sprintf("%s must be called before %s or %s calls, recording %%s", + bParams := entry.prettyParams([]string{"Hello", "there"}, false) + tMoq.onCall().Fatalf("%s must be called before %s or %s calls, recording %s", export(seqNoSeq, entry), export("returnResults", entry), - export("doReturnResults", entry)) - bParams := entry.prettyParams([]string{"Hello", "there"}, false) - tMoq.onCall().Fatalf(msg, bParams).returnResults() - fmtMsg := fmt.Sprintf(msg, bParams) + export("doReturnResults", entry), + bParams).returnResults() // ACT switch seqNoSeq { @@ -1022,8 +1016,8 @@ func TestSequences(t *testing.T) { } config := entry.config() if !config.noParams && !config.opaqueParams { - if !strings.Contains(fmtMsg, "Hello") { - t.Errorf("got: %s, want to contain Hello", fmtMsg) + if !strings.Contains(bParams, "Hello") { + t.Errorf("got: %s, want to contain Hello", bParams) } } @@ -1193,9 +1187,9 @@ func TestDoFuncs(t *testing.T) { tMoq.onCall().Helper().returnResults().repeat(moq.AnyTimes()) - msg := fmt.Sprintf("%s must be called before calling %s", - export("returnResults", entry), export("andDo", entry)) - tMoq.onCall().Fatalf(msg).returnResults() + tMoq.onCall().Fatalf("%s must be called before calling %s", + export("returnResults", entry), + export("andDo", entry)).returnResults() rec := entry.newRecorder([]string{"Hi", "you"}, true) diff --git a/generator/testmoqs/usualadaptors_test.go b/generator/testmoqs/usualadaptors_test.go index 244d69a..43070a2 100644 --- a/generator/testmoqs/usualadaptors_test.go +++ b/generator/testmoqs/usualadaptors_test.go @@ -42,7 +42,7 @@ func (a *usualAdaptor) sceneMoq() moq.Moq { } type usualRecorder struct { - r *moqUsual_Usual_fnRecorder + r *moqUsual_Usual_recorder } func (r *usualRecorder) anySParam() { @@ -141,7 +141,7 @@ func (a *exportedUsualAdaptor) sceneMoq() moq.Moq { } type exportedUsualRecorder struct { - r *exported.MoqUsual_Usual_fnRecorder + r *exported.MoqUsual_Usual_recorder } func (r *exportedUsualRecorder) anySParam() { @@ -238,7 +238,7 @@ func (a *noNamesAdaptor) sceneMoq() moq.Moq { } type noNamesRecorder struct { - r *moqUsual_NoNames_fnRecorder + r *moqUsual_NoNames_recorder } func (r *noNamesRecorder) anySParam() { @@ -337,7 +337,7 @@ func (a *exportedNoNamesAdaptor) sceneMoq() moq.Moq { } type exportedNoNamesRecorder struct { - r *exported.MoqUsual_NoNames_fnRecorder + r *exported.MoqUsual_NoNames_recorder } func (r *exportedNoNamesRecorder) anySParam() { @@ -428,7 +428,7 @@ func (a *noResultsAdaptor) sceneMoq() moq.Moq { } type noResultsRecorder struct { - r *moqUsual_NoResults_fnRecorder + r *moqUsual_NoResults_recorder } func (r *noResultsRecorder) anySParam() { @@ -520,7 +520,7 @@ func (a *exportedNoResultsAdaptor) sceneMoq() moq.Moq { } type exportedNoResultsRecorder struct { - r *exported.MoqUsual_NoResults_fnRecorder + r *exported.MoqUsual_NoResults_recorder } func (r *exportedNoResultsRecorder) anySParam() { @@ -618,7 +618,7 @@ func (a *noParamsAdaptor) sceneMoq() moq.Moq { } type noParamsRecorder struct { - r *moqUsual_NoParams_fnRecorder + r *moqUsual_NoParams_recorder } func (r *noParamsRecorder) anySParam() {} @@ -693,7 +693,7 @@ func (a *exportedNoParamsAdaptor) sceneMoq() moq.Moq { } type exportedNoParamsRecorder struct { - r *exported.MoqUsual_NoParams_fnRecorder + r *exported.MoqUsual_NoParams_recorder } func (r *exportedNoParamsRecorder) anySParam() {} @@ -762,7 +762,7 @@ func (a *nothingAdaptor) sceneMoq() moq.Moq { } type nothingRecorder struct { - r *moqUsual_Nothing_fnRecorder + r *moqUsual_Nothing_recorder } func (r *nothingRecorder) anySParam() {} @@ -830,7 +830,7 @@ func (a *exportedNothingAdaptor) sceneMoq() moq.Moq { } type exportedNothingRecorder struct { - r *exported.MoqUsual_Nothing_fnRecorder + r *exported.MoqUsual_Nothing_recorder } func (r *exportedNothingRecorder) anySParam() {} @@ -902,7 +902,7 @@ func (a *variadicAdaptor) sceneMoq() moq.Moq { } type variadicRecorder struct { - r *moqUsual_Variadic_fnRecorder + r *moqUsual_Variadic_recorder } func (r *variadicRecorder) anySParam() { @@ -1003,7 +1003,7 @@ func (a *exportedVariadicAdaptor) sceneMoq() moq.Moq { } type exportedVariadicRecorder struct { - r *exported.MoqUsual_Variadic_fnRecorder + r *exported.MoqUsual_Variadic_recorder } func (r *exportedVariadicRecorder) anySParam() { @@ -1103,7 +1103,7 @@ func (a *repeatedIdsAdaptor) sceneMoq() moq.Moq { } type repeatedIdsRecorder struct { - r *moqUsual_RepeatedIds_fnRecorder + r *moqUsual_RepeatedIds_recorder } func (r *repeatedIdsRecorder) anySParam() { @@ -1211,7 +1211,7 @@ func (a *exportedRepeatedIdsAdaptor) sceneMoq() moq.Moq { } type exportedRepeatedIdsRecorder struct { - r *exported.MoqUsual_RepeatedIds_fnRecorder + r *exported.MoqUsual_RepeatedIds_recorder } func (r *exportedRepeatedIdsRecorder) anySParam() { @@ -1314,7 +1314,7 @@ func (a *timesAdaptor) sceneMoq() moq.Moq { } type timesRecorder struct { - r *moqUsual_Times_fnRecorder + r *moqUsual_Times_recorder } func (r *timesRecorder) anySParam() { @@ -1413,7 +1413,7 @@ func (a *exportedTimesAdaptor) sceneMoq() moq.Moq { } type exportedTimesRecorder struct { - r *exported.MoqUsual_Times_fnRecorder + r *exported.MoqUsual_Times_recorder } func (r *exportedTimesRecorder) anySParam() { @@ -1505,7 +1505,7 @@ func (a *difficultParamNamesAdaptor) sceneMoq() moq.Moq { } type difficultParamNamesRecorder struct { - r *moqUsual_DifficultParamNames_fnRecorder + r *moqUsual_DifficultParamNames_recorder } func (r *difficultParamNamesRecorder) anySParam() { @@ -1601,7 +1601,7 @@ func (a *exportedDifficultParamNamesAdaptor) sceneMoq() moq.Moq { } type exportedDifficultParamNamesRecorder struct { - r *exported.MoqUsual_DifficultParamNames_fnRecorder + r *exported.MoqUsual_DifficultParamNames_recorder } func (r *exportedDifficultParamNamesRecorder) anySParam() { @@ -1704,7 +1704,7 @@ func (a *difficultResultNamesAdaptor) sceneMoq() moq.Moq { } type difficultResultNamesRecorder struct { - r *moqUsual_DifficultResultNames_fnRecorder + r *moqUsual_DifficultResultNames_recorder } func (r *difficultResultNamesRecorder) anySParam() {} @@ -1783,7 +1783,7 @@ func (a *exportedDifficultResultNamesAdaptor) sceneMoq() moq.Moq { } type exportedDifficultResultNamesRecorder struct { - r *exported.MoqUsual_DifficultResultNames_fnRecorder + r *exported.MoqUsual_DifficultResultNames_recorder } func (r *exportedDifficultResultNamesRecorder) anySParam() {} @@ -1876,7 +1876,7 @@ func (a *passByReferenceAdaptor) sceneMoq() moq.Moq { } type passByReferenceRecorder struct { - r *moqUsual_PassByReference_fnRecorder + r *moqUsual_PassByReference_recorder } func (r *passByReferenceRecorder) anySParam() { @@ -1995,7 +1995,7 @@ func (a *exportedPassByReferenceAdaptor) sceneMoq() moq.Moq { } type exportedPassByReferenceRecorder struct { - r *exported.MoqUsual_PassByReference_fnRecorder + r *exported.MoqUsual_PassByReference_recorder } func (r *exportedPassByReferenceRecorder) anySParam() { @@ -2105,7 +2105,7 @@ func (a *interfaceParamAdaptor) sceneMoq() moq.Moq { } type interfaceParamRecorder struct { - r *moqUsual_InterfaceParam_fnRecorder + r *moqUsual_InterfaceParam_recorder } func (r *interfaceParamRecorder) anySParam() { @@ -2226,7 +2226,7 @@ func (a *exportedInterfaceParamAdaptor) sceneMoq() moq.Moq { } type exportedInterfaceParamRecorder struct { - r *exported.MoqUsual_InterfaceParam_fnRecorder + r *exported.MoqUsual_InterfaceParam_recorder } func (r *exportedInterfaceParamRecorder) anySParam() { @@ -2345,7 +2345,7 @@ func (a *interfaceResultAdaptor) sceneMoq() moq.Moq { } type interfaceResultRecorder struct { - r *moqUsual_InterfaceResult_fnRecorder + r *moqUsual_InterfaceResult_recorder } func (r *interfaceResultRecorder) anySParam() { @@ -2465,7 +2465,7 @@ func (a *exportedInterfaceResultAdaptor) sceneMoq() moq.Moq { } type exportedInterfaceResultRecorder struct { - r *exported.MoqUsual_InterfaceResult_fnRecorder + r *exported.MoqUsual_InterfaceResult_recorder } func (r *exportedInterfaceResultRecorder) anySParam() { @@ -2568,7 +2568,7 @@ func (a *genericParamsAdaptor[S, B]) sceneMoq() moq.Moq { } type genericParamsRecorder[S, B any] struct { - r *moqGenericParams_Usual_fnRecorder[S, B] + r *moqGenericParams_Usual_recorder[S, B] } func (r *genericParamsRecorder[S, B]) anySParam() { @@ -2667,7 +2667,7 @@ func (a *exportedGenericParamsAdaptor[S, B]) sceneMoq() moq.Moq { } type exportedGenericParamsRecorder[S, B any] struct { - r *exported.MoqGenericParams_Usual_fnRecorder[S, B] + r *exported.MoqGenericParams_Usual_recorder[S, B] } func (r *exportedGenericParamsRecorder[S, B]) anySParam() { @@ -2766,7 +2766,7 @@ func (a *partialGenericParamsAdaptor[S]) sceneMoq() moq.Moq { } type partialGenericParamsRecorder[S any] struct { - r *moqPartialGenericParams_Usual_fnRecorder[S] + r *moqPartialGenericParams_Usual_recorder[S] } func (r *partialGenericParamsRecorder[S]) anySParam() { @@ -2867,7 +2867,7 @@ func (a *exportedPartialGenericParamsAdaptor[S]) sceneMoq() moq.Moq { } type exportedPartialGenericParamsRecorder[S any] struct { - r *exported.MoqPartialGenericParams_Usual_fnRecorder[S] + r *exported.MoqPartialGenericParams_Usual_recorder[S] } func (r *exportedPartialGenericParamsRecorder[S]) anySParam() { @@ -2968,7 +2968,7 @@ func (a *genericResultsAdaptor[S, E]) sceneMoq() moq.Moq { } type genericResultsRecorder[S ~string, E error] struct { - r *moqGenericResults_Usual_fnRecorder[S, E] + r *moqGenericResults_Usual_recorder[S, E] } func (r *genericResultsRecorder[S, E]) anySParam() { @@ -3077,7 +3077,7 @@ func (a *exportedGenericResultsAdaptor[S, E]) sceneMoq() moq.Moq { } type exportedGenericResultsRecorder[S ~string, E error] struct { - r *exported.MoqGenericResults_Usual_fnRecorder[S, E] + r *exported.MoqGenericResults_Usual_recorder[S, E] } func (r *exportedGenericResultsRecorder[S, E]) anySParam() { @@ -3186,7 +3186,7 @@ func (a *partialGenericResultsAdaptor[S]) sceneMoq() moq.Moq { } type partialGenericResultsRecorder[S ~string] struct { - r *moqPartialGenericResults_Usual_fnRecorder[S] + r *moqPartialGenericResults_Usual_recorder[S] } func (r *partialGenericResultsRecorder[S]) anySParam() { @@ -3287,7 +3287,7 @@ func (a *exportedPartialGenericResultsAdaptor[S]) sceneMoq() moq.Moq { } type exportedPartialGenericResultsRecorder[S ~string] struct { - r *exported.MoqPartialGenericResults_Usual_fnRecorder[S] + r *exported.MoqPartialGenericResults_Usual_recorder[S] } func (r *exportedPartialGenericResultsRecorder[S]) anySParam() { diff --git a/go.mod b/go.mod index 018b14e..4609398 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module moqueries.org/cli -go 1.19 +go 1.21 require ( github.com/dave/dst v0.27.3 @@ -8,7 +8,7 @@ require ( golang.org/x/mod v0.19.0 golang.org/x/text v0.16.0 golang.org/x/tools v0.23.0 - moqueries.org/runtime v0.3.0 + moqueries.org/runtime v0.4.0 ) require ( diff --git a/go.sum b/go.sum index b13215c..8c3f96b 100644 --- a/go.sum +++ b/go.sum @@ -22,5 +22,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= moqueries.org/deephash v0.26.0 h1:KvMnNvb/N9lId0OOO1X6Yp2BifVuDuJJQH3epAeF178= moqueries.org/deephash v0.26.0/go.mod h1:brwHe2Ks78ZEA1xIgUTEy0gtZfO7tJTqXT9haTdIRNE= -moqueries.org/runtime v0.3.0 h1:f1tDA+y8c60hyTqvlg1g1kyNEewAPF6UHyWgUs9sQMs= -moqueries.org/runtime v0.3.0/go.mod h1:IXFe0wh6tJnD+dfHM6BCCpBuwjQQ5JIxdhRR3Be+IbQ= +moqueries.org/runtime v0.4.0 h1:J5azoWrMEo8baBYKoJVlpw0dPjI5ZGJviPwvRJbG6Iw= +moqueries.org/runtime v0.4.0/go.mod h1:VDwSKhTpm8NBxE23Wp0+zCXiV4hvJZ6zbzh9y4LkGeE= diff --git a/metrics/moq_isloggingfn_test.go b/metrics/moq_isloggingfn_test.go index 57f1681..4a1cd03 100644 --- a/metrics/moq_isloggingfn_test.go +++ b/metrics/moq_isloggingfn_test.go @@ -4,28 +4,31 @@ package metrics_test import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/cli/metrics" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqIsLoggingFn holds the state of a moq of the IsLoggingFn type type moqIsLoggingFn struct { - scene *moq.Scene - config moq.Config - moq *moqIsLoggingFn_mock + moq *impl.Moq[ + *moqIsLoggingFn_adaptor, + moqIsLoggingFn_params, + moqIsLoggingFn_paramsKey, + moqIsLoggingFn_results, + ] - resultsByParams []moqIsLoggingFn_resultsByParams + runtime moqIsLoggingFn_runtime +} - runtime struct { - parameterIndexing struct{} - } +// moqIsLoggingFn_runtime holds runtime configuration for the IsLoggingFn type +type moqIsLoggingFn_runtime struct { + parameterIndexing moqIsLoggingFn_paramIndexing } -// moqIsLoggingFn_mock isolates the mock interface of the IsLoggingFn type -type moqIsLoggingFn_mock struct { +// moqIsLoggingFn_adaptor adapts moqIsLoggingFn as needed by the runtime +type moqIsLoggingFn_adaptor struct { moq *moqIsLoggingFn } @@ -38,14 +41,15 @@ type moqIsLoggingFn_paramsKey struct { hashes struct{} } -// moqIsLoggingFn_resultsByParams contains the results for a given set of -// parameters for the IsLoggingFn type -type moqIsLoggingFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqIsLoggingFn_paramsKey]*moqIsLoggingFn_results +// moqIsLoggingFn_results holds the results of the IsLoggingFn type +type moqIsLoggingFn_results struct { + result1 bool } +// moqIsLoggingFn_paramIndexing holds the parameter indexing runtime +// configuration for the IsLoggingFn type +type moqIsLoggingFn_paramIndexing struct{} + // moqIsLoggingFn_doFn defines the type of function needed when calling andDo // for the IsLoggingFn type type moqIsLoggingFn_doFn func() @@ -54,52 +58,37 @@ type moqIsLoggingFn_doFn func() // doReturnResults for the IsLoggingFn type type moqIsLoggingFn_doReturnFn func() bool -// moqIsLoggingFn_results holds the results of the IsLoggingFn type -type moqIsLoggingFn_results struct { - params moqIsLoggingFn_params - results []struct { - values *struct { - result1 bool - } - sequence uint32 - doFn moqIsLoggingFn_doFn - doReturnFn moqIsLoggingFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqIsLoggingFn_fnRecorder routes recorded function calls to the -// moqIsLoggingFn moq -type moqIsLoggingFn_fnRecorder struct { - params moqIsLoggingFn_params - anyParams uint64 - sequence bool - results *moqIsLoggingFn_results - moq *moqIsLoggingFn +// moqIsLoggingFn_recorder routes recorded function calls to the moqIsLoggingFn +// moq +type moqIsLoggingFn_recorder struct { + recorder *impl.Recorder[ + *moqIsLoggingFn_adaptor, + moqIsLoggingFn_params, + moqIsLoggingFn_paramsKey, + moqIsLoggingFn_results, + ] } // moqIsLoggingFn_anyParams isolates the any params functions of the // IsLoggingFn type type moqIsLoggingFn_anyParams struct { - recorder *moqIsLoggingFn_fnRecorder + recorder *moqIsLoggingFn_recorder } // newMoqIsLoggingFn creates a new moq of the IsLoggingFn type func newMoqIsLoggingFn(scene *moq.Scene, config *moq.Config) *moqIsLoggingFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqIsLoggingFn_adaptor{} m := &moqIsLoggingFn{ - scene: scene, - config: *config, - moq: &moqIsLoggingFn_mock{}, + moq: impl.NewMoq[ + *moqIsLoggingFn_adaptor, + moqIsLoggingFn_params, + moqIsLoggingFn_paramsKey, + moqIsLoggingFn_results, + ](scene, adaptor1, config), - runtime: struct { - parameterIndexing struct{} - }{parameterIndexing: struct{}{}}, + runtime: moqIsLoggingFn_runtime{parameterIndexing: moqIsLoggingFn_paramIndexing{}}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -107,237 +96,91 @@ func newMoqIsLoggingFn(scene *moq.Scene, config *moq.Config) *moqIsLoggingFn { // mock returns the moq implementation of the IsLoggingFn type func (m *moqIsLoggingFn) mock() metrics.IsLoggingFn { - return func() bool { m.scene.T.Helper(); moq := &moqIsLoggingFn_mock{moq: m}; return moq.fn() } -} - -func (m *moqIsLoggingFn_mock) fn() (result1 bool) { - m.moq.scene.T.Helper() - params := moqIsLoggingFn_params{} - var results *moqIsLoggingFn_results - 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 - } + return func() bool { + m.moq.Scene.T.Helper() + params := moqIsLoggingFn_params{} - 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)) + var result1 bool + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } + return result1 } - - if result.doFn != nil { - result.doFn() - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn() - } - return } -func (m *moqIsLoggingFn) onCall() *moqIsLoggingFn_fnRecorder { - return &moqIsLoggingFn_fnRecorder{ - params: moqIsLoggingFn_params{}, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, +func (m *moqIsLoggingFn) onCall() *moqIsLoggingFn_recorder { + return &moqIsLoggingFn_recorder{ + recorder: m.moq.OnCall(moqIsLoggingFn_params{}), } } -func (r *moqIsLoggingFn_fnRecorder) any() *moqIsLoggingFn_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(r.params)) +func (r *moqIsLoggingFn_recorder) any() *moqIsLoggingFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqIsLoggingFn_anyParams{recorder: r} } -func (r *moqIsLoggingFn_fnRecorder) seq() *moqIsLoggingFn_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(r.params)) +func (r *moqIsLoggingFn_recorder) seq() *moqIsLoggingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqIsLoggingFn_fnRecorder) noSeq() *moqIsLoggingFn_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(r.params)) +func (r *moqIsLoggingFn_recorder) noSeq() *moqIsLoggingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqIsLoggingFn_fnRecorder) returnResults(result1 bool) *moqIsLoggingFn_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 bool - } - sequence uint32 - doFn moqIsLoggingFn_doFn - doReturnFn moqIsLoggingFn_doReturnFn - }{ - values: &struct { - result1 bool - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqIsLoggingFn_recorder) returnResults(result1 bool) *moqIsLoggingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqIsLoggingFn_results{ + result1: result1, }) return r } -func (r *moqIsLoggingFn_fnRecorder) andDo(fn moqIsLoggingFn_doFn) *moqIsLoggingFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqIsLoggingFn_recorder) andDo(fn moqIsLoggingFn_doFn) *moqIsLoggingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqIsLoggingFn_params) { + fn() + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqIsLoggingFn_fnRecorder) doReturnResults(fn moqIsLoggingFn_doReturnFn) *moqIsLoggingFn_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 bool +func (r *moqIsLoggingFn_recorder) doReturnResults(fn moqIsLoggingFn_doReturnFn) *moqIsLoggingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqIsLoggingFn_params) *moqIsLoggingFn_results { + result1 := fn() + return &moqIsLoggingFn_results{ + result1: result1, } - sequence uint32 - doFn moqIsLoggingFn_doFn - doReturnFn moqIsLoggingFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqIsLoggingFn_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 *moqIsLoggingFn_resultsByParams - 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 = &moqIsLoggingFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqIsLoggingFn_paramsKey]*moqIsLoggingFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqIsLoggingFn_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 *moqIsLoggingFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqIsLoggingFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqIsLoggingFn_recorder) repeat(repeaters ...moq.Repeater) *moqIsLoggingFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 bool - } - sequence uint32 - doFn moqIsLoggingFn_doFn - doReturnFn moqIsLoggingFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqIsLoggingFn) prettyParams(params moqIsLoggingFn_params) string { +func (*moqIsLoggingFn_adaptor) PrettyParams(params moqIsLoggingFn_params) string { return fmt.Sprintf("IsLoggingFn()") } -func (m *moqIsLoggingFn) paramsKey(params moqIsLoggingFn_params, anyParams uint64) moqIsLoggingFn_paramsKey { - m.scene.T.Helper() +func (a *moqIsLoggingFn_adaptor) ParamsKey(params moqIsLoggingFn_params, anyParams uint64) moqIsLoggingFn_paramsKey { + a.moq.moq.Scene.T.Helper() return moqIsLoggingFn_paramsKey{ params: struct{}{}, hashes: struct{}{}, @@ -345,17 +188,12 @@ func (m *moqIsLoggingFn) paramsKey(params moqIsLoggingFn_params, anyParams uint6 } // Reset resets the state of the moq -func (m *moqIsLoggingFn) Reset() { m.resultsByParams = nil } +func (m *moqIsLoggingFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqIsLoggingFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/metrics/moq_loggingffn_test.go b/metrics/moq_loggingffn_test.go index 55dd9e8..5c5cf57 100644 --- a/metrics/moq_loggingffn_test.go +++ b/metrics/moq_loggingffn_test.go @@ -4,32 +4,32 @@ package metrics_test import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/cli/metrics" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqLoggingfFn holds the state of a moq of the LoggingfFn type type moqLoggingfFn struct { - scene *moq.Scene - config moq.Config - moq *moqLoggingfFn_mock + moq *impl.Moq[ + *moqLoggingfFn_adaptor, + moqLoggingfFn_params, + moqLoggingfFn_paramsKey, + moqLoggingfFn_results, + ] - resultsByParams []moqLoggingfFn_resultsByParams + runtime moqLoggingfFn_runtime +} - runtime struct { - parameterIndexing struct { - format moq.ParamIndexing - args moq.ParamIndexing - } - } +// moqLoggingfFn_runtime holds runtime configuration for the LoggingfFn type +type moqLoggingfFn_runtime struct { + parameterIndexing moqLoggingfFn_paramIndexing } -// moqLoggingfFn_mock isolates the mock interface of the LoggingfFn type -type moqLoggingfFn_mock struct { +// moqLoggingfFn_adaptor adapts moqLoggingfFn as needed by the runtime +type moqLoggingfFn_adaptor struct { moq *moqLoggingfFn } @@ -48,12 +48,14 @@ type moqLoggingfFn_paramsKey struct { } } -// moqLoggingfFn_resultsByParams contains the results for a given set of -// parameters for the LoggingfFn type -type moqLoggingfFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqLoggingfFn_paramsKey]*moqLoggingfFn_results +// moqLoggingfFn_results holds the results of the LoggingfFn type +type moqLoggingfFn_results struct{} + +// moqLoggingfFn_paramIndexing holds the parameter indexing runtime +// configuration for the LoggingfFn type +type moqLoggingfFn_paramIndexing struct { + format moq.ParamIndexing + args moq.ParamIndexing } // moqLoggingfFn_doFn defines the type of function needed when calling andDo @@ -64,59 +66,40 @@ type moqLoggingfFn_doFn func(format string, args ...interface{}) // doReturnResults for the LoggingfFn type type moqLoggingfFn_doReturnFn func(format string, args ...interface{}) -// moqLoggingfFn_results holds the results of the LoggingfFn type -type moqLoggingfFn_results struct { - params moqLoggingfFn_params - results []struct { - values *struct{} - sequence uint32 - doFn moqLoggingfFn_doFn - doReturnFn moqLoggingfFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqLoggingfFn_fnRecorder routes recorded function calls to the moqLoggingfFn +// moqLoggingfFn_recorder routes recorded function calls to the moqLoggingfFn // moq -type moqLoggingfFn_fnRecorder struct { - params moqLoggingfFn_params - anyParams uint64 - sequence bool - results *moqLoggingfFn_results - moq *moqLoggingfFn +type moqLoggingfFn_recorder struct { + recorder *impl.Recorder[ + *moqLoggingfFn_adaptor, + moqLoggingfFn_params, + moqLoggingfFn_paramsKey, + moqLoggingfFn_results, + ] } // moqLoggingfFn_anyParams isolates the any params functions of the LoggingfFn // type type moqLoggingfFn_anyParams struct { - recorder *moqLoggingfFn_fnRecorder + recorder *moqLoggingfFn_recorder } // newMoqLoggingfFn creates a new moq of the LoggingfFn type func newMoqLoggingfFn(scene *moq.Scene, config *moq.Config) *moqLoggingfFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqLoggingfFn_adaptor{} m := &moqLoggingfFn{ - scene: scene, - config: *config, - moq: &moqLoggingfFn_mock{}, - - runtime: struct { - parameterIndexing struct { - format moq.ParamIndexing - args moq.ParamIndexing - } - }{parameterIndexing: struct { - format moq.ParamIndexing - args moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqLoggingfFn_adaptor, + moqLoggingfFn_params, + moqLoggingfFn_paramsKey, + moqLoggingfFn_results, + ](scene, adaptor1, config), + + runtime: moqLoggingfFn_runtime{parameterIndexing: moqLoggingfFn_paramIndexing{ format: moq.ParamIndexByValue, args: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -125,259 +108,102 @@ func newMoqLoggingfFn(scene *moq.Scene, config *moq.Config) *moqLoggingfFn { // mock returns the moq implementation of the LoggingfFn type func (m *moqLoggingfFn) mock() metrics.LoggingfFn { return func(format string, args ...interface{}) { - m.scene.T.Helper() - moq := &moqLoggingfFn_mock{moq: m} - moq.fn(format, args...) - } -} - -func (m *moqLoggingfFn_mock) fn(format string, args ...interface{}) { - m.moq.scene.T.Helper() - params := moqLoggingfFn_params{ - format: format, - args: args, - } - var results *moqLoggingfFn_results - 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)) + m.moq.Scene.T.Helper() + params := moqLoggingfFn_params{ + format: format, + args: args, } - } - - if result.doFn != nil { - result.doFn(format, args...) - } - if result.doReturnFn != nil { - result.doReturnFn(format, args...) + m.moq.Function(params) } - return } -func (m *moqLoggingfFn) onCall(format string, args ...interface{}) *moqLoggingfFn_fnRecorder { - return &moqLoggingfFn_fnRecorder{ - params: moqLoggingfFn_params{ +func (m *moqLoggingfFn) onCall(format string, args ...interface{}) *moqLoggingfFn_recorder { + return &moqLoggingfFn_recorder{ + recorder: m.moq.OnCall(moqLoggingfFn_params{ format: format, args: args, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqLoggingfFn_fnRecorder) any() *moqLoggingfFn_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(r.params)) +func (r *moqLoggingfFn_recorder) any() *moqLoggingfFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqLoggingfFn_anyParams{recorder: r} } -func (a *moqLoggingfFn_anyParams) format() *moqLoggingfFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqLoggingfFn_anyParams) format() *moqLoggingfFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqLoggingfFn_anyParams) args() *moqLoggingfFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqLoggingfFn_anyParams) args() *moqLoggingfFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqLoggingfFn_fnRecorder) seq() *moqLoggingfFn_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(r.params)) +func (r *moqLoggingfFn_recorder) seq() *moqLoggingfFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqLoggingfFn_fnRecorder) noSeq() *moqLoggingfFn_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(r.params)) +func (r *moqLoggingfFn_recorder) noSeq() *moqLoggingfFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqLoggingfFn_fnRecorder) returnResults() *moqLoggingfFn_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 moqLoggingfFn_doFn - doReturnFn moqLoggingfFn_doReturnFn - }{ - values: &struct{}{}, - sequence: sequence, - }) +func (r *moqLoggingfFn_recorder) returnResults() *moqLoggingfFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqLoggingfFn_results{}) return r } -func (r *moqLoggingfFn_fnRecorder) andDo(fn moqLoggingfFn_doFn) *moqLoggingfFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqLoggingfFn_recorder) andDo(fn moqLoggingfFn_doFn) *moqLoggingfFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqLoggingfFn_params) { + fn(params.format, params.args...) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqLoggingfFn_fnRecorder) doReturnResults(fn moqLoggingfFn_doReturnFn) *moqLoggingfFn_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 moqLoggingfFn_doFn - doReturnFn moqLoggingfFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) +func (r *moqLoggingfFn_recorder) doReturnResults(fn moqLoggingfFn_doReturnFn) *moqLoggingfFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqLoggingfFn_params) *moqLoggingfFn_results { + fn(params.format, params.args...) + return &moqLoggingfFn_results{} + }) return r } -func (r *moqLoggingfFn_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 *moqLoggingfFn_resultsByParams - 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 = &moqLoggingfFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqLoggingfFn_paramsKey]*moqLoggingfFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqLoggingfFn_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 *moqLoggingfFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqLoggingfFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqLoggingfFn_recorder) repeat(repeaters ...moq.Repeater) *moqLoggingfFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 moqLoggingfFn_doFn - doReturnFn moqLoggingfFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqLoggingfFn) prettyParams(params moqLoggingfFn_params) string { +func (*moqLoggingfFn_adaptor) PrettyParams(params moqLoggingfFn_params) string { return fmt.Sprintf("LoggingfFn(%#v, %#v)", params.format, params.args) } -func (m *moqLoggingfFn) paramsKey(params moqLoggingfFn_params, anyParams uint64) moqLoggingfFn_paramsKey { - m.scene.T.Helper() - var formatUsed string - var formatUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.format == moq.ParamIndexByValue { - formatUsed = params.format - } else { - formatUsedHash = hash.DeepHash(params.format) - } - } - var argsUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.args == moq.ParamIndexByValue { - m.scene.T.Fatalf("The args parameter can't be indexed by value") - } - argsUsedHash = hash.DeepHash(params.args) - } +func (a *moqLoggingfFn_adaptor) ParamsKey(params moqLoggingfFn_params, anyParams uint64) moqLoggingfFn_paramsKey { + a.moq.moq.Scene.T.Helper() + formatUsed, formatUsedHash := impl.ParamKey( + params.format, 1, a.moq.runtime.parameterIndexing.format, anyParams) + argsUsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.args, "args", 2, a.moq.runtime.parameterIndexing.args, anyParams) return moqLoggingfFn_paramsKey{ params: struct{ format string }{ format: formatUsed, @@ -393,17 +219,12 @@ func (m *moqLoggingfFn) paramsKey(params moqLoggingfFn_params, anyParams uint64) } // Reset resets the state of the moq -func (m *moqLoggingfFn) Reset() { m.resultsByParams = nil } +func (m *moqLoggingfFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqLoggingfFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/metrics/moq_metrics.go b/metrics/moq_metrics.go index 0e0801f..0f926c8 100644 --- a/metrics/moq_metrics.go +++ b/metrics/moq_metrics.go @@ -4,11 +4,10 @@ package metrics import ( "fmt" - "math/bits" - "sync/atomic" "time" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -18,33 +17,46 @@ var _ Metrics = (*MoqMetrics_mock)(nil) // MoqMetrics holds the state of a moq of the Metrics type type MoqMetrics struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqMetrics_mock - - ResultsByParams_ASTPkgCacheHitsInc []MoqMetrics_ASTPkgCacheHitsInc_resultsByParams - ResultsByParams_ASTPkgCacheMissesInc []MoqMetrics_ASTPkgCacheMissesInc_resultsByParams - ResultsByParams_ASTTotalLoadTimeInc []MoqMetrics_ASTTotalLoadTimeInc_resultsByParams - ResultsByParams_ASTTotalDecorationTimeInc []MoqMetrics_ASTTotalDecorationTimeInc_resultsByParams - ResultsByParams_TotalProcessingTimeInc []MoqMetrics_TotalProcessingTimeInc_resultsByParams - ResultsByParams_Finalize []MoqMetrics_Finalize_resultsByParams - - Runtime struct { - ParameterIndexing struct { - ASTPkgCacheHitsInc struct{} - ASTPkgCacheMissesInc struct{} - ASTTotalLoadTimeInc struct { - D moq.ParamIndexing - } - ASTTotalDecorationTimeInc struct { - D moq.ParamIndexing - } - TotalProcessingTimeInc struct { - D moq.ParamIndexing - } - Finalize struct{} - } - } + Moq *MoqMetrics_mock + + Moq_ASTPkgCacheHitsInc *impl.Moq[ + *MoqMetrics_ASTPkgCacheHitsInc_adaptor, + MoqMetrics_ASTPkgCacheHitsInc_params, + MoqMetrics_ASTPkgCacheHitsInc_paramsKey, + MoqMetrics_ASTPkgCacheHitsInc_results, + ] + Moq_ASTPkgCacheMissesInc *impl.Moq[ + *MoqMetrics_ASTPkgCacheMissesInc_adaptor, + MoqMetrics_ASTPkgCacheMissesInc_params, + MoqMetrics_ASTPkgCacheMissesInc_paramsKey, + MoqMetrics_ASTPkgCacheMissesInc_results, + ] + Moq_ASTTotalLoadTimeInc *impl.Moq[ + *MoqMetrics_ASTTotalLoadTimeInc_adaptor, + MoqMetrics_ASTTotalLoadTimeInc_params, + MoqMetrics_ASTTotalLoadTimeInc_paramsKey, + MoqMetrics_ASTTotalLoadTimeInc_results, + ] + Moq_ASTTotalDecorationTimeInc *impl.Moq[ + *MoqMetrics_ASTTotalDecorationTimeInc_adaptor, + MoqMetrics_ASTTotalDecorationTimeInc_params, + MoqMetrics_ASTTotalDecorationTimeInc_paramsKey, + MoqMetrics_ASTTotalDecorationTimeInc_results, + ] + Moq_TotalProcessingTimeInc *impl.Moq[ + *MoqMetrics_TotalProcessingTimeInc_adaptor, + MoqMetrics_TotalProcessingTimeInc_params, + MoqMetrics_TotalProcessingTimeInc_paramsKey, + MoqMetrics_TotalProcessingTimeInc_results, + ] + Moq_Finalize *impl.Moq[ + *MoqMetrics_Finalize_adaptor, + MoqMetrics_Finalize_params, + MoqMetrics_Finalize_paramsKey, + MoqMetrics_Finalize_results, + ] + + Runtime MoqMetrics_runtime } // MoqMetrics_mock isolates the mock interface of the Metrics type @@ -57,6 +69,24 @@ type MoqMetrics_recorder struct { Moq *MoqMetrics } +// MoqMetrics_runtime holds runtime configuration for the Metrics type +type MoqMetrics_runtime struct { + ParameterIndexing struct { + ASTPkgCacheHitsInc MoqMetrics_ASTPkgCacheHitsInc_paramIndexing + ASTPkgCacheMissesInc MoqMetrics_ASTPkgCacheMissesInc_paramIndexing + ASTTotalLoadTimeInc MoqMetrics_ASTTotalLoadTimeInc_paramIndexing + ASTTotalDecorationTimeInc MoqMetrics_ASTTotalDecorationTimeInc_paramIndexing + TotalProcessingTimeInc MoqMetrics_TotalProcessingTimeInc_paramIndexing + Finalize MoqMetrics_Finalize_paramIndexing + } +} + +// MoqMetrics_ASTPkgCacheHitsInc_adaptor adapts MoqMetrics as needed by the +// runtime +type MoqMetrics_ASTPkgCacheHitsInc_adaptor struct { + Moq *MoqMetrics +} + // MoqMetrics_ASTPkgCacheHitsInc_params holds the params of the Metrics type type MoqMetrics_ASTPkgCacheHitsInc_params struct{} @@ -67,13 +97,12 @@ type MoqMetrics_ASTPkgCacheHitsInc_paramsKey struct { Hashes struct{} } -// MoqMetrics_ASTPkgCacheHitsInc_resultsByParams contains the results for a -// given set of parameters for the Metrics type -type MoqMetrics_ASTPkgCacheHitsInc_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqMetrics_ASTPkgCacheHitsInc_paramsKey]*MoqMetrics_ASTPkgCacheHitsInc_results -} +// MoqMetrics_ASTPkgCacheHitsInc_results holds the results of the Metrics type +type MoqMetrics_ASTPkgCacheHitsInc_results struct{} + +// MoqMetrics_ASTPkgCacheHitsInc_paramIndexing holds the parameter indexing +// runtime configuration for the Metrics type +type MoqMetrics_ASTPkgCacheHitsInc_paramIndexing struct{} // MoqMetrics_ASTPkgCacheHitsInc_doFn defines the type of function needed when // calling AndDo for the Metrics type @@ -83,33 +112,27 @@ type MoqMetrics_ASTPkgCacheHitsInc_doFn func() // when calling DoReturnResults for the Metrics type type MoqMetrics_ASTPkgCacheHitsInc_doReturnFn func() -// MoqMetrics_ASTPkgCacheHitsInc_results holds the results of the Metrics type -type MoqMetrics_ASTPkgCacheHitsInc_results struct { - Params MoqMetrics_ASTPkgCacheHitsInc_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTPkgCacheHitsInc_doFn - DoReturnFn MoqMetrics_ASTPkgCacheHitsInc_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqMetrics_ASTPkgCacheHitsInc_fnRecorder routes recorded function calls to -// the MoqMetrics moq -type MoqMetrics_ASTPkgCacheHitsInc_fnRecorder struct { - Params MoqMetrics_ASTPkgCacheHitsInc_params - AnyParams uint64 - Sequence bool - Results *MoqMetrics_ASTPkgCacheHitsInc_results - Moq *MoqMetrics +// MoqMetrics_ASTPkgCacheHitsInc_recorder routes recorded function calls to the +// MoqMetrics moq +type MoqMetrics_ASTPkgCacheHitsInc_recorder struct { + Recorder *impl.Recorder[ + *MoqMetrics_ASTPkgCacheHitsInc_adaptor, + MoqMetrics_ASTPkgCacheHitsInc_params, + MoqMetrics_ASTPkgCacheHitsInc_paramsKey, + MoqMetrics_ASTPkgCacheHitsInc_results, + ] } // MoqMetrics_ASTPkgCacheHitsInc_anyParams isolates the any params functions of // the Metrics type type MoqMetrics_ASTPkgCacheHitsInc_anyParams struct { - Recorder *MoqMetrics_ASTPkgCacheHitsInc_fnRecorder + Recorder *MoqMetrics_ASTPkgCacheHitsInc_recorder +} + +// MoqMetrics_ASTPkgCacheMissesInc_adaptor adapts MoqMetrics as needed by the +// runtime +type MoqMetrics_ASTPkgCacheMissesInc_adaptor struct { + Moq *MoqMetrics } // MoqMetrics_ASTPkgCacheMissesInc_params holds the params of the Metrics type @@ -122,13 +145,13 @@ type MoqMetrics_ASTPkgCacheMissesInc_paramsKey struct { Hashes struct{} } -// MoqMetrics_ASTPkgCacheMissesInc_resultsByParams contains the results for a -// given set of parameters for the Metrics type -type MoqMetrics_ASTPkgCacheMissesInc_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqMetrics_ASTPkgCacheMissesInc_paramsKey]*MoqMetrics_ASTPkgCacheMissesInc_results -} +// MoqMetrics_ASTPkgCacheMissesInc_results holds the results of the Metrics +// type +type MoqMetrics_ASTPkgCacheMissesInc_results struct{} + +// MoqMetrics_ASTPkgCacheMissesInc_paramIndexing holds the parameter indexing +// runtime configuration for the Metrics type +type MoqMetrics_ASTPkgCacheMissesInc_paramIndexing struct{} // MoqMetrics_ASTPkgCacheMissesInc_doFn defines the type of function needed // when calling AndDo for the Metrics type @@ -138,34 +161,27 @@ type MoqMetrics_ASTPkgCacheMissesInc_doFn func() // needed when calling DoReturnResults for the Metrics type type MoqMetrics_ASTPkgCacheMissesInc_doReturnFn func() -// MoqMetrics_ASTPkgCacheMissesInc_results holds the results of the Metrics -// type -type MoqMetrics_ASTPkgCacheMissesInc_results struct { - Params MoqMetrics_ASTPkgCacheMissesInc_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTPkgCacheMissesInc_doFn - DoReturnFn MoqMetrics_ASTPkgCacheMissesInc_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqMetrics_ASTPkgCacheMissesInc_fnRecorder routes recorded function calls to +// MoqMetrics_ASTPkgCacheMissesInc_recorder routes recorded function calls to // the MoqMetrics moq -type MoqMetrics_ASTPkgCacheMissesInc_fnRecorder struct { - Params MoqMetrics_ASTPkgCacheMissesInc_params - AnyParams uint64 - Sequence bool - Results *MoqMetrics_ASTPkgCacheMissesInc_results - Moq *MoqMetrics +type MoqMetrics_ASTPkgCacheMissesInc_recorder struct { + Recorder *impl.Recorder[ + *MoqMetrics_ASTPkgCacheMissesInc_adaptor, + MoqMetrics_ASTPkgCacheMissesInc_params, + MoqMetrics_ASTPkgCacheMissesInc_paramsKey, + MoqMetrics_ASTPkgCacheMissesInc_results, + ] } // MoqMetrics_ASTPkgCacheMissesInc_anyParams isolates the any params functions // of the Metrics type type MoqMetrics_ASTPkgCacheMissesInc_anyParams struct { - Recorder *MoqMetrics_ASTPkgCacheMissesInc_fnRecorder + Recorder *MoqMetrics_ASTPkgCacheMissesInc_recorder +} + +// MoqMetrics_ASTTotalLoadTimeInc_adaptor adapts MoqMetrics as needed by the +// runtime +type MoqMetrics_ASTTotalLoadTimeInc_adaptor struct { + Moq *MoqMetrics } // MoqMetrics_ASTTotalLoadTimeInc_params holds the params of the Metrics type @@ -178,12 +194,13 @@ type MoqMetrics_ASTTotalLoadTimeInc_paramsKey struct { Hashes struct{ D hash.Hash } } -// MoqMetrics_ASTTotalLoadTimeInc_resultsByParams contains the results for a -// given set of parameters for the Metrics type -type MoqMetrics_ASTTotalLoadTimeInc_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqMetrics_ASTTotalLoadTimeInc_paramsKey]*MoqMetrics_ASTTotalLoadTimeInc_results +// MoqMetrics_ASTTotalLoadTimeInc_results holds the results of the Metrics type +type MoqMetrics_ASTTotalLoadTimeInc_results struct{} + +// MoqMetrics_ASTTotalLoadTimeInc_paramIndexing holds the parameter indexing +// runtime configuration for the Metrics type +type MoqMetrics_ASTTotalLoadTimeInc_paramIndexing struct { + D moq.ParamIndexing } // MoqMetrics_ASTTotalLoadTimeInc_doFn defines the type of function needed when @@ -194,33 +211,27 @@ type MoqMetrics_ASTTotalLoadTimeInc_doFn func(d time.Duration) // needed when calling DoReturnResults for the Metrics type type MoqMetrics_ASTTotalLoadTimeInc_doReturnFn func(d time.Duration) -// MoqMetrics_ASTTotalLoadTimeInc_results holds the results of the Metrics type -type MoqMetrics_ASTTotalLoadTimeInc_results struct { - Params MoqMetrics_ASTTotalLoadTimeInc_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTTotalLoadTimeInc_doFn - DoReturnFn MoqMetrics_ASTTotalLoadTimeInc_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqMetrics_ASTTotalLoadTimeInc_fnRecorder routes recorded function calls to +// MoqMetrics_ASTTotalLoadTimeInc_recorder routes recorded function calls to // the MoqMetrics moq -type MoqMetrics_ASTTotalLoadTimeInc_fnRecorder struct { - Params MoqMetrics_ASTTotalLoadTimeInc_params - AnyParams uint64 - Sequence bool - Results *MoqMetrics_ASTTotalLoadTimeInc_results - Moq *MoqMetrics +type MoqMetrics_ASTTotalLoadTimeInc_recorder struct { + Recorder *impl.Recorder[ + *MoqMetrics_ASTTotalLoadTimeInc_adaptor, + MoqMetrics_ASTTotalLoadTimeInc_params, + MoqMetrics_ASTTotalLoadTimeInc_paramsKey, + MoqMetrics_ASTTotalLoadTimeInc_results, + ] } // MoqMetrics_ASTTotalLoadTimeInc_anyParams isolates the any params functions // of the Metrics type type MoqMetrics_ASTTotalLoadTimeInc_anyParams struct { - Recorder *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder + Recorder *MoqMetrics_ASTTotalLoadTimeInc_recorder +} + +// MoqMetrics_ASTTotalDecorationTimeInc_adaptor adapts MoqMetrics as needed by +// the runtime +type MoqMetrics_ASTTotalDecorationTimeInc_adaptor struct { + Moq *MoqMetrics } // MoqMetrics_ASTTotalDecorationTimeInc_params holds the params of the Metrics @@ -234,12 +245,14 @@ type MoqMetrics_ASTTotalDecorationTimeInc_paramsKey struct { Hashes struct{ D hash.Hash } } -// MoqMetrics_ASTTotalDecorationTimeInc_resultsByParams contains the results -// for a given set of parameters for the Metrics type -type MoqMetrics_ASTTotalDecorationTimeInc_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqMetrics_ASTTotalDecorationTimeInc_paramsKey]*MoqMetrics_ASTTotalDecorationTimeInc_results +// MoqMetrics_ASTTotalDecorationTimeInc_results holds the results of the +// Metrics type +type MoqMetrics_ASTTotalDecorationTimeInc_results struct{} + +// MoqMetrics_ASTTotalDecorationTimeInc_paramIndexing holds the parameter +// indexing runtime configuration for the Metrics type +type MoqMetrics_ASTTotalDecorationTimeInc_paramIndexing struct { + D moq.ParamIndexing } // MoqMetrics_ASTTotalDecorationTimeInc_doFn defines the type of function @@ -250,34 +263,27 @@ type MoqMetrics_ASTTotalDecorationTimeInc_doFn func(d time.Duration) // needed when calling DoReturnResults for the Metrics type type MoqMetrics_ASTTotalDecorationTimeInc_doReturnFn func(d time.Duration) -// MoqMetrics_ASTTotalDecorationTimeInc_results holds the results of the -// Metrics type -type MoqMetrics_ASTTotalDecorationTimeInc_results struct { - Params MoqMetrics_ASTTotalDecorationTimeInc_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_ASTTotalDecorationTimeInc_doFn - DoReturnFn MoqMetrics_ASTTotalDecorationTimeInc_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder routes recorded function -// calls to the MoqMetrics moq -type MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder struct { - Params MoqMetrics_ASTTotalDecorationTimeInc_params - AnyParams uint64 - Sequence bool - Results *MoqMetrics_ASTTotalDecorationTimeInc_results - Moq *MoqMetrics +// MoqMetrics_ASTTotalDecorationTimeInc_recorder routes recorded function calls +// to the MoqMetrics moq +type MoqMetrics_ASTTotalDecorationTimeInc_recorder struct { + Recorder *impl.Recorder[ + *MoqMetrics_ASTTotalDecorationTimeInc_adaptor, + MoqMetrics_ASTTotalDecorationTimeInc_params, + MoqMetrics_ASTTotalDecorationTimeInc_paramsKey, + MoqMetrics_ASTTotalDecorationTimeInc_results, + ] } // MoqMetrics_ASTTotalDecorationTimeInc_anyParams isolates the any params // functions of the Metrics type type MoqMetrics_ASTTotalDecorationTimeInc_anyParams struct { - Recorder *MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder + Recorder *MoqMetrics_ASTTotalDecorationTimeInc_recorder +} + +// MoqMetrics_TotalProcessingTimeInc_adaptor adapts MoqMetrics as needed by the +// runtime +type MoqMetrics_TotalProcessingTimeInc_adaptor struct { + Moq *MoqMetrics } // MoqMetrics_TotalProcessingTimeInc_params holds the params of the Metrics @@ -291,12 +297,14 @@ type MoqMetrics_TotalProcessingTimeInc_paramsKey struct { Hashes struct{ D hash.Hash } } -// MoqMetrics_TotalProcessingTimeInc_resultsByParams contains the results for a -// given set of parameters for the Metrics type -type MoqMetrics_TotalProcessingTimeInc_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqMetrics_TotalProcessingTimeInc_paramsKey]*MoqMetrics_TotalProcessingTimeInc_results +// MoqMetrics_TotalProcessingTimeInc_results holds the results of the Metrics +// type +type MoqMetrics_TotalProcessingTimeInc_results struct{} + +// MoqMetrics_TotalProcessingTimeInc_paramIndexing holds the parameter indexing +// runtime configuration for the Metrics type +type MoqMetrics_TotalProcessingTimeInc_paramIndexing struct { + D moq.ParamIndexing } // MoqMetrics_TotalProcessingTimeInc_doFn defines the type of function needed @@ -307,34 +315,26 @@ type MoqMetrics_TotalProcessingTimeInc_doFn func(d time.Duration) // needed when calling DoReturnResults for the Metrics type type MoqMetrics_TotalProcessingTimeInc_doReturnFn func(d time.Duration) -// MoqMetrics_TotalProcessingTimeInc_results holds the results of the Metrics -// type -type MoqMetrics_TotalProcessingTimeInc_results struct { - Params MoqMetrics_TotalProcessingTimeInc_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_TotalProcessingTimeInc_doFn - DoReturnFn MoqMetrics_TotalProcessingTimeInc_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqMetrics_TotalProcessingTimeInc_fnRecorder routes recorded function calls -// to the MoqMetrics moq -type MoqMetrics_TotalProcessingTimeInc_fnRecorder struct { - Params MoqMetrics_TotalProcessingTimeInc_params - AnyParams uint64 - Sequence bool - Results *MoqMetrics_TotalProcessingTimeInc_results - Moq *MoqMetrics +// MoqMetrics_TotalProcessingTimeInc_recorder routes recorded function calls to +// the MoqMetrics moq +type MoqMetrics_TotalProcessingTimeInc_recorder struct { + Recorder *impl.Recorder[ + *MoqMetrics_TotalProcessingTimeInc_adaptor, + MoqMetrics_TotalProcessingTimeInc_params, + MoqMetrics_TotalProcessingTimeInc_paramsKey, + MoqMetrics_TotalProcessingTimeInc_results, + ] } // MoqMetrics_TotalProcessingTimeInc_anyParams isolates the any params // functions of the Metrics type type MoqMetrics_TotalProcessingTimeInc_anyParams struct { - Recorder *MoqMetrics_TotalProcessingTimeInc_fnRecorder + Recorder *MoqMetrics_TotalProcessingTimeInc_recorder +} + +// MoqMetrics_Finalize_adaptor adapts MoqMetrics as needed by the runtime +type MoqMetrics_Finalize_adaptor struct { + Moq *MoqMetrics } // MoqMetrics_Finalize_params holds the params of the Metrics type @@ -346,13 +346,12 @@ type MoqMetrics_Finalize_paramsKey struct { Hashes struct{} } -// MoqMetrics_Finalize_resultsByParams contains the results for a given set of -// parameters for the Metrics type -type MoqMetrics_Finalize_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqMetrics_Finalize_paramsKey]*MoqMetrics_Finalize_results -} +// MoqMetrics_Finalize_results holds the results of the Metrics type +type MoqMetrics_Finalize_results struct{} + +// MoqMetrics_Finalize_paramIndexing holds the parameter indexing runtime +// configuration for the Metrics type +type MoqMetrics_Finalize_paramIndexing struct{} // MoqMetrics_Finalize_doFn defines the type of function needed when calling // AndDo for the Metrics type @@ -362,96 +361,102 @@ type MoqMetrics_Finalize_doFn func() // calling DoReturnResults for the Metrics type type MoqMetrics_Finalize_doReturnFn func() -// MoqMetrics_Finalize_results holds the results of the Metrics type -type MoqMetrics_Finalize_results struct { - Params MoqMetrics_Finalize_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqMetrics_Finalize_doFn - DoReturnFn MoqMetrics_Finalize_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqMetrics_Finalize_fnRecorder routes recorded function calls to the +// MoqMetrics_Finalize_recorder routes recorded function calls to the // MoqMetrics moq -type MoqMetrics_Finalize_fnRecorder struct { - Params MoqMetrics_Finalize_params - AnyParams uint64 - Sequence bool - Results *MoqMetrics_Finalize_results - Moq *MoqMetrics +type MoqMetrics_Finalize_recorder struct { + Recorder *impl.Recorder[ + *MoqMetrics_Finalize_adaptor, + MoqMetrics_Finalize_params, + MoqMetrics_Finalize_paramsKey, + MoqMetrics_Finalize_results, + ] } // MoqMetrics_Finalize_anyParams isolates the any params functions of the // Metrics type type MoqMetrics_Finalize_anyParams struct { - Recorder *MoqMetrics_Finalize_fnRecorder + Recorder *MoqMetrics_Finalize_recorder } // NewMoqMetrics creates a new moq of the Metrics type func NewMoqMetrics(scene *moq.Scene, config *moq.Config) *MoqMetrics { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqMetrics_ASTPkgCacheHitsInc_adaptor{} + adaptor2 := &MoqMetrics_ASTPkgCacheMissesInc_adaptor{} + adaptor3 := &MoqMetrics_ASTTotalLoadTimeInc_adaptor{} + adaptor4 := &MoqMetrics_ASTTotalDecorationTimeInc_adaptor{} + adaptor5 := &MoqMetrics_TotalProcessingTimeInc_adaptor{} + adaptor6 := &MoqMetrics_Finalize_adaptor{} m := &MoqMetrics{ - Scene: scene, - Config: *config, - Moq: &MoqMetrics_mock{}, - - Runtime: struct { - ParameterIndexing struct { - ASTPkgCacheHitsInc struct{} - ASTPkgCacheMissesInc struct{} - ASTTotalLoadTimeInc struct { - D moq.ParamIndexing - } - ASTTotalDecorationTimeInc struct { - D moq.ParamIndexing - } - TotalProcessingTimeInc struct { - D moq.ParamIndexing - } - Finalize struct{} - } - }{ParameterIndexing: struct { - ASTPkgCacheHitsInc struct{} - ASTPkgCacheMissesInc struct{} - ASTTotalLoadTimeInc struct { - D moq.ParamIndexing - } - ASTTotalDecorationTimeInc struct { - D moq.ParamIndexing - } - TotalProcessingTimeInc struct { - D moq.ParamIndexing - } - Finalize struct{} + Moq: &MoqMetrics_mock{}, + + Moq_ASTPkgCacheHitsInc: impl.NewMoq[ + *MoqMetrics_ASTPkgCacheHitsInc_adaptor, + MoqMetrics_ASTPkgCacheHitsInc_params, + MoqMetrics_ASTPkgCacheHitsInc_paramsKey, + MoqMetrics_ASTPkgCacheHitsInc_results, + ](scene, adaptor1, config), + Moq_ASTPkgCacheMissesInc: impl.NewMoq[ + *MoqMetrics_ASTPkgCacheMissesInc_adaptor, + MoqMetrics_ASTPkgCacheMissesInc_params, + MoqMetrics_ASTPkgCacheMissesInc_paramsKey, + MoqMetrics_ASTPkgCacheMissesInc_results, + ](scene, adaptor2, config), + Moq_ASTTotalLoadTimeInc: impl.NewMoq[ + *MoqMetrics_ASTTotalLoadTimeInc_adaptor, + MoqMetrics_ASTTotalLoadTimeInc_params, + MoqMetrics_ASTTotalLoadTimeInc_paramsKey, + MoqMetrics_ASTTotalLoadTimeInc_results, + ](scene, adaptor3, config), + Moq_ASTTotalDecorationTimeInc: impl.NewMoq[ + *MoqMetrics_ASTTotalDecorationTimeInc_adaptor, + MoqMetrics_ASTTotalDecorationTimeInc_params, + MoqMetrics_ASTTotalDecorationTimeInc_paramsKey, + MoqMetrics_ASTTotalDecorationTimeInc_results, + ](scene, adaptor4, config), + Moq_TotalProcessingTimeInc: impl.NewMoq[ + *MoqMetrics_TotalProcessingTimeInc_adaptor, + MoqMetrics_TotalProcessingTimeInc_params, + MoqMetrics_TotalProcessingTimeInc_paramsKey, + MoqMetrics_TotalProcessingTimeInc_results, + ](scene, adaptor5, config), + Moq_Finalize: impl.NewMoq[ + *MoqMetrics_Finalize_adaptor, + MoqMetrics_Finalize_params, + MoqMetrics_Finalize_paramsKey, + MoqMetrics_Finalize_results, + ](scene, adaptor6, config), + + Runtime: MoqMetrics_runtime{ParameterIndexing: struct { + ASTPkgCacheHitsInc MoqMetrics_ASTPkgCacheHitsInc_paramIndexing + ASTPkgCacheMissesInc MoqMetrics_ASTPkgCacheMissesInc_paramIndexing + ASTTotalLoadTimeInc MoqMetrics_ASTTotalLoadTimeInc_paramIndexing + ASTTotalDecorationTimeInc MoqMetrics_ASTTotalDecorationTimeInc_paramIndexing + TotalProcessingTimeInc MoqMetrics_TotalProcessingTimeInc_paramIndexing + Finalize MoqMetrics_Finalize_paramIndexing }{ - ASTPkgCacheHitsInc: struct{}{}, - ASTPkgCacheMissesInc: struct{}{}, - ASTTotalLoadTimeInc: struct { - D moq.ParamIndexing - }{ + ASTPkgCacheHitsInc: MoqMetrics_ASTPkgCacheHitsInc_paramIndexing{}, + ASTPkgCacheMissesInc: MoqMetrics_ASTPkgCacheMissesInc_paramIndexing{}, + ASTTotalLoadTimeInc: MoqMetrics_ASTTotalLoadTimeInc_paramIndexing{ D: moq.ParamIndexByValue, }, - ASTTotalDecorationTimeInc: struct { - D moq.ParamIndexing - }{ + ASTTotalDecorationTimeInc: MoqMetrics_ASTTotalDecorationTimeInc_paramIndexing{ D: moq.ParamIndexByValue, }, - TotalProcessingTimeInc: struct { - D moq.ParamIndexing - }{ + TotalProcessingTimeInc: MoqMetrics_TotalProcessingTimeInc_paramIndexing{ D: moq.ParamIndexByValue, }, - Finalize: struct{}{}, + Finalize: MoqMetrics_Finalize_paramIndexing{}, }}, } m.Moq.Moq = m + adaptor1.Moq = m + adaptor2.Moq = m + adaptor3.Moq = m + adaptor4.Moq = m + adaptor5.Moq = m + adaptor6.Moq = m + scene.AddMoq(m) return m } @@ -460,297 +465,51 @@ func NewMoqMetrics(scene *moq.Scene, config *moq.Config) *MoqMetrics { func (m *MoqMetrics) Mock() *MoqMetrics_mock { return m.Moq } func (m *MoqMetrics_mock) ASTPkgCacheHitsInc() { - m.Moq.Scene.T.Helper() + m.Moq.Moq_ASTPkgCacheHitsInc.Scene.T.Helper() params := MoqMetrics_ASTPkgCacheHitsInc_params{} - var results *MoqMetrics_ASTPkgCacheHitsInc_results - for _, resultsByParams := range m.Moq.ResultsByParams_ASTPkgCacheHitsInc { - paramsKey := m.Moq.ParamsKey_ASTPkgCacheHitsInc(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_ASTPkgCacheHitsInc(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_ASTPkgCacheHitsInc(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_ASTPkgCacheHitsInc(params)) - } - } - - if result.DoFn != nil { - result.DoFn() - } - - if result.DoReturnFn != nil { - result.DoReturnFn() - } - return + m.Moq.Moq_ASTPkgCacheHitsInc.Function(params) } func (m *MoqMetrics_mock) ASTPkgCacheMissesInc() { - m.Moq.Scene.T.Helper() + m.Moq.Moq_ASTPkgCacheMissesInc.Scene.T.Helper() params := MoqMetrics_ASTPkgCacheMissesInc_params{} - var results *MoqMetrics_ASTPkgCacheMissesInc_results - for _, resultsByParams := range m.Moq.ResultsByParams_ASTPkgCacheMissesInc { - paramsKey := m.Moq.ParamsKey_ASTPkgCacheMissesInc(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_ASTPkgCacheMissesInc(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_ASTPkgCacheMissesInc(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_ASTPkgCacheMissesInc(params)) - } - } - - if result.DoFn != nil { - result.DoFn() - } - - if result.DoReturnFn != nil { - result.DoReturnFn() - } - return + m.Moq.Moq_ASTPkgCacheMissesInc.Function(params) } func (m *MoqMetrics_mock) ASTTotalLoadTimeInc(d time.Duration) { - m.Moq.Scene.T.Helper() + m.Moq.Moq_ASTTotalLoadTimeInc.Scene.T.Helper() params := MoqMetrics_ASTTotalLoadTimeInc_params{ D: d, } - var results *MoqMetrics_ASTTotalLoadTimeInc_results - for _, resultsByParams := range m.Moq.ResultsByParams_ASTTotalLoadTimeInc { - paramsKey := m.Moq.ParamsKey_ASTTotalLoadTimeInc(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_ASTTotalLoadTimeInc(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_ASTTotalLoadTimeInc(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_ASTTotalLoadTimeInc(params)) - } - } - - if result.DoFn != nil { - result.DoFn(d) - } - if result.DoReturnFn != nil { - result.DoReturnFn(d) - } - return + m.Moq.Moq_ASTTotalLoadTimeInc.Function(params) } func (m *MoqMetrics_mock) ASTTotalDecorationTimeInc(d time.Duration) { - m.Moq.Scene.T.Helper() + m.Moq.Moq_ASTTotalDecorationTimeInc.Scene.T.Helper() params := MoqMetrics_ASTTotalDecorationTimeInc_params{ D: d, } - var results *MoqMetrics_ASTTotalDecorationTimeInc_results - for _, resultsByParams := range m.Moq.ResultsByParams_ASTTotalDecorationTimeInc { - paramsKey := m.Moq.ParamsKey_ASTTotalDecorationTimeInc(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_ASTTotalDecorationTimeInc(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_ASTTotalDecorationTimeInc(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_ASTTotalDecorationTimeInc(params)) - } - } - - if result.DoFn != nil { - result.DoFn(d) - } - if result.DoReturnFn != nil { - result.DoReturnFn(d) - } - return + m.Moq.Moq_ASTTotalDecorationTimeInc.Function(params) } func (m *MoqMetrics_mock) TotalProcessingTimeInc(d time.Duration) { - m.Moq.Scene.T.Helper() + m.Moq.Moq_TotalProcessingTimeInc.Scene.T.Helper() params := MoqMetrics_TotalProcessingTimeInc_params{ D: d, } - var results *MoqMetrics_TotalProcessingTimeInc_results - for _, resultsByParams := range m.Moq.ResultsByParams_TotalProcessingTimeInc { - paramsKey := m.Moq.ParamsKey_TotalProcessingTimeInc(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_TotalProcessingTimeInc(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_TotalProcessingTimeInc(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_TotalProcessingTimeInc(params)) - } - } - if result.DoFn != nil { - result.DoFn(d) - } - - if result.DoReturnFn != nil { - result.DoReturnFn(d) - } - return + m.Moq.Moq_TotalProcessingTimeInc.Function(params) } func (m *MoqMetrics_mock) Finalize() { - m.Moq.Scene.T.Helper() + m.Moq.Moq_Finalize.Scene.T.Helper() params := MoqMetrics_Finalize_params{} - var results *MoqMetrics_Finalize_results - for _, resultsByParams := range m.Moq.ResultsByParams_Finalize { - paramsKey := m.Moq.ParamsKey_Finalize(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_Finalize(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_Finalize(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_Finalize(params)) - } - } - - if result.DoFn != nil { - result.DoFn() - } - if result.DoReturnFn != nil { - result.DoReturnFn() - } - return + m.Moq.Moq_Finalize.Function(params) } // OnCall returns the recorder implementation of the Metrics type @@ -760,535 +519,234 @@ func (m *MoqMetrics) OnCall() *MoqMetrics_recorder { } } -func (m *MoqMetrics_recorder) ASTPkgCacheHitsInc() *MoqMetrics_ASTPkgCacheHitsInc_fnRecorder { - return &MoqMetrics_ASTPkgCacheHitsInc_fnRecorder{ - Params: MoqMetrics_ASTPkgCacheHitsInc_params{}, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, +func (m *MoqMetrics_recorder) ASTPkgCacheHitsInc() *MoqMetrics_ASTPkgCacheHitsInc_recorder { + return &MoqMetrics_ASTPkgCacheHitsInc_recorder{ + Recorder: m.Moq.Moq_ASTPkgCacheHitsInc.OnCall(MoqMetrics_ASTPkgCacheHitsInc_params{}), } } -func (r *MoqMetrics_ASTPkgCacheHitsInc_fnRecorder) Any() *MoqMetrics_ASTPkgCacheHitsInc_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_ASTPkgCacheHitsInc(r.Params)) +func (r *MoqMetrics_ASTPkgCacheHitsInc_recorder) Any() *MoqMetrics_ASTPkgCacheHitsInc_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqMetrics_ASTPkgCacheHitsInc_anyParams{Recorder: r} } -func (r *MoqMetrics_ASTPkgCacheHitsInc_fnRecorder) Seq() *MoqMetrics_ASTPkgCacheHitsInc_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_ASTPkgCacheHitsInc(r.Params)) +func (r *MoqMetrics_ASTPkgCacheHitsInc_recorder) Seq() *MoqMetrics_ASTPkgCacheHitsInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqMetrics_ASTPkgCacheHitsInc_fnRecorder) NoSeq() *MoqMetrics_ASTPkgCacheHitsInc_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_ASTPkgCacheHitsInc(r.Params)) +func (r *MoqMetrics_ASTPkgCacheHitsInc_recorder) NoSeq() *MoqMetrics_ASTPkgCacheHitsInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqMetrics_ASTPkgCacheHitsInc_fnRecorder) ReturnResults() *MoqMetrics_ASTPkgCacheHitsInc_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_ASTPkgCacheHitsInc_doFn - DoReturnFn MoqMetrics_ASTPkgCacheHitsInc_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqMetrics_ASTPkgCacheHitsInc_recorder) ReturnResults() *MoqMetrics_ASTPkgCacheHitsInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqMetrics_ASTPkgCacheHitsInc_results{}) return r } -func (r *MoqMetrics_ASTPkgCacheHitsInc_fnRecorder) AndDo(fn MoqMetrics_ASTPkgCacheHitsInc_doFn) *MoqMetrics_ASTPkgCacheHitsInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqMetrics_ASTPkgCacheHitsInc_recorder) AndDo(fn MoqMetrics_ASTPkgCacheHitsInc_doFn) *MoqMetrics_ASTPkgCacheHitsInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqMetrics_ASTPkgCacheHitsInc_params) { + fn() + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqMetrics_ASTPkgCacheHitsInc_fnRecorder) DoReturnResults(fn MoqMetrics_ASTPkgCacheHitsInc_doReturnFn) *MoqMetrics_ASTPkgCacheHitsInc_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_ASTPkgCacheHitsInc_doFn - DoReturnFn MoqMetrics_ASTPkgCacheHitsInc_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqMetrics_ASTPkgCacheHitsInc_recorder) DoReturnResults(fn MoqMetrics_ASTPkgCacheHitsInc_doReturnFn) *MoqMetrics_ASTPkgCacheHitsInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqMetrics_ASTPkgCacheHitsInc_params) *MoqMetrics_ASTPkgCacheHitsInc_results { + fn() + return &MoqMetrics_ASTPkgCacheHitsInc_results{} + }) return r } -func (r *MoqMetrics_ASTPkgCacheHitsInc_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_ASTPkgCacheHitsInc_resultsByParams - for n, res := range r.Moq.ResultsByParams_ASTPkgCacheHitsInc { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqMetrics_ASTPkgCacheHitsInc_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqMetrics_ASTPkgCacheHitsInc_paramsKey]*MoqMetrics_ASTPkgCacheHitsInc_results{}, - } - r.Moq.ResultsByParams_ASTPkgCacheHitsInc = append(r.Moq.ResultsByParams_ASTPkgCacheHitsInc, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_ASTPkgCacheHitsInc) { - copy(r.Moq.ResultsByParams_ASTPkgCacheHitsInc[insertAt+1:], r.Moq.ResultsByParams_ASTPkgCacheHitsInc[insertAt:0]) - r.Moq.ResultsByParams_ASTPkgCacheHitsInc[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_ASTPkgCacheHitsInc(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqMetrics_ASTPkgCacheHitsInc_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_ASTPkgCacheHitsInc_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_ASTPkgCacheHitsInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqMetrics_ASTPkgCacheHitsInc_recorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_ASTPkgCacheHitsInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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_ASTPkgCacheHitsInc_doFn - DoReturnFn MoqMetrics_ASTPkgCacheHitsInc_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqMetrics) PrettyParams_ASTPkgCacheHitsInc(params MoqMetrics_ASTPkgCacheHitsInc_params) string { +func (*MoqMetrics_ASTPkgCacheHitsInc_adaptor) PrettyParams(params MoqMetrics_ASTPkgCacheHitsInc_params) string { return fmt.Sprintf("ASTPkgCacheHitsInc()") } -func (m *MoqMetrics) ParamsKey_ASTPkgCacheHitsInc(params MoqMetrics_ASTPkgCacheHitsInc_params, anyParams uint64) MoqMetrics_ASTPkgCacheHitsInc_paramsKey { - m.Scene.T.Helper() +func (a *MoqMetrics_ASTPkgCacheHitsInc_adaptor) ParamsKey(params MoqMetrics_ASTPkgCacheHitsInc_params, anyParams uint64) MoqMetrics_ASTPkgCacheHitsInc_paramsKey { + a.Moq.Moq_ASTPkgCacheHitsInc.Scene.T.Helper() return MoqMetrics_ASTPkgCacheHitsInc_paramsKey{ Params: struct{}{}, Hashes: struct{}{}, } } -func (m *MoqMetrics_recorder) ASTPkgCacheMissesInc() *MoqMetrics_ASTPkgCacheMissesInc_fnRecorder { - return &MoqMetrics_ASTPkgCacheMissesInc_fnRecorder{ - Params: MoqMetrics_ASTPkgCacheMissesInc_params{}, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, +func (m *MoqMetrics_recorder) ASTPkgCacheMissesInc() *MoqMetrics_ASTPkgCacheMissesInc_recorder { + return &MoqMetrics_ASTPkgCacheMissesInc_recorder{ + Recorder: m.Moq.Moq_ASTPkgCacheMissesInc.OnCall(MoqMetrics_ASTPkgCacheMissesInc_params{}), } } -func (r *MoqMetrics_ASTPkgCacheMissesInc_fnRecorder) Any() *MoqMetrics_ASTPkgCacheMissesInc_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_ASTPkgCacheMissesInc(r.Params)) +func (r *MoqMetrics_ASTPkgCacheMissesInc_recorder) Any() *MoqMetrics_ASTPkgCacheMissesInc_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqMetrics_ASTPkgCacheMissesInc_anyParams{Recorder: r} } -func (r *MoqMetrics_ASTPkgCacheMissesInc_fnRecorder) Seq() *MoqMetrics_ASTPkgCacheMissesInc_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_ASTPkgCacheMissesInc(r.Params)) +func (r *MoqMetrics_ASTPkgCacheMissesInc_recorder) Seq() *MoqMetrics_ASTPkgCacheMissesInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqMetrics_ASTPkgCacheMissesInc_fnRecorder) NoSeq() *MoqMetrics_ASTPkgCacheMissesInc_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_ASTPkgCacheMissesInc(r.Params)) +func (r *MoqMetrics_ASTPkgCacheMissesInc_recorder) NoSeq() *MoqMetrics_ASTPkgCacheMissesInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqMetrics_ASTPkgCacheMissesInc_fnRecorder) ReturnResults() *MoqMetrics_ASTPkgCacheMissesInc_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_ASTPkgCacheMissesInc_doFn - DoReturnFn MoqMetrics_ASTPkgCacheMissesInc_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqMetrics_ASTPkgCacheMissesInc_recorder) ReturnResults() *MoqMetrics_ASTPkgCacheMissesInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqMetrics_ASTPkgCacheMissesInc_results{}) return r } -func (r *MoqMetrics_ASTPkgCacheMissesInc_fnRecorder) AndDo(fn MoqMetrics_ASTPkgCacheMissesInc_doFn) *MoqMetrics_ASTPkgCacheMissesInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqMetrics_ASTPkgCacheMissesInc_recorder) AndDo(fn MoqMetrics_ASTPkgCacheMissesInc_doFn) *MoqMetrics_ASTPkgCacheMissesInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqMetrics_ASTPkgCacheMissesInc_params) { + fn() + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqMetrics_ASTPkgCacheMissesInc_fnRecorder) DoReturnResults(fn MoqMetrics_ASTPkgCacheMissesInc_doReturnFn) *MoqMetrics_ASTPkgCacheMissesInc_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_ASTPkgCacheMissesInc_doFn - DoReturnFn MoqMetrics_ASTPkgCacheMissesInc_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqMetrics_ASTPkgCacheMissesInc_recorder) DoReturnResults(fn MoqMetrics_ASTPkgCacheMissesInc_doReturnFn) *MoqMetrics_ASTPkgCacheMissesInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqMetrics_ASTPkgCacheMissesInc_params) *MoqMetrics_ASTPkgCacheMissesInc_results { + fn() + return &MoqMetrics_ASTPkgCacheMissesInc_results{} + }) return r } -func (r *MoqMetrics_ASTPkgCacheMissesInc_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_ASTPkgCacheMissesInc_resultsByParams - for n, res := range r.Moq.ResultsByParams_ASTPkgCacheMissesInc { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqMetrics_ASTPkgCacheMissesInc_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqMetrics_ASTPkgCacheMissesInc_paramsKey]*MoqMetrics_ASTPkgCacheMissesInc_results{}, - } - r.Moq.ResultsByParams_ASTPkgCacheMissesInc = append(r.Moq.ResultsByParams_ASTPkgCacheMissesInc, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_ASTPkgCacheMissesInc) { - copy(r.Moq.ResultsByParams_ASTPkgCacheMissesInc[insertAt+1:], r.Moq.ResultsByParams_ASTPkgCacheMissesInc[insertAt:0]) - r.Moq.ResultsByParams_ASTPkgCacheMissesInc[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_ASTPkgCacheMissesInc(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqMetrics_ASTPkgCacheMissesInc_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_ASTPkgCacheMissesInc_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_ASTPkgCacheMissesInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqMetrics_ASTPkgCacheMissesInc_recorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_ASTPkgCacheMissesInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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_ASTPkgCacheMissesInc_doFn - DoReturnFn MoqMetrics_ASTPkgCacheMissesInc_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqMetrics) PrettyParams_ASTPkgCacheMissesInc(params MoqMetrics_ASTPkgCacheMissesInc_params) string { +func (*MoqMetrics_ASTPkgCacheMissesInc_adaptor) PrettyParams(params MoqMetrics_ASTPkgCacheMissesInc_params) string { return fmt.Sprintf("ASTPkgCacheMissesInc()") } -func (m *MoqMetrics) ParamsKey_ASTPkgCacheMissesInc(params MoqMetrics_ASTPkgCacheMissesInc_params, anyParams uint64) MoqMetrics_ASTPkgCacheMissesInc_paramsKey { - m.Scene.T.Helper() +func (a *MoqMetrics_ASTPkgCacheMissesInc_adaptor) ParamsKey(params MoqMetrics_ASTPkgCacheMissesInc_params, anyParams uint64) MoqMetrics_ASTPkgCacheMissesInc_paramsKey { + a.Moq.Moq_ASTPkgCacheMissesInc.Scene.T.Helper() return MoqMetrics_ASTPkgCacheMissesInc_paramsKey{ Params: struct{}{}, Hashes: struct{}{}, } } -func (m *MoqMetrics_recorder) ASTTotalLoadTimeInc(d time.Duration) *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder { - return &MoqMetrics_ASTTotalLoadTimeInc_fnRecorder{ - Params: MoqMetrics_ASTTotalLoadTimeInc_params{ +func (m *MoqMetrics_recorder) ASTTotalLoadTimeInc(d time.Duration) *MoqMetrics_ASTTotalLoadTimeInc_recorder { + return &MoqMetrics_ASTTotalLoadTimeInc_recorder{ + Recorder: m.Moq.Moq_ASTTotalLoadTimeInc.OnCall(MoqMetrics_ASTTotalLoadTimeInc_params{ D: d, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder) Any() *MoqMetrics_ASTTotalLoadTimeInc_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_ASTTotalLoadTimeInc(r.Params)) +func (r *MoqMetrics_ASTTotalLoadTimeInc_recorder) Any() *MoqMetrics_ASTTotalLoadTimeInc_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqMetrics_ASTTotalLoadTimeInc_anyParams{Recorder: r} } -func (a *MoqMetrics_ASTTotalLoadTimeInc_anyParams) D() *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqMetrics_ASTTotalLoadTimeInc_anyParams) D() *MoqMetrics_ASTTotalLoadTimeInc_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder) Seq() *MoqMetrics_ASTTotalLoadTimeInc_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_ASTTotalLoadTimeInc(r.Params)) +func (r *MoqMetrics_ASTTotalLoadTimeInc_recorder) Seq() *MoqMetrics_ASTTotalLoadTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder) NoSeq() *MoqMetrics_ASTTotalLoadTimeInc_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_ASTTotalLoadTimeInc(r.Params)) +func (r *MoqMetrics_ASTTotalLoadTimeInc_recorder) NoSeq() *MoqMetrics_ASTTotalLoadTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder) ReturnResults() *MoqMetrics_ASTTotalLoadTimeInc_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_ASTTotalLoadTimeInc_doFn - DoReturnFn MoqMetrics_ASTTotalLoadTimeInc_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqMetrics_ASTTotalLoadTimeInc_recorder) ReturnResults() *MoqMetrics_ASTTotalLoadTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqMetrics_ASTTotalLoadTimeInc_results{}) return r } -func (r *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder) AndDo(fn MoqMetrics_ASTTotalLoadTimeInc_doFn) *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqMetrics_ASTTotalLoadTimeInc_recorder) AndDo(fn MoqMetrics_ASTTotalLoadTimeInc_doFn) *MoqMetrics_ASTTotalLoadTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqMetrics_ASTTotalLoadTimeInc_params) { + fn(params.D) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder) DoReturnResults(fn MoqMetrics_ASTTotalLoadTimeInc_doReturnFn) *MoqMetrics_ASTTotalLoadTimeInc_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_ASTTotalLoadTimeInc_doFn - DoReturnFn MoqMetrics_ASTTotalLoadTimeInc_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqMetrics_ASTTotalLoadTimeInc_recorder) DoReturnResults(fn MoqMetrics_ASTTotalLoadTimeInc_doReturnFn) *MoqMetrics_ASTTotalLoadTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqMetrics_ASTTotalLoadTimeInc_params) *MoqMetrics_ASTTotalLoadTimeInc_results { + fn(params.D) + return &MoqMetrics_ASTTotalLoadTimeInc_results{} + }) return r } -func (r *MoqMetrics_ASTTotalLoadTimeInc_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_ASTTotalLoadTimeInc_resultsByParams - for n, res := range r.Moq.ResultsByParams_ASTTotalLoadTimeInc { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqMetrics_ASTTotalLoadTimeInc_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqMetrics_ASTTotalLoadTimeInc_paramsKey]*MoqMetrics_ASTTotalLoadTimeInc_results{}, - } - r.Moq.ResultsByParams_ASTTotalLoadTimeInc = append(r.Moq.ResultsByParams_ASTTotalLoadTimeInc, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_ASTTotalLoadTimeInc) { - copy(r.Moq.ResultsByParams_ASTTotalLoadTimeInc[insertAt+1:], r.Moq.ResultsByParams_ASTTotalLoadTimeInc[insertAt:0]) - r.Moq.ResultsByParams_ASTTotalLoadTimeInc[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_ASTTotalLoadTimeInc(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqMetrics_ASTTotalLoadTimeInc_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_ASTTotalLoadTimeInc_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_ASTTotalLoadTimeInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqMetrics_ASTTotalLoadTimeInc_recorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_ASTTotalLoadTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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_ASTTotalLoadTimeInc_doFn - DoReturnFn MoqMetrics_ASTTotalLoadTimeInc_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqMetrics) PrettyParams_ASTTotalLoadTimeInc(params MoqMetrics_ASTTotalLoadTimeInc_params) string { +func (*MoqMetrics_ASTTotalLoadTimeInc_adaptor) PrettyParams(params MoqMetrics_ASTTotalLoadTimeInc_params) string { return fmt.Sprintf("ASTTotalLoadTimeInc(%#v)", params.D) } -func (m *MoqMetrics) ParamsKey_ASTTotalLoadTimeInc(params MoqMetrics_ASTTotalLoadTimeInc_params, anyParams uint64) MoqMetrics_ASTTotalLoadTimeInc_paramsKey { - m.Scene.T.Helper() - var dUsed time.Duration - var dUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.ASTTotalLoadTimeInc.D == moq.ParamIndexByValue { - dUsed = params.D - } else { - dUsedHash = hash.DeepHash(params.D) - } - } +func (a *MoqMetrics_ASTTotalLoadTimeInc_adaptor) ParamsKey(params MoqMetrics_ASTTotalLoadTimeInc_params, anyParams uint64) MoqMetrics_ASTTotalLoadTimeInc_paramsKey { + a.Moq.Moq_ASTTotalLoadTimeInc.Scene.T.Helper() + dUsed, dUsedHash := impl.ParamKey( + params.D, 1, a.Moq.Runtime.ParameterIndexing.ASTTotalLoadTimeInc.D, anyParams) return MoqMetrics_ASTTotalLoadTimeInc_paramsKey{ Params: struct{ D time.Duration }{ D: dUsed, @@ -1299,189 +757,84 @@ func (m *MoqMetrics) ParamsKey_ASTTotalLoadTimeInc(params MoqMetrics_ASTTotalLoa } } -func (m *MoqMetrics_recorder) ASTTotalDecorationTimeInc(d time.Duration) *MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder { - return &MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder{ - Params: MoqMetrics_ASTTotalDecorationTimeInc_params{ +func (m *MoqMetrics_recorder) ASTTotalDecorationTimeInc(d time.Duration) *MoqMetrics_ASTTotalDecorationTimeInc_recorder { + return &MoqMetrics_ASTTotalDecorationTimeInc_recorder{ + Recorder: m.Moq.Moq_ASTTotalDecorationTimeInc.OnCall(MoqMetrics_ASTTotalDecorationTimeInc_params{ D: d, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder) Any() *MoqMetrics_ASTTotalDecorationTimeInc_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_ASTTotalDecorationTimeInc(r.Params)) +func (r *MoqMetrics_ASTTotalDecorationTimeInc_recorder) Any() *MoqMetrics_ASTTotalDecorationTimeInc_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqMetrics_ASTTotalDecorationTimeInc_anyParams{Recorder: r} } -func (a *MoqMetrics_ASTTotalDecorationTimeInc_anyParams) D() *MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqMetrics_ASTTotalDecorationTimeInc_anyParams) D() *MoqMetrics_ASTTotalDecorationTimeInc_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder) Seq() *MoqMetrics_ASTTotalDecorationTimeInc_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_ASTTotalDecorationTimeInc(r.Params)) +func (r *MoqMetrics_ASTTotalDecorationTimeInc_recorder) Seq() *MoqMetrics_ASTTotalDecorationTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder) NoSeq() *MoqMetrics_ASTTotalDecorationTimeInc_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_ASTTotalDecorationTimeInc(r.Params)) +func (r *MoqMetrics_ASTTotalDecorationTimeInc_recorder) NoSeq() *MoqMetrics_ASTTotalDecorationTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder) ReturnResults() *MoqMetrics_ASTTotalDecorationTimeInc_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_ASTTotalDecorationTimeInc_doFn - DoReturnFn MoqMetrics_ASTTotalDecorationTimeInc_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqMetrics_ASTTotalDecorationTimeInc_recorder) ReturnResults() *MoqMetrics_ASTTotalDecorationTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqMetrics_ASTTotalDecorationTimeInc_results{}) return r } -func (r *MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder) AndDo(fn MoqMetrics_ASTTotalDecorationTimeInc_doFn) *MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqMetrics_ASTTotalDecorationTimeInc_recorder) AndDo(fn MoqMetrics_ASTTotalDecorationTimeInc_doFn) *MoqMetrics_ASTTotalDecorationTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqMetrics_ASTTotalDecorationTimeInc_params) { + fn(params.D) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder) DoReturnResults(fn MoqMetrics_ASTTotalDecorationTimeInc_doReturnFn) *MoqMetrics_ASTTotalDecorationTimeInc_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_ASTTotalDecorationTimeInc_doFn - DoReturnFn MoqMetrics_ASTTotalDecorationTimeInc_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqMetrics_ASTTotalDecorationTimeInc_recorder) DoReturnResults(fn MoqMetrics_ASTTotalDecorationTimeInc_doReturnFn) *MoqMetrics_ASTTotalDecorationTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqMetrics_ASTTotalDecorationTimeInc_params) *MoqMetrics_ASTTotalDecorationTimeInc_results { + fn(params.D) + return &MoqMetrics_ASTTotalDecorationTimeInc_results{} + }) return r } -func (r *MoqMetrics_ASTTotalDecorationTimeInc_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_ASTTotalDecorationTimeInc_resultsByParams - for n, res := range r.Moq.ResultsByParams_ASTTotalDecorationTimeInc { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqMetrics_ASTTotalDecorationTimeInc_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqMetrics_ASTTotalDecorationTimeInc_paramsKey]*MoqMetrics_ASTTotalDecorationTimeInc_results{}, - } - r.Moq.ResultsByParams_ASTTotalDecorationTimeInc = append(r.Moq.ResultsByParams_ASTTotalDecorationTimeInc, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_ASTTotalDecorationTimeInc) { - copy(r.Moq.ResultsByParams_ASTTotalDecorationTimeInc[insertAt+1:], r.Moq.ResultsByParams_ASTTotalDecorationTimeInc[insertAt:0]) - r.Moq.ResultsByParams_ASTTotalDecorationTimeInc[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_ASTTotalDecorationTimeInc(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqMetrics_ASTTotalDecorationTimeInc_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_ASTTotalDecorationTimeInc_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_ASTTotalDecorationTimeInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqMetrics_ASTTotalDecorationTimeInc_recorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_ASTTotalDecorationTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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_ASTTotalDecorationTimeInc_doFn - DoReturnFn MoqMetrics_ASTTotalDecorationTimeInc_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqMetrics) PrettyParams_ASTTotalDecorationTimeInc(params MoqMetrics_ASTTotalDecorationTimeInc_params) string { +func (*MoqMetrics_ASTTotalDecorationTimeInc_adaptor) PrettyParams(params MoqMetrics_ASTTotalDecorationTimeInc_params) string { return fmt.Sprintf("ASTTotalDecorationTimeInc(%#v)", params.D) } -func (m *MoqMetrics) ParamsKey_ASTTotalDecorationTimeInc(params MoqMetrics_ASTTotalDecorationTimeInc_params, anyParams uint64) MoqMetrics_ASTTotalDecorationTimeInc_paramsKey { - m.Scene.T.Helper() - var dUsed time.Duration - var dUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.ASTTotalDecorationTimeInc.D == moq.ParamIndexByValue { - dUsed = params.D - } else { - dUsedHash = hash.DeepHash(params.D) - } - } +func (a *MoqMetrics_ASTTotalDecorationTimeInc_adaptor) ParamsKey(params MoqMetrics_ASTTotalDecorationTimeInc_params, anyParams uint64) MoqMetrics_ASTTotalDecorationTimeInc_paramsKey { + a.Moq.Moq_ASTTotalDecorationTimeInc.Scene.T.Helper() + dUsed, dUsedHash := impl.ParamKey( + params.D, 1, a.Moq.Runtime.ParameterIndexing.ASTTotalDecorationTimeInc.D, anyParams) return MoqMetrics_ASTTotalDecorationTimeInc_paramsKey{ Params: struct{ D time.Duration }{ D: dUsed, @@ -1492,189 +845,84 @@ func (m *MoqMetrics) ParamsKey_ASTTotalDecorationTimeInc(params MoqMetrics_ASTTo } } -func (m *MoqMetrics_recorder) TotalProcessingTimeInc(d time.Duration) *MoqMetrics_TotalProcessingTimeInc_fnRecorder { - return &MoqMetrics_TotalProcessingTimeInc_fnRecorder{ - Params: MoqMetrics_TotalProcessingTimeInc_params{ +func (m *MoqMetrics_recorder) TotalProcessingTimeInc(d time.Duration) *MoqMetrics_TotalProcessingTimeInc_recorder { + return &MoqMetrics_TotalProcessingTimeInc_recorder{ + Recorder: m.Moq.Moq_TotalProcessingTimeInc.OnCall(MoqMetrics_TotalProcessingTimeInc_params{ D: d, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqMetrics_TotalProcessingTimeInc_fnRecorder) Any() *MoqMetrics_TotalProcessingTimeInc_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_TotalProcessingTimeInc(r.Params)) +func (r *MoqMetrics_TotalProcessingTimeInc_recorder) Any() *MoqMetrics_TotalProcessingTimeInc_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqMetrics_TotalProcessingTimeInc_anyParams{Recorder: r} } -func (a *MoqMetrics_TotalProcessingTimeInc_anyParams) D() *MoqMetrics_TotalProcessingTimeInc_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqMetrics_TotalProcessingTimeInc_anyParams) D() *MoqMetrics_TotalProcessingTimeInc_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqMetrics_TotalProcessingTimeInc_fnRecorder) Seq() *MoqMetrics_TotalProcessingTimeInc_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_TotalProcessingTimeInc(r.Params)) +func (r *MoqMetrics_TotalProcessingTimeInc_recorder) Seq() *MoqMetrics_TotalProcessingTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqMetrics_TotalProcessingTimeInc_fnRecorder) NoSeq() *MoqMetrics_TotalProcessingTimeInc_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_TotalProcessingTimeInc(r.Params)) +func (r *MoqMetrics_TotalProcessingTimeInc_recorder) NoSeq() *MoqMetrics_TotalProcessingTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqMetrics_TotalProcessingTimeInc_fnRecorder) ReturnResults() *MoqMetrics_TotalProcessingTimeInc_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_TotalProcessingTimeInc_doFn - DoReturnFn MoqMetrics_TotalProcessingTimeInc_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqMetrics_TotalProcessingTimeInc_recorder) ReturnResults() *MoqMetrics_TotalProcessingTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqMetrics_TotalProcessingTimeInc_results{}) return r } -func (r *MoqMetrics_TotalProcessingTimeInc_fnRecorder) AndDo(fn MoqMetrics_TotalProcessingTimeInc_doFn) *MoqMetrics_TotalProcessingTimeInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqMetrics_TotalProcessingTimeInc_recorder) AndDo(fn MoqMetrics_TotalProcessingTimeInc_doFn) *MoqMetrics_TotalProcessingTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqMetrics_TotalProcessingTimeInc_params) { + fn(params.D) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqMetrics_TotalProcessingTimeInc_fnRecorder) DoReturnResults(fn MoqMetrics_TotalProcessingTimeInc_doReturnFn) *MoqMetrics_TotalProcessingTimeInc_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_TotalProcessingTimeInc_doFn - DoReturnFn MoqMetrics_TotalProcessingTimeInc_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqMetrics_TotalProcessingTimeInc_recorder) DoReturnResults(fn MoqMetrics_TotalProcessingTimeInc_doReturnFn) *MoqMetrics_TotalProcessingTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqMetrics_TotalProcessingTimeInc_params) *MoqMetrics_TotalProcessingTimeInc_results { + fn(params.D) + return &MoqMetrics_TotalProcessingTimeInc_results{} + }) return r } -func (r *MoqMetrics_TotalProcessingTimeInc_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_TotalProcessingTimeInc_resultsByParams - for n, res := range r.Moq.ResultsByParams_TotalProcessingTimeInc { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqMetrics_TotalProcessingTimeInc_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqMetrics_TotalProcessingTimeInc_paramsKey]*MoqMetrics_TotalProcessingTimeInc_results{}, - } - r.Moq.ResultsByParams_TotalProcessingTimeInc = append(r.Moq.ResultsByParams_TotalProcessingTimeInc, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_TotalProcessingTimeInc) { - copy(r.Moq.ResultsByParams_TotalProcessingTimeInc[insertAt+1:], r.Moq.ResultsByParams_TotalProcessingTimeInc[insertAt:0]) - r.Moq.ResultsByParams_TotalProcessingTimeInc[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_TotalProcessingTimeInc(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqMetrics_TotalProcessingTimeInc_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_TotalProcessingTimeInc_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_TotalProcessingTimeInc_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqMetrics_TotalProcessingTimeInc_recorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_TotalProcessingTimeInc_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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_TotalProcessingTimeInc_doFn - DoReturnFn MoqMetrics_TotalProcessingTimeInc_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqMetrics) PrettyParams_TotalProcessingTimeInc(params MoqMetrics_TotalProcessingTimeInc_params) string { +func (*MoqMetrics_TotalProcessingTimeInc_adaptor) PrettyParams(params MoqMetrics_TotalProcessingTimeInc_params) string { return fmt.Sprintf("TotalProcessingTimeInc(%#v)", params.D) } -func (m *MoqMetrics) ParamsKey_TotalProcessingTimeInc(params MoqMetrics_TotalProcessingTimeInc_params, anyParams uint64) MoqMetrics_TotalProcessingTimeInc_paramsKey { - m.Scene.T.Helper() - var dUsed time.Duration - var dUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.TotalProcessingTimeInc.D == moq.ParamIndexByValue { - dUsed = params.D - } else { - dUsedHash = hash.DeepHash(params.D) - } - } +func (a *MoqMetrics_TotalProcessingTimeInc_adaptor) ParamsKey(params MoqMetrics_TotalProcessingTimeInc_params, anyParams uint64) MoqMetrics_TotalProcessingTimeInc_paramsKey { + a.Moq.Moq_TotalProcessingTimeInc.Scene.T.Helper() + dUsed, dUsedHash := impl.ParamKey( + params.D, 1, a.Moq.Runtime.ParameterIndexing.TotalProcessingTimeInc.D, anyParams) return MoqMetrics_TotalProcessingTimeInc_paramsKey{ Params: struct{ D time.Duration }{ D: dUsed, @@ -1685,173 +933,75 @@ func (m *MoqMetrics) ParamsKey_TotalProcessingTimeInc(params MoqMetrics_TotalPro } } -func (m *MoqMetrics_recorder) Finalize() *MoqMetrics_Finalize_fnRecorder { - return &MoqMetrics_Finalize_fnRecorder{ - Params: MoqMetrics_Finalize_params{}, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, +func (m *MoqMetrics_recorder) Finalize() *MoqMetrics_Finalize_recorder { + return &MoqMetrics_Finalize_recorder{ + Recorder: m.Moq.Moq_Finalize.OnCall(MoqMetrics_Finalize_params{}), } } -func (r *MoqMetrics_Finalize_fnRecorder) Any() *MoqMetrics_Finalize_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_Finalize(r.Params)) +func (r *MoqMetrics_Finalize_recorder) Any() *MoqMetrics_Finalize_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqMetrics_Finalize_anyParams{Recorder: r} } -func (r *MoqMetrics_Finalize_fnRecorder) Seq() *MoqMetrics_Finalize_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_Finalize(r.Params)) +func (r *MoqMetrics_Finalize_recorder) Seq() *MoqMetrics_Finalize_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqMetrics_Finalize_fnRecorder) NoSeq() *MoqMetrics_Finalize_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_Finalize(r.Params)) +func (r *MoqMetrics_Finalize_recorder) NoSeq() *MoqMetrics_Finalize_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqMetrics_Finalize_fnRecorder) ReturnResults() *MoqMetrics_Finalize_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_Finalize_doFn - DoReturnFn MoqMetrics_Finalize_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqMetrics_Finalize_recorder) ReturnResults() *MoqMetrics_Finalize_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqMetrics_Finalize_results{}) return r } -func (r *MoqMetrics_Finalize_fnRecorder) AndDo(fn MoqMetrics_Finalize_doFn) *MoqMetrics_Finalize_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqMetrics_Finalize_recorder) AndDo(fn MoqMetrics_Finalize_doFn) *MoqMetrics_Finalize_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqMetrics_Finalize_params) { + fn() + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqMetrics_Finalize_fnRecorder) DoReturnResults(fn MoqMetrics_Finalize_doReturnFn) *MoqMetrics_Finalize_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_Finalize_doFn - DoReturnFn MoqMetrics_Finalize_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqMetrics_Finalize_recorder) DoReturnResults(fn MoqMetrics_Finalize_doReturnFn) *MoqMetrics_Finalize_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqMetrics_Finalize_params) *MoqMetrics_Finalize_results { + fn() + return &MoqMetrics_Finalize_results{} + }) return r } -func (r *MoqMetrics_Finalize_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_Finalize_resultsByParams - for n, res := range r.Moq.ResultsByParams_Finalize { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqMetrics_Finalize_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqMetrics_Finalize_paramsKey]*MoqMetrics_Finalize_results{}, - } - r.Moq.ResultsByParams_Finalize = append(r.Moq.ResultsByParams_Finalize, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_Finalize) { - copy(r.Moq.ResultsByParams_Finalize[insertAt+1:], r.Moq.ResultsByParams_Finalize[insertAt:0]) - r.Moq.ResultsByParams_Finalize[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_Finalize(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqMetrics_Finalize_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_Finalize_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_Finalize_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqMetrics_Finalize_recorder) Repeat(repeaters ...moq.Repeater) *MoqMetrics_Finalize_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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_Finalize_doFn - DoReturnFn MoqMetrics_Finalize_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqMetrics) PrettyParams_Finalize(params MoqMetrics_Finalize_params) string { +func (*MoqMetrics_Finalize_adaptor) PrettyParams(params MoqMetrics_Finalize_params) string { return fmt.Sprintf("Finalize()") } -func (m *MoqMetrics) ParamsKey_Finalize(params MoqMetrics_Finalize_params, anyParams uint64) MoqMetrics_Finalize_paramsKey { - m.Scene.T.Helper() +func (a *MoqMetrics_Finalize_adaptor) ParamsKey(params MoqMetrics_Finalize_params, anyParams uint64) MoqMetrics_Finalize_paramsKey { + a.Moq.Moq_Finalize.Scene.T.Helper() return MoqMetrics_Finalize_paramsKey{ Params: struct{}{}, Hashes: struct{}{}, @@ -1860,63 +1010,21 @@ func (m *MoqMetrics) ParamsKey_Finalize(params MoqMetrics_Finalize_params, anyPa // Reset resets the state of the moq func (m *MoqMetrics) Reset() { - m.ResultsByParams_ASTPkgCacheHitsInc = nil - m.ResultsByParams_ASTPkgCacheMissesInc = nil - m.ResultsByParams_ASTTotalLoadTimeInc = nil - m.ResultsByParams_ASTTotalDecorationTimeInc = nil - m.ResultsByParams_TotalProcessingTimeInc = nil - m.ResultsByParams_Finalize = nil + m.Moq_ASTPkgCacheHitsInc.Reset() + m.Moq_ASTPkgCacheMissesInc.Reset() + m.Moq_ASTTotalLoadTimeInc.Reset() + m.Moq_ASTTotalDecorationTimeInc.Reset() + m.Moq_TotalProcessingTimeInc.Reset() + m.Moq_Finalize.Reset() } // AssertExpectationsMet asserts that all expectations have been met func (m *MoqMetrics) AssertExpectationsMet() { - m.Scene.T.Helper() - for _, res := range m.ResultsByParams_ASTPkgCacheHitsInc { - 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_ASTPkgCacheHitsInc(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_ASTPkgCacheMissesInc { - 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_ASTPkgCacheMissesInc(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_ASTTotalLoadTimeInc { - 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_ASTTotalLoadTimeInc(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_ASTTotalDecorationTimeInc { - 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_ASTTotalDecorationTimeInc(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_TotalProcessingTimeInc { - 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_TotalProcessingTimeInc(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_Finalize { - 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_Finalize(results.Params)) - } - } - } + m.Moq_ASTPkgCacheHitsInc.Scene.T.Helper() + m.Moq_ASTPkgCacheHitsInc.AssertExpectationsMet() + m.Moq_ASTPkgCacheMissesInc.AssertExpectationsMet() + m.Moq_ASTTotalLoadTimeInc.AssertExpectationsMet() + m.Moq_ASTTotalDecorationTimeInc.AssertExpectationsMet() + m.Moq_TotalProcessingTimeInc.AssertExpectationsMet() + m.Moq_Finalize.AssertExpectationsMet() } diff --git a/metrics/moq_reader_test.go b/metrics/moq_reader_test.go index 0bf4c8c..9e55ad5 100644 --- a/metrics/moq_reader_test.go +++ b/metrics/moq_reader_test.go @@ -5,10 +5,9 @@ package metrics_test import ( "fmt" "io" - "math/bits" - "sync/atomic" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -17,22 +16,19 @@ var _ io.Reader = (*moqReader_mock)(nil) // moqReader holds the state of a moq of the Reader type type moqReader struct { - scene *moq.Scene - config moq.Config - moq *moqReader_mock + moq *moqReader_mock - resultsByParams_Read []moqReader_Read_resultsByParams + moq_Read *impl.Moq[ + *moqReader_Read_adaptor, + moqReader_Read_params, + moqReader_Read_paramsKey, + moqReader_Read_results, + ] - runtime struct { - parameterIndexing struct { - Read struct { - p moq.ParamIndexing - } - } - } - // moqReader_mock isolates the mock interface of the Reader type + runtime moqReader_runtime } +// moqReader_mock isolates the mock interface of the Reader type type moqReader_mock struct { moq *moqReader } @@ -42,6 +38,18 @@ type moqReader_recorder struct { moq *moqReader } +// moqReader_runtime holds runtime configuration for the Reader type +type moqReader_runtime struct { + parameterIndexing struct { + Read moqReader_Read_paramIndexing + } +} + +// moqReader_Read_adaptor adapts moqReader as needed by the runtime +type moqReader_Read_adaptor struct { + moq *moqReader +} + // moqReader_Read_params holds the params of the Reader type type moqReader_Read_params struct{ p []byte } @@ -51,12 +59,16 @@ type moqReader_Read_paramsKey struct { hashes struct{ p hash.Hash } } -// moqReader_Read_resultsByParams contains the results for a given set of -// parameters for the Reader type -type moqReader_Read_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqReader_Read_paramsKey]*moqReader_Read_results +// moqReader_Read_results holds the results of the Reader type +type moqReader_Read_results struct { + n int + err error +} + +// moqReader_Read_paramIndexing holds the parameter indexing runtime +// configuration for the Reader type +type moqReader_Read_paramIndexing struct { + p moq.ParamIndexing } // moqReader_Read_doFn defines the type of function needed when calling andDo @@ -67,68 +79,47 @@ type moqReader_Read_doFn func(p []byte) // doReturnResults for the Reader type type moqReader_Read_doReturnFn func(p []byte) (n int, err error) -// moqReader_Read_results holds the results of the Reader type -type moqReader_Read_results struct { - params moqReader_Read_params - results []struct { - values *struct { - n int - err error - } - sequence uint32 - doFn moqReader_Read_doFn - doReturnFn moqReader_Read_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqReader_Read_fnRecorder routes recorded function calls to the moqReader -// moq -type moqReader_Read_fnRecorder struct { - params moqReader_Read_params - anyParams uint64 - sequence bool - results *moqReader_Read_results - moq *moqReader +// moqReader_Read_recorder routes recorded function calls to the moqReader moq +type moqReader_Read_recorder struct { + recorder *impl.Recorder[ + *moqReader_Read_adaptor, + moqReader_Read_params, + moqReader_Read_paramsKey, + moqReader_Read_results, + ] } // moqReader_Read_anyParams isolates the any params functions of the Reader // type type moqReader_Read_anyParams struct { - recorder *moqReader_Read_fnRecorder + recorder *moqReader_Read_recorder } // newMoqReader creates a new moq of the Reader type func newMoqReader(scene *moq.Scene, config *moq.Config) *moqReader { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqReader_Read_adaptor{} m := &moqReader{ - scene: scene, - config: *config, - moq: &moqReader_mock{}, - - runtime: struct { - parameterIndexing struct { - Read struct { - p moq.ParamIndexing - } - } - }{parameterIndexing: struct { - Read struct { - p moq.ParamIndexing - } + moq: &moqReader_mock{}, + + moq_Read: impl.NewMoq[ + *moqReader_Read_adaptor, + moqReader_Read_params, + moqReader_Read_paramsKey, + moqReader_Read_results, + ](scene, adaptor1, config), + + runtime: moqReader_runtime{parameterIndexing: struct { + Read moqReader_Read_paramIndexing }{ - Read: struct { - p moq.ParamIndexing - }{ + Read: moqReader_Read_paramIndexing{ p: moq.ParamIndexByHash, }, }}, } m.moq.moq = m + adaptor1.moq = m + scene.AddMoq(m) return m } @@ -136,58 +127,19 @@ func newMoqReader(scene *moq.Scene, config *moq.Config) *moqReader { // mock returns the mock implementation of the Reader type func (m *moqReader) mock() *moqReader_mock { return m.moq } -func (m *moqReader_mock) Read(p []byte) (n int, err error) { - m.moq.scene.T.Helper() +func (m *moqReader_mock) Read(p []byte) (int, error) { + m.moq.moq_Read.Scene.T.Helper() params := moqReader_Read_params{ p: p, } - var results *moqReader_Read_results - for _, resultsByParams := range m.moq.resultsByParams_Read { - paramsKey := m.moq.paramsKey_Read(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_Read(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_Read(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_Read(params)) - } - } - if result.doFn != nil { - result.doFn(p) + var result1 int + var result2 error + if result := m.moq.moq_Read.Function(params); result != nil { + result1 = result.n + result2 = result.err } - - if result.values != nil { - n = result.values.n - err = result.values.err - } - if result.doReturnFn != nil { - n, err = result.doReturnFn(p) - } - return + return result1, result2 } // onCall returns the recorder implementation of the Reader type @@ -197,202 +149,90 @@ func (m *moqReader) onCall() *moqReader_recorder { } } -func (m *moqReader_recorder) Read(p []byte) *moqReader_Read_fnRecorder { - return &moqReader_Read_fnRecorder{ - params: moqReader_Read_params{ +func (m *moqReader_recorder) Read(p []byte) *moqReader_Read_recorder { + return &moqReader_Read_recorder{ + recorder: m.moq.moq_Read.OnCall(moqReader_Read_params{ p: p, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqReader_Read_fnRecorder) any() *moqReader_Read_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_Read(r.params)) +func (r *moqReader_Read_recorder) any() *moqReader_Read_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqReader_Read_anyParams{recorder: r} } -func (a *moqReader_Read_anyParams) p() *moqReader_Read_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqReader_Read_anyParams) p() *moqReader_Read_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqReader_Read_fnRecorder) seq() *moqReader_Read_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_Read(r.params)) +func (r *moqReader_Read_recorder) seq() *moqReader_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqReader_Read_fnRecorder) noSeq() *moqReader_Read_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_Read(r.params)) +func (r *moqReader_Read_recorder) noSeq() *moqReader_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqReader_Read_fnRecorder) returnResults(n int, err error) *moqReader_Read_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 { - n int - err error - } - sequence uint32 - doFn moqReader_Read_doFn - doReturnFn moqReader_Read_doReturnFn - }{ - values: &struct { - n int - err error - }{ - n: n, - err: err, - }, - sequence: sequence, +func (r *moqReader_Read_recorder) returnResults(n int, err error) *moqReader_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqReader_Read_results{ + n: n, + err: err, }) return r } -func (r *moqReader_Read_fnRecorder) andDo(fn moqReader_Read_doFn) *moqReader_Read_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqReader_Read_recorder) andDo(fn moqReader_Read_doFn) *moqReader_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqReader_Read_params) { + fn(params.p) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqReader_Read_fnRecorder) doReturnResults(fn moqReader_Read_doReturnFn) *moqReader_Read_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 { - n int - err error +func (r *moqReader_Read_recorder) doReturnResults(fn moqReader_Read_doReturnFn) *moqReader_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqReader_Read_params) *moqReader_Read_results { + n, err := fn(params.p) + return &moqReader_Read_results{ + n: n, + err: err, } - sequence uint32 - doFn moqReader_Read_doFn - doReturnFn moqReader_Read_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqReader_Read_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 *moqReader_Read_resultsByParams - for n, res := range r.moq.resultsByParams_Read { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqReader_Read_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqReader_Read_paramsKey]*moqReader_Read_results{}, - } - r.moq.resultsByParams_Read = append(r.moq.resultsByParams_Read, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Read) { - copy(r.moq.resultsByParams_Read[insertAt+1:], r.moq.resultsByParams_Read[insertAt:0]) - r.moq.resultsByParams_Read[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Read(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqReader_Read_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 *moqReader_Read_fnRecorder) repeat(repeaters ...moq.Repeater) *moqReader_Read_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqReader_Read_recorder) repeat(repeaters ...moq.Repeater) *moqReader_Read_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 { - n int - err error - } - sequence uint32 - doFn moqReader_Read_doFn - doReturnFn moqReader_Read_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqReader) prettyParams_Read(params moqReader_Read_params) string { +func (*moqReader_Read_adaptor) PrettyParams(params moqReader_Read_params) string { return fmt.Sprintf("Read(%#v)", params.p) } -func (m *moqReader) paramsKey_Read(params moqReader_Read_params, anyParams uint64) moqReader_Read_paramsKey { - m.scene.T.Helper() - var pUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Read.p == moq.ParamIndexByValue { - m.scene.T.Fatalf("The p parameter of the Read function can't be indexed by value") - } - pUsedHash = hash.DeepHash(params.p) - } +func (a *moqReader_Read_adaptor) ParamsKey(params moqReader_Read_params, anyParams uint64) moqReader_Read_paramsKey { + a.moq.moq_Read.Scene.T.Helper() + pUsedHash := impl.HashOnlyParamKey(a.moq.moq_Read.Scene.T, + params.p, "p", 1, a.moq.runtime.parameterIndexing.Read.p, anyParams) return moqReader_Read_paramsKey{ params: struct{}{}, hashes: struct{ p hash.Hash }{ @@ -402,17 +242,12 @@ func (m *moqReader) paramsKey_Read(params moqReader_Read_params, anyParams uint6 } // Reset resets the state of the moq -func (m *moqReader) Reset() { m.resultsByParams_Read = nil } +func (m *moqReader) Reset() { + m.moq_Read.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqReader) AssertExpectationsMet() { - m.scene.T.Helper() - for _, res := range m.resultsByParams_Read { - 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_Read(results.params)) - } - } - } + m.moq_Read.Scene.T.Helper() + m.moq_Read.AssertExpectationsMet() } diff --git a/pkg/internal/moq_generatewithtypecachefn_test.go b/pkg/internal/moq_generatewithtypecachefn_test.go index 8a25974..4c47fde 100644 --- a/pkg/internal/moq_generatewithtypecachefn_test.go +++ b/pkg/internal/moq_generatewithtypecachefn_test.go @@ -4,35 +4,36 @@ package internal_test import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/cli/generator" "moqueries.org/cli/pkg/internal" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) // moqGenerateWithTypeCacheFn holds the state of a moq of the // GenerateWithTypeCacheFn type type moqGenerateWithTypeCacheFn struct { - scene *moq.Scene - config moq.Config - moq *moqGenerateWithTypeCacheFn_mock + moq *impl.Moq[ + *moqGenerateWithTypeCacheFn_adaptor, + moqGenerateWithTypeCacheFn_params, + moqGenerateWithTypeCacheFn_paramsKey, + moqGenerateWithTypeCacheFn_results, + ] - resultsByParams []moqGenerateWithTypeCacheFn_resultsByParams - - runtime struct { - parameterIndexing struct { - cache moq.ParamIndexing - req moq.ParamIndexing - } - } + runtime moqGenerateWithTypeCacheFn_runtime } -// moqGenerateWithTypeCacheFn_mock isolates the mock interface of the +// moqGenerateWithTypeCacheFn_runtime holds runtime configuration for the // GenerateWithTypeCacheFn type -type moqGenerateWithTypeCacheFn_mock struct { +type moqGenerateWithTypeCacheFn_runtime struct { + parameterIndexing moqGenerateWithTypeCacheFn_paramIndexing +} + +// moqGenerateWithTypeCacheFn_adaptor adapts moqGenerateWithTypeCacheFn as +// needed by the runtime +type moqGenerateWithTypeCacheFn_adaptor struct { moq *moqGenerateWithTypeCacheFn } @@ -53,12 +54,17 @@ type moqGenerateWithTypeCacheFn_paramsKey struct { } } -// moqGenerateWithTypeCacheFn_resultsByParams contains the results for a given -// set of parameters for the GenerateWithTypeCacheFn type -type moqGenerateWithTypeCacheFn_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqGenerateWithTypeCacheFn_paramsKey]*moqGenerateWithTypeCacheFn_results +// moqGenerateWithTypeCacheFn_results holds the results of the +// GenerateWithTypeCacheFn type +type moqGenerateWithTypeCacheFn_results struct { + result1 error +} + +// moqGenerateWithTypeCacheFn_paramIndexing holds the parameter indexing +// runtime configuration for the GenerateWithTypeCacheFn type +type moqGenerateWithTypeCacheFn_paramIndexing struct { + cache moq.ParamIndexing + req moq.ParamIndexing } // moqGenerateWithTypeCacheFn_doFn defines the type of function needed when @@ -69,63 +75,41 @@ type moqGenerateWithTypeCacheFn_doFn func(cache generator.TypeCache, req generat // when calling doReturnResults for the GenerateWithTypeCacheFn type type moqGenerateWithTypeCacheFn_doReturnFn func(cache generator.TypeCache, req generator.GenerateRequest) error -// moqGenerateWithTypeCacheFn_results holds the results of the -// GenerateWithTypeCacheFn type -type moqGenerateWithTypeCacheFn_results struct { - params moqGenerateWithTypeCacheFn_params - results []struct { - values *struct { - result1 error - } - sequence uint32 - doFn moqGenerateWithTypeCacheFn_doFn - doReturnFn moqGenerateWithTypeCacheFn_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqGenerateWithTypeCacheFn_fnRecorder routes recorded function calls to the +// moqGenerateWithTypeCacheFn_recorder routes recorded function calls to the // moqGenerateWithTypeCacheFn moq -type moqGenerateWithTypeCacheFn_fnRecorder struct { - params moqGenerateWithTypeCacheFn_params - anyParams uint64 - sequence bool - results *moqGenerateWithTypeCacheFn_results - moq *moqGenerateWithTypeCacheFn +type moqGenerateWithTypeCacheFn_recorder struct { + recorder *impl.Recorder[ + *moqGenerateWithTypeCacheFn_adaptor, + moqGenerateWithTypeCacheFn_params, + moqGenerateWithTypeCacheFn_paramsKey, + moqGenerateWithTypeCacheFn_results, + ] } // moqGenerateWithTypeCacheFn_anyParams isolates the any params functions of // the GenerateWithTypeCacheFn type type moqGenerateWithTypeCacheFn_anyParams struct { - recorder *moqGenerateWithTypeCacheFn_fnRecorder + recorder *moqGenerateWithTypeCacheFn_recorder } // newMoqGenerateWithTypeCacheFn creates a new moq of the // GenerateWithTypeCacheFn type func newMoqGenerateWithTypeCacheFn(scene *moq.Scene, config *moq.Config) *moqGenerateWithTypeCacheFn { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqGenerateWithTypeCacheFn_adaptor{} m := &moqGenerateWithTypeCacheFn{ - scene: scene, - config: *config, - moq: &moqGenerateWithTypeCacheFn_mock{}, - - runtime: struct { - parameterIndexing struct { - cache moq.ParamIndexing - req moq.ParamIndexing - } - }{parameterIndexing: struct { - cache moq.ParamIndexing - req moq.ParamIndexing - }{ + moq: impl.NewMoq[ + *moqGenerateWithTypeCacheFn_adaptor, + moqGenerateWithTypeCacheFn_params, + moqGenerateWithTypeCacheFn_paramsKey, + moqGenerateWithTypeCacheFn_results, + ](scene, adaptor1, config), + + runtime: moqGenerateWithTypeCacheFn_runtime{parameterIndexing: moqGenerateWithTypeCacheFn_paramIndexing{ cache: moq.ParamIndexByHash, req: moq.ParamIndexByHash, }}, } - m.moq.moq = m + adaptor1.moq = m scene.AddMoq(m) return m @@ -134,272 +118,110 @@ func newMoqGenerateWithTypeCacheFn(scene *moq.Scene, config *moq.Config) *moqGen // mock returns the moq implementation of the GenerateWithTypeCacheFn type func (m *moqGenerateWithTypeCacheFn) mock() internal.GenerateWithTypeCacheFn { return func(cache generator.TypeCache, req generator.GenerateRequest) error { - m.scene.T.Helper() - moq := &moqGenerateWithTypeCacheFn_mock{moq: m} - return moq.fn(cache, req) - } -} - -func (m *moqGenerateWithTypeCacheFn_mock) fn(cache generator.TypeCache, req generator.GenerateRequest) (result1 error) { - m.moq.scene.T.Helper() - params := moqGenerateWithTypeCacheFn_params{ - cache: cache, - req: req, - } - var results *moqGenerateWithTypeCacheFn_results - 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 + m.moq.Scene.T.Helper() + params := moqGenerateWithTypeCacheFn_params{ + cache: cache, + req: req, } - 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)) + var result1 error + if result := m.moq.Function(params); result != nil { + result1 = result.result1 } + return result1 } - - if result.doFn != nil { - result.doFn(cache, req) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(cache, req) - } - return } -func (m *moqGenerateWithTypeCacheFn) onCall(cache generator.TypeCache, req generator.GenerateRequest) *moqGenerateWithTypeCacheFn_fnRecorder { - return &moqGenerateWithTypeCacheFn_fnRecorder{ - params: moqGenerateWithTypeCacheFn_params{ +func (m *moqGenerateWithTypeCacheFn) onCall(cache generator.TypeCache, req generator.GenerateRequest) *moqGenerateWithTypeCacheFn_recorder { + return &moqGenerateWithTypeCacheFn_recorder{ + recorder: m.moq.OnCall(moqGenerateWithTypeCacheFn_params{ cache: cache, req: req, - }, - sequence: m.config.Sequence == moq.SeqDefaultOn, - moq: m, + }), } } -func (r *moqGenerateWithTypeCacheFn_fnRecorder) any() *moqGenerateWithTypeCacheFn_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(r.params)) +func (r *moqGenerateWithTypeCacheFn_recorder) any() *moqGenerateWithTypeCacheFn_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqGenerateWithTypeCacheFn_anyParams{recorder: r} } -func (a *moqGenerateWithTypeCacheFn_anyParams) cache() *moqGenerateWithTypeCacheFn_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqGenerateWithTypeCacheFn_anyParams) cache() *moqGenerateWithTypeCacheFn_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqGenerateWithTypeCacheFn_anyParams) req() *moqGenerateWithTypeCacheFn_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqGenerateWithTypeCacheFn_anyParams) req() *moqGenerateWithTypeCacheFn_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqGenerateWithTypeCacheFn_fnRecorder) seq() *moqGenerateWithTypeCacheFn_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(r.params)) +func (r *moqGenerateWithTypeCacheFn_recorder) seq() *moqGenerateWithTypeCacheFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqGenerateWithTypeCacheFn_fnRecorder) noSeq() *moqGenerateWithTypeCacheFn_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(r.params)) +func (r *moqGenerateWithTypeCacheFn_recorder) noSeq() *moqGenerateWithTypeCacheFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqGenerateWithTypeCacheFn_fnRecorder) returnResults(result1 error) *moqGenerateWithTypeCacheFn_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 error - } - sequence uint32 - doFn moqGenerateWithTypeCacheFn_doFn - doReturnFn moqGenerateWithTypeCacheFn_doReturnFn - }{ - values: &struct { - result1 error - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqGenerateWithTypeCacheFn_recorder) returnResults(result1 error) *moqGenerateWithTypeCacheFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqGenerateWithTypeCacheFn_results{ + result1: result1, }) return r } -func (r *moqGenerateWithTypeCacheFn_fnRecorder) andDo(fn moqGenerateWithTypeCacheFn_doFn) *moqGenerateWithTypeCacheFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqGenerateWithTypeCacheFn_recorder) andDo(fn moqGenerateWithTypeCacheFn_doFn) *moqGenerateWithTypeCacheFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqGenerateWithTypeCacheFn_params) { + fn(params.cache, params.req) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqGenerateWithTypeCacheFn_fnRecorder) doReturnResults(fn moqGenerateWithTypeCacheFn_doReturnFn) *moqGenerateWithTypeCacheFn_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 error +func (r *moqGenerateWithTypeCacheFn_recorder) doReturnResults(fn moqGenerateWithTypeCacheFn_doReturnFn) *moqGenerateWithTypeCacheFn_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqGenerateWithTypeCacheFn_params) *moqGenerateWithTypeCacheFn_results { + result1 := fn(params.cache, params.req) + return &moqGenerateWithTypeCacheFn_results{ + result1: result1, } - sequence uint32 - doFn moqGenerateWithTypeCacheFn_doFn - doReturnFn moqGenerateWithTypeCacheFn_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqGenerateWithTypeCacheFn_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 *moqGenerateWithTypeCacheFn_resultsByParams - 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 = &moqGenerateWithTypeCacheFn_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqGenerateWithTypeCacheFn_paramsKey]*moqGenerateWithTypeCacheFn_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(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqGenerateWithTypeCacheFn_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 *moqGenerateWithTypeCacheFn_fnRecorder) repeat(repeaters ...moq.Repeater) *moqGenerateWithTypeCacheFn_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqGenerateWithTypeCacheFn_recorder) repeat(repeaters ...moq.Repeater) *moqGenerateWithTypeCacheFn_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 error - } - sequence uint32 - doFn moqGenerateWithTypeCacheFn_doFn - doReturnFn moqGenerateWithTypeCacheFn_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqGenerateWithTypeCacheFn) prettyParams(params moqGenerateWithTypeCacheFn_params) string { +func (*moqGenerateWithTypeCacheFn_adaptor) PrettyParams(params moqGenerateWithTypeCacheFn_params) string { return fmt.Sprintf("GenerateWithTypeCacheFn(%#v, %#v)", params.cache, params.req) } -func (m *moqGenerateWithTypeCacheFn) paramsKey(params moqGenerateWithTypeCacheFn_params, anyParams uint64) moqGenerateWithTypeCacheFn_paramsKey { - m.scene.T.Helper() - var cacheUsed generator.TypeCache - var cacheUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.cache == moq.ParamIndexByValue { - cacheUsed = params.cache - } else { - cacheUsedHash = hash.DeepHash(params.cache) - } - } - var reqUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.req == moq.ParamIndexByValue { - m.scene.T.Fatalf("The req parameter can't be indexed by value") - } - reqUsedHash = hash.DeepHash(params.req) - } +func (a *moqGenerateWithTypeCacheFn_adaptor) ParamsKey(params moqGenerateWithTypeCacheFn_params, anyParams uint64) moqGenerateWithTypeCacheFn_paramsKey { + a.moq.moq.Scene.T.Helper() + cacheUsed, cacheUsedHash := impl.ParamKey( + params.cache, 1, a.moq.runtime.parameterIndexing.cache, anyParams) + reqUsedHash := impl.HashOnlyParamKey(a.moq.moq.Scene.T, + params.req, "req", 2, a.moq.runtime.parameterIndexing.req, anyParams) return moqGenerateWithTypeCacheFn_paramsKey{ params: struct{ cache generator.TypeCache }{ cache: cacheUsed, @@ -415,17 +237,12 @@ func (m *moqGenerateWithTypeCacheFn) paramsKey(params moqGenerateWithTypeCacheFn } // Reset resets the state of the moq -func (m *moqGenerateWithTypeCacheFn) Reset() { m.resultsByParams = nil } +func (m *moqGenerateWithTypeCacheFn) Reset() { + m.moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *moqGenerateWithTypeCacheFn) 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)) - } - } - } + m.moq.Scene.T.Helper() + m.moq.AssertExpectationsMet() } diff --git a/pkg/internal/moq_typecache_test.go b/pkg/internal/moq_typecache_test.go index 3a77acb..94b6107 100644 --- a/pkg/internal/moq_typecache_test.go +++ b/pkg/internal/moq_typecache_test.go @@ -4,13 +4,12 @@ package internal_test import ( "fmt" - "math/bits" - "sync/atomic" "github.com/dave/dst" "moqueries.org/cli/ast" "moqueries.org/cli/pkg/internal" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -20,46 +19,49 @@ var _ internal.TypeCache = (*moqTypeCache_mock)(nil) // moqTypeCache holds the state of a moq of the TypeCache type type moqTypeCache struct { - scene *moq.Scene - config moq.Config - moq *moqTypeCache_mock - - resultsByParams_LoadPackage []moqTypeCache_LoadPackage_resultsByParams - resultsByParams_MockableTypes []moqTypeCache_MockableTypes_resultsByParams - resultsByParams_Type []moqTypeCache_Type_resultsByParams - resultsByParams_IsComparable []moqTypeCache_IsComparable_resultsByParams - resultsByParams_IsDefaultComparable []moqTypeCache_IsDefaultComparable_resultsByParams - resultsByParams_FindPackage []moqTypeCache_FindPackage_resultsByParams - - runtime struct { - parameterIndexing struct { - LoadPackage struct { - pkgPattern moq.ParamIndexing - } - MockableTypes struct { - onlyExported moq.ParamIndexing - } - Type struct { - id moq.ParamIndexing - contextPkg moq.ParamIndexing - testImport moq.ParamIndexing - } - IsComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - IsDefaultComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - FindPackage struct { - dir moq.ParamIndexing - } - } - } - // moqTypeCache_mock isolates the mock interface of the TypeCache type -} - + moq *moqTypeCache_mock + + moq_LoadPackage *impl.Moq[ + *moqTypeCache_LoadPackage_adaptor, + moqTypeCache_LoadPackage_params, + moqTypeCache_LoadPackage_paramsKey, + moqTypeCache_LoadPackage_results, + ] + moq_MockableTypes *impl.Moq[ + *moqTypeCache_MockableTypes_adaptor, + moqTypeCache_MockableTypes_params, + moqTypeCache_MockableTypes_paramsKey, + moqTypeCache_MockableTypes_results, + ] + moq_Type *impl.Moq[ + *moqTypeCache_Type_adaptor, + moqTypeCache_Type_params, + moqTypeCache_Type_paramsKey, + moqTypeCache_Type_results, + ] + moq_IsComparable *impl.Moq[ + *moqTypeCache_IsComparable_adaptor, + moqTypeCache_IsComparable_params, + moqTypeCache_IsComparable_paramsKey, + moqTypeCache_IsComparable_results, + ] + moq_IsDefaultComparable *impl.Moq[ + *moqTypeCache_IsDefaultComparable_adaptor, + moqTypeCache_IsDefaultComparable_params, + moqTypeCache_IsDefaultComparable_paramsKey, + moqTypeCache_IsDefaultComparable_results, + ] + moq_FindPackage *impl.Moq[ + *moqTypeCache_FindPackage_adaptor, + moqTypeCache_FindPackage_params, + moqTypeCache_FindPackage_paramsKey, + moqTypeCache_FindPackage_results, + ] + + runtime moqTypeCache_runtime +} + +// moqTypeCache_mock isolates the mock interface of the TypeCache type type moqTypeCache_mock struct { moq *moqTypeCache } @@ -69,6 +71,24 @@ type moqTypeCache_recorder struct { moq *moqTypeCache } +// moqTypeCache_runtime holds runtime configuration for the TypeCache type +type moqTypeCache_runtime struct { + parameterIndexing struct { + LoadPackage moqTypeCache_LoadPackage_paramIndexing + MockableTypes moqTypeCache_MockableTypes_paramIndexing + Type moqTypeCache_Type_paramIndexing + IsComparable moqTypeCache_IsComparable_paramIndexing + IsDefaultComparable moqTypeCache_IsDefaultComparable_paramIndexing + FindPackage moqTypeCache_FindPackage_paramIndexing + } +} + +// moqTypeCache_LoadPackage_adaptor adapts moqTypeCache as needed by the +// runtime +type moqTypeCache_LoadPackage_adaptor struct { + moq *moqTypeCache +} + // moqTypeCache_LoadPackage_params holds the params of the TypeCache type type moqTypeCache_LoadPackage_params struct{ pkgPattern string } @@ -79,12 +99,15 @@ type moqTypeCache_LoadPackage_paramsKey struct { hashes struct{ pkgPattern hash.Hash } } -// moqTypeCache_LoadPackage_resultsByParams contains the results for a given -// set of parameters for the TypeCache type -type moqTypeCache_LoadPackage_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTypeCache_LoadPackage_paramsKey]*moqTypeCache_LoadPackage_results +// moqTypeCache_LoadPackage_results holds the results of the TypeCache type +type moqTypeCache_LoadPackage_results struct { + result1 error +} + +// moqTypeCache_LoadPackage_paramIndexing holds the parameter indexing runtime +// configuration for the TypeCache type +type moqTypeCache_LoadPackage_paramIndexing struct { + pkgPattern moq.ParamIndexing } // moqTypeCache_LoadPackage_doFn defines the type of function needed when @@ -95,35 +118,27 @@ type moqTypeCache_LoadPackage_doFn func(pkgPattern string) // calling doReturnResults for the TypeCache type type moqTypeCache_LoadPackage_doReturnFn func(pkgPattern string) error -// moqTypeCache_LoadPackage_results holds the results of the TypeCache type -type moqTypeCache_LoadPackage_results struct { - params moqTypeCache_LoadPackage_params - results []struct { - values *struct { - result1 error - } - sequence uint32 - doFn moqTypeCache_LoadPackage_doFn - doReturnFn moqTypeCache_LoadPackage_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTypeCache_LoadPackage_fnRecorder routes recorded function calls to the +// moqTypeCache_LoadPackage_recorder routes recorded function calls to the // moqTypeCache moq -type moqTypeCache_LoadPackage_fnRecorder struct { - params moqTypeCache_LoadPackage_params - anyParams uint64 - sequence bool - results *moqTypeCache_LoadPackage_results - moq *moqTypeCache +type moqTypeCache_LoadPackage_recorder struct { + recorder *impl.Recorder[ + *moqTypeCache_LoadPackage_adaptor, + moqTypeCache_LoadPackage_params, + moqTypeCache_LoadPackage_paramsKey, + moqTypeCache_LoadPackage_results, + ] } // moqTypeCache_LoadPackage_anyParams isolates the any params functions of the // TypeCache type type moqTypeCache_LoadPackage_anyParams struct { - recorder *moqTypeCache_LoadPackage_fnRecorder + recorder *moqTypeCache_LoadPackage_recorder +} + +// moqTypeCache_MockableTypes_adaptor adapts moqTypeCache as needed by the +// runtime +type moqTypeCache_MockableTypes_adaptor struct { + moq *moqTypeCache } // moqTypeCache_MockableTypes_params holds the params of the TypeCache type @@ -136,12 +151,15 @@ type moqTypeCache_MockableTypes_paramsKey struct { hashes struct{ onlyExported hash.Hash } } -// moqTypeCache_MockableTypes_resultsByParams contains the results for a given -// set of parameters for the TypeCache type -type moqTypeCache_MockableTypes_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTypeCache_MockableTypes_paramsKey]*moqTypeCache_MockableTypes_results +// moqTypeCache_MockableTypes_results holds the results of the TypeCache type +type moqTypeCache_MockableTypes_results struct { + result1 []dst.Ident +} + +// moqTypeCache_MockableTypes_paramIndexing holds the parameter indexing +// runtime configuration for the TypeCache type +type moqTypeCache_MockableTypes_paramIndexing struct { + onlyExported moq.ParamIndexing } // moqTypeCache_MockableTypes_doFn defines the type of function needed when @@ -152,35 +170,26 @@ type moqTypeCache_MockableTypes_doFn func(onlyExported bool) // when calling doReturnResults for the TypeCache type type moqTypeCache_MockableTypes_doReturnFn func(onlyExported bool) []dst.Ident -// moqTypeCache_MockableTypes_results holds the results of the TypeCache type -type moqTypeCache_MockableTypes_results struct { - params moqTypeCache_MockableTypes_params - results []struct { - values *struct { - result1 []dst.Ident - } - sequence uint32 - doFn moqTypeCache_MockableTypes_doFn - doReturnFn moqTypeCache_MockableTypes_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTypeCache_MockableTypes_fnRecorder routes recorded function calls to the +// moqTypeCache_MockableTypes_recorder routes recorded function calls to the // moqTypeCache moq -type moqTypeCache_MockableTypes_fnRecorder struct { - params moqTypeCache_MockableTypes_params - anyParams uint64 - sequence bool - results *moqTypeCache_MockableTypes_results - moq *moqTypeCache +type moqTypeCache_MockableTypes_recorder struct { + recorder *impl.Recorder[ + *moqTypeCache_MockableTypes_adaptor, + moqTypeCache_MockableTypes_params, + moqTypeCache_MockableTypes_paramsKey, + moqTypeCache_MockableTypes_results, + ] } // moqTypeCache_MockableTypes_anyParams isolates the any params functions of // the TypeCache type type moqTypeCache_MockableTypes_anyParams struct { - recorder *moqTypeCache_MockableTypes_fnRecorder + recorder *moqTypeCache_MockableTypes_recorder +} + +// moqTypeCache_Type_adaptor adapts moqTypeCache as needed by the runtime +type moqTypeCache_Type_adaptor struct { + moq *moqTypeCache } // moqTypeCache_Type_params holds the params of the TypeCache type @@ -203,12 +212,18 @@ type moqTypeCache_Type_paramsKey struct { } } -// moqTypeCache_Type_resultsByParams contains the results for a given set of -// parameters for the TypeCache type -type moqTypeCache_Type_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTypeCache_Type_paramsKey]*moqTypeCache_Type_results +// moqTypeCache_Type_results holds the results of the TypeCache type +type moqTypeCache_Type_results struct { + result1 ast.TypeInfo + result2 error +} + +// moqTypeCache_Type_paramIndexing holds the parameter indexing runtime +// configuration for the TypeCache type +type moqTypeCache_Type_paramIndexing struct { + id moq.ParamIndexing + contextPkg moq.ParamIndexing + testImport moq.ParamIndexing } // moqTypeCache_Type_doFn defines the type of function needed when calling @@ -219,36 +234,27 @@ type moqTypeCache_Type_doFn func(id dst.Ident, contextPkg string, testImport boo // calling doReturnResults for the TypeCache type type moqTypeCache_Type_doReturnFn func(id dst.Ident, contextPkg string, testImport bool) (ast.TypeInfo, error) -// moqTypeCache_Type_results holds the results of the TypeCache type -type moqTypeCache_Type_results struct { - params moqTypeCache_Type_params - results []struct { - values *struct { - result1 ast.TypeInfo - result2 error - } - sequence uint32 - doFn moqTypeCache_Type_doFn - doReturnFn moqTypeCache_Type_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTypeCache_Type_fnRecorder routes recorded function calls to the +// moqTypeCache_Type_recorder routes recorded function calls to the // moqTypeCache moq -type moqTypeCache_Type_fnRecorder struct { - params moqTypeCache_Type_params - anyParams uint64 - sequence bool - results *moqTypeCache_Type_results - moq *moqTypeCache +type moqTypeCache_Type_recorder struct { + recorder *impl.Recorder[ + *moqTypeCache_Type_adaptor, + moqTypeCache_Type_params, + moqTypeCache_Type_paramsKey, + moqTypeCache_Type_results, + ] } // moqTypeCache_Type_anyParams isolates the any params functions of the // TypeCache type type moqTypeCache_Type_anyParams struct { - recorder *moqTypeCache_Type_fnRecorder + recorder *moqTypeCache_Type_recorder +} + +// moqTypeCache_IsComparable_adaptor adapts moqTypeCache as needed by the +// runtime +type moqTypeCache_IsComparable_adaptor struct { + moq *moqTypeCache } // moqTypeCache_IsComparable_params holds the params of the TypeCache type @@ -270,12 +276,17 @@ type moqTypeCache_IsComparable_paramsKey struct { } } -// moqTypeCache_IsComparable_resultsByParams contains the results for a given -// set of parameters for the TypeCache type -type moqTypeCache_IsComparable_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTypeCache_IsComparable_paramsKey]*moqTypeCache_IsComparable_results +// moqTypeCache_IsComparable_results holds the results of the TypeCache type +type moqTypeCache_IsComparable_results struct { + result1 bool + result2 error +} + +// moqTypeCache_IsComparable_paramIndexing holds the parameter indexing runtime +// configuration for the TypeCache type +type moqTypeCache_IsComparable_paramIndexing struct { + expr moq.ParamIndexing + parentType moq.ParamIndexing } // moqTypeCache_IsComparable_doFn defines the type of function needed when @@ -286,36 +297,27 @@ type moqTypeCache_IsComparable_doFn func(expr dst.Expr, parentType ast.TypeInfo) // when calling doReturnResults for the TypeCache type 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 { - params moqTypeCache_IsComparable_params - results []struct { - values *struct { - result1 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsComparable_doFn - doReturnFn moqTypeCache_IsComparable_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTypeCache_IsComparable_fnRecorder routes recorded function calls to the +// moqTypeCache_IsComparable_recorder routes recorded function calls to the // moqTypeCache moq -type moqTypeCache_IsComparable_fnRecorder struct { - params moqTypeCache_IsComparable_params - anyParams uint64 - sequence bool - results *moqTypeCache_IsComparable_results - moq *moqTypeCache +type moqTypeCache_IsComparable_recorder struct { + recorder *impl.Recorder[ + *moqTypeCache_IsComparable_adaptor, + moqTypeCache_IsComparable_params, + moqTypeCache_IsComparable_paramsKey, + moqTypeCache_IsComparable_results, + ] } // moqTypeCache_IsComparable_anyParams isolates the any params functions of the // TypeCache type type moqTypeCache_IsComparable_anyParams struct { - recorder *moqTypeCache_IsComparable_fnRecorder + recorder *moqTypeCache_IsComparable_recorder +} + +// moqTypeCache_IsDefaultComparable_adaptor adapts moqTypeCache as needed by +// the runtime +type moqTypeCache_IsDefaultComparable_adaptor struct { + moq *moqTypeCache } // moqTypeCache_IsDefaultComparable_params holds the params of the TypeCache @@ -338,12 +340,18 @@ type moqTypeCache_IsDefaultComparable_paramsKey struct { } } -// moqTypeCache_IsDefaultComparable_resultsByParams contains the results for a -// given set of parameters for the TypeCache type -type moqTypeCache_IsDefaultComparable_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTypeCache_IsDefaultComparable_paramsKey]*moqTypeCache_IsDefaultComparable_results +// moqTypeCache_IsDefaultComparable_results holds the results of the TypeCache +// type +type moqTypeCache_IsDefaultComparable_results struct { + result1 bool + result2 error +} + +// moqTypeCache_IsDefaultComparable_paramIndexing holds the parameter indexing +// runtime configuration for the TypeCache type +type moqTypeCache_IsDefaultComparable_paramIndexing struct { + expr moq.ParamIndexing + parentType moq.ParamIndexing } // moqTypeCache_IsDefaultComparable_doFn defines the type of function needed @@ -354,37 +362,27 @@ type moqTypeCache_IsDefaultComparable_doFn func(expr dst.Expr, parentType ast.Ty // needed when calling doReturnResults for the TypeCache type type moqTypeCache_IsDefaultComparable_doReturnFn func(expr dst.Expr, parentType ast.TypeInfo) (bool, error) -// moqTypeCache_IsDefaultComparable_results holds the results of the TypeCache -// type -type moqTypeCache_IsDefaultComparable_results struct { - params moqTypeCache_IsDefaultComparable_params - results []struct { - values *struct { - result1 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsDefaultComparable_doFn - doReturnFn moqTypeCache_IsDefaultComparable_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTypeCache_IsDefaultComparable_fnRecorder routes recorded function calls -// to the moqTypeCache moq -type moqTypeCache_IsDefaultComparable_fnRecorder struct { - params moqTypeCache_IsDefaultComparable_params - anyParams uint64 - sequence bool - results *moqTypeCache_IsDefaultComparable_results - moq *moqTypeCache +// moqTypeCache_IsDefaultComparable_recorder routes recorded function calls to +// the moqTypeCache moq +type moqTypeCache_IsDefaultComparable_recorder struct { + recorder *impl.Recorder[ + *moqTypeCache_IsDefaultComparable_adaptor, + moqTypeCache_IsDefaultComparable_params, + moqTypeCache_IsDefaultComparable_paramsKey, + moqTypeCache_IsDefaultComparable_results, + ] } // moqTypeCache_IsDefaultComparable_anyParams isolates the any params functions // of the TypeCache type type moqTypeCache_IsDefaultComparable_anyParams struct { - recorder *moqTypeCache_IsDefaultComparable_fnRecorder + recorder *moqTypeCache_IsDefaultComparable_recorder +} + +// moqTypeCache_FindPackage_adaptor adapts moqTypeCache as needed by the +// runtime +type moqTypeCache_FindPackage_adaptor struct { + moq *moqTypeCache } // moqTypeCache_FindPackage_params holds the params of the TypeCache type @@ -397,12 +395,16 @@ type moqTypeCache_FindPackage_paramsKey struct { hashes struct{ dir hash.Hash } } -// moqTypeCache_FindPackage_resultsByParams contains the results for a given -// set of parameters for the TypeCache type -type moqTypeCache_FindPackage_resultsByParams struct { - anyCount int - anyParams uint64 - results map[moqTypeCache_FindPackage_paramsKey]*moqTypeCache_FindPackage_results +// moqTypeCache_FindPackage_results holds the results of the TypeCache type +type moqTypeCache_FindPackage_results struct { + result1 string + result2 error +} + +// moqTypeCache_FindPackage_paramIndexing holds the parameter indexing runtime +// configuration for the TypeCache type +type moqTypeCache_FindPackage_paramIndexing struct { + dir moq.ParamIndexing } // moqTypeCache_FindPackage_doFn defines the type of function needed when @@ -413,139 +415,112 @@ type moqTypeCache_FindPackage_doFn func(dir string) // calling doReturnResults for the TypeCache type type moqTypeCache_FindPackage_doReturnFn func(dir string) (string, error) -// moqTypeCache_FindPackage_results holds the results of the TypeCache type -type moqTypeCache_FindPackage_results struct { - params moqTypeCache_FindPackage_params - results []struct { - values *struct { - result1 string - result2 error - } - sequence uint32 - doFn moqTypeCache_FindPackage_doFn - doReturnFn moqTypeCache_FindPackage_doReturnFn - } - index uint32 - repeat *moq.RepeatVal -} - -// moqTypeCache_FindPackage_fnRecorder routes recorded function calls to the +// moqTypeCache_FindPackage_recorder routes recorded function calls to the // moqTypeCache moq -type moqTypeCache_FindPackage_fnRecorder struct { - params moqTypeCache_FindPackage_params - anyParams uint64 - sequence bool - results *moqTypeCache_FindPackage_results - moq *moqTypeCache +type moqTypeCache_FindPackage_recorder struct { + recorder *impl.Recorder[ + *moqTypeCache_FindPackage_adaptor, + moqTypeCache_FindPackage_params, + moqTypeCache_FindPackage_paramsKey, + moqTypeCache_FindPackage_results, + ] } // moqTypeCache_FindPackage_anyParams isolates the any params functions of the // TypeCache type type moqTypeCache_FindPackage_anyParams struct { - recorder *moqTypeCache_FindPackage_fnRecorder + recorder *moqTypeCache_FindPackage_recorder } // newMoqTypeCache creates a new moq of the TypeCache type func newMoqTypeCache(scene *moq.Scene, config *moq.Config) *moqTypeCache { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &moqTypeCache_LoadPackage_adaptor{} + adaptor2 := &moqTypeCache_MockableTypes_adaptor{} + adaptor3 := &moqTypeCache_Type_adaptor{} + adaptor4 := &moqTypeCache_IsComparable_adaptor{} + adaptor5 := &moqTypeCache_IsDefaultComparable_adaptor{} + adaptor6 := &moqTypeCache_FindPackage_adaptor{} m := &moqTypeCache{ - scene: scene, - config: *config, - moq: &moqTypeCache_mock{}, - - runtime: struct { - parameterIndexing struct { - LoadPackage struct { - pkgPattern moq.ParamIndexing - } - MockableTypes struct { - onlyExported moq.ParamIndexing - } - Type struct { - id moq.ParamIndexing - contextPkg moq.ParamIndexing - testImport moq.ParamIndexing - } - IsComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - IsDefaultComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - FindPackage struct { - dir moq.ParamIndexing - } - } - }{parameterIndexing: struct { - LoadPackage struct { - pkgPattern moq.ParamIndexing - } - MockableTypes struct { - onlyExported moq.ParamIndexing - } - Type struct { - id moq.ParamIndexing - contextPkg moq.ParamIndexing - testImport moq.ParamIndexing - } - IsComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - IsDefaultComparable struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - } - FindPackage struct { - dir moq.ParamIndexing - } + moq: &moqTypeCache_mock{}, + + moq_LoadPackage: impl.NewMoq[ + *moqTypeCache_LoadPackage_adaptor, + moqTypeCache_LoadPackage_params, + moqTypeCache_LoadPackage_paramsKey, + moqTypeCache_LoadPackage_results, + ](scene, adaptor1, config), + moq_MockableTypes: impl.NewMoq[ + *moqTypeCache_MockableTypes_adaptor, + moqTypeCache_MockableTypes_params, + moqTypeCache_MockableTypes_paramsKey, + moqTypeCache_MockableTypes_results, + ](scene, adaptor2, config), + moq_Type: impl.NewMoq[ + *moqTypeCache_Type_adaptor, + moqTypeCache_Type_params, + moqTypeCache_Type_paramsKey, + moqTypeCache_Type_results, + ](scene, adaptor3, config), + moq_IsComparable: impl.NewMoq[ + *moqTypeCache_IsComparable_adaptor, + moqTypeCache_IsComparable_params, + moqTypeCache_IsComparable_paramsKey, + moqTypeCache_IsComparable_results, + ](scene, adaptor4, config), + moq_IsDefaultComparable: impl.NewMoq[ + *moqTypeCache_IsDefaultComparable_adaptor, + moqTypeCache_IsDefaultComparable_params, + moqTypeCache_IsDefaultComparable_paramsKey, + moqTypeCache_IsDefaultComparable_results, + ](scene, adaptor5, config), + moq_FindPackage: impl.NewMoq[ + *moqTypeCache_FindPackage_adaptor, + moqTypeCache_FindPackage_params, + moqTypeCache_FindPackage_paramsKey, + moqTypeCache_FindPackage_results, + ](scene, adaptor6, config), + + runtime: moqTypeCache_runtime{parameterIndexing: struct { + LoadPackage moqTypeCache_LoadPackage_paramIndexing + MockableTypes moqTypeCache_MockableTypes_paramIndexing + Type moqTypeCache_Type_paramIndexing + IsComparable moqTypeCache_IsComparable_paramIndexing + IsDefaultComparable moqTypeCache_IsDefaultComparable_paramIndexing + FindPackage moqTypeCache_FindPackage_paramIndexing }{ - LoadPackage: struct { - pkgPattern moq.ParamIndexing - }{ + LoadPackage: moqTypeCache_LoadPackage_paramIndexing{ pkgPattern: moq.ParamIndexByValue, }, - MockableTypes: struct { - onlyExported moq.ParamIndexing - }{ + MockableTypes: moqTypeCache_MockableTypes_paramIndexing{ onlyExported: moq.ParamIndexByValue, }, - Type: struct { - id moq.ParamIndexing - contextPkg moq.ParamIndexing - testImport moq.ParamIndexing - }{ + Type: moqTypeCache_Type_paramIndexing{ id: moq.ParamIndexByHash, contextPkg: moq.ParamIndexByValue, testImport: moq.ParamIndexByValue, }, - IsComparable: struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - }{ + IsComparable: moqTypeCache_IsComparable_paramIndexing{ expr: moq.ParamIndexByHash, parentType: moq.ParamIndexByHash, }, - IsDefaultComparable: struct { - expr moq.ParamIndexing - parentType moq.ParamIndexing - }{ + IsDefaultComparable: moqTypeCache_IsDefaultComparable_paramIndexing{ expr: moq.ParamIndexByHash, parentType: moq.ParamIndexByHash, }, - FindPackage: struct { - dir moq.ParamIndexing - }{ + FindPackage: moqTypeCache_FindPackage_paramIndexing{ dir: moq.ParamIndexByValue, }, }}, } m.moq.moq = m + adaptor1.moq = m + adaptor2.moq = m + adaptor3.moq = m + adaptor4.moq = m + adaptor5.moq = m + adaptor6.moq = m + scene.AddMoq(m) return m } @@ -553,330 +528,94 @@ func newMoqTypeCache(scene *moq.Scene, config *moq.Config) *moqTypeCache { // mock returns the mock implementation of the TypeCache type func (m *moqTypeCache) mock() *moqTypeCache_mock { return m.moq } -func (m *moqTypeCache_mock) LoadPackage(pkgPattern string) (result1 error) { - m.moq.scene.T.Helper() +func (m *moqTypeCache_mock) LoadPackage(pkgPattern string) error { + m.moq.moq_LoadPackage.Scene.T.Helper() params := moqTypeCache_LoadPackage_params{ pkgPattern: pkgPattern, } - var results *moqTypeCache_LoadPackage_results - for _, resultsByParams := range m.moq.resultsByParams_LoadPackage { - paramsKey := m.moq.paramsKey_LoadPackage(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_LoadPackage(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_LoadPackage(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_LoadPackage(params)) - } - } - - if result.doFn != nil { - result.doFn(pkgPattern) - } - if result.values != nil { - result1 = result.values.result1 + var result1 error + if result := m.moq.moq_LoadPackage.Function(params); result != nil { + result1 = result.result1 } - if result.doReturnFn != nil { - result1 = result.doReturnFn(pkgPattern) - } - return + return result1 } -func (m *moqTypeCache_mock) MockableTypes(onlyExported bool) (result1 []dst.Ident) { - m.moq.scene.T.Helper() +func (m *moqTypeCache_mock) MockableTypes(onlyExported bool) []dst.Ident { + m.moq.moq_MockableTypes.Scene.T.Helper() params := moqTypeCache_MockableTypes_params{ onlyExported: onlyExported, } - var results *moqTypeCache_MockableTypes_results - for _, resultsByParams := range m.moq.resultsByParams_MockableTypes { - paramsKey := m.moq.paramsKey_MockableTypes(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_MockableTypes(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_MockableTypes(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_MockableTypes(params)) - } + var result1 []dst.Ident + if result := m.moq.moq_MockableTypes.Function(params); result != nil { + result1 = result.result1 } - - if result.doFn != nil { - result.doFn(onlyExported) - } - - if result.values != nil { - result1 = result.values.result1 - } - if result.doReturnFn != nil { - result1 = result.doReturnFn(onlyExported) - } - return + return result1 } -func (m *moqTypeCache_mock) Type(id dst.Ident, contextPkg string, testImport bool) (result1 ast.TypeInfo, result2 error) { - m.moq.scene.T.Helper() +func (m *moqTypeCache_mock) Type(id dst.Ident, contextPkg string, testImport bool) (ast.TypeInfo, error) { + m.moq.moq_Type.Scene.T.Helper() params := moqTypeCache_Type_params{ id: id, contextPkg: contextPkg, testImport: testImport, } - var results *moqTypeCache_Type_results - for _, resultsByParams := range m.moq.resultsByParams_Type { - paramsKey := m.moq.paramsKey_Type(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_Type(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_Type(params)) - } - return - } - i = results.repeat.ResultCount - 1 + var result1 ast.TypeInfo + var result2 error + if result := m.moq.moq_Type.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - - 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_Type(params)) - } - } - - if result.doFn != nil { - result.doFn(id, contextPkg, testImport) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(id, contextPkg, testImport) - } - return + return result1, result2 } -func (m *moqTypeCache_mock) IsComparable(expr dst.Expr, parentType ast.TypeInfo) (result1 bool, result2 error) { - m.moq.scene.T.Helper() +func (m *moqTypeCache_mock) IsComparable(expr dst.Expr, parentType ast.TypeInfo) (bool, error) { + m.moq.moq_IsComparable.Scene.T.Helper() params := moqTypeCache_IsComparable_params{ expr: expr, parentType: parentType, } - var results *moqTypeCache_IsComparable_results - for _, resultsByParams := range m.moq.resultsByParams_IsComparable { - paramsKey := m.moq.paramsKey_IsComparable(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_IsComparable(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_IsComparable(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_IsComparable(params)) - } - } - - if result.doFn != nil { - result.doFn(expr, parentType) - } - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 + var result1 bool + var result2 error + if result := m.moq.moq_IsComparable.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(expr, parentType) - } - return + return result1, result2 } -func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) (result1 bool, result2 error) { - m.moq.scene.T.Helper() +func (m *moqTypeCache_mock) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) (bool, error) { + m.moq.moq_IsDefaultComparable.Scene.T.Helper() params := moqTypeCache_IsDefaultComparable_params{ expr: expr, parentType: parentType, } - var results *moqTypeCache_IsDefaultComparable_results - for _, resultsByParams := range m.moq.resultsByParams_IsDefaultComparable { - paramsKey := m.moq.paramsKey_IsDefaultComparable(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_IsDefaultComparable(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_IsDefaultComparable(params)) - } - return - } - i = results.repeat.ResultCount - 1 + var result1 bool + var result2 error + if result := m.moq.moq_IsDefaultComparable.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - - 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_IsDefaultComparable(params)) - } - } - - if result.doFn != nil { - result.doFn(expr, parentType) - } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(expr, parentType) - } - return + return result1, result2 } -func (m *moqTypeCache_mock) FindPackage(dir string) (result1 string, result2 error) { - m.moq.scene.T.Helper() +func (m *moqTypeCache_mock) FindPackage(dir string) (string, error) { + m.moq.moq_FindPackage.Scene.T.Helper() params := moqTypeCache_FindPackage_params{ dir: dir, } - var results *moqTypeCache_FindPackage_results - for _, resultsByParams := range m.moq.resultsByParams_FindPackage { - paramsKey := m.moq.paramsKey_FindPackage(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_FindPackage(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_FindPackage(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_FindPackage(params)) - } - } - - if result.doFn != nil { - result.doFn(dir) + var result1 string + var result2 error + if result := m.moq.moq_FindPackage.Function(params); result != nil { + result1 = result.result1 + result2 = result.result2 } - - if result.values != nil { - result1 = result.values.result1 - result2 = result.values.result2 - } - if result.doReturnFn != nil { - result1, result2 = result.doReturnFn(dir) - } - return + return result1, result2 } // onCall returns the recorder implementation of the TypeCache type @@ -886,199 +625,88 @@ func (m *moqTypeCache) onCall() *moqTypeCache_recorder { } } -func (m *moqTypeCache_recorder) LoadPackage(pkgPattern string) *moqTypeCache_LoadPackage_fnRecorder { - return &moqTypeCache_LoadPackage_fnRecorder{ - params: moqTypeCache_LoadPackage_params{ +func (m *moqTypeCache_recorder) LoadPackage(pkgPattern string) *moqTypeCache_LoadPackage_recorder { + return &moqTypeCache_LoadPackage_recorder{ + recorder: m.moq.moq_LoadPackage.OnCall(moqTypeCache_LoadPackage_params{ pkgPattern: pkgPattern, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqTypeCache_LoadPackage_fnRecorder) any() *moqTypeCache_LoadPackage_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_LoadPackage(r.params)) +func (r *moqTypeCache_LoadPackage_recorder) any() *moqTypeCache_LoadPackage_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTypeCache_LoadPackage_anyParams{recorder: r} } -func (a *moqTypeCache_LoadPackage_anyParams) pkgPattern() *moqTypeCache_LoadPackage_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqTypeCache_LoadPackage_anyParams) pkgPattern() *moqTypeCache_LoadPackage_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqTypeCache_LoadPackage_fnRecorder) seq() *moqTypeCache_LoadPackage_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_LoadPackage(r.params)) +func (r *moqTypeCache_LoadPackage_recorder) seq() *moqTypeCache_LoadPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTypeCache_LoadPackage_fnRecorder) noSeq() *moqTypeCache_LoadPackage_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_LoadPackage(r.params)) +func (r *moqTypeCache_LoadPackage_recorder) noSeq() *moqTypeCache_LoadPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTypeCache_LoadPackage_fnRecorder) returnResults(result1 error) *moqTypeCache_LoadPackage_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 error - } - sequence uint32 - doFn moqTypeCache_LoadPackage_doFn - doReturnFn moqTypeCache_LoadPackage_doReturnFn - }{ - values: &struct { - result1 error - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqTypeCache_LoadPackage_recorder) returnResults(result1 error) *moqTypeCache_LoadPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTypeCache_LoadPackage_results{ + result1: result1, }) return r } -func (r *moqTypeCache_LoadPackage_fnRecorder) andDo(fn moqTypeCache_LoadPackage_doFn) *moqTypeCache_LoadPackage_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTypeCache_LoadPackage_recorder) andDo(fn moqTypeCache_LoadPackage_doFn) *moqTypeCache_LoadPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTypeCache_LoadPackage_params) { + fn(params.pkgPattern) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTypeCache_LoadPackage_fnRecorder) doReturnResults(fn moqTypeCache_LoadPackage_doReturnFn) *moqTypeCache_LoadPackage_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 error +func (r *moqTypeCache_LoadPackage_recorder) doReturnResults(fn moqTypeCache_LoadPackage_doReturnFn) *moqTypeCache_LoadPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTypeCache_LoadPackage_params) *moqTypeCache_LoadPackage_results { + result1 := fn(params.pkgPattern) + return &moqTypeCache_LoadPackage_results{ + result1: result1, } - sequence uint32 - doFn moqTypeCache_LoadPackage_doFn - doReturnFn moqTypeCache_LoadPackage_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqTypeCache_LoadPackage_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 *moqTypeCache_LoadPackage_resultsByParams - for n, res := range r.moq.resultsByParams_LoadPackage { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqTypeCache_LoadPackage_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTypeCache_LoadPackage_paramsKey]*moqTypeCache_LoadPackage_results{}, - } - r.moq.resultsByParams_LoadPackage = append(r.moq.resultsByParams_LoadPackage, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_LoadPackage) { - copy(r.moq.resultsByParams_LoadPackage[insertAt+1:], r.moq.resultsByParams_LoadPackage[insertAt:0]) - r.moq.resultsByParams_LoadPackage[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_LoadPackage(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTypeCache_LoadPackage_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 *moqTypeCache_LoadPackage_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_LoadPackage_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqTypeCache_LoadPackage_recorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_LoadPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 error - } - sequence uint32 - doFn moqTypeCache_LoadPackage_doFn - doReturnFn moqTypeCache_LoadPackage_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqTypeCache) prettyParams_LoadPackage(params moqTypeCache_LoadPackage_params) string { +func (*moqTypeCache_LoadPackage_adaptor) PrettyParams(params moqTypeCache_LoadPackage_params) string { return fmt.Sprintf("LoadPackage(%#v)", params.pkgPattern) } -func (m *moqTypeCache) paramsKey_LoadPackage(params moqTypeCache_LoadPackage_params, anyParams uint64) moqTypeCache_LoadPackage_paramsKey { - m.scene.T.Helper() - var pkgPatternUsed string - var pkgPatternUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.LoadPackage.pkgPattern == moq.ParamIndexByValue { - pkgPatternUsed = params.pkgPattern - } else { - pkgPatternUsedHash = hash.DeepHash(params.pkgPattern) - } - } +func (a *moqTypeCache_LoadPackage_adaptor) ParamsKey(params moqTypeCache_LoadPackage_params, anyParams uint64) moqTypeCache_LoadPackage_paramsKey { + a.moq.moq_LoadPackage.Scene.T.Helper() + pkgPatternUsed, pkgPatternUsedHash := impl.ParamKey( + params.pkgPattern, 1, a.moq.runtime.parameterIndexing.LoadPackage.pkgPattern, anyParams) return moqTypeCache_LoadPackage_paramsKey{ params: struct{ pkgPattern string }{ pkgPattern: pkgPatternUsed, @@ -1089,199 +717,88 @@ func (m *moqTypeCache) paramsKey_LoadPackage(params moqTypeCache_LoadPackage_par } } -func (m *moqTypeCache_recorder) MockableTypes(onlyExported bool) *moqTypeCache_MockableTypes_fnRecorder { - return &moqTypeCache_MockableTypes_fnRecorder{ - params: moqTypeCache_MockableTypes_params{ +func (m *moqTypeCache_recorder) MockableTypes(onlyExported bool) *moqTypeCache_MockableTypes_recorder { + return &moqTypeCache_MockableTypes_recorder{ + recorder: m.moq.moq_MockableTypes.OnCall(moqTypeCache_MockableTypes_params{ onlyExported: onlyExported, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqTypeCache_MockableTypes_fnRecorder) any() *moqTypeCache_MockableTypes_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_MockableTypes(r.params)) +func (r *moqTypeCache_MockableTypes_recorder) any() *moqTypeCache_MockableTypes_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTypeCache_MockableTypes_anyParams{recorder: r} } -func (a *moqTypeCache_MockableTypes_anyParams) onlyExported() *moqTypeCache_MockableTypes_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqTypeCache_MockableTypes_anyParams) onlyExported() *moqTypeCache_MockableTypes_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqTypeCache_MockableTypes_fnRecorder) seq() *moqTypeCache_MockableTypes_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_MockableTypes(r.params)) +func (r *moqTypeCache_MockableTypes_recorder) seq() *moqTypeCache_MockableTypes_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTypeCache_MockableTypes_fnRecorder) noSeq() *moqTypeCache_MockableTypes_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_MockableTypes(r.params)) +func (r *moqTypeCache_MockableTypes_recorder) noSeq() *moqTypeCache_MockableTypes_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTypeCache_MockableTypes_fnRecorder) returnResults(result1 []dst.Ident) *moqTypeCache_MockableTypes_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 []dst.Ident - } - sequence uint32 - doFn moqTypeCache_MockableTypes_doFn - doReturnFn moqTypeCache_MockableTypes_doReturnFn - }{ - values: &struct { - result1 []dst.Ident - }{ - result1: result1, - }, - sequence: sequence, +func (r *moqTypeCache_MockableTypes_recorder) returnResults(result1 []dst.Ident) *moqTypeCache_MockableTypes_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTypeCache_MockableTypes_results{ + result1: result1, }) return r } -func (r *moqTypeCache_MockableTypes_fnRecorder) andDo(fn moqTypeCache_MockableTypes_doFn) *moqTypeCache_MockableTypes_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTypeCache_MockableTypes_recorder) andDo(fn moqTypeCache_MockableTypes_doFn) *moqTypeCache_MockableTypes_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTypeCache_MockableTypes_params) { + fn(params.onlyExported) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTypeCache_MockableTypes_fnRecorder) doReturnResults(fn moqTypeCache_MockableTypes_doReturnFn) *moqTypeCache_MockableTypes_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 []dst.Ident +func (r *moqTypeCache_MockableTypes_recorder) doReturnResults(fn moqTypeCache_MockableTypes_doReturnFn) *moqTypeCache_MockableTypes_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTypeCache_MockableTypes_params) *moqTypeCache_MockableTypes_results { + result1 := fn(params.onlyExported) + return &moqTypeCache_MockableTypes_results{ + result1: result1, } - sequence uint32 - doFn moqTypeCache_MockableTypes_doFn - doReturnFn moqTypeCache_MockableTypes_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqTypeCache_MockableTypes_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 *moqTypeCache_MockableTypes_resultsByParams - for n, res := range r.moq.resultsByParams_MockableTypes { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqTypeCache_MockableTypes_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTypeCache_MockableTypes_paramsKey]*moqTypeCache_MockableTypes_results{}, - } - r.moq.resultsByParams_MockableTypes = append(r.moq.resultsByParams_MockableTypes, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_MockableTypes) { - copy(r.moq.resultsByParams_MockableTypes[insertAt+1:], r.moq.resultsByParams_MockableTypes[insertAt:0]) - r.moq.resultsByParams_MockableTypes[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_MockableTypes(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTypeCache_MockableTypes_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 *moqTypeCache_MockableTypes_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_MockableTypes_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqTypeCache_MockableTypes_recorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_MockableTypes_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 []dst.Ident - } - sequence uint32 - doFn moqTypeCache_MockableTypes_doFn - doReturnFn moqTypeCache_MockableTypes_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqTypeCache) prettyParams_MockableTypes(params moqTypeCache_MockableTypes_params) string { +func (*moqTypeCache_MockableTypes_adaptor) PrettyParams(params moqTypeCache_MockableTypes_params) string { return fmt.Sprintf("MockableTypes(%#v)", params.onlyExported) } -func (m *moqTypeCache) paramsKey_MockableTypes(params moqTypeCache_MockableTypes_params, anyParams uint64) moqTypeCache_MockableTypes_paramsKey { - m.scene.T.Helper() - var onlyExportedUsed bool - var onlyExportedUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.MockableTypes.onlyExported == moq.ParamIndexByValue { - onlyExportedUsed = params.onlyExported - } else { - onlyExportedUsedHash = hash.DeepHash(params.onlyExported) - } - } +func (a *moqTypeCache_MockableTypes_adaptor) ParamsKey(params moqTypeCache_MockableTypes_params, anyParams uint64) moqTypeCache_MockableTypes_paramsKey { + a.moq.moq_MockableTypes.Scene.T.Helper() + onlyExportedUsed, onlyExportedUsedHash := impl.ParamKey( + params.onlyExported, 1, a.moq.runtime.parameterIndexing.MockableTypes.onlyExported, anyParams) return moqTypeCache_MockableTypes_paramsKey{ params: struct{ onlyExported bool }{ onlyExported: onlyExportedUsed, @@ -1292,232 +809,106 @@ func (m *moqTypeCache) paramsKey_MockableTypes(params moqTypeCache_MockableTypes } } -func (m *moqTypeCache_recorder) Type(id dst.Ident, contextPkg string, testImport bool) *moqTypeCache_Type_fnRecorder { - return &moqTypeCache_Type_fnRecorder{ - params: moqTypeCache_Type_params{ +func (m *moqTypeCache_recorder) Type(id dst.Ident, contextPkg string, testImport bool) *moqTypeCache_Type_recorder { + return &moqTypeCache_Type_recorder{ + recorder: m.moq.moq_Type.OnCall(moqTypeCache_Type_params{ id: id, contextPkg: contextPkg, testImport: testImport, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqTypeCache_Type_fnRecorder) any() *moqTypeCache_Type_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_Type(r.params)) +func (r *moqTypeCache_Type_recorder) any() *moqTypeCache_Type_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTypeCache_Type_anyParams{recorder: r} } -func (a *moqTypeCache_Type_anyParams) id() *moqTypeCache_Type_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqTypeCache_Type_anyParams) id() *moqTypeCache_Type_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqTypeCache_Type_anyParams) contextPkg() *moqTypeCache_Type_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqTypeCache_Type_anyParams) contextPkg() *moqTypeCache_Type_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (a *moqTypeCache_Type_anyParams) testImport() *moqTypeCache_Type_fnRecorder { - a.recorder.anyParams |= 1 << 2 +func (a *moqTypeCache_Type_anyParams) testImport() *moqTypeCache_Type_recorder { + a.recorder.recorder.AnyParam(3) return a.recorder } -func (r *moqTypeCache_Type_fnRecorder) seq() *moqTypeCache_Type_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_Type(r.params)) +func (r *moqTypeCache_Type_recorder) seq() *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTypeCache_Type_fnRecorder) noSeq() *moqTypeCache_Type_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_Type(r.params)) +func (r *moqTypeCache_Type_recorder) noSeq() *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTypeCache_Type_fnRecorder) returnResults(result1 ast.TypeInfo, result2 error) *moqTypeCache_Type_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 ast.TypeInfo - result2 error - } - sequence uint32 - doFn moqTypeCache_Type_doFn - doReturnFn moqTypeCache_Type_doReturnFn - }{ - values: &struct { - result1 ast.TypeInfo - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqTypeCache_Type_recorder) returnResults(result1 ast.TypeInfo, result2 error) *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTypeCache_Type_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqTypeCache_Type_fnRecorder) andDo(fn moqTypeCache_Type_doFn) *moqTypeCache_Type_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTypeCache_Type_recorder) andDo(fn moqTypeCache_Type_doFn) *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTypeCache_Type_params) { + fn(params.id, params.contextPkg, params.testImport) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTypeCache_Type_fnRecorder) doReturnResults(fn moqTypeCache_Type_doReturnFn) *moqTypeCache_Type_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 ast.TypeInfo - result2 error +func (r *moqTypeCache_Type_recorder) doReturnResults(fn moqTypeCache_Type_doReturnFn) *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTypeCache_Type_params) *moqTypeCache_Type_results { + result1, result2 := fn(params.id, params.contextPkg, params.testImport) + return &moqTypeCache_Type_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqTypeCache_Type_doFn - doReturnFn moqTypeCache_Type_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqTypeCache_Type_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 *moqTypeCache_Type_resultsByParams - for n, res := range r.moq.resultsByParams_Type { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqTypeCache_Type_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTypeCache_Type_paramsKey]*moqTypeCache_Type_results{}, - } - r.moq.resultsByParams_Type = append(r.moq.resultsByParams_Type, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_Type) { - copy(r.moq.resultsByParams_Type[insertAt+1:], r.moq.resultsByParams_Type[insertAt:0]) - r.moq.resultsByParams_Type[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_Type(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTypeCache_Type_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 *moqTypeCache_Type_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_Type_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqTypeCache_Type_recorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_Type_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 ast.TypeInfo - result2 error - } - sequence uint32 - doFn moqTypeCache_Type_doFn - doReturnFn moqTypeCache_Type_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqTypeCache) prettyParams_Type(params moqTypeCache_Type_params) string { +func (*moqTypeCache_Type_adaptor) PrettyParams(params moqTypeCache_Type_params) string { return fmt.Sprintf("Type(%#v, %#v, %#v)", params.id, params.contextPkg, params.testImport) } -func (m *moqTypeCache) paramsKey_Type(params moqTypeCache_Type_params, anyParams uint64) moqTypeCache_Type_paramsKey { - m.scene.T.Helper() - var idUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.Type.id == moq.ParamIndexByValue { - m.scene.T.Fatalf("The id parameter of the Type function can't be indexed by value") - } - idUsedHash = hash.DeepHash(params.id) - } - var contextPkgUsed string - var contextPkgUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.runtime.parameterIndexing.Type.contextPkg == moq.ParamIndexByValue { - contextPkgUsed = params.contextPkg - } else { - contextPkgUsedHash = hash.DeepHash(params.contextPkg) - } - } - var testImportUsed bool - var testImportUsedHash hash.Hash - if anyParams&(1<<2) == 0 { - if m.runtime.parameterIndexing.Type.testImport == moq.ParamIndexByValue { - testImportUsed = params.testImport - } else { - testImportUsedHash = hash.DeepHash(params.testImport) - } - } +func (a *moqTypeCache_Type_adaptor) ParamsKey(params moqTypeCache_Type_params, anyParams uint64) moqTypeCache_Type_paramsKey { + a.moq.moq_Type.Scene.T.Helper() + idUsedHash := impl.HashOnlyParamKey(a.moq.moq_Type.Scene.T, + params.id, "id", 1, a.moq.runtime.parameterIndexing.Type.id, anyParams) + contextPkgUsed, contextPkgUsedHash := impl.ParamKey( + params.contextPkg, 2, a.moq.runtime.parameterIndexing.Type.contextPkg, anyParams) + testImportUsed, testImportUsedHash := impl.ParamKey( + params.testImport, 3, a.moq.runtime.parameterIndexing.Type.testImport, anyParams) return moqTypeCache_Type_paramsKey{ params: struct { contextPkg string @@ -1538,219 +929,98 @@ func (m *moqTypeCache) paramsKey_Type(params moqTypeCache_Type_params, anyParams } } -func (m *moqTypeCache_recorder) IsComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsComparable_fnRecorder { - return &moqTypeCache_IsComparable_fnRecorder{ - params: moqTypeCache_IsComparable_params{ +func (m *moqTypeCache_recorder) IsComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsComparable_recorder { + return &moqTypeCache_IsComparable_recorder{ + recorder: m.moq.moq_IsComparable.OnCall(moqTypeCache_IsComparable_params{ expr: expr, parentType: parentType, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqTypeCache_IsComparable_fnRecorder) any() *moqTypeCache_IsComparable_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_IsComparable(r.params)) +func (r *moqTypeCache_IsComparable_recorder) any() *moqTypeCache_IsComparable_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTypeCache_IsComparable_anyParams{recorder: r} } -func (a *moqTypeCache_IsComparable_anyParams) expr() *moqTypeCache_IsComparable_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqTypeCache_IsComparable_anyParams) expr() *moqTypeCache_IsComparable_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqTypeCache_IsComparable_anyParams) parentType() *moqTypeCache_IsComparable_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqTypeCache_IsComparable_anyParams) parentType() *moqTypeCache_IsComparable_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqTypeCache_IsComparable_fnRecorder) seq() *moqTypeCache_IsComparable_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_IsComparable(r.params)) +func (r *moqTypeCache_IsComparable_recorder) seq() *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTypeCache_IsComparable_fnRecorder) noSeq() *moqTypeCache_IsComparable_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_IsComparable(r.params)) +func (r *moqTypeCache_IsComparable_recorder) noSeq() *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTypeCache_IsComparable_fnRecorder) returnResults(result1 bool, result2 error) *moqTypeCache_IsComparable_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 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsComparable_doFn - doReturnFn moqTypeCache_IsComparable_doReturnFn - }{ - values: &struct { - result1 bool - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqTypeCache_IsComparable_recorder) returnResults(result1 bool, result2 error) *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTypeCache_IsComparable_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqTypeCache_IsComparable_fnRecorder) andDo(fn moqTypeCache_IsComparable_doFn) *moqTypeCache_IsComparable_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTypeCache_IsComparable_recorder) andDo(fn moqTypeCache_IsComparable_doFn) *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTypeCache_IsComparable_params) { + fn(params.expr, params.parentType) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTypeCache_IsComparable_fnRecorder) doReturnResults(fn moqTypeCache_IsComparable_doReturnFn) *moqTypeCache_IsComparable_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 bool - result2 error +func (r *moqTypeCache_IsComparable_recorder) doReturnResults(fn moqTypeCache_IsComparable_doReturnFn) *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTypeCache_IsComparable_params) *moqTypeCache_IsComparable_results { + result1, result2 := fn(params.expr, params.parentType) + return &moqTypeCache_IsComparable_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqTypeCache_IsComparable_doFn - doReturnFn moqTypeCache_IsComparable_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqTypeCache_IsComparable_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 *moqTypeCache_IsComparable_resultsByParams - for n, res := range r.moq.resultsByParams_IsComparable { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqTypeCache_IsComparable_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTypeCache_IsComparable_paramsKey]*moqTypeCache_IsComparable_results{}, - } - r.moq.resultsByParams_IsComparable = append(r.moq.resultsByParams_IsComparable, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_IsComparable) { - copy(r.moq.resultsByParams_IsComparable[insertAt+1:], r.moq.resultsByParams_IsComparable[insertAt:0]) - r.moq.resultsByParams_IsComparable[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_IsComparable(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTypeCache_IsComparable_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 *moqTypeCache_IsComparable_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_IsComparable_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqTypeCache_IsComparable_recorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_IsComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsComparable_doFn - doReturnFn moqTypeCache_IsComparable_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqTypeCache) prettyParams_IsComparable(params moqTypeCache_IsComparable_params) string { +func (*moqTypeCache_IsComparable_adaptor) PrettyParams(params moqTypeCache_IsComparable_params) string { return fmt.Sprintf("IsComparable(%#v, %#v)", params.expr, params.parentType) } -func (m *moqTypeCache) paramsKey_IsComparable(params moqTypeCache_IsComparable_params, anyParams uint64) moqTypeCache_IsComparable_paramsKey { - m.scene.T.Helper() - var exprUsed dst.Expr - var exprUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.IsComparable.expr == moq.ParamIndexByValue { - exprUsed = params.expr - } else { - 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) - } - } +func (a *moqTypeCache_IsComparable_adaptor) ParamsKey(params moqTypeCache_IsComparable_params, anyParams uint64) moqTypeCache_IsComparable_paramsKey { + a.moq.moq_IsComparable.Scene.T.Helper() + exprUsed, exprUsedHash := impl.ParamKey( + params.expr, 1, a.moq.runtime.parameterIndexing.IsComparable.expr, anyParams) + parentTypeUsed, parentTypeUsedHash := impl.ParamKey( + params.parentType, 2, a.moq.runtime.parameterIndexing.IsComparable.parentType, anyParams) return moqTypeCache_IsComparable_paramsKey{ params: struct { expr dst.Expr @@ -1769,219 +1039,98 @@ func (m *moqTypeCache) paramsKey_IsComparable(params moqTypeCache_IsComparable_p } } -func (m *moqTypeCache_recorder) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsDefaultComparable_fnRecorder { - return &moqTypeCache_IsDefaultComparable_fnRecorder{ - params: moqTypeCache_IsDefaultComparable_params{ +func (m *moqTypeCache_recorder) IsDefaultComparable(expr dst.Expr, parentType ast.TypeInfo) *moqTypeCache_IsDefaultComparable_recorder { + return &moqTypeCache_IsDefaultComparable_recorder{ + recorder: m.moq.moq_IsDefaultComparable.OnCall(moqTypeCache_IsDefaultComparable_params{ expr: expr, parentType: parentType, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) any() *moqTypeCache_IsDefaultComparable_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_IsDefaultComparable(r.params)) +func (r *moqTypeCache_IsDefaultComparable_recorder) any() *moqTypeCache_IsDefaultComparable_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTypeCache_IsDefaultComparable_anyParams{recorder: r} } -func (a *moqTypeCache_IsDefaultComparable_anyParams) expr() *moqTypeCache_IsDefaultComparable_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqTypeCache_IsDefaultComparable_anyParams) expr() *moqTypeCache_IsDefaultComparable_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (a *moqTypeCache_IsDefaultComparable_anyParams) parentType() *moqTypeCache_IsDefaultComparable_fnRecorder { - a.recorder.anyParams |= 1 << 1 +func (a *moqTypeCache_IsDefaultComparable_anyParams) parentType() *moqTypeCache_IsDefaultComparable_recorder { + a.recorder.recorder.AnyParam(2) return a.recorder } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) seq() *moqTypeCache_IsDefaultComparable_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_IsDefaultComparable(r.params)) +func (r *moqTypeCache_IsDefaultComparable_recorder) seq() *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) noSeq() *moqTypeCache_IsDefaultComparable_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_IsDefaultComparable(r.params)) +func (r *moqTypeCache_IsDefaultComparable_recorder) noSeq() *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) returnResults(result1 bool, result2 error) *moqTypeCache_IsDefaultComparable_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 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsDefaultComparable_doFn - doReturnFn moqTypeCache_IsDefaultComparable_doReturnFn - }{ - values: &struct { - result1 bool - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqTypeCache_IsDefaultComparable_recorder) returnResults(result1 bool, result2 error) *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTypeCache_IsDefaultComparable_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) andDo(fn moqTypeCache_IsDefaultComparable_doFn) *moqTypeCache_IsDefaultComparable_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTypeCache_IsDefaultComparable_recorder) andDo(fn moqTypeCache_IsDefaultComparable_doFn) *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTypeCache_IsDefaultComparable_params) { + fn(params.expr, params.parentType) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTypeCache_IsDefaultComparable_fnRecorder) doReturnResults(fn moqTypeCache_IsDefaultComparable_doReturnFn) *moqTypeCache_IsDefaultComparable_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 bool - result2 error +func (r *moqTypeCache_IsDefaultComparable_recorder) doReturnResults(fn moqTypeCache_IsDefaultComparable_doReturnFn) *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTypeCache_IsDefaultComparable_params) *moqTypeCache_IsDefaultComparable_results { + result1, result2 := fn(params.expr, params.parentType) + return &moqTypeCache_IsDefaultComparable_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqTypeCache_IsDefaultComparable_doFn - doReturnFn moqTypeCache_IsDefaultComparable_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqTypeCache_IsDefaultComparable_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 *moqTypeCache_IsDefaultComparable_resultsByParams - for n, res := range r.moq.resultsByParams_IsDefaultComparable { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqTypeCache_IsDefaultComparable_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTypeCache_IsDefaultComparable_paramsKey]*moqTypeCache_IsDefaultComparable_results{}, - } - r.moq.resultsByParams_IsDefaultComparable = append(r.moq.resultsByParams_IsDefaultComparable, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_IsDefaultComparable) { - copy(r.moq.resultsByParams_IsDefaultComparable[insertAt+1:], r.moq.resultsByParams_IsDefaultComparable[insertAt:0]) - r.moq.resultsByParams_IsDefaultComparable[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_IsDefaultComparable(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTypeCache_IsDefaultComparable_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 *moqTypeCache_IsDefaultComparable_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_IsDefaultComparable_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqTypeCache_IsDefaultComparable_recorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_IsDefaultComparable_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 bool - result2 error - } - sequence uint32 - doFn moqTypeCache_IsDefaultComparable_doFn - doReturnFn moqTypeCache_IsDefaultComparable_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqTypeCache) prettyParams_IsDefaultComparable(params moqTypeCache_IsDefaultComparable_params) string { +func (*moqTypeCache_IsDefaultComparable_adaptor) PrettyParams(params moqTypeCache_IsDefaultComparable_params) string { return fmt.Sprintf("IsDefaultComparable(%#v, %#v)", params.expr, params.parentType) } -func (m *moqTypeCache) paramsKey_IsDefaultComparable(params moqTypeCache_IsDefaultComparable_params, anyParams uint64) moqTypeCache_IsDefaultComparable_paramsKey { - m.scene.T.Helper() - var exprUsed dst.Expr - var exprUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.IsDefaultComparable.expr == moq.ParamIndexByValue { - exprUsed = params.expr - } else { - 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) - } - } +func (a *moqTypeCache_IsDefaultComparable_adaptor) ParamsKey(params moqTypeCache_IsDefaultComparable_params, anyParams uint64) moqTypeCache_IsDefaultComparable_paramsKey { + a.moq.moq_IsDefaultComparable.Scene.T.Helper() + exprUsed, exprUsedHash := impl.ParamKey( + params.expr, 1, a.moq.runtime.parameterIndexing.IsDefaultComparable.expr, anyParams) + parentTypeUsed, parentTypeUsedHash := impl.ParamKey( + params.parentType, 2, a.moq.runtime.parameterIndexing.IsDefaultComparable.parentType, anyParams) return moqTypeCache_IsDefaultComparable_paramsKey{ params: struct { expr dst.Expr @@ -2000,204 +1149,90 @@ func (m *moqTypeCache) paramsKey_IsDefaultComparable(params moqTypeCache_IsDefau } } -func (m *moqTypeCache_recorder) FindPackage(dir string) *moqTypeCache_FindPackage_fnRecorder { - return &moqTypeCache_FindPackage_fnRecorder{ - params: moqTypeCache_FindPackage_params{ +func (m *moqTypeCache_recorder) FindPackage(dir string) *moqTypeCache_FindPackage_recorder { + return &moqTypeCache_FindPackage_recorder{ + recorder: m.moq.moq_FindPackage.OnCall(moqTypeCache_FindPackage_params{ dir: dir, - }, - sequence: m.moq.config.Sequence == moq.SeqDefaultOn, - moq: m.moq, + }), } } -func (r *moqTypeCache_FindPackage_fnRecorder) any() *moqTypeCache_FindPackage_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_FindPackage(r.params)) +func (r *moqTypeCache_FindPackage_recorder) any() *moqTypeCache_FindPackage_anyParams { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.IsAnyPermitted(false) { return nil } return &moqTypeCache_FindPackage_anyParams{recorder: r} } -func (a *moqTypeCache_FindPackage_anyParams) dir() *moqTypeCache_FindPackage_fnRecorder { - a.recorder.anyParams |= 1 << 0 +func (a *moqTypeCache_FindPackage_anyParams) dir() *moqTypeCache_FindPackage_recorder { + a.recorder.recorder.AnyParam(1) return a.recorder } -func (r *moqTypeCache_FindPackage_fnRecorder) seq() *moqTypeCache_FindPackage_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_FindPackage(r.params)) +func (r *moqTypeCache_FindPackage_recorder) seq() *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(true, "seq", false) { return nil } - r.sequence = true return r } -func (r *moqTypeCache_FindPackage_fnRecorder) noSeq() *moqTypeCache_FindPackage_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_FindPackage(r.params)) +func (r *moqTypeCache_FindPackage_recorder) noSeq() *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Seq(false, "noSeq", false) { return nil } - r.sequence = false return r } -func (r *moqTypeCache_FindPackage_fnRecorder) returnResults(result1 string, result2 error) *moqTypeCache_FindPackage_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 moqTypeCache_FindPackage_doFn - doReturnFn moqTypeCache_FindPackage_doReturnFn - }{ - values: &struct { - result1 string - result2 error - }{ - result1: result1, - result2: result2, - }, - sequence: sequence, +func (r *moqTypeCache_FindPackage_recorder) returnResults(result1 string, result2 error) *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.ReturnResults(moqTypeCache_FindPackage_results{ + result1: result1, + result2: result2, }) return r } -func (r *moqTypeCache_FindPackage_fnRecorder) andDo(fn moqTypeCache_FindPackage_doFn) *moqTypeCache_FindPackage_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults must be called before calling andDo") +func (r *moqTypeCache_FindPackage_recorder) andDo(fn moqTypeCache_FindPackage_doFn) *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.AndDo(func(params moqTypeCache_FindPackage_params) { + fn(params.dir) + }, false) { return nil } - last := &r.results.results[len(r.results.results)-1] - last.doFn = fn return r } -func (r *moqTypeCache_FindPackage_fnRecorder) doReturnResults(fn moqTypeCache_FindPackage_doReturnFn) *moqTypeCache_FindPackage_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 +func (r *moqTypeCache_FindPackage_recorder) doReturnResults(fn moqTypeCache_FindPackage_doReturnFn) *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + r.recorder.DoReturnResults(func(params moqTypeCache_FindPackage_params) *moqTypeCache_FindPackage_results { + result1, result2 := fn(params.dir) + return &moqTypeCache_FindPackage_results{ + result1: result1, + result2: result2, } - sequence uint32 - doFn moqTypeCache_FindPackage_doFn - doReturnFn moqTypeCache_FindPackage_doReturnFn - }{sequence: sequence, doReturnFn: fn}) + }) return r } -func (r *moqTypeCache_FindPackage_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 *moqTypeCache_FindPackage_resultsByParams - for n, res := range r.moq.resultsByParams_FindPackage { - if res.anyParams == r.anyParams { - results = &res - break - } - if res.anyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &moqTypeCache_FindPackage_resultsByParams{ - anyCount: anyCount, - anyParams: r.anyParams, - results: map[moqTypeCache_FindPackage_paramsKey]*moqTypeCache_FindPackage_results{}, - } - r.moq.resultsByParams_FindPackage = append(r.moq.resultsByParams_FindPackage, *results) - if insertAt != -1 && insertAt+1 < len(r.moq.resultsByParams_FindPackage) { - copy(r.moq.resultsByParams_FindPackage[insertAt+1:], r.moq.resultsByParams_FindPackage[insertAt:0]) - r.moq.resultsByParams_FindPackage[insertAt] = *results - } - } - - paramsKey := r.moq.paramsKey_FindPackage(r.params, r.anyParams) - - var ok bool - r.results, ok = results.results[paramsKey] - if !ok { - r.results = &moqTypeCache_FindPackage_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 *moqTypeCache_FindPackage_fnRecorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_FindPackage_fnRecorder { - r.moq.scene.T.Helper() - if r.results == nil { - r.moq.scene.T.Fatalf("returnResults or doReturnResults must be called before calling repeat") +func (r *moqTypeCache_FindPackage_recorder) repeat(repeaters ...moq.Repeater) *moqTypeCache_FindPackage_recorder { + r.recorder.Moq.Scene.T.Helper() + if !r.recorder.Repeat(repeaters, false) { 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 moqTypeCache_FindPackage_doFn - doReturnFn moqTypeCache_FindPackage_doReturnFn - }{ - values: last.values, - sequence: r.moq.scene.NextRecorderSequence(), - } - } - r.results.results = append(r.results.results, last) - } return r } -func (m *moqTypeCache) prettyParams_FindPackage(params moqTypeCache_FindPackage_params) string { +func (*moqTypeCache_FindPackage_adaptor) PrettyParams(params moqTypeCache_FindPackage_params) string { return fmt.Sprintf("FindPackage(%#v)", params.dir) } -func (m *moqTypeCache) paramsKey_FindPackage(params moqTypeCache_FindPackage_params, anyParams uint64) moqTypeCache_FindPackage_paramsKey { - m.scene.T.Helper() - var dirUsed string - var dirUsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.runtime.parameterIndexing.FindPackage.dir == moq.ParamIndexByValue { - dirUsed = params.dir - } else { - dirUsedHash = hash.DeepHash(params.dir) - } - } +func (a *moqTypeCache_FindPackage_adaptor) ParamsKey(params moqTypeCache_FindPackage_params, anyParams uint64) moqTypeCache_FindPackage_paramsKey { + a.moq.moq_FindPackage.Scene.T.Helper() + dirUsed, dirUsedHash := impl.ParamKey( + params.dir, 1, a.moq.runtime.parameterIndexing.FindPackage.dir, anyParams) return moqTypeCache_FindPackage_paramsKey{ params: struct{ dir string }{ dir: dirUsed, @@ -2210,63 +1245,21 @@ func (m *moqTypeCache) paramsKey_FindPackage(params moqTypeCache_FindPackage_par // Reset resets the state of the moq func (m *moqTypeCache) Reset() { - m.resultsByParams_LoadPackage = nil - m.resultsByParams_MockableTypes = nil - m.resultsByParams_Type = nil - m.resultsByParams_IsComparable = nil - m.resultsByParams_IsDefaultComparable = nil - m.resultsByParams_FindPackage = nil + m.moq_LoadPackage.Reset() + m.moq_MockableTypes.Reset() + m.moq_Type.Reset() + m.moq_IsComparable.Reset() + m.moq_IsDefaultComparable.Reset() + m.moq_FindPackage.Reset() } // AssertExpectationsMet asserts that all expectations have been met func (m *moqTypeCache) AssertExpectationsMet() { - m.scene.T.Helper() - for _, res := range m.resultsByParams_LoadPackage { - 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_LoadPackage(results.params)) - } - } - } - for _, res := range m.resultsByParams_MockableTypes { - 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_MockableTypes(results.params)) - } - } - } - for _, res := range m.resultsByParams_Type { - 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_Type(results.params)) - } - } - } - for _, res := range m.resultsByParams_IsComparable { - 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_IsComparable(results.params)) - } - } - } - for _, res := range m.resultsByParams_IsDefaultComparable { - 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_IsDefaultComparable(results.params)) - } - } - } - for _, res := range m.resultsByParams_FindPackage { - 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_FindPackage(results.params)) - } - } - } + m.moq_LoadPackage.Scene.T.Helper() + m.moq_LoadPackage.AssertExpectationsMet() + m.moq_MockableTypes.AssertExpectationsMet() + m.moq_Type.AssertExpectationsMet() + m.moq_IsComparable.AssertExpectationsMet() + m.moq_IsDefaultComparable.AssertExpectationsMet() + m.moq_FindPackage.AssertExpectationsMet() } diff --git a/pkg/testmoqs/pkgout/moq_dosomethingwithparam.go b/pkg/testmoqs/pkgout/moq_dosomethingwithparam.go index bda7832..84e42b7 100644 --- a/pkg/testmoqs/pkgout/moq_dosomethingwithparam.go +++ b/pkg/testmoqs/pkgout/moq_dosomethingwithparam.go @@ -4,11 +4,10 @@ package pkgout import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/cli/pkg/testmoqs" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -19,22 +18,25 @@ type DoSomethingWithParam_genType func(testmoqs.Param) // MoqDoSomethingWithParam_genType holds the state of a moq of the // DoSomethingWithParam_genType type type MoqDoSomethingWithParam_genType struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqDoSomethingWithParam_genType_mock + Moq *impl.Moq[ + *MoqDoSomethingWithParam_genType_adaptor, + MoqDoSomethingWithParam_genType_params, + MoqDoSomethingWithParam_genType_paramsKey, + MoqDoSomethingWithParam_genType_results, + ] - ResultsByParams []MoqDoSomethingWithParam_genType_resultsByParams - - Runtime struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - } - } + Runtime MoqDoSomethingWithParam_genType_runtime } -// MoqDoSomethingWithParam_genType_mock isolates the mock interface of the +// MoqDoSomethingWithParam_genType_runtime holds runtime configuration for the // DoSomethingWithParam_genType type -type MoqDoSomethingWithParam_genType_mock struct { +type MoqDoSomethingWithParam_genType_runtime struct { + ParameterIndexing MoqDoSomethingWithParam_genType_paramIndexing +} + +// MoqDoSomethingWithParam_genType_adaptor adapts +// MoqDoSomethingWithParam_genType as needed by the runtime +type MoqDoSomethingWithParam_genType_adaptor struct { Moq *MoqDoSomethingWithParam_genType } @@ -49,12 +51,14 @@ type MoqDoSomethingWithParam_genType_paramsKey struct { Hashes struct{ Param1 hash.Hash } } -// MoqDoSomethingWithParam_genType_resultsByParams contains the results for a -// given set of parameters for the DoSomethingWithParam_genType type -type MoqDoSomethingWithParam_genType_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqDoSomethingWithParam_genType_paramsKey]*MoqDoSomethingWithParam_genType_results +// MoqDoSomethingWithParam_genType_results holds the results of the +// DoSomethingWithParam_genType type +type MoqDoSomethingWithParam_genType_results struct{} + +// MoqDoSomethingWithParam_genType_paramIndexing holds the parameter indexing +// runtime configuration for the DoSomethingWithParam_genType type +type MoqDoSomethingWithParam_genType_paramIndexing struct { + Param1 moq.ParamIndexing } // MoqDoSomethingWithParam_genType_doFn defines the type of function needed @@ -66,58 +70,40 @@ type MoqDoSomethingWithParam_genType_doFn func(testmoqs.Param) // type type MoqDoSomethingWithParam_genType_doReturnFn func(testmoqs.Param) -// MoqDoSomethingWithParam_genType_results holds the results of the -// DoSomethingWithParam_genType type -type MoqDoSomethingWithParam_genType_results struct { - Params MoqDoSomethingWithParam_genType_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqDoSomethingWithParam_genType_doFn - DoReturnFn MoqDoSomethingWithParam_genType_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqDoSomethingWithParam_genType_fnRecorder routes recorded function calls to +// MoqDoSomethingWithParam_genType_recorder routes recorded function calls to // the MoqDoSomethingWithParam_genType moq -type MoqDoSomethingWithParam_genType_fnRecorder struct { - Params MoqDoSomethingWithParam_genType_params - AnyParams uint64 - Sequence bool - Results *MoqDoSomethingWithParam_genType_results - Moq *MoqDoSomethingWithParam_genType +type MoqDoSomethingWithParam_genType_recorder struct { + Recorder *impl.Recorder[ + *MoqDoSomethingWithParam_genType_adaptor, + MoqDoSomethingWithParam_genType_params, + MoqDoSomethingWithParam_genType_paramsKey, + MoqDoSomethingWithParam_genType_results, + ] } // MoqDoSomethingWithParam_genType_anyParams isolates the any params functions // of the DoSomethingWithParam_genType type type MoqDoSomethingWithParam_genType_anyParams struct { - Recorder *MoqDoSomethingWithParam_genType_fnRecorder + Recorder *MoqDoSomethingWithParam_genType_recorder } // NewMoqDoSomethingWithParam_genType creates a new moq of the // DoSomethingWithParam_genType type func NewMoqDoSomethingWithParam_genType(scene *moq.Scene, config *moq.Config) *MoqDoSomethingWithParam_genType { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqDoSomethingWithParam_genType_adaptor{} m := &MoqDoSomethingWithParam_genType{ - Scene: scene, - Config: *config, - Moq: &MoqDoSomethingWithParam_genType_mock{}, - - Runtime: struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - } - }{ParameterIndexing: struct { - Param1 moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqDoSomethingWithParam_genType_adaptor, + MoqDoSomethingWithParam_genType_params, + MoqDoSomethingWithParam_genType_paramsKey, + MoqDoSomethingWithParam_genType_results, + ](scene, adaptor1, config), + + Runtime: MoqDoSomethingWithParam_genType_runtime{ParameterIndexing: MoqDoSomethingWithParam_genType_paramIndexing{ Param1: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -126,245 +112,93 @@ func NewMoqDoSomethingWithParam_genType(scene *moq.Scene, config *moq.Config) *M // Mock returns the moq implementation of the DoSomethingWithParam_genType type func (m *MoqDoSomethingWithParam_genType) Mock() DoSomethingWithParam_genType { return func(param1 testmoqs.Param) { - m.Scene.T.Helper() - moq := &MoqDoSomethingWithParam_genType_mock{Moq: m} - moq.Fn(param1) - } -} - -func (m *MoqDoSomethingWithParam_genType_mock) Fn(param1 testmoqs.Param) { - m.Moq.Scene.T.Helper() - params := MoqDoSomethingWithParam_genType_params{ - Param1: param1, - } - var results *MoqDoSomethingWithParam_genType_results - 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)) + m.Moq.Scene.T.Helper() + params := MoqDoSomethingWithParam_genType_params{ + Param1: param1, } - } - - if result.DoFn != nil { - result.DoFn(param1) - } - if result.DoReturnFn != nil { - result.DoReturnFn(param1) + m.Moq.Function(params) } - return } -func (m *MoqDoSomethingWithParam_genType) OnCall(param1 testmoqs.Param) *MoqDoSomethingWithParam_genType_fnRecorder { - return &MoqDoSomethingWithParam_genType_fnRecorder{ - Params: MoqDoSomethingWithParam_genType_params{ +func (m *MoqDoSomethingWithParam_genType) OnCall(param1 testmoqs.Param) *MoqDoSomethingWithParam_genType_recorder { + return &MoqDoSomethingWithParam_genType_recorder{ + Recorder: m.Moq.OnCall(MoqDoSomethingWithParam_genType_params{ Param1: param1, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqDoSomethingWithParam_genType_fnRecorder) Any() *MoqDoSomethingWithParam_genType_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(r.Params)) +func (r *MoqDoSomethingWithParam_genType_recorder) Any() *MoqDoSomethingWithParam_genType_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqDoSomethingWithParam_genType_anyParams{Recorder: r} } -func (a *MoqDoSomethingWithParam_genType_anyParams) Param1() *MoqDoSomethingWithParam_genType_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqDoSomethingWithParam_genType_anyParams) Param1() *MoqDoSomethingWithParam_genType_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqDoSomethingWithParam_genType_fnRecorder) Seq() *MoqDoSomethingWithParam_genType_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(r.Params)) +func (r *MoqDoSomethingWithParam_genType_recorder) Seq() *MoqDoSomethingWithParam_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqDoSomethingWithParam_genType_fnRecorder) NoSeq() *MoqDoSomethingWithParam_genType_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(r.Params)) +func (r *MoqDoSomethingWithParam_genType_recorder) NoSeq() *MoqDoSomethingWithParam_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqDoSomethingWithParam_genType_fnRecorder) ReturnResults() *MoqDoSomethingWithParam_genType_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 MoqDoSomethingWithParam_genType_doFn - DoReturnFn MoqDoSomethingWithParam_genType_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqDoSomethingWithParam_genType_recorder) ReturnResults() *MoqDoSomethingWithParam_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqDoSomethingWithParam_genType_results{}) return r } -func (r *MoqDoSomethingWithParam_genType_fnRecorder) AndDo(fn MoqDoSomethingWithParam_genType_doFn) *MoqDoSomethingWithParam_genType_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqDoSomethingWithParam_genType_recorder) AndDo(fn MoqDoSomethingWithParam_genType_doFn) *MoqDoSomethingWithParam_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqDoSomethingWithParam_genType_params) { + fn(params.Param1) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqDoSomethingWithParam_genType_fnRecorder) DoReturnResults(fn MoqDoSomethingWithParam_genType_doReturnFn) *MoqDoSomethingWithParam_genType_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 MoqDoSomethingWithParam_genType_doFn - DoReturnFn MoqDoSomethingWithParam_genType_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqDoSomethingWithParam_genType_recorder) DoReturnResults(fn MoqDoSomethingWithParam_genType_doReturnFn) *MoqDoSomethingWithParam_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqDoSomethingWithParam_genType_params) *MoqDoSomethingWithParam_genType_results { + fn(params.Param1) + return &MoqDoSomethingWithParam_genType_results{} + }) return r } -func (r *MoqDoSomethingWithParam_genType_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 *MoqDoSomethingWithParam_genType_resultsByParams - 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 = &MoqDoSomethingWithParam_genType_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqDoSomethingWithParam_genType_paramsKey]*MoqDoSomethingWithParam_genType_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqDoSomethingWithParam_genType_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 *MoqDoSomethingWithParam_genType_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqDoSomethingWithParam_genType_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqDoSomethingWithParam_genType_recorder) Repeat(repeaters ...moq.Repeater) *MoqDoSomethingWithParam_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 MoqDoSomethingWithParam_genType_doFn - DoReturnFn MoqDoSomethingWithParam_genType_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqDoSomethingWithParam_genType) PrettyParams(params MoqDoSomethingWithParam_genType_params) string { +func (*MoqDoSomethingWithParam_genType_adaptor) PrettyParams(params MoqDoSomethingWithParam_genType_params) string { return fmt.Sprintf("DoSomethingWithParam_genType(%#v)", params.Param1) } -func (m *MoqDoSomethingWithParam_genType) ParamsKey(params MoqDoSomethingWithParam_genType_params, anyParams uint64) MoqDoSomethingWithParam_genType_paramsKey { - m.Scene.T.Helper() - var param1Used testmoqs.Param - 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) - } - } +func (a *MoqDoSomethingWithParam_genType_adaptor) ParamsKey(params MoqDoSomethingWithParam_genType_params, anyParams uint64) MoqDoSomethingWithParam_genType_paramsKey { + a.Moq.Moq.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.Param1, anyParams) return MoqDoSomethingWithParam_genType_paramsKey{ Params: struct{ Param1 testmoqs.Param }{ Param1: param1Used, @@ -376,17 +210,12 @@ func (m *MoqDoSomethingWithParam_genType) ParamsKey(params MoqDoSomethingWithPar } // Reset resets the state of the moq -func (m *MoqDoSomethingWithParam_genType) Reset() { m.ResultsByParams = nil } +func (m *MoqDoSomethingWithParam_genType) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqDoSomethingWithParam_genType) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() } diff --git a/pkg/testmoqs/pkgout/moq_passbyrefsimple.go b/pkg/testmoqs/pkgout/moq_passbyrefsimple.go index 7e8dcf1..c8b3547 100644 --- a/pkg/testmoqs/pkgout/moq_passbyrefsimple.go +++ b/pkg/testmoqs/pkgout/moq_passbyrefsimple.go @@ -4,10 +4,9 @@ package pkgout import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -25,23 +24,19 @@ type PassByRefSimple_genType interface { // MoqPassByRefSimple_genType holds the state of a moq of the // PassByRefSimple_genType type type MoqPassByRefSimple_genType struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqPassByRefSimple_genType_mock - - ResultsByParams_Usual []MoqPassByRefSimple_genType_Usual_resultsByParams - - Runtime struct { - ParameterIndexing struct { - Usual struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - } - } - // MoqPassByRefSimple_genType_mock isolates the mock interface of the + Moq *MoqPassByRefSimple_genType_mock + + Moq_Usual *impl.Moq[ + *MoqPassByRefSimple_genType_Usual_adaptor, + MoqPassByRefSimple_genType_Usual_params, + MoqPassByRefSimple_genType_Usual_paramsKey, + MoqPassByRefSimple_genType_Usual_results, + ] + + Runtime MoqPassByRefSimple_genType_runtime } +// MoqPassByRefSimple_genType_mock isolates the mock interface of the // PassByRefSimple_genType type type MoqPassByRefSimple_genType_mock struct { Moq *MoqPassByRefSimple_genType @@ -53,6 +48,20 @@ type MoqPassByRefSimple_genType_recorder struct { Moq *MoqPassByRefSimple_genType } +// MoqPassByRefSimple_genType_runtime holds runtime configuration for the +// PassByRefSimple_genType type +type MoqPassByRefSimple_genType_runtime struct { + ParameterIndexing struct { + Usual MoqPassByRefSimple_genType_Usual_paramIndexing + } +} + +// MoqPassByRefSimple_genType_Usual_adaptor adapts MoqPassByRefSimple_genType +// as needed by the runtime +type MoqPassByRefSimple_genType_Usual_adaptor struct { + Moq *MoqPassByRefSimple_genType +} + // MoqPassByRefSimple_genType_Usual_params holds the params of the // PassByRefSimple_genType type type MoqPassByRefSimple_genType_Usual_params struct { @@ -73,12 +82,18 @@ type MoqPassByRefSimple_genType_Usual_paramsKey struct { } } -// MoqPassByRefSimple_genType_Usual_resultsByParams contains the results for a -// given set of parameters for the PassByRefSimple_genType type -type MoqPassByRefSimple_genType_Usual_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqPassByRefSimple_genType_Usual_paramsKey]*MoqPassByRefSimple_genType_Usual_results +// MoqPassByRefSimple_genType_Usual_results holds the results of the +// PassByRefSimple_genType type +type MoqPassByRefSimple_genType_Usual_results struct { + Result1 string + Result2 error +} + +// MoqPassByRefSimple_genType_Usual_paramIndexing holds the parameter indexing +// runtime configuration for the PassByRefSimple_genType type +type MoqPassByRefSimple_genType_Usual_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqPassByRefSimple_genType_Usual_doFn defines the type of function needed @@ -89,67 +104,41 @@ type MoqPassByRefSimple_genType_Usual_doFn func(string, bool) // needed when calling DoReturnResults for the PassByRefSimple_genType type type MoqPassByRefSimple_genType_Usual_doReturnFn func(string, bool) (string, error) -// MoqPassByRefSimple_genType_Usual_results holds the results of the -// PassByRefSimple_genType type -type MoqPassByRefSimple_genType_Usual_results struct { - Params MoqPassByRefSimple_genType_Usual_params - Results []struct { - Values *struct { - Result1 string - Result2 error - } - Sequence uint32 - DoFn MoqPassByRefSimple_genType_Usual_doFn - DoReturnFn MoqPassByRefSimple_genType_Usual_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqPassByRefSimple_genType_Usual_fnRecorder routes recorded function calls -// to the MoqPassByRefSimple_genType moq -type MoqPassByRefSimple_genType_Usual_fnRecorder struct { - Params MoqPassByRefSimple_genType_Usual_params - AnyParams uint64 - Sequence bool - Results *MoqPassByRefSimple_genType_Usual_results - Moq *MoqPassByRefSimple_genType +// MoqPassByRefSimple_genType_Usual_recorder routes recorded function calls to +// the MoqPassByRefSimple_genType moq +type MoqPassByRefSimple_genType_Usual_recorder struct { + Recorder *impl.Recorder[ + *MoqPassByRefSimple_genType_Usual_adaptor, + MoqPassByRefSimple_genType_Usual_params, + MoqPassByRefSimple_genType_Usual_paramsKey, + MoqPassByRefSimple_genType_Usual_results, + ] } // MoqPassByRefSimple_genType_Usual_anyParams isolates the any params functions // of the PassByRefSimple_genType type type MoqPassByRefSimple_genType_Usual_anyParams struct { - Recorder *MoqPassByRefSimple_genType_Usual_fnRecorder + Recorder *MoqPassByRefSimple_genType_Usual_recorder } // NewMoqPassByRefSimple_genType creates a new moq of the // PassByRefSimple_genType type func NewMoqPassByRefSimple_genType(scene *moq.Scene, config *moq.Config) *MoqPassByRefSimple_genType { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqPassByRefSimple_genType_Usual_adaptor{} m := &MoqPassByRefSimple_genType{ - Scene: scene, - Config: *config, - Moq: &MoqPassByRefSimple_genType_mock{}, - - Runtime: struct { - ParameterIndexing struct { - Usual struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - } - }{ParameterIndexing: struct { - Usual struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } + Moq: &MoqPassByRefSimple_genType_mock{}, + + Moq_Usual: impl.NewMoq[ + *MoqPassByRefSimple_genType_Usual_adaptor, + MoqPassByRefSimple_genType_Usual_params, + MoqPassByRefSimple_genType_Usual_paramsKey, + MoqPassByRefSimple_genType_Usual_results, + ](scene, adaptor1, config), + + Runtime: MoqPassByRefSimple_genType_runtime{ParameterIndexing: struct { + Usual MoqPassByRefSimple_genType_Usual_paramIndexing }{ - Usual: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - }{ + Usual: MoqPassByRefSimple_genType_Usual_paramIndexing{ Param1: moq.ParamIndexByValue, Param2: moq.ParamIndexByValue, }, @@ -157,6 +146,8 @@ func NewMoqPassByRefSimple_genType(scene *moq.Scene, config *moq.Config) *MoqPas } m.Moq.Moq = m + adaptor1.Moq = m + scene.AddMoq(m) return m } @@ -164,59 +155,20 @@ func NewMoqPassByRefSimple_genType(scene *moq.Scene, config *moq.Config) *MoqPas // Mock returns the mock implementation of the PassByRefSimple_genType type func (m *MoqPassByRefSimple_genType) Mock() *MoqPassByRefSimple_genType_mock { return m.Moq } -func (m *MoqPassByRefSimple_genType_mock) Usual(param1 string, param2 bool) (result1 string, result2 error) { - m.Moq.Scene.T.Helper() +func (m *MoqPassByRefSimple_genType_mock) Usual(param1 string, param2 bool) (string, error) { + m.Moq.Moq_Usual.Scene.T.Helper() params := MoqPassByRefSimple_genType_Usual_params{ Param1: param1, Param2: param2, } - var results *MoqPassByRefSimple_genType_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(param1, param2) - } - - if result.Values != nil { - result1 = result.Values.Result1 - result2 = result.Values.Result2 - } - if result.DoReturnFn != nil { - result1, result2 = result.DoReturnFn(param1, param2) + var result1 string + var result2 error + if result := m.Moq.Moq_Usual.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } - return + return result1, result2 } // OnCall returns the recorder implementation of the PassByRefSimple_genType @@ -227,219 +179,98 @@ func (m *MoqPassByRefSimple_genType) OnCall() *MoqPassByRefSimple_genType_record } } -func (m *MoqPassByRefSimple_genType_recorder) Usual(param1 string, param2 bool) *MoqPassByRefSimple_genType_Usual_fnRecorder { - return &MoqPassByRefSimple_genType_Usual_fnRecorder{ - Params: MoqPassByRefSimple_genType_Usual_params{ +func (m *MoqPassByRefSimple_genType_recorder) Usual(param1 string, param2 bool) *MoqPassByRefSimple_genType_Usual_recorder { + return &MoqPassByRefSimple_genType_Usual_recorder{ + Recorder: m.Moq.Moq_Usual.OnCall(MoqPassByRefSimple_genType_Usual_params{ Param1: param1, Param2: param2, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqPassByRefSimple_genType_Usual_fnRecorder) Any() *MoqPassByRefSimple_genType_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)) +func (r *MoqPassByRefSimple_genType_Usual_recorder) Any() *MoqPassByRefSimple_genType_Usual_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPassByRefSimple_genType_Usual_anyParams{Recorder: r} } -func (a *MoqPassByRefSimple_genType_Usual_anyParams) Param1() *MoqPassByRefSimple_genType_Usual_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPassByRefSimple_genType_Usual_anyParams) Param1() *MoqPassByRefSimple_genType_Usual_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqPassByRefSimple_genType_Usual_anyParams) Param2() *MoqPassByRefSimple_genType_Usual_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqPassByRefSimple_genType_Usual_anyParams) Param2() *MoqPassByRefSimple_genType_Usual_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (r *MoqPassByRefSimple_genType_Usual_fnRecorder) Seq() *MoqPassByRefSimple_genType_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)) +func (r *MoqPassByRefSimple_genType_Usual_recorder) Seq() *MoqPassByRefSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqPassByRefSimple_genType_Usual_fnRecorder) NoSeq() *MoqPassByRefSimple_genType_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)) +func (r *MoqPassByRefSimple_genType_Usual_recorder) NoSeq() *MoqPassByRefSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPassByRefSimple_genType_Usual_fnRecorder) ReturnResults(result1 string, result2 error) *MoqPassByRefSimple_genType_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 { - Result1 string - Result2 error - } - Sequence uint32 - DoFn MoqPassByRefSimple_genType_Usual_doFn - DoReturnFn MoqPassByRefSimple_genType_Usual_doReturnFn - }{ - Values: &struct { - Result1 string - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqPassByRefSimple_genType_Usual_recorder) ReturnResults(result1 string, result2 error) *MoqPassByRefSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPassByRefSimple_genType_Usual_results{ + Result1: result1, + Result2: result2, }) return r } -func (r *MoqPassByRefSimple_genType_Usual_fnRecorder) AndDo(fn MoqPassByRefSimple_genType_Usual_doFn) *MoqPassByRefSimple_genType_Usual_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqPassByRefSimple_genType_Usual_recorder) AndDo(fn MoqPassByRefSimple_genType_Usual_doFn) *MoqPassByRefSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPassByRefSimple_genType_Usual_params) { + fn(params.Param1, params.Param2) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPassByRefSimple_genType_Usual_fnRecorder) DoReturnResults(fn MoqPassByRefSimple_genType_Usual_doReturnFn) *MoqPassByRefSimple_genType_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 { - Result1 string - Result2 error +func (r *MoqPassByRefSimple_genType_Usual_recorder) DoReturnResults(fn MoqPassByRefSimple_genType_Usual_doReturnFn) *MoqPassByRefSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPassByRefSimple_genType_Usual_params) *MoqPassByRefSimple_genType_Usual_results { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqPassByRefSimple_genType_Usual_results{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqPassByRefSimple_genType_Usual_doFn - DoReturnFn MoqPassByRefSimple_genType_Usual_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPassByRefSimple_genType_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 *MoqPassByRefSimple_genType_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 = &MoqPassByRefSimple_genType_Usual_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPassByRefSimple_genType_Usual_paramsKey]*MoqPassByRefSimple_genType_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 = &MoqPassByRefSimple_genType_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 *MoqPassByRefSimple_genType_Usual_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqPassByRefSimple_genType_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") +func (r *MoqPassByRefSimple_genType_Usual_recorder) Repeat(repeaters ...moq.Repeater) *MoqPassByRefSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 MoqPassByRefSimple_genType_Usual_doFn - DoReturnFn MoqPassByRefSimple_genType_Usual_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqPassByRefSimple_genType) PrettyParams_Usual(params MoqPassByRefSimple_genType_Usual_params) string { +func (*MoqPassByRefSimple_genType_Usual_adaptor) PrettyParams(params MoqPassByRefSimple_genType_Usual_params) string { return fmt.Sprintf("Usual(%#v, %#v)", params.Param1, params.Param2) } -func (m *MoqPassByRefSimple_genType) ParamsKey_Usual(params MoqPassByRefSimple_genType_Usual_params, anyParams uint64) MoqPassByRefSimple_genType_Usual_paramsKey { - 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) - } - } +func (a *MoqPassByRefSimple_genType_Usual_adaptor) ParamsKey(params MoqPassByRefSimple_genType_Usual_params, anyParams uint64) MoqPassByRefSimple_genType_Usual_paramsKey { + a.Moq.Moq_Usual.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.Usual.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.Usual.Param2, anyParams) return MoqPassByRefSimple_genType_Usual_paramsKey{ Params: struct { Param1 string @@ -459,17 +290,12 @@ func (m *MoqPassByRefSimple_genType) ParamsKey_Usual(params MoqPassByRefSimple_g } // Reset resets the state of the moq -func (m *MoqPassByRefSimple_genType) Reset() { m.ResultsByParams_Usual = nil } +func (m *MoqPassByRefSimple_genType) Reset() { + m.Moq_Usual.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqPassByRefSimple_genType) 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)) - } - } - } + m.Moq_Usual.Scene.T.Helper() + m.Moq_Usual.AssertExpectationsMet() } diff --git a/pkg/testmoqs/pkgout/moq_passbyvaluesimple.go b/pkg/testmoqs/pkgout/moq_passbyvaluesimple.go index 3aade1d..3c8435a 100644 --- a/pkg/testmoqs/pkgout/moq_passbyvaluesimple.go +++ b/pkg/testmoqs/pkgout/moq_passbyvaluesimple.go @@ -4,10 +4,9 @@ package pkgout import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -25,23 +24,19 @@ type PassByValueSimple_genType interface { // MoqPassByValueSimple_genType holds the state of a moq of the // PassByValueSimple_genType type type MoqPassByValueSimple_genType struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqPassByValueSimple_genType_mock - - ResultsByParams_Usual []MoqPassByValueSimple_genType_Usual_resultsByParams - - Runtime struct { - ParameterIndexing struct { - Usual struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - } - } - // MoqPassByValueSimple_genType_mock isolates the mock interface of the + Moq *MoqPassByValueSimple_genType_mock + + Moq_Usual *impl.Moq[ + *MoqPassByValueSimple_genType_Usual_adaptor, + MoqPassByValueSimple_genType_Usual_params, + MoqPassByValueSimple_genType_Usual_paramsKey, + MoqPassByValueSimple_genType_Usual_results, + ] + + Runtime MoqPassByValueSimple_genType_runtime } +// MoqPassByValueSimple_genType_mock isolates the mock interface of the // PassByValueSimple_genType type type MoqPassByValueSimple_genType_mock struct { Moq *MoqPassByValueSimple_genType @@ -53,6 +48,20 @@ type MoqPassByValueSimple_genType_recorder struct { Moq *MoqPassByValueSimple_genType } +// MoqPassByValueSimple_genType_runtime holds runtime configuration for the +// PassByValueSimple_genType type +type MoqPassByValueSimple_genType_runtime struct { + ParameterIndexing struct { + Usual MoqPassByValueSimple_genType_Usual_paramIndexing + } +} + +// MoqPassByValueSimple_genType_Usual_adaptor adapts +// MoqPassByValueSimple_genType as needed by the runtime +type MoqPassByValueSimple_genType_Usual_adaptor struct { + Moq *MoqPassByValueSimple_genType +} + // MoqPassByValueSimple_genType_Usual_params holds the params of the // PassByValueSimple_genType type type MoqPassByValueSimple_genType_Usual_params struct { @@ -73,12 +82,18 @@ type MoqPassByValueSimple_genType_Usual_paramsKey struct { } } -// MoqPassByValueSimple_genType_Usual_resultsByParams contains the results for -// a given set of parameters for the PassByValueSimple_genType type -type MoqPassByValueSimple_genType_Usual_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqPassByValueSimple_genType_Usual_paramsKey]*MoqPassByValueSimple_genType_Usual_results +// MoqPassByValueSimple_genType_Usual_results holds the results of the +// PassByValueSimple_genType type +type MoqPassByValueSimple_genType_Usual_results struct { + Result1 string + Result2 error +} + +// MoqPassByValueSimple_genType_Usual_paramIndexing holds the parameter +// indexing runtime configuration for the PassByValueSimple_genType type +type MoqPassByValueSimple_genType_Usual_paramIndexing struct { + Param1 moq.ParamIndexing + Param2 moq.ParamIndexing } // MoqPassByValueSimple_genType_Usual_doFn defines the type of function needed @@ -89,67 +104,41 @@ type MoqPassByValueSimple_genType_Usual_doFn func(string, bool) // needed when calling DoReturnResults for the PassByValueSimple_genType type type MoqPassByValueSimple_genType_Usual_doReturnFn func(string, bool) (string, error) -// MoqPassByValueSimple_genType_Usual_results holds the results of the -// PassByValueSimple_genType type -type MoqPassByValueSimple_genType_Usual_results struct { - Params MoqPassByValueSimple_genType_Usual_params - Results []struct { - Values *struct { - Result1 string - Result2 error - } - Sequence uint32 - DoFn MoqPassByValueSimple_genType_Usual_doFn - DoReturnFn MoqPassByValueSimple_genType_Usual_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqPassByValueSimple_genType_Usual_fnRecorder routes recorded function calls +// MoqPassByValueSimple_genType_Usual_recorder routes recorded function calls // to the MoqPassByValueSimple_genType moq -type MoqPassByValueSimple_genType_Usual_fnRecorder struct { - Params MoqPassByValueSimple_genType_Usual_params - AnyParams uint64 - Sequence bool - Results *MoqPassByValueSimple_genType_Usual_results - Moq *MoqPassByValueSimple_genType +type MoqPassByValueSimple_genType_Usual_recorder struct { + Recorder *impl.Recorder[ + *MoqPassByValueSimple_genType_Usual_adaptor, + MoqPassByValueSimple_genType_Usual_params, + MoqPassByValueSimple_genType_Usual_paramsKey, + MoqPassByValueSimple_genType_Usual_results, + ] } // MoqPassByValueSimple_genType_Usual_anyParams isolates the any params // functions of the PassByValueSimple_genType type type MoqPassByValueSimple_genType_Usual_anyParams struct { - Recorder *MoqPassByValueSimple_genType_Usual_fnRecorder + Recorder *MoqPassByValueSimple_genType_Usual_recorder } // NewMoqPassByValueSimple_genType creates a new moq of the // PassByValueSimple_genType type func NewMoqPassByValueSimple_genType(scene *moq.Scene, config *moq.Config) *MoqPassByValueSimple_genType { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqPassByValueSimple_genType_Usual_adaptor{} m := &MoqPassByValueSimple_genType{ - Scene: scene, - Config: *config, - Moq: &MoqPassByValueSimple_genType_mock{}, - - Runtime: struct { - ParameterIndexing struct { - Usual struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } - } - }{ParameterIndexing: struct { - Usual struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - } + Moq: &MoqPassByValueSimple_genType_mock{}, + + Moq_Usual: impl.NewMoq[ + *MoqPassByValueSimple_genType_Usual_adaptor, + MoqPassByValueSimple_genType_Usual_params, + MoqPassByValueSimple_genType_Usual_paramsKey, + MoqPassByValueSimple_genType_Usual_results, + ](scene, adaptor1, config), + + Runtime: MoqPassByValueSimple_genType_runtime{ParameterIndexing: struct { + Usual MoqPassByValueSimple_genType_Usual_paramIndexing }{ - Usual: struct { - Param1 moq.ParamIndexing - Param2 moq.ParamIndexing - }{ + Usual: MoqPassByValueSimple_genType_Usual_paramIndexing{ Param1: moq.ParamIndexByValue, Param2: moq.ParamIndexByValue, }, @@ -157,6 +146,8 @@ func NewMoqPassByValueSimple_genType(scene *moq.Scene, config *moq.Config) *MoqP } m.Moq.Moq = m + adaptor1.Moq = m + scene.AddMoq(m) return m } @@ -164,59 +155,20 @@ func NewMoqPassByValueSimple_genType(scene *moq.Scene, config *moq.Config) *MoqP // Mock returns the mock implementation of the PassByValueSimple_genType type func (m *MoqPassByValueSimple_genType) Mock() *MoqPassByValueSimple_genType_mock { return m.Moq } -func (m *MoqPassByValueSimple_genType_mock) Usual(param1 string, param2 bool) (result1 string, result2 error) { - m.Moq.Scene.T.Helper() +func (m *MoqPassByValueSimple_genType_mock) Usual(param1 string, param2 bool) (string, error) { + m.Moq.Moq_Usual.Scene.T.Helper() params := MoqPassByValueSimple_genType_Usual_params{ Param1: param1, Param2: param2, } - var results *MoqPassByValueSimple_genType_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(param1, param2) - } - - if result.Values != nil { - result1 = result.Values.Result1 - result2 = result.Values.Result2 - } - if result.DoReturnFn != nil { - result1, result2 = result.DoReturnFn(param1, param2) + var result1 string + var result2 error + if result := m.Moq.Moq_Usual.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } - return + return result1, result2 } // OnCall returns the recorder implementation of the PassByValueSimple_genType @@ -227,219 +179,98 @@ func (m *MoqPassByValueSimple_genType) OnCall() *MoqPassByValueSimple_genType_re } } -func (m *MoqPassByValueSimple_genType_recorder) Usual(param1 string, param2 bool) *MoqPassByValueSimple_genType_Usual_fnRecorder { - return &MoqPassByValueSimple_genType_Usual_fnRecorder{ - Params: MoqPassByValueSimple_genType_Usual_params{ +func (m *MoqPassByValueSimple_genType_recorder) Usual(param1 string, param2 bool) *MoqPassByValueSimple_genType_Usual_recorder { + return &MoqPassByValueSimple_genType_Usual_recorder{ + Recorder: m.Moq.Moq_Usual.OnCall(MoqPassByValueSimple_genType_Usual_params{ Param1: param1, Param2: param2, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqPassByValueSimple_genType_Usual_fnRecorder) Any() *MoqPassByValueSimple_genType_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)) +func (r *MoqPassByValueSimple_genType_Usual_recorder) Any() *MoqPassByValueSimple_genType_Usual_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqPassByValueSimple_genType_Usual_anyParams{Recorder: r} } -func (a *MoqPassByValueSimple_genType_Usual_anyParams) Param1() *MoqPassByValueSimple_genType_Usual_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqPassByValueSimple_genType_Usual_anyParams) Param1() *MoqPassByValueSimple_genType_Usual_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqPassByValueSimple_genType_Usual_anyParams) Param2() *MoqPassByValueSimple_genType_Usual_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqPassByValueSimple_genType_Usual_anyParams) Param2() *MoqPassByValueSimple_genType_Usual_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (r *MoqPassByValueSimple_genType_Usual_fnRecorder) Seq() *MoqPassByValueSimple_genType_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)) +func (r *MoqPassByValueSimple_genType_Usual_recorder) Seq() *MoqPassByValueSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqPassByValueSimple_genType_Usual_fnRecorder) NoSeq() *MoqPassByValueSimple_genType_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)) +func (r *MoqPassByValueSimple_genType_Usual_recorder) NoSeq() *MoqPassByValueSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqPassByValueSimple_genType_Usual_fnRecorder) ReturnResults(result1 string, result2 error) *MoqPassByValueSimple_genType_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 { - Result1 string - Result2 error - } - Sequence uint32 - DoFn MoqPassByValueSimple_genType_Usual_doFn - DoReturnFn MoqPassByValueSimple_genType_Usual_doReturnFn - }{ - Values: &struct { - Result1 string - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqPassByValueSimple_genType_Usual_recorder) ReturnResults(result1 string, result2 error) *MoqPassByValueSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqPassByValueSimple_genType_Usual_results{ + Result1: result1, + Result2: result2, }) return r } -func (r *MoqPassByValueSimple_genType_Usual_fnRecorder) AndDo(fn MoqPassByValueSimple_genType_Usual_doFn) *MoqPassByValueSimple_genType_Usual_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqPassByValueSimple_genType_Usual_recorder) AndDo(fn MoqPassByValueSimple_genType_Usual_doFn) *MoqPassByValueSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqPassByValueSimple_genType_Usual_params) { + fn(params.Param1, params.Param2) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqPassByValueSimple_genType_Usual_fnRecorder) DoReturnResults(fn MoqPassByValueSimple_genType_Usual_doReturnFn) *MoqPassByValueSimple_genType_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 { - Result1 string - Result2 error +func (r *MoqPassByValueSimple_genType_Usual_recorder) DoReturnResults(fn MoqPassByValueSimple_genType_Usual_doReturnFn) *MoqPassByValueSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqPassByValueSimple_genType_Usual_params) *MoqPassByValueSimple_genType_Usual_results { + result1, result2 := fn(params.Param1, params.Param2) + return &MoqPassByValueSimple_genType_Usual_results{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqPassByValueSimple_genType_Usual_doFn - DoReturnFn MoqPassByValueSimple_genType_Usual_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqPassByValueSimple_genType_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 *MoqPassByValueSimple_genType_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 = &MoqPassByValueSimple_genType_Usual_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqPassByValueSimple_genType_Usual_paramsKey]*MoqPassByValueSimple_genType_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 = &MoqPassByValueSimple_genType_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 *MoqPassByValueSimple_genType_Usual_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqPassByValueSimple_genType_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") +func (r *MoqPassByValueSimple_genType_Usual_recorder) Repeat(repeaters ...moq.Repeater) *MoqPassByValueSimple_genType_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 MoqPassByValueSimple_genType_Usual_doFn - DoReturnFn MoqPassByValueSimple_genType_Usual_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqPassByValueSimple_genType) PrettyParams_Usual(params MoqPassByValueSimple_genType_Usual_params) string { +func (*MoqPassByValueSimple_genType_Usual_adaptor) PrettyParams(params MoqPassByValueSimple_genType_Usual_params) string { return fmt.Sprintf("Usual(%#v, %#v)", params.Param1, params.Param2) } -func (m *MoqPassByValueSimple_genType) ParamsKey_Usual(params MoqPassByValueSimple_genType_Usual_params, anyParams uint64) MoqPassByValueSimple_genType_Usual_paramsKey { - 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) - } - } +func (a *MoqPassByValueSimple_genType_Usual_adaptor) ParamsKey(params MoqPassByValueSimple_genType_Usual_params, anyParams uint64) MoqPassByValueSimple_genType_Usual_paramsKey { + a.Moq.Moq_Usual.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.Usual.Param1, anyParams) + param2Used, param2UsedHash := impl.ParamKey( + params.Param2, 2, a.Moq.Runtime.ParameterIndexing.Usual.Param2, anyParams) return MoqPassByValueSimple_genType_Usual_paramsKey{ Params: struct { Param1 string @@ -459,17 +290,12 @@ func (m *MoqPassByValueSimple_genType) ParamsKey_Usual(params MoqPassByValueSimp } // Reset resets the state of the moq -func (m *MoqPassByValueSimple_genType) Reset() { m.ResultsByParams_Usual = nil } +func (m *MoqPassByValueSimple_genType) Reset() { + m.Moq_Usual.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqPassByValueSimple_genType) 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)) - } - } - } + m.Moq_Usual.Scene.T.Helper() + m.Moq_Usual.AssertExpectationsMet() } diff --git a/pkg/testmoqs/pkgout/moq_reduced.go b/pkg/testmoqs/pkgout/moq_reduced.go index 3015cba..daab22c 100644 --- a/pkg/testmoqs/pkgout/moq_reduced.go +++ b/pkg/testmoqs/pkgout/moq_reduced.go @@ -4,10 +4,9 @@ package pkgout import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -25,26 +24,28 @@ type Reduced_reduced interface { // MoqReduced holds the state of a moq of the Reduced_reduced type type MoqReduced struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqReduced_mock - - ResultsByParams_Usual []MoqReduced_Usual_resultsByParams - ResultsByParams_ReallyUnusualParams []MoqReduced_ReallyUnusualParams_resultsByParams - ResultsByParams_ReallyUnusualResults []MoqReduced_ReallyUnusualResults_resultsByParams - - Runtime struct { - ParameterIndexing struct { - Usual struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - ReallyUnusualParams struct { - Param1 moq.ParamIndexing - } - ReallyUnusualResults struct{} - } - } + Moq *MoqReduced_mock + + Moq_Usual *impl.Moq[ + *MoqReduced_Usual_adaptor, + MoqReduced_Usual_params, + MoqReduced_Usual_paramsKey, + MoqReduced_Usual_results, + ] + Moq_ReallyUnusualParams *impl.Moq[ + *MoqReduced_ReallyUnusualParams_adaptor, + MoqReduced_ReallyUnusualParams_params, + MoqReduced_ReallyUnusualParams_paramsKey, + MoqReduced_ReallyUnusualParams_results, + ] + Moq_ReallyUnusualResults *impl.Moq[ + *MoqReduced_ReallyUnusualResults_adaptor, + MoqReduced_ReallyUnusualResults_params, + MoqReduced_ReallyUnusualResults_paramsKey, + MoqReduced_ReallyUnusualResults_results, + ] + + Runtime MoqReduced_runtime } // MoqReduced_mock isolates the mock interface of the Reduced type @@ -57,6 +58,20 @@ type MoqReduced_recorder struct { Moq *MoqReduced } +// MoqReduced_runtime holds runtime configuration for the Reduced type +type MoqReduced_runtime struct { + ParameterIndexing struct { + Usual MoqReduced_Usual_paramIndexing + ReallyUnusualParams MoqReduced_ReallyUnusualParams_paramIndexing + ReallyUnusualResults MoqReduced_ReallyUnusualResults_paramIndexing + } +} + +// MoqReduced_Usual_adaptor adapts MoqReduced as needed by the runtime +type MoqReduced_Usual_adaptor struct { + Moq *MoqReduced +} + // MoqReduced_Usual_params holds the params of the Reduced type type MoqReduced_Usual_params struct { SParam string @@ -75,12 +90,17 @@ type MoqReduced_Usual_paramsKey struct { } } -// MoqReduced_Usual_resultsByParams contains the results for a given set of -// parameters for the Reduced type -type MoqReduced_Usual_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqReduced_Usual_paramsKey]*MoqReduced_Usual_results +// MoqReduced_Usual_results holds the results of the Reduced type +type MoqReduced_Usual_results struct { + SResult string + Err error +} + +// MoqReduced_Usual_paramIndexing holds the parameter indexing runtime +// configuration for the Reduced type +type MoqReduced_Usual_paramIndexing struct { + SParam moq.ParamIndexing + BParam moq.ParamIndexing } // MoqReduced_Usual_doFn defines the type of function needed when calling AndDo @@ -91,36 +111,27 @@ type MoqReduced_Usual_doFn func(sParam string, bParam bool) // DoReturnResults for the Reduced type type MoqReduced_Usual_doReturnFn func(sParam string, bParam bool) (sResult string, err error) -// MoqReduced_Usual_results holds the results of the Reduced type -type MoqReduced_Usual_results struct { - Params MoqReduced_Usual_params - Results []struct { - Values *struct { - SResult string - Err error - } - Sequence uint32 - DoFn MoqReduced_Usual_doFn - DoReturnFn MoqReduced_Usual_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqReduced_Usual_fnRecorder routes recorded function calls to the MoqReduced +// MoqReduced_Usual_recorder routes recorded function calls to the MoqReduced // moq -type MoqReduced_Usual_fnRecorder struct { - Params MoqReduced_Usual_params - AnyParams uint64 - Sequence bool - Results *MoqReduced_Usual_results - Moq *MoqReduced +type MoqReduced_Usual_recorder struct { + Recorder *impl.Recorder[ + *MoqReduced_Usual_adaptor, + MoqReduced_Usual_params, + MoqReduced_Usual_paramsKey, + MoqReduced_Usual_results, + ] } // MoqReduced_Usual_anyParams isolates the any params functions of the Reduced // type type MoqReduced_Usual_anyParams struct { - Recorder *MoqReduced_Usual_fnRecorder + Recorder *MoqReduced_Usual_recorder +} + +// MoqReduced_ReallyUnusualParams_adaptor adapts MoqReduced as needed by the +// runtime +type MoqReduced_ReallyUnusualParams_adaptor struct { + Moq *MoqReduced } // MoqReduced_ReallyUnusualParams_params holds the params of the Reduced type @@ -133,12 +144,13 @@ type MoqReduced_ReallyUnusualParams_paramsKey struct { Hashes struct{ Param1 hash.Hash } } -// MoqReduced_ReallyUnusualParams_resultsByParams contains the results for a -// given set of parameters for the Reduced type -type MoqReduced_ReallyUnusualParams_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqReduced_ReallyUnusualParams_paramsKey]*MoqReduced_ReallyUnusualParams_results +// MoqReduced_ReallyUnusualParams_results holds the results of the Reduced type +type MoqReduced_ReallyUnusualParams_results struct{} + +// MoqReduced_ReallyUnusualParams_paramIndexing holds the parameter indexing +// runtime configuration for the Reduced type +type MoqReduced_ReallyUnusualParams_paramIndexing struct { + Param1 moq.ParamIndexing } // MoqReduced_ReallyUnusualParams_doFn defines the type of function needed when @@ -149,33 +161,27 @@ type MoqReduced_ReallyUnusualParams_doFn func(struct{ a string }) // needed when calling DoReturnResults for the Reduced type type MoqReduced_ReallyUnusualParams_doReturnFn func(struct{ a string }) -// MoqReduced_ReallyUnusualParams_results holds the results of the Reduced type -type MoqReduced_ReallyUnusualParams_results struct { - Params MoqReduced_ReallyUnusualParams_params - Results []struct { - Values *struct{} - Sequence uint32 - DoFn MoqReduced_ReallyUnusualParams_doFn - DoReturnFn MoqReduced_ReallyUnusualParams_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqReduced_ReallyUnusualParams_fnRecorder routes recorded function calls to +// MoqReduced_ReallyUnusualParams_recorder routes recorded function calls to // the MoqReduced moq -type MoqReduced_ReallyUnusualParams_fnRecorder struct { - Params MoqReduced_ReallyUnusualParams_params - AnyParams uint64 - Sequence bool - Results *MoqReduced_ReallyUnusualParams_results - Moq *MoqReduced +type MoqReduced_ReallyUnusualParams_recorder struct { + Recorder *impl.Recorder[ + *MoqReduced_ReallyUnusualParams_adaptor, + MoqReduced_ReallyUnusualParams_params, + MoqReduced_ReallyUnusualParams_paramsKey, + MoqReduced_ReallyUnusualParams_results, + ] } // MoqReduced_ReallyUnusualParams_anyParams isolates the any params functions // of the Reduced type type MoqReduced_ReallyUnusualParams_anyParams struct { - Recorder *MoqReduced_ReallyUnusualParams_fnRecorder + Recorder *MoqReduced_ReallyUnusualParams_recorder +} + +// MoqReduced_ReallyUnusualResults_adaptor adapts MoqReduced as needed by the +// runtime +type MoqReduced_ReallyUnusualResults_adaptor struct { + Moq *MoqReduced } // MoqReduced_ReallyUnusualResults_params holds the params of the Reduced type @@ -188,14 +194,16 @@ type MoqReduced_ReallyUnusualResults_paramsKey struct { Hashes struct{} } -// MoqReduced_ReallyUnusualResults_resultsByParams contains the results for a -// given set of parameters for the Reduced type -type MoqReduced_ReallyUnusualResults_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqReduced_ReallyUnusualResults_paramsKey]*MoqReduced_ReallyUnusualResults_results +// MoqReduced_ReallyUnusualResults_results holds the results of the Reduced +// type +type MoqReduced_ReallyUnusualResults_results struct { + Result1 struct{ a string } } +// MoqReduced_ReallyUnusualResults_paramIndexing holds the parameter indexing +// runtime configuration for the Reduced type +type MoqReduced_ReallyUnusualResults_paramIndexing struct{} + // MoqReduced_ReallyUnusualResults_doFn defines the type of function needed // when calling AndDo for the Reduced type type MoqReduced_ReallyUnusualResults_doFn func() @@ -204,86 +212,71 @@ type MoqReduced_ReallyUnusualResults_doFn func() // needed when calling DoReturnResults for the Reduced type type MoqReduced_ReallyUnusualResults_doReturnFn func() struct{ a string } -// MoqReduced_ReallyUnusualResults_results holds the results of the Reduced -// type -type MoqReduced_ReallyUnusualResults_results struct { - Params MoqReduced_ReallyUnusualResults_params - Results []struct { - Values *struct { - Result1 struct{ a string } - } - Sequence uint32 - DoFn MoqReduced_ReallyUnusualResults_doFn - DoReturnFn MoqReduced_ReallyUnusualResults_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqReduced_ReallyUnusualResults_fnRecorder routes recorded function calls to +// MoqReduced_ReallyUnusualResults_recorder routes recorded function calls to // the MoqReduced moq -type MoqReduced_ReallyUnusualResults_fnRecorder struct { - Params MoqReduced_ReallyUnusualResults_params - AnyParams uint64 - Sequence bool - Results *MoqReduced_ReallyUnusualResults_results - Moq *MoqReduced +type MoqReduced_ReallyUnusualResults_recorder struct { + Recorder *impl.Recorder[ + *MoqReduced_ReallyUnusualResults_adaptor, + MoqReduced_ReallyUnusualResults_params, + MoqReduced_ReallyUnusualResults_paramsKey, + MoqReduced_ReallyUnusualResults_results, + ] } // MoqReduced_ReallyUnusualResults_anyParams isolates the any params functions // of the Reduced type type MoqReduced_ReallyUnusualResults_anyParams struct { - Recorder *MoqReduced_ReallyUnusualResults_fnRecorder + Recorder *MoqReduced_ReallyUnusualResults_recorder } // NewMoqReduced creates a new moq of the Reduced type func NewMoqReduced(scene *moq.Scene, config *moq.Config) *MoqReduced { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqReduced_Usual_adaptor{} + adaptor2 := &MoqReduced_ReallyUnusualParams_adaptor{} + adaptor3 := &MoqReduced_ReallyUnusualResults_adaptor{} m := &MoqReduced{ - Scene: scene, - Config: *config, - Moq: &MoqReduced_mock{}, - - Runtime: struct { - ParameterIndexing struct { - Usual struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - ReallyUnusualParams struct { - Param1 moq.ParamIndexing - } - ReallyUnusualResults struct{} - } - }{ParameterIndexing: struct { - Usual struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - } - ReallyUnusualParams struct { - Param1 moq.ParamIndexing - } - ReallyUnusualResults struct{} + Moq: &MoqReduced_mock{}, + + Moq_Usual: impl.NewMoq[ + *MoqReduced_Usual_adaptor, + MoqReduced_Usual_params, + MoqReduced_Usual_paramsKey, + MoqReduced_Usual_results, + ](scene, adaptor1, config), + Moq_ReallyUnusualParams: impl.NewMoq[ + *MoqReduced_ReallyUnusualParams_adaptor, + MoqReduced_ReallyUnusualParams_params, + MoqReduced_ReallyUnusualParams_paramsKey, + MoqReduced_ReallyUnusualParams_results, + ](scene, adaptor2, config), + Moq_ReallyUnusualResults: impl.NewMoq[ + *MoqReduced_ReallyUnusualResults_adaptor, + MoqReduced_ReallyUnusualResults_params, + MoqReduced_ReallyUnusualResults_paramsKey, + MoqReduced_ReallyUnusualResults_results, + ](scene, adaptor3, config), + + Runtime: MoqReduced_runtime{ParameterIndexing: struct { + Usual MoqReduced_Usual_paramIndexing + ReallyUnusualParams MoqReduced_ReallyUnusualParams_paramIndexing + ReallyUnusualResults MoqReduced_ReallyUnusualResults_paramIndexing }{ - Usual: struct { - SParam moq.ParamIndexing - BParam moq.ParamIndexing - }{ + Usual: MoqReduced_Usual_paramIndexing{ SParam: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }, - ReallyUnusualParams: struct { - Param1 moq.ParamIndexing - }{ + ReallyUnusualParams: MoqReduced_ReallyUnusualParams_paramIndexing{ Param1: moq.ParamIndexByValue, }, - ReallyUnusualResults: struct{}{}, + ReallyUnusualResults: MoqReduced_ReallyUnusualResults_paramIndexing{}, }}, } m.Moq.Moq = m + adaptor1.Moq = m + adaptor2.Moq = m + adaptor3.Moq = m + scene.AddMoq(m) return m } @@ -291,160 +284,40 @@ func NewMoqReduced(scene *moq.Scene, config *moq.Config) *MoqReduced { // Mock returns the mock implementation of the Reduced type func (m *MoqReduced) Mock() *MoqReduced_mock { return m.Moq } -func (m *MoqReduced_mock) Usual(sParam string, bParam bool) (sResult string, err error) { - m.Moq.Scene.T.Helper() +func (m *MoqReduced_mock) Usual(sParam string, bParam bool) (string, error) { + m.Moq.Moq_Usual.Scene.T.Helper() params := MoqReduced_Usual_params{ SParam: sParam, BParam: bParam, } - var results *MoqReduced_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 + var result1 string + var result2 error + if result := m.Moq.Moq_Usual.Function(params); result != nil { + result1 = result.SResult + result2 = result.Err } - if result.DoReturnFn != nil { - sResult, err = result.DoReturnFn(sParam, bParam) - } - return + return result1, result2 } func (m *MoqReduced_mock) ReallyUnusualParams(param1 struct{ a string }) { - m.Moq.Scene.T.Helper() + m.Moq.Moq_ReallyUnusualParams.Scene.T.Helper() params := MoqReduced_ReallyUnusualParams_params{ Param1: param1, } - var results *MoqReduced_ReallyUnusualParams_results - for _, resultsByParams := range m.Moq.ResultsByParams_ReallyUnusualParams { - paramsKey := m.Moq.ParamsKey_ReallyUnusualParams(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_ReallyUnusualParams(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_ReallyUnusualParams(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_ReallyUnusualParams(params)) - } - } - - if result.DoFn != nil { - result.DoFn(param1) - } - - if result.DoReturnFn != nil { - result.DoReturnFn(param1) - } - return + m.Moq.Moq_ReallyUnusualParams.Function(params) } -func (m *MoqReduced_mock) ReallyUnusualResults() (result1 struct{ a string }) { - m.Moq.Scene.T.Helper() +func (m *MoqReduced_mock) ReallyUnusualResults() struct{ a string } { + m.Moq.Moq_ReallyUnusualResults.Scene.T.Helper() params := MoqReduced_ReallyUnusualResults_params{} - var results *MoqReduced_ReallyUnusualResults_results - for _, resultsByParams := range m.Moq.ResultsByParams_ReallyUnusualResults { - paramsKey := m.Moq.ParamsKey_ReallyUnusualResults(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_ReallyUnusualResults(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_ReallyUnusualResults(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_ReallyUnusualResults(params)) - } - } - - if result.DoFn != nil { - result.DoFn() - } - if result.Values != nil { - result1 = result.Values.Result1 - } - if result.DoReturnFn != nil { - result1 = result.DoReturnFn() + var result1 struct{ a string } + if result := m.Moq.Moq_ReallyUnusualResults.Function(params); result != nil { + result1 = result.Result1 } - return + return result1 } // OnCall returns the recorder implementation of the Reduced type @@ -454,219 +327,98 @@ func (m *MoqReduced) OnCall() *MoqReduced_recorder { } } -func (m *MoqReduced_recorder) Usual(sParam string, bParam bool) *MoqReduced_Usual_fnRecorder { - return &MoqReduced_Usual_fnRecorder{ - Params: MoqReduced_Usual_params{ +func (m *MoqReduced_recorder) Usual(sParam string, bParam bool) *MoqReduced_Usual_recorder { + return &MoqReduced_Usual_recorder{ + Recorder: m.Moq.Moq_Usual.OnCall(MoqReduced_Usual_params{ SParam: sParam, BParam: bParam, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqReduced_Usual_fnRecorder) Any() *MoqReduced_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)) +func (r *MoqReduced_Usual_recorder) Any() *MoqReduced_Usual_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqReduced_Usual_anyParams{Recorder: r} } -func (a *MoqReduced_Usual_anyParams) SParam() *MoqReduced_Usual_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqReduced_Usual_anyParams) SParam() *MoqReduced_Usual_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqReduced_Usual_anyParams) BParam() *MoqReduced_Usual_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqReduced_Usual_anyParams) BParam() *MoqReduced_Usual_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (r *MoqReduced_Usual_fnRecorder) Seq() *MoqReduced_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)) +func (r *MoqReduced_Usual_recorder) Seq() *MoqReduced_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqReduced_Usual_fnRecorder) NoSeq() *MoqReduced_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)) +func (r *MoqReduced_Usual_recorder) NoSeq() *MoqReduced_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqReduced_Usual_fnRecorder) ReturnResults(sResult string, err error) *MoqReduced_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 MoqReduced_Usual_doFn - DoReturnFn MoqReduced_Usual_doReturnFn - }{ - Values: &struct { - SResult string - Err error - }{ - SResult: sResult, - Err: err, - }, - Sequence: sequence, +func (r *MoqReduced_Usual_recorder) ReturnResults(sResult string, err error) *MoqReduced_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqReduced_Usual_results{ + SResult: sResult, + Err: err, }) return r } -func (r *MoqReduced_Usual_fnRecorder) AndDo(fn MoqReduced_Usual_doFn) *MoqReduced_Usual_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqReduced_Usual_recorder) AndDo(fn MoqReduced_Usual_doFn) *MoqReduced_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqReduced_Usual_params) { + fn(params.SParam, params.BParam) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqReduced_Usual_fnRecorder) DoReturnResults(fn MoqReduced_Usual_doReturnFn) *MoqReduced_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 +func (r *MoqReduced_Usual_recorder) DoReturnResults(fn MoqReduced_Usual_doReturnFn) *MoqReduced_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqReduced_Usual_params) *MoqReduced_Usual_results { + sResult, err := fn(params.SParam, params.BParam) + return &MoqReduced_Usual_results{ + SResult: sResult, + Err: err, } - Sequence uint32 - DoFn MoqReduced_Usual_doFn - DoReturnFn MoqReduced_Usual_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqReduced_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 *MoqReduced_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 = &MoqReduced_Usual_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqReduced_Usual_paramsKey]*MoqReduced_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 = &MoqReduced_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 *MoqReduced_Usual_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqReduced_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") +func (r *MoqReduced_Usual_recorder) Repeat(repeaters ...moq.Repeater) *MoqReduced_Usual_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 MoqReduced_Usual_doFn - DoReturnFn MoqReduced_Usual_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqReduced) PrettyParams_Usual(params MoqReduced_Usual_params) string { +func (*MoqReduced_Usual_adaptor) PrettyParams(params MoqReduced_Usual_params) string { return fmt.Sprintf("Usual(%#v, %#v)", params.SParam, params.BParam) } -func (m *MoqReduced) ParamsKey_Usual(params MoqReduced_Usual_params, anyParams uint64) MoqReduced_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) - } - } +func (a *MoqReduced_Usual_adaptor) ParamsKey(params MoqReduced_Usual_params, anyParams uint64) MoqReduced_Usual_paramsKey { + a.Moq.Moq_Usual.Scene.T.Helper() + sParamUsed, sParamUsedHash := impl.ParamKey( + params.SParam, 1, a.Moq.Runtime.ParameterIndexing.Usual.SParam, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 2, a.Moq.Runtime.ParameterIndexing.Usual.BParam, anyParams) return MoqReduced_Usual_paramsKey{ Params: struct { SParam string @@ -685,189 +437,84 @@ func (m *MoqReduced) ParamsKey_Usual(params MoqReduced_Usual_params, anyParams u } } -func (m *MoqReduced_recorder) ReallyUnusualParams(param1 struct{ a string }) *MoqReduced_ReallyUnusualParams_fnRecorder { - return &MoqReduced_ReallyUnusualParams_fnRecorder{ - Params: MoqReduced_ReallyUnusualParams_params{ +func (m *MoqReduced_recorder) ReallyUnusualParams(param1 struct{ a string }) *MoqReduced_ReallyUnusualParams_recorder { + return &MoqReduced_ReallyUnusualParams_recorder{ + Recorder: m.Moq.Moq_ReallyUnusualParams.OnCall(MoqReduced_ReallyUnusualParams_params{ Param1: param1, - }, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, + }), } } -func (r *MoqReduced_ReallyUnusualParams_fnRecorder) Any() *MoqReduced_ReallyUnusualParams_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_ReallyUnusualParams(r.Params)) +func (r *MoqReduced_ReallyUnusualParams_recorder) Any() *MoqReduced_ReallyUnusualParams_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqReduced_ReallyUnusualParams_anyParams{Recorder: r} } -func (a *MoqReduced_ReallyUnusualParams_anyParams) Param1() *MoqReduced_ReallyUnusualParams_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqReduced_ReallyUnusualParams_anyParams) Param1() *MoqReduced_ReallyUnusualParams_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (r *MoqReduced_ReallyUnusualParams_fnRecorder) Seq() *MoqReduced_ReallyUnusualParams_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_ReallyUnusualParams(r.Params)) +func (r *MoqReduced_ReallyUnusualParams_recorder) Seq() *MoqReduced_ReallyUnusualParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqReduced_ReallyUnusualParams_fnRecorder) NoSeq() *MoqReduced_ReallyUnusualParams_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_ReallyUnusualParams(r.Params)) +func (r *MoqReduced_ReallyUnusualParams_recorder) NoSeq() *MoqReduced_ReallyUnusualParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqReduced_ReallyUnusualParams_fnRecorder) ReturnResults() *MoqReduced_ReallyUnusualParams_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 MoqReduced_ReallyUnusualParams_doFn - DoReturnFn MoqReduced_ReallyUnusualParams_doReturnFn - }{ - Values: &struct{}{}, - Sequence: sequence, - }) +func (r *MoqReduced_ReallyUnusualParams_recorder) ReturnResults() *MoqReduced_ReallyUnusualParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqReduced_ReallyUnusualParams_results{}) return r } -func (r *MoqReduced_ReallyUnusualParams_fnRecorder) AndDo(fn MoqReduced_ReallyUnusualParams_doFn) *MoqReduced_ReallyUnusualParams_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqReduced_ReallyUnusualParams_recorder) AndDo(fn MoqReduced_ReallyUnusualParams_doFn) *MoqReduced_ReallyUnusualParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqReduced_ReallyUnusualParams_params) { + fn(params.Param1) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqReduced_ReallyUnusualParams_fnRecorder) DoReturnResults(fn MoqReduced_ReallyUnusualParams_doReturnFn) *MoqReduced_ReallyUnusualParams_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 MoqReduced_ReallyUnusualParams_doFn - DoReturnFn MoqReduced_ReallyUnusualParams_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) +func (r *MoqReduced_ReallyUnusualParams_recorder) DoReturnResults(fn MoqReduced_ReallyUnusualParams_doReturnFn) *MoqReduced_ReallyUnusualParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqReduced_ReallyUnusualParams_params) *MoqReduced_ReallyUnusualParams_results { + fn(params.Param1) + return &MoqReduced_ReallyUnusualParams_results{} + }) return r } -func (r *MoqReduced_ReallyUnusualParams_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 *MoqReduced_ReallyUnusualParams_resultsByParams - for n, res := range r.Moq.ResultsByParams_ReallyUnusualParams { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqReduced_ReallyUnusualParams_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqReduced_ReallyUnusualParams_paramsKey]*MoqReduced_ReallyUnusualParams_results{}, - } - r.Moq.ResultsByParams_ReallyUnusualParams = append(r.Moq.ResultsByParams_ReallyUnusualParams, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_ReallyUnusualParams) { - copy(r.Moq.ResultsByParams_ReallyUnusualParams[insertAt+1:], r.Moq.ResultsByParams_ReallyUnusualParams[insertAt:0]) - r.Moq.ResultsByParams_ReallyUnusualParams[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_ReallyUnusualParams(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqReduced_ReallyUnusualParams_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 *MoqReduced_ReallyUnusualParams_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqReduced_ReallyUnusualParams_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqReduced_ReallyUnusualParams_recorder) Repeat(repeaters ...moq.Repeater) *MoqReduced_ReallyUnusualParams_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 MoqReduced_ReallyUnusualParams_doFn - DoReturnFn MoqReduced_ReallyUnusualParams_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqReduced) PrettyParams_ReallyUnusualParams(params MoqReduced_ReallyUnusualParams_params) string { +func (*MoqReduced_ReallyUnusualParams_adaptor) PrettyParams(params MoqReduced_ReallyUnusualParams_params) string { return fmt.Sprintf("ReallyUnusualParams(%#v)", params.Param1) } -func (m *MoqReduced) ParamsKey_ReallyUnusualParams(params MoqReduced_ReallyUnusualParams_params, anyParams uint64) MoqReduced_ReallyUnusualParams_paramsKey { - m.Scene.T.Helper() - var param1Used struct{ a string } - var param1UsedHash hash.Hash - if anyParams&(1<<0) == 0 { - if m.Runtime.ParameterIndexing.ReallyUnusualParams.Param1 == moq.ParamIndexByValue { - param1Used = params.Param1 - } else { - param1UsedHash = hash.DeepHash(params.Param1) - } - } +func (a *MoqReduced_ReallyUnusualParams_adaptor) ParamsKey(params MoqReduced_ReallyUnusualParams_params, anyParams uint64) MoqReduced_ReallyUnusualParams_paramsKey { + a.Moq.Moq_ReallyUnusualParams.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.ReallyUnusualParams.Param1, anyParams) return MoqReduced_ReallyUnusualParams_paramsKey{ Params: struct{ Param1 struct{ a string } }{ Param1: param1Used, @@ -878,183 +525,79 @@ func (m *MoqReduced) ParamsKey_ReallyUnusualParams(params MoqReduced_ReallyUnusu } } -func (m *MoqReduced_recorder) ReallyUnusualResults() *MoqReduced_ReallyUnusualResults_fnRecorder { - return &MoqReduced_ReallyUnusualResults_fnRecorder{ - Params: MoqReduced_ReallyUnusualResults_params{}, - Sequence: m.Moq.Config.Sequence == moq.SeqDefaultOn, - Moq: m.Moq, +func (m *MoqReduced_recorder) ReallyUnusualResults() *MoqReduced_ReallyUnusualResults_recorder { + return &MoqReduced_ReallyUnusualResults_recorder{ + Recorder: m.Moq.Moq_ReallyUnusualResults.OnCall(MoqReduced_ReallyUnusualResults_params{}), } } -func (r *MoqReduced_ReallyUnusualResults_fnRecorder) Any() *MoqReduced_ReallyUnusualResults_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_ReallyUnusualResults(r.Params)) +func (r *MoqReduced_ReallyUnusualResults_recorder) Any() *MoqReduced_ReallyUnusualResults_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqReduced_ReallyUnusualResults_anyParams{Recorder: r} } -func (r *MoqReduced_ReallyUnusualResults_fnRecorder) Seq() *MoqReduced_ReallyUnusualResults_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_ReallyUnusualResults(r.Params)) +func (r *MoqReduced_ReallyUnusualResults_recorder) Seq() *MoqReduced_ReallyUnusualResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqReduced_ReallyUnusualResults_fnRecorder) NoSeq() *MoqReduced_ReallyUnusualResults_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_ReallyUnusualResults(r.Params)) +func (r *MoqReduced_ReallyUnusualResults_recorder) NoSeq() *MoqReduced_ReallyUnusualResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqReduced_ReallyUnusualResults_fnRecorder) ReturnResults(result1 struct{ a string }) *MoqReduced_ReallyUnusualResults_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 struct{ a string } - } - Sequence uint32 - DoFn MoqReduced_ReallyUnusualResults_doFn - DoReturnFn MoqReduced_ReallyUnusualResults_doReturnFn - }{ - Values: &struct { - Result1 struct{ a string } - }{ - Result1: result1, - }, - Sequence: sequence, +func (r *MoqReduced_ReallyUnusualResults_recorder) ReturnResults(result1 struct{ a string }) *MoqReduced_ReallyUnusualResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqReduced_ReallyUnusualResults_results{ + Result1: result1, }) return r } -func (r *MoqReduced_ReallyUnusualResults_fnRecorder) AndDo(fn MoqReduced_ReallyUnusualResults_doFn) *MoqReduced_ReallyUnusualResults_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqReduced_ReallyUnusualResults_recorder) AndDo(fn MoqReduced_ReallyUnusualResults_doFn) *MoqReduced_ReallyUnusualResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqReduced_ReallyUnusualResults_params) { + fn() + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqReduced_ReallyUnusualResults_fnRecorder) DoReturnResults(fn MoqReduced_ReallyUnusualResults_doReturnFn) *MoqReduced_ReallyUnusualResults_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 struct{ a string } +func (r *MoqReduced_ReallyUnusualResults_recorder) DoReturnResults(fn MoqReduced_ReallyUnusualResults_doReturnFn) *MoqReduced_ReallyUnusualResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqReduced_ReallyUnusualResults_params) *MoqReduced_ReallyUnusualResults_results { + result1 := fn() + return &MoqReduced_ReallyUnusualResults_results{ + Result1: result1, } - Sequence uint32 - DoFn MoqReduced_ReallyUnusualResults_doFn - DoReturnFn MoqReduced_ReallyUnusualResults_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqReduced_ReallyUnusualResults_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 *MoqReduced_ReallyUnusualResults_resultsByParams - for n, res := range r.Moq.ResultsByParams_ReallyUnusualResults { - if res.AnyParams == r.AnyParams { - results = &res - break - } - if res.AnyCount > anyCount { - insertAt = n - } - } - if results == nil { - results = &MoqReduced_ReallyUnusualResults_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqReduced_ReallyUnusualResults_paramsKey]*MoqReduced_ReallyUnusualResults_results{}, - } - r.Moq.ResultsByParams_ReallyUnusualResults = append(r.Moq.ResultsByParams_ReallyUnusualResults, *results) - if insertAt != -1 && insertAt+1 < len(r.Moq.ResultsByParams_ReallyUnusualResults) { - copy(r.Moq.ResultsByParams_ReallyUnusualResults[insertAt+1:], r.Moq.ResultsByParams_ReallyUnusualResults[insertAt:0]) - r.Moq.ResultsByParams_ReallyUnusualResults[insertAt] = *results - } - } - - paramsKey := r.Moq.ParamsKey_ReallyUnusualResults(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqReduced_ReallyUnusualResults_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 *MoqReduced_ReallyUnusualResults_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqReduced_ReallyUnusualResults_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqReduced_ReallyUnusualResults_recorder) Repeat(repeaters ...moq.Repeater) *MoqReduced_ReallyUnusualResults_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 struct{ a string } - } - Sequence uint32 - DoFn MoqReduced_ReallyUnusualResults_doFn - DoReturnFn MoqReduced_ReallyUnusualResults_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqReduced) PrettyParams_ReallyUnusualResults(params MoqReduced_ReallyUnusualResults_params) string { +func (*MoqReduced_ReallyUnusualResults_adaptor) PrettyParams(params MoqReduced_ReallyUnusualResults_params) string { return fmt.Sprintf("ReallyUnusualResults()") } -func (m *MoqReduced) ParamsKey_ReallyUnusualResults(params MoqReduced_ReallyUnusualResults_params, anyParams uint64) MoqReduced_ReallyUnusualResults_paramsKey { - m.Scene.T.Helper() +func (a *MoqReduced_ReallyUnusualResults_adaptor) ParamsKey(params MoqReduced_ReallyUnusualResults_params, anyParams uint64) MoqReduced_ReallyUnusualResults_paramsKey { + a.Moq.Moq_ReallyUnusualResults.Scene.T.Helper() return MoqReduced_ReallyUnusualResults_paramsKey{ Params: struct{}{}, Hashes: struct{}{}, @@ -1063,36 +606,15 @@ func (m *MoqReduced) ParamsKey_ReallyUnusualResults(params MoqReduced_ReallyUnus // Reset resets the state of the moq func (m *MoqReduced) Reset() { - m.ResultsByParams_Usual = nil - m.ResultsByParams_ReallyUnusualParams = nil - m.ResultsByParams_ReallyUnusualResults = nil + m.Moq_Usual.Reset() + m.Moq_ReallyUnusualParams.Reset() + m.Moq_ReallyUnusualResults.Reset() } // AssertExpectationsMet asserts that all expectations have been met func (m *MoqReduced) 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)) - } - } - } - for _, res := range m.ResultsByParams_ReallyUnusualParams { - 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_ReallyUnusualParams(results.Params)) - } - } - } - for _, res := range m.ResultsByParams_ReallyUnusualResults { - 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_ReallyUnusualResults(results.Params)) - } - } - } + m.Moq_Usual.Scene.T.Helper() + m.Moq_Usual.AssertExpectationsMet() + m.Moq_ReallyUnusualParams.AssertExpectationsMet() + m.Moq_ReallyUnusualResults.AssertExpectationsMet() } diff --git a/pkg/testmoqs/pkgout/moq_standalonefunc.go b/pkg/testmoqs/pkgout/moq_standalonefunc.go index 3ed63cd..37ef275 100644 --- a/pkg/testmoqs/pkgout/moq_standalonefunc.go +++ b/pkg/testmoqs/pkgout/moq_standalonefunc.go @@ -4,10 +4,9 @@ package pkgout import ( "fmt" - "math/bits" - "sync/atomic" "moqueries.org/runtime/hash" + "moqueries.org/runtime/impl" "moqueries.org/runtime/moq" ) @@ -18,23 +17,25 @@ type StandaloneFunc_genType func(_ string, bParam bool) (string, error) // MoqStandaloneFunc_genType holds the state of a moq of the // StandaloneFunc_genType type type MoqStandaloneFunc_genType struct { - Scene *moq.Scene - Config moq.Config - Moq *MoqStandaloneFunc_genType_mock - - ResultsByParams []MoqStandaloneFunc_genType_resultsByParams - - Runtime struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - BParam moq.ParamIndexing - } - } + Moq *impl.Moq[ + *MoqStandaloneFunc_genType_adaptor, + MoqStandaloneFunc_genType_params, + MoqStandaloneFunc_genType_paramsKey, + MoqStandaloneFunc_genType_results, + ] + + Runtime MoqStandaloneFunc_genType_runtime } -// MoqStandaloneFunc_genType_mock isolates the mock interface of the +// MoqStandaloneFunc_genType_runtime holds runtime configuration for the // StandaloneFunc_genType type -type MoqStandaloneFunc_genType_mock struct { +type MoqStandaloneFunc_genType_runtime struct { + ParameterIndexing MoqStandaloneFunc_genType_paramIndexing +} + +// MoqStandaloneFunc_genType_adaptor adapts MoqStandaloneFunc_genType as needed +// by the runtime +type MoqStandaloneFunc_genType_adaptor struct { Moq *MoqStandaloneFunc_genType } @@ -58,12 +59,18 @@ type MoqStandaloneFunc_genType_paramsKey struct { } } -// MoqStandaloneFunc_genType_resultsByParams contains the results for a given -// set of parameters for the StandaloneFunc_genType type -type MoqStandaloneFunc_genType_resultsByParams struct { - AnyCount int - AnyParams uint64 - Results map[MoqStandaloneFunc_genType_paramsKey]*MoqStandaloneFunc_genType_results +// MoqStandaloneFunc_genType_results holds the results of the +// StandaloneFunc_genType type +type MoqStandaloneFunc_genType_results struct { + Result1 string + Result2 error +} + +// MoqStandaloneFunc_genType_paramIndexing holds the parameter indexing runtime +// configuration for the StandaloneFunc_genType type +type MoqStandaloneFunc_genType_paramIndexing struct { + Param1 moq.ParamIndexing + BParam moq.ParamIndexing } // MoqStandaloneFunc_genType_doFn defines the type of function needed when @@ -74,64 +81,41 @@ type MoqStandaloneFunc_genType_doFn func(_ string, bParam bool) // when calling DoReturnResults for the StandaloneFunc_genType type type MoqStandaloneFunc_genType_doReturnFn func(_ string, bParam bool) (string, error) -// MoqStandaloneFunc_genType_results holds the results of the -// StandaloneFunc_genType type -type MoqStandaloneFunc_genType_results struct { - Params MoqStandaloneFunc_genType_params - Results []struct { - Values *struct { - Result1 string - Result2 error - } - Sequence uint32 - DoFn MoqStandaloneFunc_genType_doFn - DoReturnFn MoqStandaloneFunc_genType_doReturnFn - } - Index uint32 - Repeat *moq.RepeatVal -} - -// MoqStandaloneFunc_genType_fnRecorder routes recorded function calls to the +// MoqStandaloneFunc_genType_recorder routes recorded function calls to the // MoqStandaloneFunc_genType moq -type MoqStandaloneFunc_genType_fnRecorder struct { - Params MoqStandaloneFunc_genType_params - AnyParams uint64 - Sequence bool - Results *MoqStandaloneFunc_genType_results - Moq *MoqStandaloneFunc_genType +type MoqStandaloneFunc_genType_recorder struct { + Recorder *impl.Recorder[ + *MoqStandaloneFunc_genType_adaptor, + MoqStandaloneFunc_genType_params, + MoqStandaloneFunc_genType_paramsKey, + MoqStandaloneFunc_genType_results, + ] } // MoqStandaloneFunc_genType_anyParams isolates the any params functions of the // StandaloneFunc_genType type type MoqStandaloneFunc_genType_anyParams struct { - Recorder *MoqStandaloneFunc_genType_fnRecorder + Recorder *MoqStandaloneFunc_genType_recorder } // NewMoqStandaloneFunc_genType creates a new moq of the StandaloneFunc_genType // type func NewMoqStandaloneFunc_genType(scene *moq.Scene, config *moq.Config) *MoqStandaloneFunc_genType { - if config == nil { - config = &moq.Config{} - } + adaptor1 := &MoqStandaloneFunc_genType_adaptor{} m := &MoqStandaloneFunc_genType{ - Scene: scene, - Config: *config, - Moq: &MoqStandaloneFunc_genType_mock{}, - - Runtime: struct { - ParameterIndexing struct { - Param1 moq.ParamIndexing - BParam moq.ParamIndexing - } - }{ParameterIndexing: struct { - Param1 moq.ParamIndexing - BParam moq.ParamIndexing - }{ + Moq: impl.NewMoq[ + *MoqStandaloneFunc_genType_adaptor, + MoqStandaloneFunc_genType_params, + MoqStandaloneFunc_genType_paramsKey, + MoqStandaloneFunc_genType_results, + ](scene, adaptor1, config), + + Runtime: MoqStandaloneFunc_genType_runtime{ParameterIndexing: MoqStandaloneFunc_genType_paramIndexing{ Param1: moq.ParamIndexByValue, BParam: moq.ParamIndexByValue, }}, } - m.Moq.Moq = m + adaptor1.Moq = m scene.AddMoq(m) return m @@ -140,280 +124,114 @@ func NewMoqStandaloneFunc_genType(scene *moq.Scene, config *moq.Config) *MoqStan // Mock returns the moq implementation of the StandaloneFunc_genType type func (m *MoqStandaloneFunc_genType) Mock() StandaloneFunc_genType { return func(param1 string, bParam bool) (string, error) { - m.Scene.T.Helper() - moq := &MoqStandaloneFunc_genType_mock{Moq: m} - return moq.Fn(param1, bParam) - } -} - -func (m *MoqStandaloneFunc_genType_mock) Fn(param1 string, bParam bool) (result1 string, result2 error) { - m.Moq.Scene.T.Helper() - params := MoqStandaloneFunc_genType_params{ - Param1: param1, - BParam: bParam, - } - var results *MoqStandaloneFunc_genType_results - 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 + m.Moq.Scene.T.Helper() + params := MoqStandaloneFunc_genType_params{ + Param1: param1, + BParam: bParam, } - 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)) + var result1 string + var result2 error + if result := m.Moq.Function(params); result != nil { + result1 = result.Result1 + result2 = result.Result2 } + return result1, result2 } - - if result.DoFn != nil { - result.DoFn(param1, bParam) - } - - if result.Values != nil { - result1 = result.Values.Result1 - result2 = result.Values.Result2 - } - if result.DoReturnFn != nil { - result1, result2 = result.DoReturnFn(param1, bParam) - } - return } -func (m *MoqStandaloneFunc_genType) OnCall(param1 string, bParam bool) *MoqStandaloneFunc_genType_fnRecorder { - return &MoqStandaloneFunc_genType_fnRecorder{ - Params: MoqStandaloneFunc_genType_params{ +func (m *MoqStandaloneFunc_genType) OnCall(param1 string, bParam bool) *MoqStandaloneFunc_genType_recorder { + return &MoqStandaloneFunc_genType_recorder{ + Recorder: m.Moq.OnCall(MoqStandaloneFunc_genType_params{ Param1: param1, BParam: bParam, - }, - Sequence: m.Config.Sequence == moq.SeqDefaultOn, - Moq: m, + }), } } -func (r *MoqStandaloneFunc_genType_fnRecorder) Any() *MoqStandaloneFunc_genType_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(r.Params)) +func (r *MoqStandaloneFunc_genType_recorder) Any() *MoqStandaloneFunc_genType_anyParams { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.IsAnyPermitted(true) { return nil } return &MoqStandaloneFunc_genType_anyParams{Recorder: r} } -func (a *MoqStandaloneFunc_genType_anyParams) Param1() *MoqStandaloneFunc_genType_fnRecorder { - a.Recorder.AnyParams |= 1 << 0 +func (a *MoqStandaloneFunc_genType_anyParams) Param1() *MoqStandaloneFunc_genType_recorder { + a.Recorder.Recorder.AnyParam(1) return a.Recorder } -func (a *MoqStandaloneFunc_genType_anyParams) BParam() *MoqStandaloneFunc_genType_fnRecorder { - a.Recorder.AnyParams |= 1 << 1 +func (a *MoqStandaloneFunc_genType_anyParams) BParam() *MoqStandaloneFunc_genType_recorder { + a.Recorder.Recorder.AnyParam(2) return a.Recorder } -func (r *MoqStandaloneFunc_genType_fnRecorder) Seq() *MoqStandaloneFunc_genType_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(r.Params)) +func (r *MoqStandaloneFunc_genType_recorder) Seq() *MoqStandaloneFunc_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(true, "Seq", true) { return nil } - r.Sequence = true return r } -func (r *MoqStandaloneFunc_genType_fnRecorder) NoSeq() *MoqStandaloneFunc_genType_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(r.Params)) +func (r *MoqStandaloneFunc_genType_recorder) NoSeq() *MoqStandaloneFunc_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Seq(false, "NoSeq", true) { return nil } - r.Sequence = false return r } -func (r *MoqStandaloneFunc_genType_fnRecorder) ReturnResults(result1 string, result2 error) *MoqStandaloneFunc_genType_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 MoqStandaloneFunc_genType_doFn - DoReturnFn MoqStandaloneFunc_genType_doReturnFn - }{ - Values: &struct { - Result1 string - Result2 error - }{ - Result1: result1, - Result2: result2, - }, - Sequence: sequence, +func (r *MoqStandaloneFunc_genType_recorder) ReturnResults(result1 string, result2 error) *MoqStandaloneFunc_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.ReturnResults(MoqStandaloneFunc_genType_results{ + Result1: result1, + Result2: result2, }) return r } -func (r *MoqStandaloneFunc_genType_fnRecorder) AndDo(fn MoqStandaloneFunc_genType_doFn) *MoqStandaloneFunc_genType_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults must be called before calling AndDo") +func (r *MoqStandaloneFunc_genType_recorder) AndDo(fn MoqStandaloneFunc_genType_doFn) *MoqStandaloneFunc_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.AndDo(func(params MoqStandaloneFunc_genType_params) { + fn(params.Param1, params.BParam) + }, true) { return nil } - last := &r.Results.Results[len(r.Results.Results)-1] - last.DoFn = fn return r } -func (r *MoqStandaloneFunc_genType_fnRecorder) DoReturnResults(fn MoqStandaloneFunc_genType_doReturnFn) *MoqStandaloneFunc_genType_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 +func (r *MoqStandaloneFunc_genType_recorder) DoReturnResults(fn MoqStandaloneFunc_genType_doReturnFn) *MoqStandaloneFunc_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + r.Recorder.DoReturnResults(func(params MoqStandaloneFunc_genType_params) *MoqStandaloneFunc_genType_results { + result1, result2 := fn(params.Param1, params.BParam) + return &MoqStandaloneFunc_genType_results{ + Result1: result1, + Result2: result2, } - Sequence uint32 - DoFn MoqStandaloneFunc_genType_doFn - DoReturnFn MoqStandaloneFunc_genType_doReturnFn - }{Sequence: sequence, DoReturnFn: fn}) + }) return r } -func (r *MoqStandaloneFunc_genType_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 *MoqStandaloneFunc_genType_resultsByParams - 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 = &MoqStandaloneFunc_genType_resultsByParams{ - AnyCount: anyCount, - AnyParams: r.AnyParams, - Results: map[MoqStandaloneFunc_genType_paramsKey]*MoqStandaloneFunc_genType_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(r.Params, r.AnyParams) - - var ok bool - r.Results, ok = results.Results[paramsKey] - if !ok { - r.Results = &MoqStandaloneFunc_genType_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 *MoqStandaloneFunc_genType_fnRecorder) Repeat(repeaters ...moq.Repeater) *MoqStandaloneFunc_genType_fnRecorder { - r.Moq.Scene.T.Helper() - if r.Results == nil { - r.Moq.Scene.T.Fatalf("ReturnResults or DoReturnResults must be called before calling Repeat") +func (r *MoqStandaloneFunc_genType_recorder) Repeat(repeaters ...moq.Repeater) *MoqStandaloneFunc_genType_recorder { + r.Recorder.Moq.Scene.T.Helper() + if !r.Recorder.Repeat(repeaters, true) { 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 MoqStandaloneFunc_genType_doFn - DoReturnFn MoqStandaloneFunc_genType_doReturnFn - }{ - Values: last.Values, - Sequence: r.Moq.Scene.NextRecorderSequence(), - } - } - r.Results.Results = append(r.Results.Results, last) - } return r } -func (m *MoqStandaloneFunc_genType) PrettyParams(params MoqStandaloneFunc_genType_params) string { +func (*MoqStandaloneFunc_genType_adaptor) PrettyParams(params MoqStandaloneFunc_genType_params) string { return fmt.Sprintf("StandaloneFunc_genType(%#v, %#v)", params.Param1, params.BParam) } -func (m *MoqStandaloneFunc_genType) ParamsKey(params MoqStandaloneFunc_genType_params, anyParams uint64) MoqStandaloneFunc_genType_paramsKey { - 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) - } - } - var bParamUsed bool - var bParamUsedHash hash.Hash - if anyParams&(1<<1) == 0 { - if m.Runtime.ParameterIndexing.BParam == moq.ParamIndexByValue { - bParamUsed = params.BParam - } else { - bParamUsedHash = hash.DeepHash(params.BParam) - } - } +func (a *MoqStandaloneFunc_genType_adaptor) ParamsKey(params MoqStandaloneFunc_genType_params, anyParams uint64) MoqStandaloneFunc_genType_paramsKey { + a.Moq.Moq.Scene.T.Helper() + param1Used, param1UsedHash := impl.ParamKey( + params.Param1, 1, a.Moq.Runtime.ParameterIndexing.Param1, anyParams) + bParamUsed, bParamUsedHash := impl.ParamKey( + params.BParam, 2, a.Moq.Runtime.ParameterIndexing.BParam, anyParams) return MoqStandaloneFunc_genType_paramsKey{ Params: struct { Param1 string @@ -433,17 +251,12 @@ func (m *MoqStandaloneFunc_genType) ParamsKey(params MoqStandaloneFunc_genType_p } // Reset resets the state of the moq -func (m *MoqStandaloneFunc_genType) Reset() { m.ResultsByParams = nil } +func (m *MoqStandaloneFunc_genType) Reset() { + m.Moq.Reset() +} // AssertExpectationsMet asserts that all expectations have been met func (m *MoqStandaloneFunc_genType) 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)) - } - } - } + m.Moq.Scene.T.Helper() + m.Moq.AssertExpectationsMet() }