diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/basic/packed-arrays.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/basic/packed-arrays.js')
-rw-r--r-- | js/src/jit-test/tests/basic/packed-arrays.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/packed-arrays.js b/js/src/jit-test/tests/basic/packed-arrays.js new file mode 100644 index 0000000000..a6814d47aa --- /dev/null +++ b/js/src/jit-test/tests/basic/packed-arrays.js @@ -0,0 +1,51 @@ +var isPacked = getSelfHostedValue("IsPackedArray"); + +function test() { + var arr; + + // basic + arr = []; + assertEq(isPacked(arr), true); + arr[0] = 0; + assertEq(isPacked(arr), true); + arr[2] = 2; + assertEq(isPacked(arr), false); + + // delete + arr = [1, 2, 3]; + assertEq(isPacked(arr), true); + delete arr[1]; + assertEq(isPacked(arr), false); + + // setting .length + arr = [1]; + arr.length = 0; + assertEq(isPacked(arr), true); + arr.length = 1; + assertEq(isPacked(arr), false); + + // slice + arr = [1, 2, , 3]; + assertEq(isPacked(arr), false); + assertEq(isPacked(arr.slice(0, 2)), true); + assertEq(isPacked(arr.slice(0, 3)), false); + assertEq(isPacked(arr.slice(2, 3)), false); + assertEq(isPacked(arr.slice(3, 4)), true); + + // splice + arr = [1, 2, 3]; + assertEq(isPacked(arr.splice(0)), true); + arr = [1, , 2]; + assertEq(isPacked(arr.splice(0)), false); + arr = [1, , 2]; + assertEq(isPacked(arr.splice(0, 1)), true); + assertEq(arr.length, 2); + assertEq(isPacked(arr.splice(0, 1)), false); + assertEq(arr.length, 1); + assertEq(isPacked(arr.splice(0, 1)), true); + assertEq(arr.length, 0); + assertEq(isPacked(arr.splice(0)), true); +} +for (var i = 0; i < 5; i++) { + test(); +} |