Closed belyaev-mikhail closed 3 years ago
An assert(newNode.ownedBy === owner) // newNode is newly created by this builder
can also be added to check the assumption that if newNode
is not the targetNode
, than it must have been newly created.
Rebased onto master + regression test (lousy naming) + assertion
Thank you!
Github does not allow me to reopen #110, so a new PR
Comments from #110:
Seems like some logic here is broken:
mutableUpdateNodeAtIndex
expectsnewNode
to be newly-created, butmutableReplaceNode
does not check for it properly (newNode
may be equal totargetNode
, which may be any node of any builder previously created)Maybe the idea was to check
newNode.ownedBy
instead ofownedBy
? Anyway, removing the check fixes the test.I'd love to provide a regression test, but have no idea how to reproduce this outside the node implementation. Even random test triggers this exclusively on JVM, because JVM implementation of these tests (and no other platform) actually calls builder's
remove(key, value)
method due to overloading witchcrafting, no other tests seem to call it under such stressful conditions.