Skip to content

Commit 112cf9a

Browse files
204: Add removingElementFromOneIteratorAndAccessingAnotherThrowsConcurrentModificationException test
1 parent fdaa0f7 commit 112cf9a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/commonTest/src/stress/map/PersistentHashMapBuilderTest.kt

+14
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,20 @@ class PersistentHashMapBuilderTest : ExecutionTimeMeasuringTest() {
312312
}
313313
}
314314

315+
@Test
316+
fun removingElementFromOneIteratorAndAccessingAnotherThrowsConcurrentModificationException() {
317+
val map = persistentHashMapOf(1 to "a", 2 to "b", 3 to "c")
318+
val builder = map.builder()
319+
val iterator1 = builder.entries.iterator()
320+
val iterator2 = builder.entries.iterator()
321+
322+
assertFailsWith<ConcurrentModificationException> {
323+
iterator1.next()
324+
iterator1.remove()
325+
iterator2.next()
326+
}
327+
}
328+
315329
@Test
316330
fun removeTests() {
317331
val builder = persistentHashMapOf<Int, String>().builder()

0 commit comments

Comments
 (0)