io.mockk.impl.eval.EveryBlockEvaluator.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mockk-common Show documentation
Show all versions of mockk-common Show documentation
Common(JS and Java) MockK module
The newest version!
package io.mockk.impl.eval
import io.mockk.CapturingSlot
import io.mockk.MockKGateway
import io.mockk.MockKGateway.CallRecorder
import io.mockk.MockKGateway.Stubber
import io.mockk.MockKMatcherScope
import io.mockk.MockKStubScope
import io.mockk.impl.recording.AutoHinter
class EveryBlockEvaluator(
callRecorder: () -> CallRecorder,
autoHinterFactory: () -> AutoHinter
) : RecordedBlockEvaluator(callRecorder, autoHinterFactory), Stubber {
@Suppress("UNCHECKED_CAST")
override fun every(
mockBlock: (MockKMatcherScope.() -> T)?,
coMockBlock: (suspend MockKMatcherScope.() -> T)?
): MockKStubScope {
if (coMockBlock != null) {
initializeCoroutines()
}
callRecorder().startStubbing()
val lambda = CapturingSlot>()
val scope = MockKMatcherScope(callRecorder(), lambda)
record(scope, mockBlock, coMockBlock)
val opportunity = callRecorder().answerOpportunity() as MockKGateway.AnswerOpportunity
return MockKStubScope(opportunity, callRecorder(), lambda)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy