-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.ts
70 lines (48 loc) · 1.53 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { strict as assert } from "assert";
import {
set,
and,
intersection,
or,
union,
not,
subtract,
difference,
xor,
equal,
subset,
strictSubset,
superset,
strictSuperset,
intersects
} from "./index";
assert.deepEqual(set(), new Set());
assert.deepEqual(set([1, 2, 3]), new Set([1, 2, 3]));
(() => {
const a = new Set([1, 2, 3]);
assert.equal(set(a), a);
})();
assert.deepEqual(and([1, 2, 3], [2, 3, 4]), set([2, 3]));
assert.deepEqual(intersection([1, 2, 3], [2, 3, 4]), set([2, 3]));
assert.deepEqual(or([1, 2, 3], [2, 3, 4]), set([1, 2, 3, 4]));
assert.deepEqual(union([1, 2, 3], [2, 3, 4]), set([1, 2, 3, 4]));
assert.deepEqual(not([1, 2, 3], [2, 3, 4]), set([1]));
assert.deepEqual(subtract([1, 2, 3], [2, 3, 4]), set([1]));
assert.deepEqual(difference([1, 2, 3], [2, 3, 4]), set([1]));
assert.deepEqual(xor([1, 2, 3], [2, 3, 4]), set([1, 4]));
assert(equal([1, 2, 3], [3, 2, 1]));
assert(!equal([1, 2, 3], [4, 5, 6]));
assert(subset([1, 2, 3], [4, 3, 2, 1]));
assert(subset([1, 2, 3], [3, 2, 1]));
assert(!subset([1, 2, 3], [2, 1]));
assert(strictSubset([1, 2, 3], [4, 3, 2, 1]));
assert(!strictSubset([1, 2, 3], [3, 2, 1]));
assert(!strictSubset([1, 2, 3], [2, 1]));
assert(superset([4, 3, 2, 1], [1, 2, 3]));
assert(superset([3, 2, 1], [1, 2, 3]));
assert(!superset([2, 1], [1, 2, 3]));
assert(strictSuperset([4, 3, 2, 1], [1, 2, 3]));
assert(!strictSuperset([3, 2, 1], [1, 2, 3]));
assert(!strictSuperset([2, 1], [1, 2, 3]));
assert(intersects([1, 2], [2, 3]));
assert(!intersects([1, 2], [3, 4]));