16147
|
1 |
/*
|
16151
|
2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
16147
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* NASHORN-424: Sparse array cause OutOfMemory exception.
|
|
26 |
*
|
|
27 |
* @test
|
|
28 |
* @run
|
|
29 |
*/
|
|
30 |
|
|
31 |
if (typeof print === 'undefined') {
|
|
32 |
print = console.log;
|
|
33 |
}
|
|
34 |
|
|
35 |
var l = -1
|
|
36 |
, LEVEL = { silly : l++
|
|
37 |
, verbose : l++
|
|
38 |
, info : l++
|
|
39 |
, "http" : l++
|
|
40 |
, WARN : l++
|
|
41 |
, "ERR!" : l++
|
|
42 |
, ERROR : "ERR!"
|
|
43 |
, ERR : "ERR!"
|
|
44 |
, win : 0x15AAC5
|
|
45 |
, paused : 0x19790701
|
|
46 |
, silent : 0xDECAFBAD
|
|
47 |
}
|
|
48 |
|
|
49 |
Object.keys(LEVEL).forEach(function (l) {
|
|
50 |
if (typeof LEVEL[l] === "string") LEVEL[l] = LEVEL[LEVEL[l]]
|
|
51 |
else LEVEL[LEVEL[l]] = l
|
|
52 |
LEVEL[l.toLowerCase()] = LEVEL[l]
|
|
53 |
if (l === "silent" || l === "paused") return
|
|
54 |
log[l] = log[l.toLowerCase()] =
|
|
55 |
function (msg, pref, cb) { return log(msg, pref, l, cb) }
|
|
56 |
})
|
|
57 |
|
|
58 |
function log(msg, pref, level, cb) {
|
|
59 |
print("[" +level + "] " + msg);
|
|
60 |
}
|
|
61 |
|
|
62 |
Object.keys(LEVEL).forEach(function(l) {
|
|
63 |
log("has value " + LEVEL[l], null, l, null);
|
|
64 |
});
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
var ar = [ "Hello", "World", 0xDECAFBAD ]
|
|
69 |
|
|
70 |
Object.keys(ar).forEach(function(e) {
|
|
71 |
print("ar[" + e + "] = " + ar[e]);
|
|
72 |
});
|
|
73 |
|
|
74 |
ar[34254236] = 17;
|
|
75 |
ar[-1] = "boom";
|
|
76 |
ar[0xDECAFBAD] = "ka-boom";
|
|
77 |
|
|
78 |
ar[ar[2]] = "bye";
|
|
79 |
|
|
80 |
Object.keys(ar).forEach(function(e) {
|
|
81 |
print("ar[" + e + "] = " + ar[e]);
|
|
82 |
});
|
|
83 |
|