|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 //----------------------------------------------------------------------------- |
|
7 var BUGNUMBER = 311497; |
|
8 var summary = 'Root pivots in js_HeapSort'; |
|
9 var actual = 'No Crash'; |
|
10 var expect = 'No Crash'; |
|
11 |
|
12 printBugNumber(BUGNUMBER); |
|
13 printStatus (summary); |
|
14 |
|
15 |
|
16 function force_gc() |
|
17 { |
|
18 if (this.gc) gc(); |
|
19 for (var i = 0; i != 30000; ++i) { |
|
20 var tmp = Math.sin(i); |
|
21 tmp = null; |
|
22 } |
|
23 } |
|
24 |
|
25 var array = new Array(10); |
|
26 for (var i = 0; i != array.length; ++i) { |
|
27 array[i] = String.fromCharCode(i, i, i); |
|
28 } |
|
29 |
|
30 function cmp(a, b) |
|
31 { |
|
32 for (var i = 0; i != array.length; ++i) { |
|
33 array[i] = null; |
|
34 } |
|
35 force_gc(); |
|
36 return 0; |
|
37 } |
|
38 |
|
39 array.sort(cmp); |
|
40 |
|
41 // Verify that array contains either null or original strings |
|
42 |
|
43 var null_count = 0; |
|
44 var original_string_count = 0; |
|
45 for (var i = 0; i != array.length; ++i) { |
|
46 var elem = array[i]; |
|
47 if (elem === null) { |
|
48 ++null_count; |
|
49 } else if (typeof elem == "string" && elem.length == 3) { |
|
50 var code = elem.charCodeAt(0); |
|
51 if (0 <= code && code < array.length) { |
|
52 if (code === elem.charCodeAt(1) && code == elem.charCodeAt(2)) |
|
53 ++original_string_count; |
|
54 } |
|
55 } |
|
56 } |
|
57 |
|
58 var expect = array.length; |
|
59 var actual = null_count + original_string_count; |
|
60 |
|
61 reportCompare(expect, actual, summary); |