2020-01-14 23:29:54 +01:00
|
|
|
const LazySet = zrequire('lazy_set').LazySet;
|
|
|
|
|
|
|
|
/*
|
|
|
|
We mostly test LazySet indirectly. This code
|
|
|
|
may be short-lived, anyway, once we change
|
|
|
|
how we download subscribers in page_params.
|
|
|
|
*/
|
|
|
|
|
|
|
|
run_test('map', () => {
|
2020-02-03 07:48:50 +01:00
|
|
|
const ls = new LazySet([1, 2]);
|
2020-01-14 23:29:54 +01:00
|
|
|
|
|
|
|
const triple = (n) => n * 3;
|
|
|
|
|
|
|
|
assert.deepEqual(ls.map(triple), [3, 6]);
|
|
|
|
});
|
|
|
|
|
|
|
|
run_test('conversions', () => {
|
2020-04-03 17:18:04 +02:00
|
|
|
blueslip.expect('error', 'not a number');
|
2020-02-03 07:48:50 +01:00
|
|
|
const ls = new LazySet([1, 2]);
|
2020-01-14 23:29:54 +01:00
|
|
|
ls.add('3');
|
|
|
|
assert(ls.has('3'));
|
|
|
|
});
|