hannesw@1542: /* hannesw@1542: * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. hannesw@1542: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. hannesw@1542: * hannesw@1542: * This code is free software; you can redistribute it and/or modify it hannesw@1542: * under the terms of the GNU General Public License version 2 only, as hannesw@1542: * published by the Free Software Foundation. hannesw@1542: * hannesw@1542: * This code is distributed in the hope that it will be useful, but WITHOUT hannesw@1542: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or hannesw@1542: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License hannesw@1542: * version 2 for more details (a copy is included in the LICENSE file that hannesw@1542: * accompanied this code). hannesw@1542: * hannesw@1542: * You should have received a copy of the GNU General Public License version hannesw@1542: * 2 along with this work; if not, write to the Free Software Foundation, hannesw@1542: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. hannesw@1542: * hannesw@1542: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA hannesw@1542: * or visit www.oracle.com if you need additional information or have any hannesw@1542: * questions. hannesw@1542: */ hannesw@1542: hannesw@1542: /** hannesw@1542: * JDK-8135190: Method code too large in Babel browser.js script hannesw@1542: * hannesw@1542: * @test hannesw@1542: * @run hannesw@1542: */ hannesw@1542: hannesw@1542: // Make sure huge object literals are parsed correctly and don't throw hannesw@1542: // (using buildObject -> JSON.stringify -> eval -> testObject) hannesw@1542: hannesw@1542: function buildObject(n, d) { hannesw@1542: if (n < 2) { hannesw@1542: return {name: "property", type: "identifier"}; hannesw@1542: } hannesw@1542: var obj = {}; hannesw@1542: for (var i = 0; i < n; i++) { hannesw@1542: obj["expr" + i] = buildObject(Math.floor(n / d), d); hannesw@1542: } hannesw@1542: return obj; hannesw@1542: } hannesw@1542: hannesw@1542: function testObject(obj, n, d) { hannesw@1542: var keys = Object.keys(obj); hannesw@1542: if (n < 2) { hannesw@1542: Assert.assertTrue(keys.length === 2); hannesw@1542: Assert.assertTrue(keys[0] === "name"); hannesw@1542: Assert.assertTrue(keys[1] === "type"); hannesw@1542: } else { hannesw@1542: Assert.assertTrue(keys.length === n); hannesw@1542: for (var i = 0; i < n; i++) { hannesw@1542: Assert.assertTrue(keys[i] === "expr" + i); hannesw@1542: } hannesw@1542: } hannesw@1542: if (n >= 2) { hannesw@1542: for (var k in keys) { hannesw@1542: testObject(obj[keys[k]], Math.floor(n / d), d) hannesw@1542: } hannesw@1542: } hannesw@1542: } hannesw@1542: hannesw@1542: var fieldObject = (eval("(" + JSON.stringify(buildObject(25, 2)) + ")")); hannesw@1542: testObject(fieldObject, 25, 2); hannesw@1542: var spillObject = (eval("(" + JSON.stringify(buildObject(1000, 100)) + ")")); hannesw@1542: testObject(spillObject, 1000, 100);