Skip to content

Commit 8fb6764

Browse files
authored
Use deep equality for mock results (#1885)
1 parent 6f6fb0f commit 8fb6764

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/tree/CgMethodConstructor.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
577577
val modelWithField = ModelWithField(expectedModel, expectedModelField)
578578
if (modelWithField in visitedModels) return
579579

580+
@Suppress("NAME_SHADOWING")
580581
var expected = expected
581582
if (expected == null) {
582583
require(!needExpectedDeclaration(expectedModel))
@@ -754,7 +755,8 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
754755
return
755756
}
756757

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

0 commit comments

Comments
 (0)