diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/ion/setelem-hole.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/ion/setelem-hole.js')
-rw-r--r-- | js/src/jit-test/tests/ion/setelem-hole.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/ion/setelem-hole.js b/js/src/jit-test/tests/ion/setelem-hole.js new file mode 100644 index 0000000000..3f5333fb2e --- /dev/null +++ b/js/src/jit-test/tests/ion/setelem-hole.js @@ -0,0 +1,68 @@ +// Storing a typed value. +function test1() { + var a = []; + for (var i=0; i<130; i++) { + a[i] = i + 1; + } + return a; +} + +var arr = test1(); +assertEq(arr.length, 130); + +for (var i=0; i<130; i++) + assertEq(arr[i], i + 1); + +// Storing a Value. +function getValue(x) { + var y = x & 0x3; + if (y == 0) return null; + if (y == 1) return true; + if (y == 2) return 1.23; + if (y == 3) return Math; + assertEq(0, 1); +} +getValue(0); +getValue(1); + +function test2() { + var a = []; + for (var i=0; i<130; i++) { + a[i] = getValue(i); + } + return a; +} + +var arr = test2(); +assertEq(arr.length, 130); + +for (var i=0; i<130; i++) + assertEq(arr[i], getValue(i)); + +// Make sure the length-property is not updated if it's greater than +// the (new) initialized length. +function test3(arr, start, end) { + for (var i=start; i<end; i++) { + arr[i] = 10; + } +} +var a = new Array(200); +test3(a, 10, 130); +assertEq(a.length, 200); + +for (var i=10; i<130; i++) + assertEq(a[i], 10); + +test3(a, 130, 220); +assertEq(a.length, 220); + +// Test constant index. +function test4() { + var a = [0, 1, 2, 3, 4, 5]; + for (var i=0; i<150; i++) { + a[6] = i; + } + return a; +} +var arr = test4(); +assertEq(arr[6], 149); |