started implementing the garbage collector
This commit is contained in:
@@ -179,6 +179,27 @@ describe('Array Type', function () {
|
||||
await wait(50)
|
||||
done()
|
||||
})
|
||||
it('garbage collects', async function (done) {
|
||||
var l1, l2, l3
|
||||
l1 = await y1.set('Array', Y.Array)
|
||||
l1.insert(0, ['x', 'y', 'z'])
|
||||
await flushAll()
|
||||
yconfig1.disconnect()
|
||||
l1.delete(0, 3)
|
||||
l2 = await y2.get('Array')
|
||||
await wait()
|
||||
yconfig1.reconnect()
|
||||
await wait()
|
||||
l3 = await y3.get('Array')
|
||||
await flushAll()
|
||||
yconfig1.db.garbageCollect()
|
||||
yconfig1.db.garbageCollect()
|
||||
yconfig1.db.logTable()
|
||||
expect(l1.toArray()).toEqual(l2.toArray())
|
||||
expect(l2.toArray()).toEqual(l3.toArray())
|
||||
expect(l2.toArray()).toEqual([])
|
||||
done()
|
||||
})
|
||||
})
|
||||
describe(`Random tests`, function () {
|
||||
var randomArrayTransactions = [
|
||||
|
||||
@@ -34,10 +34,18 @@
|
||||
if (op.left === null) {
|
||||
if (op.opContent != null) {
|
||||
delete this.contents[key]
|
||||
this.opContents[key] = op.opContent
|
||||
if (op.deleted) {
|
||||
delete this.opContents[key]
|
||||
} else {
|
||||
this.opContents[key] = op.opContent
|
||||
}
|
||||
} else {
|
||||
delete this.opContents[key]
|
||||
this.contents[key] = op.content
|
||||
if (op.deleted) {
|
||||
delete this.contents[key]
|
||||
} else {
|
||||
this.contents[key] = op.content
|
||||
}
|
||||
}
|
||||
this.map[key] = op.id
|
||||
var insertEvent = {
|
||||
@@ -54,11 +62,8 @@
|
||||
}
|
||||
} else if (op.struct === 'Delete') {
|
||||
if (compareIds(this.map[key], op.target)) {
|
||||
if (this.opContents[key] != null) {
|
||||
delete this.opContents[key]
|
||||
} else {
|
||||
delete this.contents[key]
|
||||
}
|
||||
delete this.opContents[key]
|
||||
delete this.contents[key]
|
||||
var deleteEvent = {
|
||||
name: key,
|
||||
object: this,
|
||||
|
||||
Reference in New Issue
Block a user