-
-
Notifications
You must be signed in to change notification settings - Fork 184
Expand file tree
/
Copy pathweakSet.spec.ts
More file actions
70 lines (61 loc) · 1.86 KB
/
weakSet.spec.ts
File metadata and controls
70 lines (61 loc) · 1.86 KB
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 * as util from "../../util";
const initRefsTs = `
let ref = {};
let ref2 = () => {};
`;
test("weakSet constructor", () => {
util.testFunction`
${initRefsTs}
let myset = new WeakSet([ref]);
return myset.has(ref)
`.expectToMatchJsResult();
});
test("weakSet iterable constructor", () => {
util.testFunction`
${initRefsTs}
let myset = new WeakSet([ref, ref2]);
return myset.has(ref) && myset.has(ref2);
`.expectToMatchJsResult();
});
test("weakSet iterable constructor set", () => {
util.testFunction`
${initRefsTs}
let myset = new WeakSet(new Set([ref, ref2]));
return myset.has(ref) && myset.has(ref2);
`.expectToMatchJsResult();
});
test("weakSet add", () => {
util.testFunction`
${initRefsTs}
let myset = new WeakSet();
myset.add(ref);
return myset.has(ref);
`.expectToMatchJsResult();
});
test("weakSet add different references", () => {
util.testFunction`
${initRefsTs}
let myset = new WeakSet();
myset.add({});
return myset.has({});
`.expectToMatchJsResult();
});
test("weakSet delete", () => {
util.testFunction`
${initRefsTs}
let myset = new WeakSet([ref, ref2]);
myset.delete(ref);
return myset.has(ref2) && !myset.has(ref);
`.expectToMatchJsResult();
});
test("weakSet has no set features (size)", () => {
util.testExpression("(new WeakSet() as any).size").expectToMatchJsResult();
});
test.each(["clear()", "keys()", "values()", "entries()", "forEach(() => {})"])(
"weakSet has no set features (%p)",
call => {
const testBuilder = util.testFunction(`(new WeakSet() as any).${call}`);
const luaResult = testBuilder.getLuaExecutionResult();
expect(luaResult.message).toContain("attempt to call a nil value");
}
);