Skip to content

Commit a0cc115

Browse files
committed
Similar test for withTimeoutOrNull
1 parent ea4cd45 commit a0cc115

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

common/kotlinx-coroutines-core-common/src/test/kotlin/kotlinx/coroutines/experimental/CommonWithTimeoutOrNullTest.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,19 @@ class CommonWithTimeoutOrNullTest : TestBase() {
126126
println("Executed: $counter times")
127127
check(counter in 1..2)
128128
}
129+
130+
@Test
131+
fun testBadClass() = runTest {
132+
val bad = BadClass()
133+
val result = withTimeoutOrNull(100) {
134+
bad
135+
}
136+
assertSame(bad, result)
137+
}
138+
139+
class BadClass {
140+
override fun equals(other: Any?): Boolean = error("Should not be called")
141+
override fun hashCode(): Int = error("Should not be called")
142+
override fun toString(): String = error("Should not be called")
143+
}
129144
}

0 commit comments

Comments
 (0)