aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/v4/sparsearraytest.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/v4/sparsearraytest.js')
-rw-r--r--tests/manual/v4/sparsearraytest.js38
1 files changed, 36 insertions, 2 deletions
diff --git a/tests/manual/v4/sparsearraytest.js b/tests/manual/v4/sparsearraytest.js
index 921a750472..3d7adfe903 100644
--- a/tests/manual/v4/sparsearraytest.js
+++ b/tests/manual/v4/sparsearraytest.js
@@ -1,10 +1,16 @@
var max
for (max = 2; max < 100; ++max) {
var arr = [];
- arr[10000000] = -1
+ // force a sparse array
+ Object.defineProperty(arr, "0", {
+ get: function () {
+ return 0;
+ },
+ configurable: true
+ });
var i;
var j;
- for (i = 0; i < max; ++i)
+ for (i = 1; i < max; ++i)
arr[i] = i;
for (i = 1; i < max; i += 2) {
delete arr[i];
@@ -19,3 +25,31 @@ for (max = 2; max < 100; ++max) {
}
}
}
+
+for (max = 2; max < 100; ++max) {
+ var arr = [];
+ // force a sparse array
+ Object.defineProperty(arr, "0", {
+ get: function () {
+ return 0;
+ },
+ configurable: true
+ });
+
+ var i;
+ var j;
+ for (i = 1; i < max; ++i)
+ arr[i] = i;
+ for (i = 0; i < max; i += 2) {
+ delete arr[i];
+ for (j = 0; j < max; ++j) {
+ if (j <= i && !(j %2)) {
+ if (arr[j] != undefined)
+ throw "err1 " + i + " " + j + " " + arr[j]
+ } else {
+ if (arr[j] != j)
+ throw "err2 " + j
+ }
+ }
+ }
+}