michael@0: // |reftest| skip 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 = 417131; michael@0: var summary = 'stress test for cache'; 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: function f(N) michael@0: { michael@0: for (var i = 0; i != N; ++i) { michael@0: var obj0 = {}, obj1 = {}, obj2 = {}; michael@0: obj1['a'+i] = 0; michael@0: obj2['b'+i] = 0; michael@0: obj2['b'+(i+1)] = 1; michael@0: for (var repeat = 0;repeat != 2; ++repeat) { michael@0: var count = 0; michael@0: for (var j in obj1) { michael@0: if (j !== 'a'+i) michael@0: throw "Bad:"+j; michael@0: for (var k in obj2) { michael@0: if (i == Math.floor(N/3) || i == Math.floor(2*N/3)) michael@0: gc(); michael@0: var expected; michael@0: switch (count) { michael@0: case 0: expected='b'+i; break; michael@0: case 1: expected='b'+(i+1); break; michael@0: default: michael@0: throw "Bad count: "+count; michael@0: } michael@0: if (expected != k) michael@0: throw "Bad k, expected="+expected+", actual="+k; michael@0: for (var l in obj0) michael@0: ++count; michael@0: ++count; michael@0: } michael@0: } michael@0: if (count !== 2) michael@0: throw "Bad count: "+count; michael@0: } michael@0: } michael@0: } michael@0: michael@0: var array = [function() { f(10); }, michael@0: function() { f(50); }, michael@0: function() { f(200); }, michael@0: function() { f(400); } michael@0: ]; michael@0: michael@0: if (typeof scatter == "function") { michael@0: scatter(array); michael@0: } else { michael@0: for (var i = 0; i != array.length; ++i) michael@0: array[i](); michael@0: } michael@0: michael@0: michael@0: reportCompare(expect, actual, summary); michael@0: michael@0: exitFunc ('test'); michael@0: }