mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 19:14:38 +02:00
8024693: Various minor issues with JSONWriter used by script parser API
Reviewed-by: jlaskey, hannesw
This commit is contained in:
parent
58b4892936
commit
a122ebe169
49 changed files with 4311 additions and 39 deletions
|
@ -264,6 +264,13 @@ grant codeBase "file:/${basedir}/test/script/basic/*" {
|
||||||
permission java.util.PropertyPermission "nashorn.test.*", "read";
|
permission java.util.PropertyPermission "nashorn.test.*", "read";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
grant codeBase "file:/${basedir}/test/script/basic/parser/*" {
|
||||||
|
permission java.io.FilePermission "${basedir}/test/script/-", "read";
|
||||||
|
permission java.io.FilePermission "$${user.dir}", "read";
|
||||||
|
permission java.util.PropertyPermission "user.dir", "read";
|
||||||
|
permission java.util.PropertyPermission "nashorn.test.*", "read";
|
||||||
|
};
|
||||||
|
|
||||||
grant codeBase "file:/${basedir}/test/script/basic/JDK-8010946-privileged.js" {
|
grant codeBase "file:/${basedir}/test/script/basic/JDK-8010946-privileged.js" {
|
||||||
permission java.util.PropertyPermission "java.security.policy", "read";
|
permission java.util.PropertyPermission "java.security.policy", "read";
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,6 +27,7 @@ package jdk.nashorn.internal.ir.debug;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.ArrayList;
|
||||||
import jdk.nashorn.internal.codegen.CompilerConstants;
|
import jdk.nashorn.internal.codegen.CompilerConstants;
|
||||||
import jdk.nashorn.internal.ir.AccessNode;
|
import jdk.nashorn.internal.ir.AccessNode;
|
||||||
import jdk.nashorn.internal.ir.BinaryNode;
|
import jdk.nashorn.internal.ir.BinaryNode;
|
||||||
|
@ -197,10 +198,10 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
final IdentNode label = breakNode.getLabel();
|
final IdentNode label = breakNode.getLabel();
|
||||||
if (label != null) {
|
|
||||||
property("label", label.getName());
|
|
||||||
} else {
|
|
||||||
property("label");
|
property("label");
|
||||||
|
if (label != null) {
|
||||||
|
label.accept(this);
|
||||||
|
} else {
|
||||||
nullValue();
|
nullValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,13 +257,11 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
final Node guard = catchNode.getExceptionCondition();
|
final Node guard = catchNode.getExceptionCondition();
|
||||||
property("guard");
|
|
||||||
if (guard != null) {
|
if (guard != null) {
|
||||||
|
property("guard");
|
||||||
guard.accept(this);
|
guard.accept(this);
|
||||||
} else {
|
|
||||||
nullValue();
|
|
||||||
}
|
|
||||||
comma();
|
comma();
|
||||||
|
}
|
||||||
|
|
||||||
property("body");
|
property("body");
|
||||||
catchNode.getBody().accept(this);
|
catchNode.getBody().accept(this);
|
||||||
|
@ -278,10 +277,10 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
final IdentNode label = continueNode.getLabel();
|
final IdentNode label = continueNode.getLabel();
|
||||||
if (label != null) {
|
|
||||||
property("label", label.getName());
|
|
||||||
} else {
|
|
||||||
property("label");
|
property("label");
|
||||||
|
if (label != null) {
|
||||||
|
label.accept(this);
|
||||||
|
} else {
|
||||||
nullValue();
|
nullValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,13 +298,20 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) {
|
public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) {
|
||||||
|
// handle debugger statement
|
||||||
|
final Node expression = expressionStatement.getExpression();
|
||||||
|
if (expression instanceof RuntimeNode) {
|
||||||
|
expression.accept(this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
enterDefault(expressionStatement);
|
enterDefault(expressionStatement);
|
||||||
|
|
||||||
type("ExpressionStatement");
|
type("ExpressionStatement");
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
property("expression");
|
property("expression");
|
||||||
expressionStatement.getExpression().accept(this);
|
expression.accept(this);
|
||||||
|
|
||||||
return leave();
|
return leave();
|
||||||
}
|
}
|
||||||
|
@ -388,13 +394,14 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean enterFunctionNode(final FunctionNode functionNode) {
|
public boolean enterFunctionNode(final FunctionNode functionNode) {
|
||||||
enterDefault(functionNode);
|
|
||||||
|
|
||||||
final boolean program = functionNode.isProgram();
|
final boolean program = functionNode.isProgram();
|
||||||
final String name;
|
|
||||||
if (program) {
|
if (program) {
|
||||||
name = "Program";
|
return emitProgram(functionNode);
|
||||||
} else if (functionNode.isDeclared()) {
|
}
|
||||||
|
|
||||||
|
enterDefault(functionNode);
|
||||||
|
final String name;
|
||||||
|
if (functionNode.isDeclared()) {
|
||||||
name = "FunctionDeclaration";
|
name = "FunctionDeclaration";
|
||||||
} else {
|
} else {
|
||||||
name = "FunctionExpression";
|
name = "FunctionExpression";
|
||||||
|
@ -402,7 +409,6 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
type(name);
|
type(name);
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
if (! program) {
|
|
||||||
property("id");
|
property("id");
|
||||||
if (functionNode.isAnonymous()) {
|
if (functionNode.isAnonymous()) {
|
||||||
nullValue();
|
nullValue();
|
||||||
|
@ -410,17 +416,35 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
functionNode.getIdent().accept(this);
|
functionNode.getIdent().accept(this);
|
||||||
}
|
}
|
||||||
comma();
|
comma();
|
||||||
}
|
|
||||||
|
array("params", functionNode.getParameters());
|
||||||
|
comma();
|
||||||
|
|
||||||
|
arrayStart("defaults");
|
||||||
|
arrayEnd();
|
||||||
|
comma();
|
||||||
|
|
||||||
property("rest");
|
property("rest");
|
||||||
nullValue();
|
nullValue();
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
if (!program) {
|
property("body");
|
||||||
array("params", functionNode.getParameters());
|
functionNode.getBody().accept(this);
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
|
property("generator", false);
|
||||||
|
comma();
|
||||||
|
|
||||||
|
property("expression", false);
|
||||||
|
|
||||||
|
return leave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean emitProgram(final FunctionNode functionNode) {
|
||||||
|
enterDefault(functionNode);
|
||||||
|
type("Program");
|
||||||
|
comma();
|
||||||
|
|
||||||
// body consists of nested functions and statements
|
// body consists of nested functions and statements
|
||||||
final List<Statement> stats = functionNode.getBody().getStatements();
|
final List<Statement> stats = functionNode.getBody().getStatements();
|
||||||
final int size = stats.size();
|
final int size = stats.size();
|
||||||
|
@ -730,7 +754,31 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
tryNode.getBody().accept(this);
|
tryNode.getBody().accept(this);
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
array("handlers", tryNode.getCatches());
|
|
||||||
|
final List<? extends Node> catches = tryNode.getCatches();
|
||||||
|
final List<CatchNode> guarded = new ArrayList<>();
|
||||||
|
CatchNode unguarded = null;
|
||||||
|
if (catches != null) {
|
||||||
|
for (Node n : catches) {
|
||||||
|
CatchNode cn = (CatchNode)n;
|
||||||
|
if (cn.getExceptionCondition() != null) {
|
||||||
|
guarded.add(cn);
|
||||||
|
} else {
|
||||||
|
assert unguarded == null: "too many unguarded?";
|
||||||
|
unguarded = cn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
array("guardedHandlers", guarded);
|
||||||
|
comma();
|
||||||
|
|
||||||
|
property("handler");
|
||||||
|
if (unguarded != null) {
|
||||||
|
unguarded.accept(this);
|
||||||
|
} else {
|
||||||
|
nullValue();
|
||||||
|
}
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
property("finalizer");
|
property("finalizer");
|
||||||
|
@ -760,8 +808,8 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
|
|
||||||
array("arguments", callNode.getArgs());
|
array("arguments", callNode.getArgs());
|
||||||
} else {
|
} else {
|
||||||
final boolean prefix;
|
|
||||||
final String operator;
|
final String operator;
|
||||||
|
final boolean prefix;
|
||||||
switch (tokenType) {
|
switch (tokenType) {
|
||||||
case INCPOSTFIX:
|
case INCPOSTFIX:
|
||||||
prefix = false;
|
prefix = false;
|
||||||
|
@ -780,8 +828,9 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
prefix = true;
|
prefix = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
prefix = false;
|
prefix = true;
|
||||||
operator = tokenType.getName();
|
operator = tokenType.getName();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
|
type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
|
||||||
|
@ -802,6 +851,14 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean enterVarNode(final VarNode varNode) {
|
public boolean enterVarNode(final VarNode varNode) {
|
||||||
|
final Node init = varNode.getInit();
|
||||||
|
if (init instanceof FunctionNode && ((FunctionNode)init).isDeclared()) {
|
||||||
|
// function declaration - don't emit VariableDeclaration instead
|
||||||
|
// just emit FunctionDeclaration using 'init' Node.
|
||||||
|
init.accept(this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
enterDefault(varNode);
|
enterDefault(varNode);
|
||||||
|
|
||||||
type("VariableDeclaration");
|
type("VariableDeclaration");
|
||||||
|
@ -816,11 +873,11 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
type("VariableDeclarator");
|
type("VariableDeclarator");
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
property("id", varNode.getName().toString());
|
property("id");
|
||||||
|
varNode.getName().accept(this);
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
property("init");
|
property("init");
|
||||||
final Node init = varNode.getInit();
|
|
||||||
if (init != null) {
|
if (init != null) {
|
||||||
init.accept(this);
|
init.accept(this);
|
||||||
} else {
|
} else {
|
||||||
|
@ -855,7 +912,7 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
whileNode.getTest().accept(this);
|
whileNode.getTest().accept(this);
|
||||||
comma();
|
comma();
|
||||||
|
|
||||||
property("block");
|
property("body");
|
||||||
whileNode.getBody().accept(this);
|
whileNode.getBody().accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,23 +951,27 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void property(final String key, final String value) {
|
private void property(final String key, final String value, final boolean escape) {
|
||||||
buf.append('"');
|
buf.append('"');
|
||||||
buf.append(key);
|
buf.append(key);
|
||||||
buf.append("\":");
|
buf.append("\":");
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
buf.append('"');
|
if (escape) buf.append('"');
|
||||||
buf.append(value);
|
buf.append(value);
|
||||||
buf.append('"');
|
if (escape) buf.append('"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void property(final String key, final String value) {
|
||||||
|
property(key, value, true);
|
||||||
|
}
|
||||||
|
|
||||||
private void property(final String key, final boolean value) {
|
private void property(final String key, final boolean value) {
|
||||||
property(key, Boolean.toString(value));
|
property(key, Boolean.toString(value), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void property(final String key, final int value) {
|
private void property(final String key, final int value) {
|
||||||
property(key, Integer.toString(value));
|
property(key, Integer.toString(value), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void property(final String key) {
|
private void property(final String key) {
|
||||||
|
|
|
@ -30,4 +30,4 @@
|
||||||
|
|
||||||
load("nashorn:parser.js");
|
load("nashorn:parser.js");
|
||||||
var ast = parse("label: while(true) break label;");
|
var ast = parse("label: while(true) break label;");
|
||||||
print(JSON.stringify(ast));
|
print(JSON.stringify(ast, null, " "));
|
||||||
|
|
|
@ -1 +1,36 @@
|
||||||
{"type":"Program","rest":null,"body":[{"type":"LabeledStatement","label":{"type":"Identifier","name":"label"},"body":{"type":"BlockStatement","body":[{"type":"WhileStatement","test":{"type":"Literal","value":true},"block":{"type":"BlockStatement","body":[{"type":"BreakStatement","label":"label"}]}}]}}]}
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "LabeledStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "label"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "WhileStatement",
|
||||||
|
"test": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BreakStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "label"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
44
nashorn/test/script/basic/parser/assignmentExpr.js
Normal file
44
nashorn/test/script/basic/parser/assignmentExpr.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check assignment e xyzpressions.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("xyz = 314");
|
||||||
|
printParse("xyz += 314");
|
||||||
|
printParse("xyz -= 314");
|
||||||
|
printParse("xyz *= 314");
|
||||||
|
printParse("xyz /= 314");
|
||||||
|
printParse("xyz %= 314");
|
||||||
|
printParse("xyz <<= 314");
|
||||||
|
printParse("xyz >>= 314");
|
||||||
|
printParse("xyz >>>= 314");
|
||||||
|
printParse("xyz &= 314");
|
||||||
|
printParse("xyz ^= 314");
|
||||||
|
printParse("xyz |= 314");
|
240
nashorn/test/script/basic/parser/assignmentExpr.js.EXPECTED
Normal file
240
nashorn/test/script/basic/parser/assignmentExpr.js.EXPECTED
Normal file
|
@ -0,0 +1,240 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "+=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "-=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "*=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "/=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "%=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "<<=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": ">>=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": ">>>=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "&=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "^=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "|=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xyz"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 314
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
54
nashorn/test/script/basic/parser/binaryExpr.js
Normal file
54
nashorn/test/script/basic/parser/binaryExpr.js
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check binary operators.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("a * b")
|
||||||
|
printParse("a / b");
|
||||||
|
printParse("a % b");
|
||||||
|
printParse("a + b");
|
||||||
|
printParse("a - b");
|
||||||
|
printParse("a << b");
|
||||||
|
printParse("a >> b");
|
||||||
|
printParse("a >>> b");
|
||||||
|
printParse("a < b");
|
||||||
|
printParse("a > b");
|
||||||
|
printParse("a <= b");
|
||||||
|
printParse("a >= b");
|
||||||
|
printParse("a instanceof b");
|
||||||
|
printParse("a == b");
|
||||||
|
printParse("a != b");
|
||||||
|
printParse("a === b");
|
||||||
|
printParse("a !== b");
|
||||||
|
printParse("a & b");
|
||||||
|
printParse("a ^ b");
|
||||||
|
printParse("a | b");
|
||||||
|
printParse("a && b");
|
||||||
|
printParse("a || b");
|
440
nashorn/test/script/basic/parser/binaryExpr.js.EXPECTED
Normal file
440
nashorn/test/script/basic/parser/binaryExpr.js.EXPECTED
Normal file
|
@ -0,0 +1,440 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "*",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "/",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "%",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "+",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "-",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "<<",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": ">>",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": ">>>",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "<",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": ">",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "<=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": ">=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "instanceof",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "==",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "!=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "===",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "!==",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "&",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "^",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "|",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "LogicalExpression",
|
||||||
|
"operator": "&&",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "LogicalExpression",
|
||||||
|
"operator": "||",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
35
nashorn/test/script/basic/parser/breakStat.js
Normal file
35
nashorn/test/script/basic/parser/breakStat.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check 'break' statement.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("while (true) { break; }");
|
||||||
|
printParse("loop: { while (true) { break loop } }");
|
||||||
|
printParse("loop: { for (;;) { break loop } }");
|
92
nashorn/test/script/basic/parser/breakStat.js.EXPECTED
Normal file
92
nashorn/test/script/basic/parser/breakStat.js.EXPECTED
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "WhileStatement",
|
||||||
|
"test": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BreakStatement",
|
||||||
|
"label": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "LabeledStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "loop"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "WhileStatement",
|
||||||
|
"test": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BreakStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "loop"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "LabeledStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "loop"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ForStatement",
|
||||||
|
"init": null,
|
||||||
|
"test": null,
|
||||||
|
"update": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BreakStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "loop"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
33
nashorn/test/script/basic/parser/condExpr.js
Normal file
33
nashorn/test/script/basic/parser/condExpr.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check ternary operator.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("a? b : c");
|
23
nashorn/test/script/basic/parser/condExpr.js.EXPECTED
Normal file
23
nashorn/test/script/basic/parser/condExpr.js.EXPECTED
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "ConditionalExpression",
|
||||||
|
"test": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"consequent": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
},
|
||||||
|
"alternate": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
35
nashorn/test/script/basic/parser/continueStat.js
Normal file
35
nashorn/test/script/basic/parser/continueStat.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check 'continue' statement.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("while (true) { continue; }");
|
||||||
|
printParse("begin: { while (true) { continue begin; } }");
|
||||||
|
printParse("start: { for(;;) { continue start; } }");
|
92
nashorn/test/script/basic/parser/continueStat.js.EXPECTED
Normal file
92
nashorn/test/script/basic/parser/continueStat.js.EXPECTED
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "WhileStatement",
|
||||||
|
"test": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ContinueStatement",
|
||||||
|
"label": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "LabeledStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "begin"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "WhileStatement",
|
||||||
|
"test": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ContinueStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "begin"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "LabeledStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "start"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ForStatement",
|
||||||
|
"init": null,
|
||||||
|
"test": null,
|
||||||
|
"update": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ContinueStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "start"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
33
nashorn/test/script/basic/parser/debuggerStat.js
Normal file
33
nashorn/test/script/basic/parser/debuggerStat.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check debugger statement.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("debugger");
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "DebuggerStatement"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
39
nashorn/test/script/basic/parser/functions.js
Normal file
39
nashorn/test/script/basic/parser/functions.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check 'function' statements and expressions.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("function hello() { print('hello') }")
|
||||||
|
printParse("function hello(a) { print(a) }")
|
||||||
|
printParse("function hello(a, b) { print(a, b) }")
|
||||||
|
printParse("var hello = function() { print('hello') };")
|
||||||
|
printParse("var hello = function hello() { print('hello') };")
|
||||||
|
printParse("(function(){})")
|
||||||
|
printParse("function test() { 'use strict' }");
|
279
nashorn/test/script/basic/parser/functions.js.EXPECTED
Normal file
279
nashorn/test/script/basic/parser/functions.js.EXPECTED
Normal file
|
@ -0,0 +1,279 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "hello"
|
||||||
|
},
|
||||||
|
"params": [],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "print"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "hello"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "hello"
|
||||||
|
},
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "print"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "hello"
|
||||||
|
},
|
||||||
|
"params": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "print"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "hello"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "FunctionExpression",
|
||||||
|
"id": null,
|
||||||
|
"params": [],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "print"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "hello"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "hello"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "FunctionExpression",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "hello"
|
||||||
|
},
|
||||||
|
"params": [],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "print"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "hello"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "FunctionExpression",
|
||||||
|
"id": null,
|
||||||
|
"params": [],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": []
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "test"
|
||||||
|
},
|
||||||
|
"params": [],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "use strict"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
34
nashorn/test/script/basic/parser/ifStat.js
Normal file
34
nashorn/test/script/basic/parser/ifStat.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check 'if' statement.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("if (js) { nashorn() }");
|
||||||
|
printParse("if (js) { nashorn() } else { java() }");
|
73
nashorn/test/script/basic/parser/ifStat.js.EXPECTED
Normal file
73
nashorn/test/script/basic/parser/ifStat.js.EXPECTED
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "IfStatement",
|
||||||
|
"test": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "js"
|
||||||
|
},
|
||||||
|
"consequent": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "nashorn"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"alternate": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "IfStatement",
|
||||||
|
"test": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "js"
|
||||||
|
},
|
||||||
|
"consequent": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "nashorn"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"alternate": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "java"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
34
nashorn/test/script/basic/parser/labelledStat.js
Normal file
34
nashorn/test/script/basic/parser/labelledStat.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test for labelled statements.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("begin: { for (;;) break begin }");
|
||||||
|
printParse("begin: { while (true) break begin }");
|
71
nashorn/test/script/basic/parser/labelledStat.js.EXPECTED
Normal file
71
nashorn/test/script/basic/parser/labelledStat.js.EXPECTED
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "LabeledStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "begin"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ForStatement",
|
||||||
|
"init": null,
|
||||||
|
"test": null,
|
||||||
|
"update": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BreakStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "begin"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "LabeledStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "begin"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "WhileStatement",
|
||||||
|
"test": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BreakStatement",
|
||||||
|
"label": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "begin"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
47
nashorn/test/script/basic/parser/lhsExpr.js
Normal file
47
nashorn/test/script/basic/parser/lhsExpr.js
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check left-hand-side expressions
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("a[3]");
|
||||||
|
printParse("a[b]");
|
||||||
|
printParse("a['foo']");
|
||||||
|
printParse("obj.foo");
|
||||||
|
printParse("obj.foo.bar");
|
||||||
|
printParse("new Type");
|
||||||
|
printParse("new Type()");
|
||||||
|
printParse("new Type(a, 'hello')");
|
||||||
|
printParse("new obj.Type");
|
||||||
|
printParse("new obj.Type()");
|
||||||
|
printParse("new obj.Type(a, 'hello')");
|
||||||
|
printParse("foo()")
|
||||||
|
printParse("obj.foo()");
|
||||||
|
printParse("foo(a,b)");
|
||||||
|
printParse("obj.foo(a, b)");
|
344
nashorn/test/script/basic/parser/lhsExpr.js.EXPECTED
Normal file
344
nashorn/test/script/basic/parser/lhsExpr.js.EXPECTED
Normal file
|
@ -0,0 +1,344 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 3
|
||||||
|
},
|
||||||
|
"computed": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
},
|
||||||
|
"computed": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "foo"
|
||||||
|
},
|
||||||
|
"computed": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "obj"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "obj"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "bar"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "NewExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "Type"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "NewExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "Type"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "NewExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "Type"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "hello"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "NewExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "obj"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "Type"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "NewExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "obj"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "Type"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "NewExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "obj"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "Type"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "hello"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "obj"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "obj"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"computed": false
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
37
nashorn/test/script/basic/parser/loopStat.js
Normal file
37
nashorn/test/script/basic/parser/loopStat.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for loop statements.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("while(true) { print('hello') }")
|
||||||
|
printParse("do { print('hello') } while(true)")
|
||||||
|
printParse("for (i in obj) { print(obj[i]) }")
|
||||||
|
printParse("for each (i in obj) { print(i) }")
|
||||||
|
printParse("for (i = 0; i < 10; i++) { print(i) }")
|
212
nashorn/test/script/basic/parser/loopStat.js.EXPECTED
Normal file
212
nashorn/test/script/basic/parser/loopStat.js.EXPECTED
Normal file
|
@ -0,0 +1,212 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "WhileStatement",
|
||||||
|
"test": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": true
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "print"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "hello"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "DoWhileStatement",
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "print"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "hello"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ForInStatement",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "i"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "obj"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "print"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "MemberExpression",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "obj"
|
||||||
|
},
|
||||||
|
"property": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "i"
|
||||||
|
},
|
||||||
|
"computed": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"each": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ForInStatement",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "i"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "obj"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "print"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "i"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"each": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ForStatement",
|
||||||
|
"init": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "i"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "<",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "i"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"update": {
|
||||||
|
"type": "UpdateExpression",
|
||||||
|
"operator": "++",
|
||||||
|
"prefix": false,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "i"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "print"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "i"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
36
nashorn/test/script/basic/parser/objectLitExpr.js
Normal file
36
nashorn/test/script/basic/parser/objectLitExpr.js
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check assignment e xyzpressions.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("obj = {}");
|
||||||
|
printParse("p = { x: 10, y: 2 }");
|
||||||
|
printParse("p = { 'x': 10, 'y': 2 }");
|
||||||
|
printParse("p = { get x() { return xValue }, get y() { return yValue } }");
|
189
nashorn/test/script/basic/parser/objectLitExpr.js.EXPECTED
Normal file
189
nashorn/test/script/basic/parser/objectLitExpr.js.EXPECTED
Normal file
|
@ -0,0 +1,189 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "obj"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "ObjectExpression",
|
||||||
|
"properties": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "p"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "ObjectExpression",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
"kind": "init"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "y"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 2
|
||||||
|
},
|
||||||
|
"kind": "init"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "p"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "ObjectExpression",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "x"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
"kind": "init"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "y"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 2
|
||||||
|
},
|
||||||
|
"kind": "init"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "p"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "ObjectExpression",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "FunctionExpression",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "get x"
|
||||||
|
},
|
||||||
|
"params": [],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ReturnStatement",
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "xValue"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
},
|
||||||
|
"kind": "get"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "y"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "FunctionExpression",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "get y"
|
||||||
|
},
|
||||||
|
"params": [],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ReturnStatement",
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "yValue"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
},
|
||||||
|
"kind": "get"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
34
nashorn/test/script/basic/parser/parenExpr.js
Normal file
34
nashorn/test/script/basic/parser/parenExpr.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for parenthesis expressions.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("(2) + (1) + 4");
|
||||||
|
printParse("3 + (7) << (5)");
|
56
nashorn/test/script/basic/parser/parenExpr.js.EXPECTED
Normal file
56
nashorn/test/script/basic/parser/parenExpr.js.EXPECTED
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "+",
|
||||||
|
"left": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "+",
|
||||||
|
"left": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 2
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "<<",
|
||||||
|
"left": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "+",
|
||||||
|
"left": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 3
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 7
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
45
nashorn/test/script/basic/parser/primaryExpr.js
Normal file
45
nashorn/test/script/basic/parser/primaryExpr.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check primary expressions.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("this");
|
||||||
|
printParse("foo");
|
||||||
|
printParse("null");
|
||||||
|
printParse("true");
|
||||||
|
printParse("false");
|
||||||
|
printParse("33");
|
||||||
|
printParse("3.14");
|
||||||
|
printParse("(10 + 3)*2");
|
||||||
|
printParse("({})");
|
||||||
|
printParse("({ x: 3 })");
|
||||||
|
printParse("[]");
|
||||||
|
printParse("[,,]");
|
||||||
|
printParse("[4, 5, 5]");
|
199
nashorn/test/script/basic/parser/primaryExpr.js.EXPECTED
Normal file
199
nashorn/test/script/basic/parser/primaryExpr.js.EXPECTED
Normal file
|
@ -0,0 +1,199 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "ThisExpression"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "foo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 33
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 3.14
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "*",
|
||||||
|
"left": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "+",
|
||||||
|
"left": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 10
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 3
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "ObjectExpression",
|
||||||
|
"properties": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "ObjectExpression",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 3
|
||||||
|
},
|
||||||
|
"kind": "init"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "ArrayExpression",
|
||||||
|
"elements": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "ArrayExpression",
|
||||||
|
"elements": [
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "ArrayExpression",
|
||||||
|
"elements": [
|
||||||
|
{
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 5
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
35
nashorn/test/script/basic/parser/returnStat.js
Normal file
35
nashorn/test/script/basic/parser/returnStat.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check 'return' statement.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("(function() { return })");
|
||||||
|
printParse("(function() { return res })");
|
||||||
|
printParse("(function() { return foo() })");
|
88
nashorn/test/script/basic/parser/returnStat.js.EXPECTED
Normal file
88
nashorn/test/script/basic/parser/returnStat.js.EXPECTED
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "FunctionExpression",
|
||||||
|
"id": null,
|
||||||
|
"params": [],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ReturnStatement",
|
||||||
|
"argument": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "FunctionExpression",
|
||||||
|
"id": null,
|
||||||
|
"params": [],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ReturnStatement",
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "res"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "FunctionExpression",
|
||||||
|
"id": null,
|
||||||
|
"params": [],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ReturnStatement",
|
||||||
|
"argument": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "foo"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
35
nashorn/test/script/basic/parser/switchStat.js
Normal file
35
nashorn/test/script/basic/parser/switchStat.js
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for switch statement.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("switch (key) {}");
|
||||||
|
printParse("switch (key) { case 2: hello(); break; }");
|
||||||
|
printParse("switch (key) { case 4: hello(); break; case 2: world(); break; default: break }");
|
123
nashorn/test/script/basic/parser/switchStat.js.EXPECTED
Normal file
123
nashorn/test/script/basic/parser/switchStat.js.EXPECTED
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "SwitchStatement",
|
||||||
|
"discriminant": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "key"
|
||||||
|
},
|
||||||
|
"cases": []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "SwitchStatement",
|
||||||
|
"discriminant": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "key"
|
||||||
|
},
|
||||||
|
"cases": [
|
||||||
|
{
|
||||||
|
"type": "SwitchCase",
|
||||||
|
"test": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 2
|
||||||
|
},
|
||||||
|
"consequent": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "hello"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BreakStatement",
|
||||||
|
"label": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "SwitchStatement",
|
||||||
|
"discriminant": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "key"
|
||||||
|
},
|
||||||
|
"cases": [
|
||||||
|
{
|
||||||
|
"type": "SwitchCase",
|
||||||
|
"test": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 4
|
||||||
|
},
|
||||||
|
"consequent": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "hello"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BreakStatement",
|
||||||
|
"label": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SwitchCase",
|
||||||
|
"test": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 2
|
||||||
|
},
|
||||||
|
"consequent": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "world"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BreakStatement",
|
||||||
|
"label": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SwitchCase",
|
||||||
|
"test": null,
|
||||||
|
"consequent": [
|
||||||
|
{
|
||||||
|
"type": "BreakStatement",
|
||||||
|
"label": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
37
nashorn/test/script/basic/parser/throwStat.js
Normal file
37
nashorn/test/script/basic/parser/throwStat.js
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for throw statement.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("throw err");
|
||||||
|
printParse("throw 'wrong'");
|
||||||
|
printParse("throw new TypeError");
|
||||||
|
printParse("throw new TypeError('not an array')");
|
||||||
|
printParse("throw { msg: 'wrong!' }");
|
85
nashorn/test/script/basic/parser/throwStat.js.EXPECTED
Normal file
85
nashorn/test/script/basic/parser/throwStat.js.EXPECTED
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ThrowStatement",
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "err"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ThrowStatement",
|
||||||
|
"argument": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "wrong"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ThrowStatement",
|
||||||
|
"argument": {
|
||||||
|
"type": "NewExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "TypeError"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ThrowStatement",
|
||||||
|
"argument": {
|
||||||
|
"type": "NewExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "TypeError"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "not an array"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ThrowStatement",
|
||||||
|
"argument": {
|
||||||
|
"type": "ObjectExpression",
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"key": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "msg"
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "wrong!"
|
||||||
|
},
|
||||||
|
"kind": "init"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
38
nashorn/test/script/basic/parser/tryCatchStat.js
Normal file
38
nashorn/test/script/basic/parser/tryCatchStat.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check try..catch statements.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("try { } catch (e) { }");
|
||||||
|
printParse("try { } catch (e) { } finally {}");
|
||||||
|
printParse("try { } finally {}");
|
||||||
|
printParse("try { } catch (e) { handle() }");
|
||||||
|
printParse("try { that() } catch (e) { handle() } finally { clean() }");
|
||||||
|
printParse("try { that() } catch (e if e instanceof TypeError) { handle() } catch (e) { rest() }");
|
305
nashorn/test/script/basic/parser/tryCatchStat.js.EXPECTED
Normal file
305
nashorn/test/script/basic/parser/tryCatchStat.js.EXPECTED
Normal file
|
@ -0,0 +1,305 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "TryStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": []
|
||||||
|
},
|
||||||
|
"guardedHandlers": [],
|
||||||
|
"handler": {
|
||||||
|
"type": "CatchClause",
|
||||||
|
"param": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "e"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"finalizer": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "TryStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": []
|
||||||
|
},
|
||||||
|
"guardedHandlers": [],
|
||||||
|
"handler": {
|
||||||
|
"type": "CatchClause",
|
||||||
|
"param": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "e"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"finalizer": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "TryStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": []
|
||||||
|
},
|
||||||
|
"guardedHandlers": [],
|
||||||
|
"handler": null,
|
||||||
|
"finalizer": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "TryStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": []
|
||||||
|
},
|
||||||
|
"guardedHandlers": [],
|
||||||
|
"handler": {
|
||||||
|
"type": "CatchClause",
|
||||||
|
"param": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "e"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "handle"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"finalizer": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "TryStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "that"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"guardedHandlers": [],
|
||||||
|
"handler": {
|
||||||
|
"type": "CatchClause",
|
||||||
|
"param": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "e"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "handle"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"finalizer": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "clean"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "TryStatement",
|
||||||
|
"block": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "that"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"guardedHandlers": [
|
||||||
|
{
|
||||||
|
"type": "CatchClause",
|
||||||
|
"param": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "e"
|
||||||
|
},
|
||||||
|
"guard": {
|
||||||
|
"type": "BinaryExpression",
|
||||||
|
"operator": "instanceof",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "e"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "TypeError"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "handle"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"handler": {
|
||||||
|
"type": "CatchClause",
|
||||||
|
"param": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "e"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "CallExpression",
|
||||||
|
"callee": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "rest"
|
||||||
|
},
|
||||||
|
"arguments": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"finalizer": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
43
nashorn/test/script/basic/parser/unaryExpr.js
Normal file
43
nashorn/test/script/basic/parser/unaryExpr.js
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check unary operators.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("x++");
|
||||||
|
printParse("x--");
|
||||||
|
printParse("delete x");
|
||||||
|
printParse("void x");
|
||||||
|
printParse("typeof x");
|
||||||
|
printParse("++x");
|
||||||
|
printParse("--x");
|
||||||
|
printParse("+x");
|
||||||
|
printParse("-x");
|
||||||
|
printParse("~x");
|
||||||
|
printParse("!x");
|
187
nashorn/test/script/basic/parser/unaryExpr.js.EXPECTED
Normal file
187
nashorn/test/script/basic/parser/unaryExpr.js.EXPECTED
Normal file
|
@ -0,0 +1,187 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "UpdateExpression",
|
||||||
|
"operator": "++",
|
||||||
|
"prefix": false,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "UpdateExpression",
|
||||||
|
"operator": "--",
|
||||||
|
"prefix": false,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "UnaryExpression",
|
||||||
|
"operator": "delete",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "UnaryExpression",
|
||||||
|
"operator": "void",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "UnaryExpression",
|
||||||
|
"operator": "typeof",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "UpdateExpression",
|
||||||
|
"operator": "++",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "UpdateExpression",
|
||||||
|
"operator": "--",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "UnaryExpression",
|
||||||
|
"operator": "+",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "UnaryExpression",
|
||||||
|
"operator": "-",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "UnaryExpression",
|
||||||
|
"operator": "~",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "UnaryExpression",
|
||||||
|
"operator": "!",
|
||||||
|
"prefix": true,
|
||||||
|
"argument": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
34
nashorn/test/script/basic/parser/useStrict.js
Normal file
34
nashorn/test/script/basic/parser/useStrict.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check if statement.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("'use strict'");
|
||||||
|
printParse("function f() { 'use strict' }");
|
41
nashorn/test/script/basic/parser/useStrict.js.EXPECTED
Normal file
41
nashorn/test/script/basic/parser/useStrict.js.EXPECTED
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "use strict"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "FunctionDeclaration",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "f"
|
||||||
|
},
|
||||||
|
"params": [],
|
||||||
|
"defaults": [],
|
||||||
|
"rest": null,
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "use strict"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"generator": false,
|
||||||
|
"expression": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
33
nashorn/test/script/basic/parser/util.js
Normal file
33
nashorn/test/script/basic/parser/util.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @subtest
|
||||||
|
*/
|
||||||
|
|
||||||
|
// utilitity for parser tests
|
||||||
|
|
||||||
|
load("nashorn:parser.js");
|
||||||
|
function printParse(code) {
|
||||||
|
print(JSON.stringify(parse(code), null, ' '));
|
||||||
|
}
|
39
nashorn/test/script/basic/parser/varDecl.js
Normal file
39
nashorn/test/script/basic/parser/varDecl.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests to check variable declarations.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
// no initialization
|
||||||
|
printParse("var a");
|
||||||
|
printParse("var a, b");
|
||||||
|
|
||||||
|
// init single, multiple
|
||||||
|
printParse("var a = 'hello'");
|
||||||
|
printParse("var a = 1, b = 2, c = 3");
|
123
nashorn/test/script/basic/parser/varDecl.js.EXPECTED
Normal file
123
nashorn/test/script/basic/parser/varDecl.js.EXPECTED
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"init": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"init": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
},
|
||||||
|
"init": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": "hello"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "a"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "b"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "VariableDeclaration",
|
||||||
|
"declarations": [
|
||||||
|
{
|
||||||
|
"type": "VariableDeclarator",
|
||||||
|
"id": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "c"
|
||||||
|
},
|
||||||
|
"init": {
|
||||||
|
"type": "Literal",
|
||||||
|
"value": 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
33
nashorn/test/script/basic/parser/withStat.js
Normal file
33
nashorn/test/script/basic/parser/withStat.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for 'with' statement.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
load(__DIR__ + "util.js");
|
||||||
|
|
||||||
|
printParse("with (scope) { x = y }");
|
32
nashorn/test/script/basic/parser/withStat.js.EXPECTED
Normal file
32
nashorn/test/script/basic/parser/withStat.js.EXPECTED
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
"type": "Program",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "WithStatement",
|
||||||
|
"object": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "scope"
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
"type": "BlockStatement",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "ExpressionStatement",
|
||||||
|
"expression": {
|
||||||
|
"type": "AssignmentExpression",
|
||||||
|
"operator": "=",
|
||||||
|
"left": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "x"
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"name": "y"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue