Skip to content

Use deep equality for mock results #1885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
val modelWithField = ModelWithField(expectedModel, expectedModelField)
if (modelWithField in visitedModels) return

@Suppress("NAME_SHADOWING")
var expected = expected
if (expected == null) {
require(!needExpectedDeclaration(expectedModel))
Expand Down Expand Up @@ -754,7 +755,8 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
return
}

if (expected.hasNotParametrizedCustomEquals()) {
// We can use overridden equals if we have one, but not for mocks.
if (expected.hasNotParametrizedCustomEquals() && !expectedModel.isMock) {
// We rely on already existing equals
currentBlock += CgSingleLineComment("${expected.type.canonicalName} has overridden equals method")
currentBlock += assertions[assertEquals](expected, actual).toStatement()
Expand Down