michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 311497; michael@0: var summary = 'Root pivots in js_HeapSort'; michael@0: var actual = 'No Crash'; michael@0: var expect = 'No Crash'; michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: michael@0: function force_gc() michael@0: { michael@0: if (this.gc) gc(); michael@0: for (var i = 0; i != 30000; ++i) { michael@0: var tmp = Math.sin(i); michael@0: tmp = null; michael@0: } michael@0: } michael@0: michael@0: var array = new Array(10); michael@0: for (var i = 0; i != array.length; ++i) { michael@0: array[i] = String.fromCharCode(i, i, i); michael@0: } michael@0: michael@0: function cmp(a, b) michael@0: { michael@0: for (var i = 0; i != array.length; ++i) { michael@0: array[i] = null; michael@0: } michael@0: force_gc(); michael@0: return 0; michael@0: } michael@0: michael@0: array.sort(cmp); michael@0: michael@0: // Verify that array contains either null or original strings michael@0: michael@0: var null_count = 0; michael@0: var original_string_count = 0; michael@0: for (var i = 0; i != array.length; ++i) { michael@0: var elem = array[i]; michael@0: if (elem === null) { michael@0: ++null_count; michael@0: } else if (typeof elem == "string" && elem.length == 3) { michael@0: var code = elem.charCodeAt(0); michael@0: if (0 <= code && code < array.length) { michael@0: if (code === elem.charCodeAt(1) && code == elem.charCodeAt(2)) michael@0: ++original_string_count; michael@0: } michael@0: } michael@0: } michael@0: michael@0: var expect = array.length; michael@0: var actual = null_count + original_string_count; michael@0: michael@0: reportCompare(expect, actual, summary);