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

Function test

deps/v8/test/mjsunit/object-in-array.js:21–40  ·  view source on GitHub ↗
(creator, getter, setter, expectedToken = T)

Source from the content-addressed store, hash-verified

19}
20
21function test(creator, getter, setter, expectedToken = T) {
22 // Warm up the creator function so there's feedback and the boilerplate
23 // gets created.
24 warmup(creator);
25
26 const o1 = creator();
27 assertEquals(expectedToken, getter(o1));
28
29 if (setter == undefined) {
30 return;
31 }
32
33 // Test that we did a deep copy by setting a field in o1, creating another
34 // object, and asserting that it got a fresh copy of the data.
35 setter(o1);
36 assertNotEquals(expectedToken, getter(o1));
37
38 const o2 = creator();
39 assertEquals(expectedToken, getter(o2));
40}
41
42// Shallow array:
43test(() => { return [T, 2, 3]; }, (o) => o[0], (o) => o[0] = T2);

Callers 1

object-in-array.jsFile · 0.70

Calls 4

warmupFunction · 0.70
getterFunction · 0.70
assertEqualsFunction · 0.50
setterFunction · 0.50

Tested by

no test coverage detected