MCPcopy Create free account
hub / github.com/nodejs/node / test_attributes

Function test_attributes

test/fixtures/wpt/wasm/jsapi/interface.any.js:25–54  ·  view source on GitHub ↗
(object, object_name, attributes)

Source from the content-addressed store, hash-verified

23}
24
25function test_attributes(object, object_name, attributes) {
26 for (const [name, mutable] of attributes) {
27 test(() => {
28 const propdesc = Object.getOwnPropertyDescriptor(object, name);
29 assert_equals(typeof propdesc, "object");
30 assert_true(propdesc.enumerable, "enumerable");
31 assert_true(propdesc.configurable, "configurable");
32 }, `${object_name}.${name}`);
33
34 test(() => {
35 const propdesc = Object.getOwnPropertyDescriptor(object, name);
36 assert_equals(typeof propdesc, "object");
37 assert_equals(typeof propdesc.get, "function");
38 assert_function_name(propdesc.get, "get " + name, `getter for "${name}"`);
39 assert_function_length(propdesc.get, 0, `getter for "${name}"`);
40 }, `${object_name}.${name}: getter`);
41
42 test(() => {
43 const propdesc = Object.getOwnPropertyDescriptor(object, name);
44 assert_equals(typeof propdesc, "object");
45 if (mutable) {
46 assert_equals(typeof propdesc.set, "function");
47 assert_function_name(propdesc.set, "set " + name, `setter for "${name}"`);
48 assert_function_length(propdesc.set, 1, `setter for "${name}"`);
49 } else {
50 assert_equals(typeof propdesc.set, "undefined");
51 }
52 }, `${object_name}.${name}: setter`);
53 }
54}
55
56test(() => {
57 const propdesc = Object.getOwnPropertyDescriptor(this, "WebAssembly");

Callers 1

interface.any.jsFile · 0.85

Calls 5

assert_function_nameFunction · 0.85
assert_function_lengthFunction · 0.85
testFunction · 0.50
assert_equalsFunction · 0.50
assert_trueFunction · 0.50

Tested by

no test coverage detected