Skip to content

Commit 326289e

Browse files
committed
chore: even more detailed explanation of ContextValueTests
1 parent 6ccb9b8 commit 326289e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

kotlin-utils/src/commonTest/kotlin/org/modelix/kotlin/utils/ContextValueTests.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ import kotlin.time.Duration.Companion.milliseconds
2626

2727
class ContextValueTests {
2828

29+
/*
30+
* Runs multiple suspendable and non-suspendable functions in parallel to ensure they always read their own value
31+
* and not a value from a different coroutine/thread.
32+
33+
* This test starts two coroutines and tries to run into a race-condition. A successful test doesn't proof the
34+
* correctness, but a failing test proofs its incorrectness. If it ever becomes unstable, meaning it first fails
35+
* and then succeeds after a second run, this shouldn't be ignored.
36+
*/
2937
@Test
3038
fun testIsolation() = runTest {
31-
// run multiple suspendable and non-suspendable functions in parallel to ensure they always read their own value
32-
// and not a value from a different coroutine/thread.
33-
3439
val contextValue = ContextValue<String>("a")
3540
assertEquals("a", contextValue.getValueOrNull())
3641
coroutineScope {

0 commit comments

Comments
 (0)