Name Description Size
11.1.4.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1382
15.4.4.5-1.js File Name: 15.4.4.5.js ECMA Section: Array.prototype.sort(comparefn) Description: This test file tests cases in which the compare function is not supplied. The elements of this array are sorted. The sort is not necessarily stable. If comparefn is provided, it should be a function that accepts two arguments x and y and returns a negative value if x < y, zero if x = y, or a positive value if x > y. 1. Call the [[Get]] method of this object with argument "length". 2. Call ToUint32(Result(1)). 1. Perform an implementation-dependent sequence of calls to the [[Get]] , [[Put]], and [[Delete]] methods of this object and toSortCompare (described below), where the first argument for each call to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less than Result(2) and where the arguments for calls to SortCompare are results of previous calls to the [[Get]] method. After this sequence is complete, this object must have the following two properties. (1) There must be some mathematical permutation of the nonnegative integers less than Result(2), such that for every nonnegative integer j less than Result(2), if property old[j] existed, then new[(j)] is exactly the same value as old[j],. but if property old[j] did not exist, then new[(j)] either does not exist or exists with value undefined. (2) If comparefn is not supplied or is a consistent comparison function for the elements of this array, then for all nonnegative integers j and k, each less than Result(2), if old[j] compares less than old[k] (see SortCompare below), then (j) < (k). Here we use the notation old[j] to refer to the hypothetical result of calling the [ [Get]] method of this object with argument j before this step is executed, and the notation new[j] to refer to the hypothetical result of calling the [[Get]] method of this object with argument j after this step has been completely executed. A function is a consistent comparison function for a set of values if (a) for any two of those values (possibly the same value) considered as an ordered pair, it always returns the same value when given that pair of values as its two arguments, and the result of applying ToNumber to this value is not NaN; (b) when considered as a relation, where the pair (x, y) is considered to be in the relation if and only if applying the function to x and y and then applying ToNumber to the result produces a negative value, this relation is a partial order; and (c) when considered as a different relation, where the pair (x, y) is considered to be in the relation if and only if applying the function to x and y and then applying ToNumber to the result produces a zero value (of either sign), this relation is an equivalence relation. In this context, the phrase "x compares less than y" means applying Result(2) to x and y and then applying ToNumber to the result produces a negative value. 3.Return this object. When the SortCompare operator is called with two arguments x and y, the following steps are taken: 1.If x and y are both undefined, return +0. 2.If x is undefined, return 1. 3.If y is undefined, return 1. 4.If the argument comparefn was not provided in the call to sort, go to step 7. 5.Call comparefn with arguments x and y. 6.Return Result(5). 7.Call ToString(x). 8.Call ToString(y). 9.If Result(7) < Result(8), return 1. 10.If Result(7) > Result(8), return 1. 11.Return +0. Note that, because undefined always compared greater than any other value, undefined and nonexistent property values always sort to the end of the result. It is implementation-dependent whether or not such properties will exist or not at the end of the array when the sort is concluded. Note that the sort function is intentionally generic; it does not require that its this value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be applied successfully to a host object is implementation dependent . Author: christine@netscape.com Date: 12 november 1997 6680
15.4.4.5-2.js File Name: 15.4.4.5-2.js ECMA Section: Array.prototype.sort(comparefn) Description: This test file tests cases in which the compare function is supplied. In this cases, the sort creates a reverse sort. The elements of this array are sorted. The sort is not necessarily stable. If comparefn is provided, it should be a function that accepts two arguments x and y and returns a negative value if x < y, zero if x = y, or a positive value if x > y. 1. Call the [[Get]] method of this object with argument "length". 2. Call ToUint32(Result(1)). 1. Perform an implementation-dependent sequence of calls to the [[Get]] , [[Put]], and [[Delete]] methods of this object and toSortCompare (described below), where the first argument for each call to [[Get]], [[Put]] , or [[Delete]] is a nonnegative integer less than Result(2) and where the arguments for calls to SortCompare are results of previous calls to the [[Get]] method. After this sequence is complete, this object must have the following two properties. (1) There must be some mathematical permutation of the nonnegative integers less than Result(2), such that for every nonnegative integer j less than Result(2), if property old[j] existed, then new[(j)] is exactly the same value as old[j],. but if property old[j] did not exist, then new[(j)] either does not exist or exists with value undefined. (2) If comparefn is not supplied or is a consistent comparison function for the elements of this array, then for all nonnegative integers j and k, each less than Result(2), if old[j] compares less than old[k] (see SortCompare below), then (j) < (k). Here we use the notation old[j] to refer to the hypothetical result of calling the [ [Get]] method of this object with argument j before this step is executed, and the notation new[j] to refer to the hypothetical result of calling the [[Get]] method of this object with argument j after this step has been completely executed. A function is a consistent comparison function for a set of values if (a) for any two of those values (possibly the same value) considered as an ordered pair, it always returns the same value when given that pair of values as its two arguments, and the result of applying ToNumber to this value is not NaN; (b) when considered as a relation, where the pair (x, y) is considered to be in the relation if and only if applying the function to x and y and then applying ToNumber to the result produces a negative value, this relation is a partial order; and (c) when considered as a different relation, where the pair (x, y) is considered to be in the relation if and only if applying the function to x and y and then applying ToNumber to the result produces a zero value (of either sign), this relation is an equivalence relation. In this context, the phrase "x compares less than y" means applying Result(2) to x and y and then applying ToNumber to the result produces a negative value. 3.Return this object. When the SortCompare operator is called with two arguments x and y, the following steps are taken: 1.If x and y are both undefined, return +0. 2.If x is undefined, return 1. 3.If y is undefined, return 1. 4.If the argument comparefn was not provided in the call to sort, go to step 7. 5.Call comparefn with arguments x and y. 6.Return Result(5). 7.Call ToString(x). 8.Call ToString(y). 9.If Result(7) < Result(8), return 1. 10.If Result(7) > Result(8), return 1. 11.Return +0. Note that, because undefined always compared greater than any other value, undefined and nonexistent property values always sort to the end of the result. It is implementation-dependent whether or not such properties will exist or not at the end of the array when the sort is concluded. Note that the sort function is intentionally generic; it does not require that its this value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method. Whether the sort function can be applied successfully to a host object is implementation dependent . Author: christine@netscape.com Date: 12 november 1997 6757
15.4.4.5-3.js File Name: 15.4.4.5-3.js ECMA Section: Array.prototype.sort(comparefn) Description: This is a regression test for http://scopus/bugsplat/show_bug.cgi?id=117144 Verify that sort is successfull, even if the sort compare function returns a very large negative or positive value. Author: christine@netscape.com Date: 12 november 1997 3513
array-001.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1963
array-length-set-during-for-in.js 185
array-length-set-on-nonarray.js BEGIN TEST * ************ 630
at.js 918
browser.js 0
change-array-by-copy-cross-compartment-create.js 1156
change-array-by-copy-errors-from-correct-realm.js 3074
concat-proxy.js 650
concat-spreadable-basic.js 1134
concat-spreadable-primitive.js 805
fill.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 3892
filter.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1222
find_findindex.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 5994
findLast_findLastIndex.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 6205
for_of_1.js 3097
for_of_2.js 1485
for_of_3.js 1493
for_of_4.js 1612
from-iterator-close.js 4787
from_async.js 7620
from_basics.js 1703
from_constructor.js 1708
from_errors.js 5361
from_iterable.js 1480
from_length_setter.js 368
from_mapping.js 1459
from_primitive.js 617
from_proxy.js 1774
from_realms.js 1442
from_string.js 964
from_surfaces.js 493
from_this.js 1050
frozen-dense-array.js 1451
frozen-dict-mode-length.js Convert to dictionary mode 558
getter-name.js 286
group-callback-evaluation.js 242
group-propertkey-is-length.js 285
group.js 2871
includes-trailing-holes.js 616
includes.js 2149
index-with-null-character.js 525
indexOf-never-returns-negative-zero.js 107
indexOf-packed-array.js 945
isArray.js 1945
iterator_edge_cases.js 1320
join-01.js BEGIN TEST * ************ 2273
join-no-has-trap.js 831
lastIndexOf-never-returns-negative-zero.js 111
length-01.js BEGIN TEST * ************ 1464
length-nonwritable-redefine-nop.js BEGIN TEST * ************ 3155
length-set-object.js BEGIN TEST * ************ 1562
length-truncate-nonconfigurable-sparse.js BEGIN TEST * ************ 3286
length-truncate-nonconfigurable.js BEGIN TEST * ************ 1253
length-truncate-with-indexed.js BEGIN TEST * ************ 2556
pop-empty-nonwritable.js BEGIN TEST * ************ 735
pop-no-has-trap.js 1392
pop-nonarray-higher-elements.js BEGIN TEST * ************ 1757
redefine-length-accessor.js 1370
redefine-length-frozen-array.js BEGIN TEST * ************ 682
redefine-length-frozen-dictionarymode-array.js BEGIN TEST * ************ 909
redefine-nonwritable-length-custom-conversion-call-counts.js BEGIN TEST * ************ 1006
redefine-nonwritable-length-custom-conversion-throw.js BEGIN TEST * ************ 1327
redefine-nonwritable-length-nonnumeric.js BEGIN TEST * ************ 929
regress-94257.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1666
regress-101488.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 2985
regress-107138.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 3622
regress-108440.js Date: 30 October 2001 SUMMARY: Regression test for bug 108440 See http://bugzilla.mozilla.org/show_bug.cgi?id=108440 We shouldn't crash trying to add an array as an element of itself (!) Brendan: "...it appears that Array.prototype.toString is unsafe, and what's more, ECMA-262 Edition 3 has no helpful words about avoiding recursive death on a cycle." 1649
regress-130451.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 4047
regress-154338.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1914
regress-157652.js Date: 16 July 2002 SUMMARY: Testing that Array.sort() doesn't crash on very large arrays See http://bugzilla.mozilla.org/show_bug.cgi?id=157652 How large can a JavaScript array be? ECMA-262 Ed.3 Final, Section 15.4.2.2 : new Array(len) This states that |len| must be a a uint32_t (unsigned 32-bit integer). Note the UBound for uint32's is 2^32 -1 = 0xFFFFFFFF = 4,294,967,295. Check: js> var arr = new Array(0xFFFFFFFF) js> arr.length 4294967295 js> var arr = new Array(0x100000000) RangeError: invalid array length We'll try the largest possible array first, then a couple others. We're just testing that we don't crash on Array.sort(). Try to be good about memory by nulling each array variable after it is used. This will tell the garbage collector the memory is no longer needed. As of 2002-08-13, the JS shell runs out of memory no matter what we do, when trying to sort such large arrays. We only want to test that we don't CRASH on the sort. So it will be OK if we get the JS "out of memory" error. Note this terminates the test with exit code 3. Therefore we put |expectExitCode(3);| The only problem will arise if the JS shell ever DOES have enough memory to do the sort. Then this test will terminate with the normal exit code 0 and fail. Right now, I can't see any other way to do this, because "out of memory" is not a catchable error: it cannot be trapped with try...catch. FURTHER HEADACHE: Rhino can't seem to handle the largest array: it hangs. So we skip this case in Rhino. Here is correspondence with Igor Bukanov. He explains that Rhino isn't actually hanging; it's doing the huge sort: Philip Schwartau wrote: > Hi, > > I'm getting a graceful OOM message on trying to sort certain large > arrays. But if the array is too big, Rhino simply hangs. Note that ECMA > allows array lengths to be anything less than Math.pow(2,32), so the > arrays I'm sorting are legal. > > Note below, I'm getting an instantaneous OOM error on arr.sort() for LEN > = Math.pow(2, 30). So shouldn't I also get one for every LEN between > that and Math.pow(2, 32)? For some reason, I start to hang with 100% CPU > as LEN hits, say, Math.pow(2, 31) and higher. SpiderMonkey gives OOM > messages for all of these. Should I file a bug on this? Igor Bukanov wrote: This is due to different sorting algorithm Rhino uses when sorting arrays with length > Integer.MAX_VALUE. If length can fit Java int, Rhino first copies internal spare array to a temporary buffer, and then sorts it, otherwise it sorts array directly. In case of very spare arrays, that Array(big_number) generates, it is rather inefficient and generates OutOfMemory if length fits int. It may be worth in your case to optimize sorting to take into account array spareness, but then it would be a good idea to file a bug about ineficient sorting of spare arrays both in case of Rhino and SpiderMonkey as SM always uses a temporary buffer. 4243
regress-178722.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 3286
regress-255555.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 858
regress-290592.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 13603
regress-299644.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 781
regress-300858.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 677
regress-304828.js 4889
regress-305002.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 656
regress-310351.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1366
regress-310425-01.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 806
regress-310425-02.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 590
regress-311515.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 647
regress-315509-01.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 746
regress-322135-01.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1150
regress-330812.js 1030
regress-345961.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 965
regress-348810.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 798
regress-350256-01.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1214
regress-350256-02.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1261
regress-352742-01.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 935
regress-352742-02.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 860
regress-360681-01.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 854
regress-360681-02.js 1707
regress-364104.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 2774
regress-386030.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1501
regress-387501.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1423
regress-390598.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 996
regress-415451.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 820
regress-421325.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 853
regress-422286.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 882
regress-424954.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 709
regress-430717.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 874
regress-451483.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 882
regress-451906.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 787
regress-456845.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1148
regress-465980-01.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 834
regress-465980-02.js 3164
regress-474529.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1700
regress-488989.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 1043
regress-566651.js -*- indent-tabs-mode: nil; js-indent-level: 2 -*- 544
regress-599159.js 219
regress-619970.js 228
reverse-order-of-low-high-accesses.js BEGIN TEST * ************ 3018
set-with-indexed-property-on-prototype-chain.js hole 1399
shell.js 0
shift-no-has-trap.js 1638
shift_for_in.js 355
slice-sparse-with-large-index.js 646
sort-01.js BEGIN TEST * ************ 624
sort-array-with-holes-and-undefined.js BEGIN TEST * ************ 834
sort-delete-ascending-order.js 912
sort-non-function.js 837
sort-typedarray-with-own-length.js 1075
sort_basics.js 1698
sort_holes.js 2000
sort_native_string_nan.js 358
sort_proxy.js Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ 1293
sort_small.js 1075
species.js 5857
splice-return-array-elements-defined-not-set.js BEGIN TEST * ************ 1096
splice-species-changes-length.js hole 1299
splice-suppresses-unvisited-indexes.js BEGIN TEST * ************ 1683
to-length.js 2671
toLocaleString-01.js BEGIN TEST * ************ 941
toLocaleString-nointl.js 856
toLocaleString.js 310
toSpliced-dense.js 2805
toSpliced.js 651
toString-01.js BEGIN TEST * ************ 1415
unscopables.js 1308
unshift-01.js BEGIN TEST * ************ 1099
unshift-with-enumeration.js hole 456
values.js 606
with-dense.js 1826
with.js 329