Skip to content

Commit

Permalink
Using if else instead of switch and pulling out the commone one
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinesh Kumar committed Dec 29, 2017
1 parent 936f63d commit a7101ec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ _testmain.go
*.exe

.DS_Store
*.swp
13 changes: 3 additions & 10 deletions mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,19 +317,12 @@ func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Argumen
}
}

//TODO: could simplify this
switch {
case call.Repeatability == 1:
if call.Repeatability == 1 {
call.Repeatability = -1
call.totalCalls++

case call.Repeatability > 1:
} else if call.Repeatability > 1 {
call.Repeatability--
call.totalCalls++

case call.Repeatability == 0:
call.totalCalls++
}
call.totalCalls++

// add the call
m.Calls = append(m.Calls, *newCall(m, methodName, arguments...))
Expand Down

0 comments on commit a7101ec

Please # to comment.