test/script/basic/JDK-8135190.js

Tue, 21 Mar 2017 13:41:57 -0700

author
asaha
date
Tue, 21 Mar 2017 13:41:57 -0700
changeset 2160
1df40fe54cd6
parent 1542
89477d713a96
permissions
-rw-r--r--

Merge

hannesw@1542 1 /*
hannesw@1542 2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
hannesw@1542 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
hannesw@1542 4 *
hannesw@1542 5 * This code is free software; you can redistribute it and/or modify it
hannesw@1542 6 * under the terms of the GNU General Public License version 2 only, as
hannesw@1542 7 * published by the Free Software Foundation.
hannesw@1542 8 *
hannesw@1542 9 * This code is distributed in the hope that it will be useful, but WITHOUT
hannesw@1542 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
hannesw@1542 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
hannesw@1542 12 * version 2 for more details (a copy is included in the LICENSE file that
hannesw@1542 13 * accompanied this code).
hannesw@1542 14 *
hannesw@1542 15 * You should have received a copy of the GNU General Public License version
hannesw@1542 16 * 2 along with this work; if not, write to the Free Software Foundation,
hannesw@1542 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
hannesw@1542 18 *
hannesw@1542 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
hannesw@1542 20 * or visit www.oracle.com if you need additional information or have any
hannesw@1542 21 * questions.
hannesw@1542 22 */
hannesw@1542 23
hannesw@1542 24 /**
hannesw@1542 25 * JDK-8135190: Method code too large in Babel browser.js script
hannesw@1542 26 *
hannesw@1542 27 * @test
hannesw@1542 28 * @run
hannesw@1542 29 */
hannesw@1542 30
hannesw@1542 31 // Make sure huge object literals are parsed correctly and don't throw
hannesw@1542 32 // (using buildObject -> JSON.stringify -> eval -> testObject)
hannesw@1542 33
hannesw@1542 34 function buildObject(n, d) {
hannesw@1542 35 if (n < 2) {
hannesw@1542 36 return {name: "property", type: "identifier"};
hannesw@1542 37 }
hannesw@1542 38 var obj = {};
hannesw@1542 39 for (var i = 0; i < n; i++) {
hannesw@1542 40 obj["expr" + i] = buildObject(Math.floor(n / d), d);
hannesw@1542 41 }
hannesw@1542 42 return obj;
hannesw@1542 43 }
hannesw@1542 44
hannesw@1542 45 function testObject(obj, n, d) {
hannesw@1542 46 var keys = Object.keys(obj);
hannesw@1542 47 if (n < 2) {
hannesw@1542 48 Assert.assertTrue(keys.length === 2);
hannesw@1542 49 Assert.assertTrue(keys[0] === "name");
hannesw@1542 50 Assert.assertTrue(keys[1] === "type");
hannesw@1542 51 } else {
hannesw@1542 52 Assert.assertTrue(keys.length === n);
hannesw@1542 53 for (var i = 0; i < n; i++) {
hannesw@1542 54 Assert.assertTrue(keys[i] === "expr" + i);
hannesw@1542 55 }
hannesw@1542 56 }
hannesw@1542 57 if (n >= 2) {
hannesw@1542 58 for (var k in keys) {
hannesw@1542 59 testObject(obj[keys[k]], Math.floor(n / d), d)
hannesw@1542 60 }
hannesw@1542 61 }
hannesw@1542 62 }
hannesw@1542 63
hannesw@1542 64 var fieldObject = (eval("(" + JSON.stringify(buildObject(25, 2)) + ")"));
hannesw@1542 65 testObject(fieldObject, 25, 2);
hannesw@1542 66 var spillObject = (eval("(" + JSON.stringify(buildObject(1000, 100)) + ")"));
hannesw@1542 67 testObject(spillObject, 1000, 100);

mercurial