2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2020-11-30 23:46:45 +01:00
|
|
|
const {strict: assert} = require("assert");
|
|
|
|
|
2020-08-03 23:57:48 +02:00
|
|
|
const {LazySet} = zrequire("lazy_set");
|
2020-01-14 23:29:54 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
We mostly test LazySet indirectly. This code
|
|
|
|
may be short-lived, anyway, once we change
|
|
|
|
how we download subscribers in page_params.
|
|
|
|
*/
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
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]);
|
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
run_test("conversions", () => {
|
|
|
|
blueslip.expect("error", "not a number", 2);
|
2020-02-03 07:48:50 +01:00
|
|
|
const ls = new LazySet([1, 2]);
|
2020-07-15 01:29:15 +02:00
|
|
|
ls.add("3");
|
|
|
|
assert(ls.has("3"));
|
2020-01-14 23:29:54 +01:00
|
|
|
});
|