Skip to content

Commit 338990f

Browse files
committed
Added reproducer for jqno/equalsverifier#1097.
1 parent 194926e commit 338990f

File tree

2 files changed

+32
-0
lines changed
  • subprojects/equalsverifier-with-kotlin/src

2 files changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.sdkotlin.equalsverifier.delegation
2+
3+
interface LazyEquals {
4+
val foo: Int
5+
}
6+
7+
class LazyEqualsImpl(foo: Int) : LazyEquals {
8+
9+
override val foo: Int by lazy { foo }
10+
11+
override fun equals(other: Any?) =
12+
other is LazyEqualsImpl && other.foo == foo
13+
14+
override fun hashCode() = foo.hashCode()
15+
override fun toString() = "LazyEqualsImpl(foo=$foo)"
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.sdkotlin.equalsverifier.delegation
2+
3+
import nl.jqno.equalsverifier.EqualsVerifier
4+
import org.junit.jupiter.api.Test
5+
6+
class LazyEqualsImplTest {
7+
8+
@Test
9+
fun `test equals, hashCode, and toString`() {
10+
11+
EqualsVerifier.forClass(LazyEqualsImpl::class.java)
12+
// Required per https://github.com/jqno/equalsverifier/issues/1097
13+
.withPrefabValues(Lazy::class.java, lazy { 1 }, lazy { 2 })
14+
.verify()
15+
}
16+
}

0 commit comments

Comments
 (0)