summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/toSorted/holes-not-preserved.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/toSorted/holes-not-preserved.js')
-rw-r--r--js/src/tests/test262/built-ins/Array/prototype/toSorted/holes-not-preserved.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/holes-not-preserved.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/holes-not-preserved.js
new file mode 100644
index 0000000000..1a88422f0d
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/holes-not-preserved.js
@@ -0,0 +1,27 @@
+// Copyright (C) 2021 Igalia, S.L. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-array.prototype.toSorted
+description: >
+ Array.prototype.toSorted does not preserve holes in the array
+info: |
+ Array.prototype.toSorted ( compareFn )
+
+ ...
+ 8. Repeat, while j < len,
+ a. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(j)), sortedList[j]).
+ b. Set j to j + 1.
+ ...
+features: [change-array-by-copy]
+includes: [compareArray.js]
+---*/
+
+var arr = [3, /* hole */, 4, /* hole */, 1];
+Array.prototype[3] = 2;
+
+var sorted = arr.toSorted();
+assert.compareArray(sorted, [1, 2, 3, 4, undefined]);
+assert(sorted.hasOwnProperty(4));
+
+reportCompare(0, 0);