blob: 01a2de15edf26409cb5963889dde12afc286d4bc [file] [log] [blame]
function assert(b) {
if (!b)
throw new Error("Bad!")
}
let set = new Set;
let items = [];
for (let i = 0; i < 3000; i++) {
items.push(i);
set.add(i);
}
let counter = 1000000;
while (items.length) {
if (Math.random() < 0.85) {
let item = items.pop();
let removed = set.delete(item);
assert(removed);
assert(items.length === set.size);
} else {
let newItem = ++counter;
items.push(newItem);
set.add(newItem);
assert(items.length === set.size);
}
}