author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 31485 | nashorn/test/script/basic/JDK-8075454.js@be1acaee8e9e |
permissions | -rw-r--r-- |
29540
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
1 |
/* |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
4 |
* |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
8 |
* |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
13 |
* accompanied this code). |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
14 |
* |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
18 |
* |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
21 |
* questions. |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
22 |
*/ |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
23 |
|
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
24 |
/** |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
25 |
* JDK-8075454: Anonymous functions have internal names exposed via parser API |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
26 |
* |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
27 |
* @test |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
28 |
* @option -scripting |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
29 |
* @run |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
30 |
*/ |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
31 |
|
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
32 |
var Parser = Java.type("jdk.nashorn.api.tree.Parser"); |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
33 |
var parser = Parser.create(); |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
34 |
|
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
35 |
var ast = parser.parse("test.js", <<EOF |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
36 |
|
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
37 |
function(x) { |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
38 |
return x*x |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
39 |
} |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
40 |
|
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
41 |
EOF, print); |
b8c821a13ffb
8075454: Anonymous functions have internal names exposed via parser API
sundar
parents:
diff
changeset
|
42 |
|
31485
be1acaee8e9e
8114838: Anonymous functions escape to surrounding scope when defined under "with" statement
sundar
parents:
29540
diff
changeset
|
43 |
Assert.assertNull(ast.sourceElements[0].expression.name); |