Skip to content

Commit 340155d

Browse files
committed
Stress test testOuterTimeoutTest
1 parent b78fa42 commit 340155d

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

kotlinx-coroutines-core/src/test/kotlin/kotlinx/coroutines/experimental/WithTimeoutOrNullTest.kt

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,26 @@ class WithTimeoutOrNullTest : TestBase() {
122122
}
123123

124124
@Test
125-
fun testOuterTimeoutTest() = runBlocking {
126-
var counter = 0
127-
val result = withTimeoutOrNull(250) {
128-
while (true) {
129-
val inner = withTimeoutOrNull(100) {
125+
fun testOuterTimeoutTest() {
126+
// stress test this particular case 1000 times
127+
val nTimes = if (isStressTest) 1000 else 1
128+
repeat(nTimes) {
129+
runBlocking {
130+
var counter = 0
131+
val result = withTimeoutOrNull(250) {
130132
while (true) {
131-
yield()
133+
val inner = withTimeoutOrNull(100) {
134+
while (true) {
135+
yield()
136+
}
137+
}
138+
assertThat(inner, IsNull())
139+
counter++
132140
}
133141
}
134-
assertThat(inner, IsNull())
135-
counter++
142+
assertThat(result, IsNull())
143+
assertThat(counter, IsEqual(2))
136144
}
137145
}
138-
assertThat(result, IsNull())
139-
assertThat(counter, IsEqual(2))
140146
}
141147
}

0 commit comments

Comments
 (0)