MCPcopy Index your code
hub / github.com/nodejs/node / testAdd

Function testAdd

deps/v8/test/mjsunit/array-methods-read-only-length.js:7–51  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

5// Flags: --allow-natives-syntax
6
7function testAdd(mode) {
8 var a = [];
9 Object.defineProperty(a, "length", { writable : false});
10
11 function check(f) {
12 assertThrows(function() { f(a) }, TypeError);
13 assertFalse(0 in a);
14 assertEquals(0, a.length);
15 }
16
17 function push(a) {
18 a.push(3);
19 }
20
21 if (mode == "fast properties") %ToFastProperties(a);
22
23 %PrepareFunctionForOptimization(push);
24 check(push);
25 check(push);
26 check(push);
27 %OptimizeFunctionOnNextCall(push);
28 check(push);
29
30 function unshift(a) {
31 a.unshift(3);
32 }
33
34 %PrepareFunctionForOptimization(unshift);
35 check(unshift);
36 check(unshift);
37 check(unshift);
38 %OptimizeFunctionOnNextCall(unshift);
39 check(unshift);
40
41 function splice(a) {
42 a.splice(0, 0, 3);
43 }
44
45 %PrepareFunctionForOptimization(splice);
46 check(splice);
47 check(splice);
48 check(splice);
49 %OptimizeFunctionOnNextCall(splice);
50 check(splice);
51}
52
53testAdd("fast properties");
54

Calls 3

unshiftMethod · 0.80
checkFunction · 0.70
definePropertyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…