fix test-move logic

This commit is contained in:
Kevin Jahns 2022-04-04 16:35:50 +02:00
parent e8ecc8f74b
commit a0c9235a36
2 changed files with 8 additions and 7 deletions

View File

@ -49,9 +49,6 @@ const popMovedStack = (tr, li) => {
const coords = getMovedCoords(moveContent, tr)
start = coords.start
end = coords.end
// @todo why are we not running into this?
console.log('found edge case 42') // @todo remove
debugger
}
}
li.currMove = move

View File

@ -563,11 +563,15 @@ const arrayTransactions = [
return
}
const pos = prng.int32(gen, 0, yarray.length - 1)
const newPos = prng.int32(gen, 0, yarray.length)
const len = 1 // prng.int32(gen, 1, math.min(3, yarray.length - pos))
const _newPosAdj = prng.int32(gen, 0, yarray.length - len)
// make sure that we don't insert in-between the moved range
const newPos = _newPosAdj + (_newPosAdj > yarray.length - len ? len : 0)
const oldContent = yarray.toArray()
yarray.move(pos, newPos)
const [x] = oldContent.splice(pos, 1)
oldContent.splice(pos < newPos ? newPos - 1 : newPos, 0, x)
yarray.moveRange(pos, pos + len - 1, newPos)
console.log(`moving range ${pos}-${pos + len} to ${newPos}`)
const movedValues = oldContent.splice(pos, len)
oldContent.splice(pos < newPos ? newPos - len : newPos, 0, ...movedValues)
t.compareArrays(yarray.toArray(), oldContent) // we want to make sure that fastSearch markers insert at the correct position
},
function insert (user, gen) {