michael@0: // |reftest| skip -- slow 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 = 345967; michael@0: var summary = 'Yet another unrooted atom in jsarray.c'; michael@0: var actual = ''; michael@0: var expect = ''; michael@0: michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: test(); michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: function test() michael@0: { michael@0: enterFunc ('test'); michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: expectExitCode(0); michael@0: expectExitCode(3); michael@0: michael@0: print('This test will probably run out of memory'); michael@0: print('This test really should only fail on 64 bit machines'); michael@0: michael@0: var JSVAL_INT_MAX = (1 << 30) - 1; michael@0: michael@0: var a = new Array(JSVAL_INT_MAX + 2); michael@0: a[JSVAL_INT_MAX] = 0; michael@0: a[JSVAL_INT_MAX + 1] = 1; michael@0: michael@0: a.__defineGetter__(JSVAL_INT_MAX, function() { return 0; }); michael@0: michael@0: a.__defineSetter__(JSVAL_INT_MAX, function(value) { michael@0: delete a[JSVAL_INT_MAX + 1]; michael@0: var tmp = []; michael@0: tmp[JSVAL_INT_MAX + 2] = 2; michael@0: michael@0: if (typeof gc == 'function') michael@0: gc(); michael@0: for (var i = 0; i != 50000; ++i) { michael@0: var tmp = 1 / 3; michael@0: tmp /= 10; michael@0: } michael@0: for (var i = 0; i != 1000; ++i) { michael@0: // Make string with 11 characters that would take michael@0: // (11 + 1) * 2 bytes or sizeof(JSAtom) so eventually michael@0: // malloc will ovewrite just freed atoms. michael@0: var tmp2 = Array(12).join(' '); michael@0: } michael@0: }); michael@0: michael@0: michael@0: a.shift(); michael@0: michael@0: expect = 0; michael@0: actual = a[JSVAL_INT_MAX]; michael@0: if (expect !== actual) michael@0: print("BAD"); michael@0: michael@0: reportCompare(expect, actual, summary); michael@0: michael@0: exitFunc ('test'); michael@0: }