Index: test/mjsunit/array-sort.js |
diff --git a/test/mjsunit/array-sort.js b/test/mjsunit/array-sort.js |
index dfa45906ec7bfde093bd3ff90cb26eeaf135bdfa..54435945b649442e3ac724bfe25452531313afac 100644 |
--- a/test/mjsunit/array-sort.js |
+++ b/test/mjsunit/array-sort.js |
@@ -152,3 +152,24 @@ function TestArraySortingWithUnsoundComparisonFunction() { |
} |
TestArraySortingWithUnsoundComparisonFunction(); |
+ |
+function TestSparseNonArraySorting(length) { |
+ assertTrue(length > 101); |
+ var obj = {length: length}; |
+ obj[0] = 42; |
+ obj[10] = 37; |
+ obj[100] = undefined; |
+ obj[length - 1] = null; |
+ Array.prototype.sort.call(obj); |
+ assertEquals(length, obj.length, "objsort length unaffected"); |
+ assertEquals(37, obj[0], "objsort smallest number"); |
+ assertEquals(42, obj[1], "objsort largest number"); |
+ assertEquals(null, obj[2], "objsort null"); |
+ assertEquals(undefined, obj[3], "objsort undefined"); |
+ assertTrue(3 in obj, "objsort undefined retained"); |
+ assertFalse(4 in obj, "objsort non-existing retained"); |
+} |
+ |
+TestSparseNonArraySorting(5000); |
+TestSparseNonArraySorting(500000); |
+TestSparseNonArraySorting(Math.pow(2, 31) + 1); |