Skip to content

Commit

Permalink
added a fix for #132
Browse files Browse the repository at this point in the history
  • Loading branch information
barkhorn committed Jan 7, 2017
1 parent 4a73040 commit 88504cc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,14 @@ class MockMaker[C <: Context](val ctx: C) {
val anon = TypeName("$anon")
val methodsToMock = methodsNotInObject.filter { m =>
!m.isConstructor && !m.isPrivate && m.privateWithin == NoSymbol &&
!m.isFinal &&
!m.asInstanceOf[reflect.internal.HasFlags].hasFlag(reflect.internal.Flags.BRIDGE) &&
!m.isParamWithDefault && // see issue #43
(!(m.isStable || m.isAccessor) ||
m.asInstanceOf[reflect.internal.HasFlags].isDeferred) //! TODO - stop using internal if/when this gets into the API
}.toList
val forwarders = methodsToMock map forwarderImpl _
val mocks = methodsToMock map mockMethod _
val forwarders = methodsToMock map forwarderImpl
val mocks = methodsToMock map mockMethod
val members = mockNameGenerator.mockNameVal :: forwarders ++ mocks

def make() = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,5 +441,16 @@ class MockTest extends FreeSpec with MockFactory with Matchers {
// assertResult("curried func return method called") { partial(1.23) }
// }
// }


// issue 132
"mock a trait which has a final method" in withExpectations {
trait FinalMethodTrait {
def somePublicMethod(param: String)
final def someFinalMethod(param: Int) = "final method"
}

val m = mock[FinalMethodTrait] //test will not compile if the test fails (cannot override final member)
}
}
}

0 comments on commit 88504cc

Please sign in to comment.