Skip to content

Commit

Permalink
Bug in PersistentList - list is broken after removeAll call #92
Browse files Browse the repository at this point in the history
  • Loading branch information
qurbonzoda committed Nov 30, 2020
1 parent b6885b3 commit 304e8e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ internal class PersistentVectorBuilder<E>(private var vector: PersistentList<E>,
while (lastIndex shr rootShift == 0) {
rootShift -= LOG_MAX_BUFFER_SIZE
@Suppress("UNCHECKED_CAST")
newRoot = root[0] as Array<Any?>
newRoot = newRoot[0] as Array<Any?>
}
return nullifyAfter(newRoot, lastIndex, rootShift)
}
Expand Down
13 changes: 13 additions & 0 deletions core/commonTest/src/contract/list/ImmutableListTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ class ImmutableListTest {

}

@Test
fun persistentListFails() {
var xs = persistentListOf(
*(1..1885).map { it }.toTypedArray()
)

xs = xs.removeAll(
(1..1837).map { it }
)

assertEquals((1838..1885).toList(), xs)
}

@Test fun ofElements() {
val list0 = listOf("a", "d", 1, null)
val list1 = persistentListOf("a", "d", 1, null)
Expand Down

0 comments on commit 304e8e7

Please sign in to comment.