File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
subprojects/equalsverifier-with-kotlin/src
main/kotlin/org/sdkotlin/equalsverifier/delegation
test/kotlin/org/sdkotlin/equalsverifier/delegation Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 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 number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments