aoqi@0: /* aoqi@0: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. attila@962: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. attila@962: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). attila@962: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. attila@962: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: /* aoqi@0: * NASHORN-424: Sparse array cause OutOfMemory exception. aoqi@0: * aoqi@0: * @test aoqi@0: * @run aoqi@0: */ aoqi@0: aoqi@0: if (typeof print === 'undefined') { aoqi@0: print = console.log; aoqi@0: } aoqi@0: aoqi@0: var l = -1 aoqi@0: , LEVEL = { silly : l++ aoqi@0: , verbose : l++ aoqi@0: , info : l++ aoqi@0: , "http" : l++ aoqi@0: , WARN : l++ aoqi@0: , "ERR!" : l++ aoqi@0: , ERROR : "ERR!" aoqi@0: , ERR : "ERR!" aoqi@0: , win : 0x15AAC5 aoqi@0: , paused : 0x19790701 aoqi@0: , silent : 0xDECAFBAD aoqi@0: } aoqi@0: aoqi@0: Object.keys(LEVEL).forEach(function (l) { aoqi@0: if (typeof LEVEL[l] === "string") LEVEL[l] = LEVEL[LEVEL[l]] aoqi@0: else LEVEL[LEVEL[l]] = l aoqi@0: LEVEL[l.toLowerCase()] = LEVEL[l] aoqi@0: if (l === "silent" || l === "paused") return aoqi@0: log[l] = log[l.toLowerCase()] = aoqi@0: function (msg, pref, cb) { return log(msg, pref, l, cb) } aoqi@0: }) aoqi@0: aoqi@0: function log(msg, pref, level, cb) { aoqi@0: print("[" +level + "] " + msg); aoqi@0: } aoqi@0: aoqi@0: Object.keys(LEVEL).forEach(function(l) { aoqi@0: log("has value " + LEVEL[l], null, l, null); aoqi@0: }); aoqi@0: aoqi@0: aoqi@0: aoqi@0: var ar = [ "Hello", "World", 0xDECAFBAD ] aoqi@0: aoqi@0: Object.keys(ar).forEach(function(e) { aoqi@0: print("ar[" + e + "] = " + ar[e]); aoqi@0: }); aoqi@0: aoqi@0: ar[34254236] = 17; aoqi@0: ar[-1] = "boom"; aoqi@0: ar[0xDECAFBAD] = "ka-boom"; aoqi@0: aoqi@0: ar[ar[2]] = "bye"; aoqi@0: aoqi@0: Object.keys(ar).forEach(function(e) { aoqi@0: print("ar[" + e + "] = " + ar[e]); aoqi@0: }); aoqi@0: