2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2020-11-30 23:46:45 +01:00
|
|
|
const {strict: assert} = require("assert");
|
|
|
|
|
2020-12-01 00:02:16 +01:00
|
|
|
const {zrequire} = require("../zjsunit/namespace");
|
2020-12-01 00:39:47 +01:00
|
|
|
const {run_test} = require("../zjsunit/test");
|
2021-03-16 23:38:59 +01:00
|
|
|
const blueslip = require("../zjsunit/zblueslip");
|
2020-12-01 00:02:16 +01:00
|
|
|
|
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
|
|
|
|
2021-01-23 02:36:54 +01:00
|
|
|
assert.deepEqual(
|
|
|
|
ls.map((n) => n * 3),
|
|
|
|
[3, 6],
|
|
|
|
);
|
2020-01-14 23:29:54 +01:00
|
|
|
});
|
|
|
|
|
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
|
|
|
});
|