no new variables on left side of :=
o1egl opened this issue · 1 comments
o1egl commented
Generates incorrect code if function has params
param.
Example:
type I interface {
F(params []int) int
}
Output:
// F implements a.I
func (mmF *IMock) F(params []int) (i1 int) {
mm_atomic.AddUint64(&mmF.beforeFCounter, 1)
defer mm_atomic.AddUint64(&mmF.afterFCounter, 1)
if mmF.inspectFuncF != nil {
mmF.inspectFuncF(params)
}
params := &IMockFParams{params}
// Record call args
mmF.FMock.mutex.Lock()
mmF.FMock.callArgs = append(mmF.FMock.callArgs, params)
mmF.FMock.mutex.Unlock()
for _, e := range mmF.FMock.expectations {
if minimock.Equal(e.params, params) {
mm_atomic.AddUint64(&e.Counter, 1)
return e.results.i1
}
}
if mmF.FMock.defaultExpectation != nil {
mm_atomic.AddUint64(&mmF.FMock.defaultExpectation.Counter, 1)
want := mmF.FMock.defaultExpectation.params
got := IMockFParams{params}
if want != nil && !minimock.Equal(*want, got) {
mmF.t.Errorf("IMock.F got unexpected parameters, want: %#v, got: %#v%s\n", *want, got, minimock.Diff(*want, got))
}
results := mmF.FMock.defaultExpectation.results
if results == nil {
mmF.t.Fatal("No results are set for the IMock.F")
}
return (*results).i1
}
if mmF.funcF != nil {
return mmF.funcF(params)
}
mmF.t.Fatalf("Unexpected call to IMock.F. %v", params)
return
}```