MIRROR: javascript for 馃悳's, a tiny runtime with big ambitions
1import { test, summary } from './helpers.js';
2
3console.log('WeakSet Tests\n');
4
5const ws = new WeakSet();
6const obj1 = {};
7const obj2 = {};
8
9ws.add(obj1);
10ws.add(obj2);
11
12test('weakset has true', ws.has(obj1), true);
13test('weakset has true 2', ws.has(obj2), true);
14test('weakset has false', ws.has({}), false);
15
16ws.delete(obj1);
17test('weakset delete', ws.has(obj1), false);
18test('weakset still has obj2', ws.has(obj2), true);
19
20const obj3 = { id: 1 };
21ws.add(obj3);
22ws.add(obj3);
23test('weakset duplicate add', ws.has(obj3), true);
24
25summary();