Skip to content

Commit b8f5f7f

Browse files
committed
Expanded reproducer for jqno/equalsverifier#1097.
1 parent 338990f commit b8f5f7f

File tree

2 files changed

+8
-6
lines changed
  • subprojects/equalsverifier-with-kotlin/src

2 files changed

+8
-6
lines changed

subprojects/equalsverifier-with-kotlin/src/main/kotlin/org/sdkotlin/equalsverifier/delegation/LazyEquals.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@ package org.sdkotlin.equalsverifier.delegation
22

33
interface LazyEquals {
44
val foo: Int
5+
val bar: String
56
}
67

7-
class LazyEqualsImpl(foo: Int) : LazyEquals {
8+
class LazyEqualsImpl(foo: Int, bar: String) : LazyEquals {
89

910
override val foo: Int by lazy { foo }
11+
override val bar: String by lazy { bar }
1012

1113
override fun equals(other: Any?) =
12-
other is LazyEqualsImpl && other.foo == foo
14+
other is LazyEqualsImpl && other.foo == foo && other.bar == bar
1315

14-
override fun hashCode() = foo.hashCode()
15-
override fun toString() = "LazyEqualsImpl(foo=$foo)"
16+
override fun hashCode() = foo.hashCode() + 31 * bar.hashCode()
17+
override fun toString() = "LazyEqualsImpl(foo=$foo, bar=$bar)"
1618
}

subprojects/equalsverifier-with-kotlin/src/test/kotlin/org/sdkotlin/equalsverifier/delegation/LazyEqualsImplTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ class LazyEqualsImplTest {
88
@Test
99
fun `test equals, hashCode, and toString`() {
1010

11-
EqualsVerifier.forClass(LazyEqualsImpl::class.java)
11+
EqualsVerifier
1212
// Required per https://github.com/jqno/equalsverifier/issues/1097
13-
.withPrefabValues(Lazy::class.java, lazy { 1 }, lazy { 2 })
13+
.forExamples(LazyEqualsImpl(1, "red"), LazyEqualsImpl(2, "blue"))
1414
.verify()
1515
}
1616
}

0 commit comments

Comments
 (0)