MCPcopy Create free account
hub / github.com/dop251/goja / TestWeakSetArrayGeneric

Function TestWeakSetArrayGeneric

builtin_weakset_test.go:33–63  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

31}
32
33func TestWeakSetArrayGeneric(t *testing.T) {
34 const SCRIPT = `
35 var o1 = {}, o2 = {}, o3 = {};
36 var a = new Array();
37 var s;
38 var thrown = false;
39 a[1] = o2;
40
41 try {
42 s = new WeakSet(a);
43 } catch (e) {
44 if (e instanceof TypeError) {
45 thrown = true;
46 }
47 }
48 if (!thrown) {
49 throw new Error("Case 1 does not throw");
50 }
51
52 Object.defineProperty(a.__proto__, "0", {value: o1, writable: true, enumerable: true, configurable: true});
53 s = new WeakSet(a);
54 if (!(s.has(o1) && s.has(o2) && !s.has(o3))) {
55 throw new Error("Case 2 failed");
56 }
57
58 Object.defineProperty(a, "2", {value: o3, configurable: true});
59 s = new WeakSet(a);
60 s.has(o1) && s.has(o2) && s.has(o3);
61 `
62 testScript(SCRIPT, valueTrue, t)
63}
64
65func TestWeakSetGetAdderGetIteratorOrder(t *testing.T) {
66 const SCRIPT = `

Callers

nothing calls this directly

Calls 1

testScriptFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…