Debian Codegraph @

js/src/jit-test/tests/basic/testTypedArrayOutOfBounds.js

raw
1 function f1() {
2 var a = new Int32Array(50);
3 for (var i=0; i<100; i++) {
4 var x = a[i];
5 assertEq(typeof x, i < a.length ? "number" : "undefined");
6 }
7
8 var b = new Float32Array(50);
9 for (var i=0; i<100; i++) {
10 var x = b[i];
11 assertEq(typeof x, i < b.length ? "number" : "undefined");
12 }
13 }
14 f1();
15
16 function f2() {
17 // Test that values on the prototype are ignored,
18 // even for OOB accesses. This behavior is new
19 // with ECMA 6 (see bug 829896).
20 Object.prototype[50] = 4.4;
21 Object.prototype[55] = Math;
22
23 var a = new Int16Array(50);
24 for (var i=0; i<100; i++) {
25 var x = a[i];
26 if (i < a.length)
27 assertEq(x, 0);
28 else
29 assertEq(x, undefined);
30 }
31 }
32 f2();