2020-01-14 23:29:54 +01:00
|
|
|
set_global('blueslip', global.make_zblueslip());
|
|
|
|
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', () => {
|
|
|
|
blueslip.set_test_data('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'));
|
|
|
|
});
|