MCPcopy
hub / github.com/yjs/yjs / testRepeatMergingMultipleIdsets

Function testRepeatMergingMultipleIdsets

tests/IdSet.tests.js:181–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179 * @param {t.TestCase} tc
180 */
181export const testRepeatMergingMultipleIdsets = tc => {
182 const clients = 4
183 const clockRange = 100
184 /**
185 * @type {Array<d.IdSet>}
186 */
187 const idss = []
188 for (let i = 0; i < 3; i++) {
189 idss.push(createRandomIdSet(tc.prng, clients, clockRange))
190 }
191 const merged = d.mergeIdSets(idss)
192 const mergedReverse = d.mergeIdSets(idss.reverse())
193 compareIdSets(merged, mergedReverse)
194 const composed = d.createIdSet()
195 for (let iclient = 0; iclient < clients; iclient++) {
196 for (let iclock = 0; iclock < clockRange + 42; iclock++) {
197 const mergedHas = merged.hasId(new ID(iclient, iclock))
198 const oneHas = idss.some(ids => ids.hasId(new ID(iclient, iclock)))
199 t.assert(mergedHas === oneHas)
200 if (oneHas) {
201 d.addToIdSet(composed, iclient, iclock, 1)
202 }
203 }
204 }
205 compareIdSets(merged, composed)
206}
207
208/**
209 * @param {t.TestCase} tc

Callers

nothing calls this directly

Calls 4

createRandomIdSetFunction · 0.90
compareIdSetsFunction · 0.90
pushMethod · 0.80
hasIdMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…