Thu, 12 Sep 2013 22:16:40 +0530
8024693: Various minor issues with JSONWriter used by script parser API
Reviewed-by: jlaskey, hannesw
1.1 --- a/make/build.xml Thu Sep 12 17:13:59 2013 +0200 1.2 +++ b/make/build.xml Thu Sep 12 22:16:40 2013 +0530 1.3 @@ -264,6 +264,13 @@ 1.4 permission java.util.PropertyPermission "nashorn.test.*", "read"; 1.5 }; 1.6 1.7 +grant codeBase "file:/${basedir}/test/script/basic/parser/*" { 1.8 + permission java.io.FilePermission "${basedir}/test/script/-", "read"; 1.9 + permission java.io.FilePermission "$${user.dir}", "read"; 1.10 + permission java.util.PropertyPermission "user.dir", "read"; 1.11 + permission java.util.PropertyPermission "nashorn.test.*", "read"; 1.12 +}; 1.13 + 1.14 grant codeBase "file:/${basedir}/test/script/basic/JDK-8010946-privileged.js" { 1.15 permission java.util.PropertyPermission "java.security.policy", "read"; 1.16 };
2.1 --- a/src/jdk/nashorn/internal/ir/debug/JSONWriter.java Thu Sep 12 17:13:59 2013 +0200 2.2 +++ b/src/jdk/nashorn/internal/ir/debug/JSONWriter.java Thu Sep 12 22:16:40 2013 +0530 2.3 @@ -27,6 +27,7 @@ 2.4 2.5 import java.util.Arrays; 2.6 import java.util.List; 2.7 +import java.util.ArrayList; 2.8 import jdk.nashorn.internal.codegen.CompilerConstants; 2.9 import jdk.nashorn.internal.ir.AccessNode; 2.10 import jdk.nashorn.internal.ir.BinaryNode; 2.11 @@ -197,10 +198,10 @@ 2.12 comma(); 2.13 2.14 final IdentNode label = breakNode.getLabel(); 2.15 + property("label"); 2.16 if (label != null) { 2.17 - property("label", label.getName()); 2.18 + label.accept(this); 2.19 } else { 2.20 - property("label"); 2.21 nullValue(); 2.22 } 2.23 2.24 @@ -256,13 +257,11 @@ 2.25 comma(); 2.26 2.27 final Node guard = catchNode.getExceptionCondition(); 2.28 - property("guard"); 2.29 if (guard != null) { 2.30 + property("guard"); 2.31 guard.accept(this); 2.32 - } else { 2.33 - nullValue(); 2.34 + comma(); 2.35 } 2.36 - comma(); 2.37 2.38 property("body"); 2.39 catchNode.getBody().accept(this); 2.40 @@ -278,10 +277,10 @@ 2.41 comma(); 2.42 2.43 final IdentNode label = continueNode.getLabel(); 2.44 + property("label"); 2.45 if (label != null) { 2.46 - property("label", label.getName()); 2.47 + label.accept(this); 2.48 } else { 2.49 - property("label"); 2.50 nullValue(); 2.51 } 2.52 2.53 @@ -299,13 +298,20 @@ 2.54 2.55 @Override 2.56 public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) { 2.57 + // handle debugger statement 2.58 + final Node expression = expressionStatement.getExpression(); 2.59 + if (expression instanceof RuntimeNode) { 2.60 + expression.accept(this); 2.61 + return false; 2.62 + } 2.63 + 2.64 enterDefault(expressionStatement); 2.65 2.66 type("ExpressionStatement"); 2.67 comma(); 2.68 2.69 property("expression"); 2.70 - expressionStatement.getExpression().accept(this); 2.71 + expression.accept(this); 2.72 2.73 return leave(); 2.74 } 2.75 @@ -388,13 +394,14 @@ 2.76 2.77 @Override 2.78 public boolean enterFunctionNode(final FunctionNode functionNode) { 2.79 + final boolean program = functionNode.isProgram(); 2.80 + if (program) { 2.81 + return emitProgram(functionNode); 2.82 + } 2.83 + 2.84 enterDefault(functionNode); 2.85 - 2.86 - final boolean program = functionNode.isProgram(); 2.87 final String name; 2.88 - if (program) { 2.89 - name = "Program"; 2.90 - } else if (functionNode.isDeclared()) { 2.91 + if (functionNode.isDeclared()) { 2.92 name = "FunctionDeclaration"; 2.93 } else { 2.94 name = "FunctionExpression"; 2.95 @@ -402,24 +409,41 @@ 2.96 type(name); 2.97 comma(); 2.98 2.99 - if (! program) { 2.100 - property("id"); 2.101 - if (functionNode.isAnonymous()) { 2.102 - nullValue(); 2.103 - } else { 2.104 - functionNode.getIdent().accept(this); 2.105 - } 2.106 - comma(); 2.107 + property("id"); 2.108 + if (functionNode.isAnonymous()) { 2.109 + nullValue(); 2.110 + } else { 2.111 + functionNode.getIdent().accept(this); 2.112 } 2.113 + comma(); 2.114 + 2.115 + array("params", functionNode.getParameters()); 2.116 + comma(); 2.117 + 2.118 + arrayStart("defaults"); 2.119 + arrayEnd(); 2.120 + comma(); 2.121 2.122 property("rest"); 2.123 nullValue(); 2.124 comma(); 2.125 2.126 - if (!program) { 2.127 - array("params", functionNode.getParameters()); 2.128 - comma(); 2.129 - } 2.130 + property("body"); 2.131 + functionNode.getBody().accept(this); 2.132 + comma(); 2.133 + 2.134 + property("generator", false); 2.135 + comma(); 2.136 + 2.137 + property("expression", false); 2.138 + 2.139 + return leave(); 2.140 + } 2.141 + 2.142 + private boolean emitProgram(final FunctionNode functionNode) { 2.143 + enterDefault(functionNode); 2.144 + type("Program"); 2.145 + comma(); 2.146 2.147 // body consists of nested functions and statements 2.148 final List<Statement> stats = functionNode.getBody().getStatements(); 2.149 @@ -730,7 +754,31 @@ 2.150 tryNode.getBody().accept(this); 2.151 comma(); 2.152 2.153 - array("handlers", tryNode.getCatches()); 2.154 + 2.155 + final List<? extends Node> catches = tryNode.getCatches(); 2.156 + final List<CatchNode> guarded = new ArrayList<>(); 2.157 + CatchNode unguarded = null; 2.158 + if (catches != null) { 2.159 + for (Node n : catches) { 2.160 + CatchNode cn = (CatchNode)n; 2.161 + if (cn.getExceptionCondition() != null) { 2.162 + guarded.add(cn); 2.163 + } else { 2.164 + assert unguarded == null: "too many unguarded?"; 2.165 + unguarded = cn; 2.166 + } 2.167 + } 2.168 + } 2.169 + 2.170 + array("guardedHandlers", guarded); 2.171 + comma(); 2.172 + 2.173 + property("handler"); 2.174 + if (unguarded != null) { 2.175 + unguarded.accept(this); 2.176 + } else { 2.177 + nullValue(); 2.178 + } 2.179 comma(); 2.180 2.181 property("finalizer"); 2.182 @@ -760,8 +808,8 @@ 2.183 2.184 array("arguments", callNode.getArgs()); 2.185 } else { 2.186 + final String operator; 2.187 final boolean prefix; 2.188 - final String operator; 2.189 switch (tokenType) { 2.190 case INCPOSTFIX: 2.191 prefix = false; 2.192 @@ -780,8 +828,9 @@ 2.193 prefix = true; 2.194 break; 2.195 default: 2.196 - prefix = false; 2.197 + prefix = true; 2.198 operator = tokenType.getName(); 2.199 + break; 2.200 } 2.201 2.202 type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression"); 2.203 @@ -802,6 +851,14 @@ 2.204 2.205 @Override 2.206 public boolean enterVarNode(final VarNode varNode) { 2.207 + final Node init = varNode.getInit(); 2.208 + if (init instanceof FunctionNode && ((FunctionNode)init).isDeclared()) { 2.209 + // function declaration - don't emit VariableDeclaration instead 2.210 + // just emit FunctionDeclaration using 'init' Node. 2.211 + init.accept(this); 2.212 + return false; 2.213 + } 2.214 + 2.215 enterDefault(varNode); 2.216 2.217 type("VariableDeclaration"); 2.218 @@ -816,11 +873,11 @@ 2.219 type("VariableDeclarator"); 2.220 comma(); 2.221 2.222 - property("id", varNode.getName().toString()); 2.223 + property("id"); 2.224 + varNode.getName().accept(this); 2.225 comma(); 2.226 2.227 property("init"); 2.228 - final Node init = varNode.getInit(); 2.229 if (init != null) { 2.230 init.accept(this); 2.231 } else { 2.232 @@ -855,7 +912,7 @@ 2.233 whileNode.getTest().accept(this); 2.234 comma(); 2.235 2.236 - property("block"); 2.237 + property("body"); 2.238 whileNode.getBody().accept(this); 2.239 } 2.240 2.241 @@ -894,23 +951,27 @@ 2.242 return buf.toString(); 2.243 } 2.244 2.245 - private void property(final String key, final String value) { 2.246 + private void property(final String key, final String value, final boolean escape) { 2.247 buf.append('"'); 2.248 buf.append(key); 2.249 buf.append("\":"); 2.250 if (value != null) { 2.251 - buf.append('"'); 2.252 + if (escape) buf.append('"'); 2.253 buf.append(value); 2.254 - buf.append('"'); 2.255 + if (escape) buf.append('"'); 2.256 } 2.257 } 2.258 2.259 + private void property(final String key, final String value) { 2.260 + property(key, value, true); 2.261 + } 2.262 + 2.263 private void property(final String key, final boolean value) { 2.264 - property(key, Boolean.toString(value)); 2.265 + property(key, Boolean.toString(value), false); 2.266 } 2.267 2.268 private void property(final String key, final int value) { 2.269 - property(key, Integer.toString(value)); 2.270 + property(key, Integer.toString(value), false); 2.271 } 2.272 2.273 private void property(final String key) {
3.1 --- a/test/script/basic/NASHORN-737.js Thu Sep 12 17:13:59 2013 +0200 3.2 +++ b/test/script/basic/NASHORN-737.js Thu Sep 12 22:16:40 2013 +0530 3.3 @@ -30,4 +30,4 @@ 3.4 3.5 load("nashorn:parser.js"); 3.6 var ast = parse("label: while(true) break label;"); 3.7 -print(JSON.stringify(ast)); 3.8 +print(JSON.stringify(ast, null, " "));
4.1 --- a/test/script/basic/NASHORN-737.js.EXPECTED Thu Sep 12 17:13:59 2013 +0200 4.2 +++ b/test/script/basic/NASHORN-737.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 4.3 @@ -1,1 +1,36 @@ 4.4 -{"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"}]}}]}}]} 4.5 +{ 4.6 + "type": "Program", 4.7 + "body": [ 4.8 + { 4.9 + "type": "LabeledStatement", 4.10 + "label": { 4.11 + "type": "Identifier", 4.12 + "name": "label" 4.13 + }, 4.14 + "body": { 4.15 + "type": "BlockStatement", 4.16 + "body": [ 4.17 + { 4.18 + "type": "WhileStatement", 4.19 + "test": { 4.20 + "type": "Literal", 4.21 + "value": true 4.22 + }, 4.23 + "body": { 4.24 + "type": "BlockStatement", 4.25 + "body": [ 4.26 + { 4.27 + "type": "BreakStatement", 4.28 + "label": { 4.29 + "type": "Identifier", 4.30 + "name": "label" 4.31 + } 4.32 + } 4.33 + ] 4.34 + } 4.35 + } 4.36 + ] 4.37 + } 4.38 + } 4.39 + ] 4.40 +}
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/test/script/basic/parser/assignmentExpr.js Thu Sep 12 22:16:40 2013 +0530 5.3 @@ -0,0 +1,44 @@ 5.4 +/* 5.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 + * 5.8 + * This code is free software; you can redistribute it and/or modify it 5.9 + * under the terms of the GNU General Public License version 2 only, as 5.10 + * published by the Free Software Foundation. 5.11 + * 5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.15 + * version 2 for more details (a copy is included in the LICENSE file that 5.16 + * accompanied this code). 5.17 + * 5.18 + * You should have received a copy of the GNU General Public License version 5.19 + * 2 along with this work; if not, write to the Free Software Foundation, 5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.21 + * 5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 5.23 + * or visit www.oracle.com if you need additional information or have any 5.24 + * questions. 5.25 + */ 5.26 + 5.27 +/** 5.28 + * Tests to check assignment e xyzpressions. 5.29 + * 5.30 + * @test 5.31 + * @run 5.32 + */ 5.33 + 5.34 +load(__DIR__ + "util.js"); 5.35 + 5.36 +printParse("xyz = 314"); 5.37 +printParse("xyz += 314"); 5.38 +printParse("xyz -= 314"); 5.39 +printParse("xyz *= 314"); 5.40 +printParse("xyz /= 314"); 5.41 +printParse("xyz %= 314"); 5.42 +printParse("xyz <<= 314"); 5.43 +printParse("xyz >>= 314"); 5.44 +printParse("xyz >>>= 314"); 5.45 +printParse("xyz &= 314"); 5.46 +printParse("xyz ^= 314"); 5.47 +printParse("xyz |= 314");
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/test/script/basic/parser/assignmentExpr.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 6.3 @@ -0,0 +1,240 @@ 6.4 +{ 6.5 + "type": "Program", 6.6 + "body": [ 6.7 + { 6.8 + "type": "ExpressionStatement", 6.9 + "expression": { 6.10 + "type": "AssignmentExpression", 6.11 + "operator": "=", 6.12 + "left": { 6.13 + "type": "Identifier", 6.14 + "name": "xyz" 6.15 + }, 6.16 + "right": { 6.17 + "type": "Literal", 6.18 + "value": 314 6.19 + } 6.20 + } 6.21 + } 6.22 + ] 6.23 +} 6.24 +{ 6.25 + "type": "Program", 6.26 + "body": [ 6.27 + { 6.28 + "type": "ExpressionStatement", 6.29 + "expression": { 6.30 + "type": "AssignmentExpression", 6.31 + "operator": "+=", 6.32 + "left": { 6.33 + "type": "Identifier", 6.34 + "name": "xyz" 6.35 + }, 6.36 + "right": { 6.37 + "type": "Literal", 6.38 + "value": 314 6.39 + } 6.40 + } 6.41 + } 6.42 + ] 6.43 +} 6.44 +{ 6.45 + "type": "Program", 6.46 + "body": [ 6.47 + { 6.48 + "type": "ExpressionStatement", 6.49 + "expression": { 6.50 + "type": "AssignmentExpression", 6.51 + "operator": "-=", 6.52 + "left": { 6.53 + "type": "Identifier", 6.54 + "name": "xyz" 6.55 + }, 6.56 + "right": { 6.57 + "type": "Literal", 6.58 + "value": 314 6.59 + } 6.60 + } 6.61 + } 6.62 + ] 6.63 +} 6.64 +{ 6.65 + "type": "Program", 6.66 + "body": [ 6.67 + { 6.68 + "type": "ExpressionStatement", 6.69 + "expression": { 6.70 + "type": "AssignmentExpression", 6.71 + "operator": "*=", 6.72 + "left": { 6.73 + "type": "Identifier", 6.74 + "name": "xyz" 6.75 + }, 6.76 + "right": { 6.77 + "type": "Literal", 6.78 + "value": 314 6.79 + } 6.80 + } 6.81 + } 6.82 + ] 6.83 +} 6.84 +{ 6.85 + "type": "Program", 6.86 + "body": [ 6.87 + { 6.88 + "type": "ExpressionStatement", 6.89 + "expression": { 6.90 + "type": "AssignmentExpression", 6.91 + "operator": "/=", 6.92 + "left": { 6.93 + "type": "Identifier", 6.94 + "name": "xyz" 6.95 + }, 6.96 + "right": { 6.97 + "type": "Literal", 6.98 + "value": 314 6.99 + } 6.100 + } 6.101 + } 6.102 + ] 6.103 +} 6.104 +{ 6.105 + "type": "Program", 6.106 + "body": [ 6.107 + { 6.108 + "type": "ExpressionStatement", 6.109 + "expression": { 6.110 + "type": "AssignmentExpression", 6.111 + "operator": "%=", 6.112 + "left": { 6.113 + "type": "Identifier", 6.114 + "name": "xyz" 6.115 + }, 6.116 + "right": { 6.117 + "type": "Literal", 6.118 + "value": 314 6.119 + } 6.120 + } 6.121 + } 6.122 + ] 6.123 +} 6.124 +{ 6.125 + "type": "Program", 6.126 + "body": [ 6.127 + { 6.128 + "type": "ExpressionStatement", 6.129 + "expression": { 6.130 + "type": "AssignmentExpression", 6.131 + "operator": "<<=", 6.132 + "left": { 6.133 + "type": "Identifier", 6.134 + "name": "xyz" 6.135 + }, 6.136 + "right": { 6.137 + "type": "Literal", 6.138 + "value": 314 6.139 + } 6.140 + } 6.141 + } 6.142 + ] 6.143 +} 6.144 +{ 6.145 + "type": "Program", 6.146 + "body": [ 6.147 + { 6.148 + "type": "ExpressionStatement", 6.149 + "expression": { 6.150 + "type": "AssignmentExpression", 6.151 + "operator": ">>=", 6.152 + "left": { 6.153 + "type": "Identifier", 6.154 + "name": "xyz" 6.155 + }, 6.156 + "right": { 6.157 + "type": "Literal", 6.158 + "value": 314 6.159 + } 6.160 + } 6.161 + } 6.162 + ] 6.163 +} 6.164 +{ 6.165 + "type": "Program", 6.166 + "body": [ 6.167 + { 6.168 + "type": "ExpressionStatement", 6.169 + "expression": { 6.170 + "type": "AssignmentExpression", 6.171 + "operator": ">>>=", 6.172 + "left": { 6.173 + "type": "Identifier", 6.174 + "name": "xyz" 6.175 + }, 6.176 + "right": { 6.177 + "type": "Literal", 6.178 + "value": 314 6.179 + } 6.180 + } 6.181 + } 6.182 + ] 6.183 +} 6.184 +{ 6.185 + "type": "Program", 6.186 + "body": [ 6.187 + { 6.188 + "type": "ExpressionStatement", 6.189 + "expression": { 6.190 + "type": "AssignmentExpression", 6.191 + "operator": "&=", 6.192 + "left": { 6.193 + "type": "Identifier", 6.194 + "name": "xyz" 6.195 + }, 6.196 + "right": { 6.197 + "type": "Literal", 6.198 + "value": 314 6.199 + } 6.200 + } 6.201 + } 6.202 + ] 6.203 +} 6.204 +{ 6.205 + "type": "Program", 6.206 + "body": [ 6.207 + { 6.208 + "type": "ExpressionStatement", 6.209 + "expression": { 6.210 + "type": "AssignmentExpression", 6.211 + "operator": "^=", 6.212 + "left": { 6.213 + "type": "Identifier", 6.214 + "name": "xyz" 6.215 + }, 6.216 + "right": { 6.217 + "type": "Literal", 6.218 + "value": 314 6.219 + } 6.220 + } 6.221 + } 6.222 + ] 6.223 +} 6.224 +{ 6.225 + "type": "Program", 6.226 + "body": [ 6.227 + { 6.228 + "type": "ExpressionStatement", 6.229 + "expression": { 6.230 + "type": "AssignmentExpression", 6.231 + "operator": "|=", 6.232 + "left": { 6.233 + "type": "Identifier", 6.234 + "name": "xyz" 6.235 + }, 6.236 + "right": { 6.237 + "type": "Literal", 6.238 + "value": 314 6.239 + } 6.240 + } 6.241 + } 6.242 + ] 6.243 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/test/script/basic/parser/binaryExpr.js Thu Sep 12 22:16:40 2013 +0530 7.3 @@ -0,0 +1,54 @@ 7.4 +/* 7.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.7 + * 7.8 + * This code is free software; you can redistribute it and/or modify it 7.9 + * under the terms of the GNU General Public License version 2 only, as 7.10 + * published by the Free Software Foundation. 7.11 + * 7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7.15 + * version 2 for more details (a copy is included in the LICENSE file that 7.16 + * accompanied this code). 7.17 + * 7.18 + * You should have received a copy of the GNU General Public License version 7.19 + * 2 along with this work; if not, write to the Free Software Foundation, 7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7.21 + * 7.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 7.23 + * or visit www.oracle.com if you need additional information or have any 7.24 + * questions. 7.25 + */ 7.26 + 7.27 +/** 7.28 + * Tests to check binary operators. 7.29 + * 7.30 + * @test 7.31 + * @run 7.32 + */ 7.33 + 7.34 +load(__DIR__ + "util.js"); 7.35 + 7.36 +printParse("a * b") 7.37 +printParse("a / b"); 7.38 +printParse("a % b"); 7.39 +printParse("a + b"); 7.40 +printParse("a - b"); 7.41 +printParse("a << b"); 7.42 +printParse("a >> b"); 7.43 +printParse("a >>> b"); 7.44 +printParse("a < b"); 7.45 +printParse("a > b"); 7.46 +printParse("a <= b"); 7.47 +printParse("a >= b"); 7.48 +printParse("a instanceof b"); 7.49 +printParse("a == b"); 7.50 +printParse("a != b"); 7.51 +printParse("a === b"); 7.52 +printParse("a !== b"); 7.53 +printParse("a & b"); 7.54 +printParse("a ^ b"); 7.55 +printParse("a | b"); 7.56 +printParse("a && b"); 7.57 +printParse("a || b");
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/script/basic/parser/binaryExpr.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 8.3 @@ -0,0 +1,440 @@ 8.4 +{ 8.5 + "type": "Program", 8.6 + "body": [ 8.7 + { 8.8 + "type": "ExpressionStatement", 8.9 + "expression": { 8.10 + "type": "BinaryExpression", 8.11 + "operator": "*", 8.12 + "left": { 8.13 + "type": "Identifier", 8.14 + "name": "a" 8.15 + }, 8.16 + "right": { 8.17 + "type": "Identifier", 8.18 + "name": "b" 8.19 + } 8.20 + } 8.21 + } 8.22 + ] 8.23 +} 8.24 +{ 8.25 + "type": "Program", 8.26 + "body": [ 8.27 + { 8.28 + "type": "ExpressionStatement", 8.29 + "expression": { 8.30 + "type": "BinaryExpression", 8.31 + "operator": "/", 8.32 + "left": { 8.33 + "type": "Identifier", 8.34 + "name": "a" 8.35 + }, 8.36 + "right": { 8.37 + "type": "Identifier", 8.38 + "name": "b" 8.39 + } 8.40 + } 8.41 + } 8.42 + ] 8.43 +} 8.44 +{ 8.45 + "type": "Program", 8.46 + "body": [ 8.47 + { 8.48 + "type": "ExpressionStatement", 8.49 + "expression": { 8.50 + "type": "BinaryExpression", 8.51 + "operator": "%", 8.52 + "left": { 8.53 + "type": "Identifier", 8.54 + "name": "a" 8.55 + }, 8.56 + "right": { 8.57 + "type": "Identifier", 8.58 + "name": "b" 8.59 + } 8.60 + } 8.61 + } 8.62 + ] 8.63 +} 8.64 +{ 8.65 + "type": "Program", 8.66 + "body": [ 8.67 + { 8.68 + "type": "ExpressionStatement", 8.69 + "expression": { 8.70 + "type": "BinaryExpression", 8.71 + "operator": "+", 8.72 + "left": { 8.73 + "type": "Identifier", 8.74 + "name": "a" 8.75 + }, 8.76 + "right": { 8.77 + "type": "Identifier", 8.78 + "name": "b" 8.79 + } 8.80 + } 8.81 + } 8.82 + ] 8.83 +} 8.84 +{ 8.85 + "type": "Program", 8.86 + "body": [ 8.87 + { 8.88 + "type": "ExpressionStatement", 8.89 + "expression": { 8.90 + "type": "BinaryExpression", 8.91 + "operator": "-", 8.92 + "left": { 8.93 + "type": "Identifier", 8.94 + "name": "a" 8.95 + }, 8.96 + "right": { 8.97 + "type": "Identifier", 8.98 + "name": "b" 8.99 + } 8.100 + } 8.101 + } 8.102 + ] 8.103 +} 8.104 +{ 8.105 + "type": "Program", 8.106 + "body": [ 8.107 + { 8.108 + "type": "ExpressionStatement", 8.109 + "expression": { 8.110 + "type": "BinaryExpression", 8.111 + "operator": "<<", 8.112 + "left": { 8.113 + "type": "Identifier", 8.114 + "name": "a" 8.115 + }, 8.116 + "right": { 8.117 + "type": "Identifier", 8.118 + "name": "b" 8.119 + } 8.120 + } 8.121 + } 8.122 + ] 8.123 +} 8.124 +{ 8.125 + "type": "Program", 8.126 + "body": [ 8.127 + { 8.128 + "type": "ExpressionStatement", 8.129 + "expression": { 8.130 + "type": "BinaryExpression", 8.131 + "operator": ">>", 8.132 + "left": { 8.133 + "type": "Identifier", 8.134 + "name": "a" 8.135 + }, 8.136 + "right": { 8.137 + "type": "Identifier", 8.138 + "name": "b" 8.139 + } 8.140 + } 8.141 + } 8.142 + ] 8.143 +} 8.144 +{ 8.145 + "type": "Program", 8.146 + "body": [ 8.147 + { 8.148 + "type": "ExpressionStatement", 8.149 + "expression": { 8.150 + "type": "BinaryExpression", 8.151 + "operator": ">>>", 8.152 + "left": { 8.153 + "type": "Identifier", 8.154 + "name": "a" 8.155 + }, 8.156 + "right": { 8.157 + "type": "Identifier", 8.158 + "name": "b" 8.159 + } 8.160 + } 8.161 + } 8.162 + ] 8.163 +} 8.164 +{ 8.165 + "type": "Program", 8.166 + "body": [ 8.167 + { 8.168 + "type": "ExpressionStatement", 8.169 + "expression": { 8.170 + "type": "BinaryExpression", 8.171 + "operator": "<", 8.172 + "left": { 8.173 + "type": "Identifier", 8.174 + "name": "a" 8.175 + }, 8.176 + "right": { 8.177 + "type": "Identifier", 8.178 + "name": "b" 8.179 + } 8.180 + } 8.181 + } 8.182 + ] 8.183 +} 8.184 +{ 8.185 + "type": "Program", 8.186 + "body": [ 8.187 + { 8.188 + "type": "ExpressionStatement", 8.189 + "expression": { 8.190 + "type": "BinaryExpression", 8.191 + "operator": ">", 8.192 + "left": { 8.193 + "type": "Identifier", 8.194 + "name": "a" 8.195 + }, 8.196 + "right": { 8.197 + "type": "Identifier", 8.198 + "name": "b" 8.199 + } 8.200 + } 8.201 + } 8.202 + ] 8.203 +} 8.204 +{ 8.205 + "type": "Program", 8.206 + "body": [ 8.207 + { 8.208 + "type": "ExpressionStatement", 8.209 + "expression": { 8.210 + "type": "BinaryExpression", 8.211 + "operator": "<=", 8.212 + "left": { 8.213 + "type": "Identifier", 8.214 + "name": "a" 8.215 + }, 8.216 + "right": { 8.217 + "type": "Identifier", 8.218 + "name": "b" 8.219 + } 8.220 + } 8.221 + } 8.222 + ] 8.223 +} 8.224 +{ 8.225 + "type": "Program", 8.226 + "body": [ 8.227 + { 8.228 + "type": "ExpressionStatement", 8.229 + "expression": { 8.230 + "type": "BinaryExpression", 8.231 + "operator": ">=", 8.232 + "left": { 8.233 + "type": "Identifier", 8.234 + "name": "a" 8.235 + }, 8.236 + "right": { 8.237 + "type": "Identifier", 8.238 + "name": "b" 8.239 + } 8.240 + } 8.241 + } 8.242 + ] 8.243 +} 8.244 +{ 8.245 + "type": "Program", 8.246 + "body": [ 8.247 + { 8.248 + "type": "ExpressionStatement", 8.249 + "expression": { 8.250 + "type": "BinaryExpression", 8.251 + "operator": "instanceof", 8.252 + "left": { 8.253 + "type": "Identifier", 8.254 + "name": "a" 8.255 + }, 8.256 + "right": { 8.257 + "type": "Identifier", 8.258 + "name": "b" 8.259 + } 8.260 + } 8.261 + } 8.262 + ] 8.263 +} 8.264 +{ 8.265 + "type": "Program", 8.266 + "body": [ 8.267 + { 8.268 + "type": "ExpressionStatement", 8.269 + "expression": { 8.270 + "type": "BinaryExpression", 8.271 + "operator": "==", 8.272 + "left": { 8.273 + "type": "Identifier", 8.274 + "name": "a" 8.275 + }, 8.276 + "right": { 8.277 + "type": "Identifier", 8.278 + "name": "b" 8.279 + } 8.280 + } 8.281 + } 8.282 + ] 8.283 +} 8.284 +{ 8.285 + "type": "Program", 8.286 + "body": [ 8.287 + { 8.288 + "type": "ExpressionStatement", 8.289 + "expression": { 8.290 + "type": "BinaryExpression", 8.291 + "operator": "!=", 8.292 + "left": { 8.293 + "type": "Identifier", 8.294 + "name": "a" 8.295 + }, 8.296 + "right": { 8.297 + "type": "Identifier", 8.298 + "name": "b" 8.299 + } 8.300 + } 8.301 + } 8.302 + ] 8.303 +} 8.304 +{ 8.305 + "type": "Program", 8.306 + "body": [ 8.307 + { 8.308 + "type": "ExpressionStatement", 8.309 + "expression": { 8.310 + "type": "BinaryExpression", 8.311 + "operator": "===", 8.312 + "left": { 8.313 + "type": "Identifier", 8.314 + "name": "a" 8.315 + }, 8.316 + "right": { 8.317 + "type": "Identifier", 8.318 + "name": "b" 8.319 + } 8.320 + } 8.321 + } 8.322 + ] 8.323 +} 8.324 +{ 8.325 + "type": "Program", 8.326 + "body": [ 8.327 + { 8.328 + "type": "ExpressionStatement", 8.329 + "expression": { 8.330 + "type": "BinaryExpression", 8.331 + "operator": "!==", 8.332 + "left": { 8.333 + "type": "Identifier", 8.334 + "name": "a" 8.335 + }, 8.336 + "right": { 8.337 + "type": "Identifier", 8.338 + "name": "b" 8.339 + } 8.340 + } 8.341 + } 8.342 + ] 8.343 +} 8.344 +{ 8.345 + "type": "Program", 8.346 + "body": [ 8.347 + { 8.348 + "type": "ExpressionStatement", 8.349 + "expression": { 8.350 + "type": "BinaryExpression", 8.351 + "operator": "&", 8.352 + "left": { 8.353 + "type": "Identifier", 8.354 + "name": "a" 8.355 + }, 8.356 + "right": { 8.357 + "type": "Identifier", 8.358 + "name": "b" 8.359 + } 8.360 + } 8.361 + } 8.362 + ] 8.363 +} 8.364 +{ 8.365 + "type": "Program", 8.366 + "body": [ 8.367 + { 8.368 + "type": "ExpressionStatement", 8.369 + "expression": { 8.370 + "type": "BinaryExpression", 8.371 + "operator": "^", 8.372 + "left": { 8.373 + "type": "Identifier", 8.374 + "name": "a" 8.375 + }, 8.376 + "right": { 8.377 + "type": "Identifier", 8.378 + "name": "b" 8.379 + } 8.380 + } 8.381 + } 8.382 + ] 8.383 +} 8.384 +{ 8.385 + "type": "Program", 8.386 + "body": [ 8.387 + { 8.388 + "type": "ExpressionStatement", 8.389 + "expression": { 8.390 + "type": "BinaryExpression", 8.391 + "operator": "|", 8.392 + "left": { 8.393 + "type": "Identifier", 8.394 + "name": "a" 8.395 + }, 8.396 + "right": { 8.397 + "type": "Identifier", 8.398 + "name": "b" 8.399 + } 8.400 + } 8.401 + } 8.402 + ] 8.403 +} 8.404 +{ 8.405 + "type": "Program", 8.406 + "body": [ 8.407 + { 8.408 + "type": "ExpressionStatement", 8.409 + "expression": { 8.410 + "type": "LogicalExpression", 8.411 + "operator": "&&", 8.412 + "left": { 8.413 + "type": "Identifier", 8.414 + "name": "a" 8.415 + }, 8.416 + "right": { 8.417 + "type": "Identifier", 8.418 + "name": "b" 8.419 + } 8.420 + } 8.421 + } 8.422 + ] 8.423 +} 8.424 +{ 8.425 + "type": "Program", 8.426 + "body": [ 8.427 + { 8.428 + "type": "ExpressionStatement", 8.429 + "expression": { 8.430 + "type": "LogicalExpression", 8.431 + "operator": "||", 8.432 + "left": { 8.433 + "type": "Identifier", 8.434 + "name": "a" 8.435 + }, 8.436 + "right": { 8.437 + "type": "Identifier", 8.438 + "name": "b" 8.439 + } 8.440 + } 8.441 + } 8.442 + ] 8.443 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/script/basic/parser/breakStat.js Thu Sep 12 22:16:40 2013 +0530 9.3 @@ -0,0 +1,35 @@ 9.4 +/* 9.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.7 + * 9.8 + * This code is free software; you can redistribute it and/or modify it 9.9 + * under the terms of the GNU General Public License version 2 only, as 9.10 + * published by the Free Software Foundation. 9.11 + * 9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 9.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 9.15 + * version 2 for more details (a copy is included in the LICENSE file that 9.16 + * accompanied this code). 9.17 + * 9.18 + * You should have received a copy of the GNU General Public License version 9.19 + * 2 along with this work; if not, write to the Free Software Foundation, 9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 9.21 + * 9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 9.23 + * or visit www.oracle.com if you need additional information or have any 9.24 + * questions. 9.25 + */ 9.26 + 9.27 +/** 9.28 + * Tests to check 'break' statement. 9.29 + * 9.30 + * @test 9.31 + * @run 9.32 + */ 9.33 + 9.34 +load(__DIR__ + "util.js"); 9.35 + 9.36 +printParse("while (true) { break; }"); 9.37 +printParse("loop: { while (true) { break loop } }"); 9.38 +printParse("loop: { for (;;) { break loop } }");
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/script/basic/parser/breakStat.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 10.3 @@ -0,0 +1,92 @@ 10.4 +{ 10.5 + "type": "Program", 10.6 + "body": [ 10.7 + { 10.8 + "type": "WhileStatement", 10.9 + "test": { 10.10 + "type": "Literal", 10.11 + "value": true 10.12 + }, 10.13 + "body": { 10.14 + "type": "BlockStatement", 10.15 + "body": [ 10.16 + { 10.17 + "type": "BreakStatement", 10.18 + "label": null 10.19 + } 10.20 + ] 10.21 + } 10.22 + } 10.23 + ] 10.24 +} 10.25 +{ 10.26 + "type": "Program", 10.27 + "body": [ 10.28 + { 10.29 + "type": "LabeledStatement", 10.30 + "label": { 10.31 + "type": "Identifier", 10.32 + "name": "loop" 10.33 + }, 10.34 + "body": { 10.35 + "type": "BlockStatement", 10.36 + "body": [ 10.37 + { 10.38 + "type": "WhileStatement", 10.39 + "test": { 10.40 + "type": "Literal", 10.41 + "value": true 10.42 + }, 10.43 + "body": { 10.44 + "type": "BlockStatement", 10.45 + "body": [ 10.46 + { 10.47 + "type": "BreakStatement", 10.48 + "label": { 10.49 + "type": "Identifier", 10.50 + "name": "loop" 10.51 + } 10.52 + } 10.53 + ] 10.54 + } 10.55 + } 10.56 + ] 10.57 + } 10.58 + } 10.59 + ] 10.60 +} 10.61 +{ 10.62 + "type": "Program", 10.63 + "body": [ 10.64 + { 10.65 + "type": "LabeledStatement", 10.66 + "label": { 10.67 + "type": "Identifier", 10.68 + "name": "loop" 10.69 + }, 10.70 + "body": { 10.71 + "type": "BlockStatement", 10.72 + "body": [ 10.73 + { 10.74 + "type": "ForStatement", 10.75 + "init": null, 10.76 + "test": null, 10.77 + "update": null, 10.78 + "body": { 10.79 + "type": "BlockStatement", 10.80 + "body": [ 10.81 + { 10.82 + "type": "BreakStatement", 10.83 + "label": { 10.84 + "type": "Identifier", 10.85 + "name": "loop" 10.86 + } 10.87 + } 10.88 + ] 10.89 + } 10.90 + } 10.91 + ] 10.92 + } 10.93 + } 10.94 + ] 10.95 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/script/basic/parser/condExpr.js Thu Sep 12 22:16:40 2013 +0530 11.3 @@ -0,0 +1,33 @@ 11.4 +/* 11.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 + * 11.8 + * This code is free software; you can redistribute it and/or modify it 11.9 + * under the terms of the GNU General Public License version 2 only, as 11.10 + * published by the Free Software Foundation. 11.11 + * 11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.15 + * version 2 for more details (a copy is included in the LICENSE file that 11.16 + * accompanied this code). 11.17 + * 11.18 + * You should have received a copy of the GNU General Public License version 11.19 + * 2 along with this work; if not, write to the Free Software Foundation, 11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.21 + * 11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.23 + * or visit www.oracle.com if you need additional information or have any 11.24 + * questions. 11.25 + */ 11.26 + 11.27 +/** 11.28 + * Tests to check ternary operator. 11.29 + * 11.30 + * @test 11.31 + * @run 11.32 + */ 11.33 + 11.34 +load(__DIR__ + "util.js"); 11.35 + 11.36 +printParse("a? b : c");
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/script/basic/parser/condExpr.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 12.3 @@ -0,0 +1,23 @@ 12.4 +{ 12.5 + "type": "Program", 12.6 + "body": [ 12.7 + { 12.8 + "type": "ExpressionStatement", 12.9 + "expression": { 12.10 + "type": "ConditionalExpression", 12.11 + "test": { 12.12 + "type": "Identifier", 12.13 + "name": "a" 12.14 + }, 12.15 + "consequent": { 12.16 + "type": "Identifier", 12.17 + "name": "b" 12.18 + }, 12.19 + "alternate": { 12.20 + "type": "Identifier", 12.21 + "name": "c" 12.22 + } 12.23 + } 12.24 + } 12.25 + ] 12.26 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/script/basic/parser/continueStat.js Thu Sep 12 22:16:40 2013 +0530 13.3 @@ -0,0 +1,35 @@ 13.4 +/* 13.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.7 + * 13.8 + * This code is free software; you can redistribute it and/or modify it 13.9 + * under the terms of the GNU General Public License version 2 only, as 13.10 + * published by the Free Software Foundation. 13.11 + * 13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13.15 + * version 2 for more details (a copy is included in the LICENSE file that 13.16 + * accompanied this code). 13.17 + * 13.18 + * You should have received a copy of the GNU General Public License version 13.19 + * 2 along with this work; if not, write to the Free Software Foundation, 13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 13.21 + * 13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 13.23 + * or visit www.oracle.com if you need additional information or have any 13.24 + * questions. 13.25 + */ 13.26 + 13.27 +/** 13.28 + * Tests to check 'continue' statement. 13.29 + * 13.30 + * @test 13.31 + * @run 13.32 + */ 13.33 + 13.34 +load(__DIR__ + "util.js"); 13.35 + 13.36 +printParse("while (true) { continue; }"); 13.37 +printParse("begin: { while (true) { continue begin; } }"); 13.38 +printParse("start: { for(;;) { continue start; } }");
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/test/script/basic/parser/continueStat.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 14.3 @@ -0,0 +1,92 @@ 14.4 +{ 14.5 + "type": "Program", 14.6 + "body": [ 14.7 + { 14.8 + "type": "WhileStatement", 14.9 + "test": { 14.10 + "type": "Literal", 14.11 + "value": true 14.12 + }, 14.13 + "body": { 14.14 + "type": "BlockStatement", 14.15 + "body": [ 14.16 + { 14.17 + "type": "ContinueStatement", 14.18 + "label": null 14.19 + } 14.20 + ] 14.21 + } 14.22 + } 14.23 + ] 14.24 +} 14.25 +{ 14.26 + "type": "Program", 14.27 + "body": [ 14.28 + { 14.29 + "type": "LabeledStatement", 14.30 + "label": { 14.31 + "type": "Identifier", 14.32 + "name": "begin" 14.33 + }, 14.34 + "body": { 14.35 + "type": "BlockStatement", 14.36 + "body": [ 14.37 + { 14.38 + "type": "WhileStatement", 14.39 + "test": { 14.40 + "type": "Literal", 14.41 + "value": true 14.42 + }, 14.43 + "body": { 14.44 + "type": "BlockStatement", 14.45 + "body": [ 14.46 + { 14.47 + "type": "ContinueStatement", 14.48 + "label": { 14.49 + "type": "Identifier", 14.50 + "name": "begin" 14.51 + } 14.52 + } 14.53 + ] 14.54 + } 14.55 + } 14.56 + ] 14.57 + } 14.58 + } 14.59 + ] 14.60 +} 14.61 +{ 14.62 + "type": "Program", 14.63 + "body": [ 14.64 + { 14.65 + "type": "LabeledStatement", 14.66 + "label": { 14.67 + "type": "Identifier", 14.68 + "name": "start" 14.69 + }, 14.70 + "body": { 14.71 + "type": "BlockStatement", 14.72 + "body": [ 14.73 + { 14.74 + "type": "ForStatement", 14.75 + "init": null, 14.76 + "test": null, 14.77 + "update": null, 14.78 + "body": { 14.79 + "type": "BlockStatement", 14.80 + "body": [ 14.81 + { 14.82 + "type": "ContinueStatement", 14.83 + "label": { 14.84 + "type": "Identifier", 14.85 + "name": "start" 14.86 + } 14.87 + } 14.88 + ] 14.89 + } 14.90 + } 14.91 + ] 14.92 + } 14.93 + } 14.94 + ] 14.95 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/test/script/basic/parser/debuggerStat.js Thu Sep 12 22:16:40 2013 +0530 15.3 @@ -0,0 +1,33 @@ 15.4 +/* 15.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.7 + * 15.8 + * This code is free software; you can redistribute it and/or modify it 15.9 + * under the terms of the GNU General Public License version 2 only, as 15.10 + * published by the Free Software Foundation. 15.11 + * 15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15.15 + * version 2 for more details (a copy is included in the LICENSE file that 15.16 + * accompanied this code). 15.17 + * 15.18 + * You should have received a copy of the GNU General Public License version 15.19 + * 2 along with this work; if not, write to the Free Software Foundation, 15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 15.21 + * 15.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 15.23 + * or visit www.oracle.com if you need additional information or have any 15.24 + * questions. 15.25 + */ 15.26 + 15.27 +/** 15.28 + * Tests to check debugger statement. 15.29 + * 15.30 + * @test 15.31 + * @run 15.32 + */ 15.33 + 15.34 +load(__DIR__ + "util.js"); 15.35 + 15.36 +printParse("debugger");
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/test/script/basic/parser/debuggerStat.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 16.3 @@ -0,0 +1,8 @@ 16.4 +{ 16.5 + "type": "Program", 16.6 + "body": [ 16.7 + { 16.8 + "type": "DebuggerStatement" 16.9 + } 16.10 + ] 16.11 +}
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/test/script/basic/parser/functions.js Thu Sep 12 22:16:40 2013 +0530 17.3 @@ -0,0 +1,39 @@ 17.4 +/* 17.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 17.7 + * 17.8 + * This code is free software; you can redistribute it and/or modify it 17.9 + * under the terms of the GNU General Public License version 2 only, as 17.10 + * published by the Free Software Foundation. 17.11 + * 17.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 17.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 17.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17.15 + * version 2 for more details (a copy is included in the LICENSE file that 17.16 + * accompanied this code). 17.17 + * 17.18 + * You should have received a copy of the GNU General Public License version 17.19 + * 2 along with this work; if not, write to the Free Software Foundation, 17.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17.21 + * 17.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 17.23 + * or visit www.oracle.com if you need additional information or have any 17.24 + * questions. 17.25 + */ 17.26 + 17.27 +/** 17.28 + * Tests to check 'function' statements and expressions. 17.29 + * 17.30 + * @test 17.31 + * @run 17.32 + */ 17.33 + 17.34 +load(__DIR__ + "util.js"); 17.35 + 17.36 +printParse("function hello() { print('hello') }") 17.37 +printParse("function hello(a) { print(a) }") 17.38 +printParse("function hello(a, b) { print(a, b) }") 17.39 +printParse("var hello = function() { print('hello') };") 17.40 +printParse("var hello = function hello() { print('hello') };") 17.41 +printParse("(function(){})") 17.42 +printParse("function test() { 'use strict' }");
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/test/script/basic/parser/functions.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 18.3 @@ -0,0 +1,279 @@ 18.4 +{ 18.5 + "type": "Program", 18.6 + "body": [ 18.7 + { 18.8 + "type": "FunctionDeclaration", 18.9 + "id": { 18.10 + "type": "Identifier", 18.11 + "name": "hello" 18.12 + }, 18.13 + "params": [], 18.14 + "defaults": [], 18.15 + "rest": null, 18.16 + "body": { 18.17 + "type": "BlockStatement", 18.18 + "body": [ 18.19 + { 18.20 + "type": "ExpressionStatement", 18.21 + "expression": { 18.22 + "type": "CallExpression", 18.23 + "callee": { 18.24 + "type": "Identifier", 18.25 + "name": "print" 18.26 + }, 18.27 + "arguments": [ 18.28 + { 18.29 + "type": "Literal", 18.30 + "value": "hello" 18.31 + } 18.32 + ] 18.33 + } 18.34 + } 18.35 + ] 18.36 + }, 18.37 + "generator": false, 18.38 + "expression": false 18.39 + } 18.40 + ] 18.41 +} 18.42 +{ 18.43 + "type": "Program", 18.44 + "body": [ 18.45 + { 18.46 + "type": "FunctionDeclaration", 18.47 + "id": { 18.48 + "type": "Identifier", 18.49 + "name": "hello" 18.50 + }, 18.51 + "params": [ 18.52 + { 18.53 + "type": "Identifier", 18.54 + "name": "a" 18.55 + } 18.56 + ], 18.57 + "defaults": [], 18.58 + "rest": null, 18.59 + "body": { 18.60 + "type": "BlockStatement", 18.61 + "body": [ 18.62 + { 18.63 + "type": "ExpressionStatement", 18.64 + "expression": { 18.65 + "type": "CallExpression", 18.66 + "callee": { 18.67 + "type": "Identifier", 18.68 + "name": "print" 18.69 + }, 18.70 + "arguments": [ 18.71 + { 18.72 + "type": "Identifier", 18.73 + "name": "a" 18.74 + } 18.75 + ] 18.76 + } 18.77 + } 18.78 + ] 18.79 + }, 18.80 + "generator": false, 18.81 + "expression": false 18.82 + } 18.83 + ] 18.84 +} 18.85 +{ 18.86 + "type": "Program", 18.87 + "body": [ 18.88 + { 18.89 + "type": "FunctionDeclaration", 18.90 + "id": { 18.91 + "type": "Identifier", 18.92 + "name": "hello" 18.93 + }, 18.94 + "params": [ 18.95 + { 18.96 + "type": "Identifier", 18.97 + "name": "a" 18.98 + }, 18.99 + { 18.100 + "type": "Identifier", 18.101 + "name": "b" 18.102 + } 18.103 + ], 18.104 + "defaults": [], 18.105 + "rest": null, 18.106 + "body": { 18.107 + "type": "BlockStatement", 18.108 + "body": [ 18.109 + { 18.110 + "type": "ExpressionStatement", 18.111 + "expression": { 18.112 + "type": "CallExpression", 18.113 + "callee": { 18.114 + "type": "Identifier", 18.115 + "name": "print" 18.116 + }, 18.117 + "arguments": [ 18.118 + { 18.119 + "type": "Identifier", 18.120 + "name": "a" 18.121 + }, 18.122 + { 18.123 + "type": "Identifier", 18.124 + "name": "b" 18.125 + } 18.126 + ] 18.127 + } 18.128 + } 18.129 + ] 18.130 + }, 18.131 + "generator": false, 18.132 + "expression": false 18.133 + } 18.134 + ] 18.135 +} 18.136 +{ 18.137 + "type": "Program", 18.138 + "body": [ 18.139 + { 18.140 + "type": "VariableDeclaration", 18.141 + "declarations": [ 18.142 + { 18.143 + "type": "VariableDeclarator", 18.144 + "id": { 18.145 + "type": "Identifier", 18.146 + "name": "hello" 18.147 + }, 18.148 + "init": { 18.149 + "type": "FunctionExpression", 18.150 + "id": null, 18.151 + "params": [], 18.152 + "defaults": [], 18.153 + "rest": null, 18.154 + "body": { 18.155 + "type": "BlockStatement", 18.156 + "body": [ 18.157 + { 18.158 + "type": "ExpressionStatement", 18.159 + "expression": { 18.160 + "type": "CallExpression", 18.161 + "callee": { 18.162 + "type": "Identifier", 18.163 + "name": "print" 18.164 + }, 18.165 + "arguments": [ 18.166 + { 18.167 + "type": "Literal", 18.168 + "value": "hello" 18.169 + } 18.170 + ] 18.171 + } 18.172 + } 18.173 + ] 18.174 + }, 18.175 + "generator": false, 18.176 + "expression": false 18.177 + } 18.178 + } 18.179 + ] 18.180 + } 18.181 + ] 18.182 +} 18.183 +{ 18.184 + "type": "Program", 18.185 + "body": [ 18.186 + { 18.187 + "type": "VariableDeclaration", 18.188 + "declarations": [ 18.189 + { 18.190 + "type": "VariableDeclarator", 18.191 + "id": { 18.192 + "type": "Identifier", 18.193 + "name": "hello" 18.194 + }, 18.195 + "init": { 18.196 + "type": "FunctionExpression", 18.197 + "id": { 18.198 + "type": "Identifier", 18.199 + "name": "hello" 18.200 + }, 18.201 + "params": [], 18.202 + "defaults": [], 18.203 + "rest": null, 18.204 + "body": { 18.205 + "type": "BlockStatement", 18.206 + "body": [ 18.207 + { 18.208 + "type": "ExpressionStatement", 18.209 + "expression": { 18.210 + "type": "CallExpression", 18.211 + "callee": { 18.212 + "type": "Identifier", 18.213 + "name": "print" 18.214 + }, 18.215 + "arguments": [ 18.216 + { 18.217 + "type": "Literal", 18.218 + "value": "hello" 18.219 + } 18.220 + ] 18.221 + } 18.222 + } 18.223 + ] 18.224 + }, 18.225 + "generator": false, 18.226 + "expression": false 18.227 + } 18.228 + } 18.229 + ] 18.230 + } 18.231 + ] 18.232 +} 18.233 +{ 18.234 + "type": "Program", 18.235 + "body": [ 18.236 + { 18.237 + "type": "ExpressionStatement", 18.238 + "expression": { 18.239 + "type": "FunctionExpression", 18.240 + "id": null, 18.241 + "params": [], 18.242 + "defaults": [], 18.243 + "rest": null, 18.244 + "body": { 18.245 + "type": "BlockStatement", 18.246 + "body": [] 18.247 + }, 18.248 + "generator": false, 18.249 + "expression": false 18.250 + } 18.251 + } 18.252 + ] 18.253 +} 18.254 +{ 18.255 + "type": "Program", 18.256 + "body": [ 18.257 + { 18.258 + "type": "FunctionDeclaration", 18.259 + "id": { 18.260 + "type": "Identifier", 18.261 + "name": "test" 18.262 + }, 18.263 + "params": [], 18.264 + "defaults": [], 18.265 + "rest": null, 18.266 + "body": { 18.267 + "type": "BlockStatement", 18.268 + "body": [ 18.269 + { 18.270 + "type": "ExpressionStatement", 18.271 + "expression": { 18.272 + "type": "Literal", 18.273 + "value": "use strict" 18.274 + } 18.275 + } 18.276 + ] 18.277 + }, 18.278 + "generator": false, 18.279 + "expression": false 18.280 + } 18.281 + ] 18.282 +}
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/test/script/basic/parser/ifStat.js Thu Sep 12 22:16:40 2013 +0530 19.3 @@ -0,0 +1,34 @@ 19.4 +/* 19.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.7 + * 19.8 + * This code is free software; you can redistribute it and/or modify it 19.9 + * under the terms of the GNU General Public License version 2 only, as 19.10 + * published by the Free Software Foundation. 19.11 + * 19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19.15 + * version 2 for more details (a copy is included in the LICENSE file that 19.16 + * accompanied this code). 19.17 + * 19.18 + * You should have received a copy of the GNU General Public License version 19.19 + * 2 along with this work; if not, write to the Free Software Foundation, 19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19.21 + * 19.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19.23 + * or visit www.oracle.com if you need additional information or have any 19.24 + * questions. 19.25 + */ 19.26 + 19.27 +/** 19.28 + * Tests to check 'if' statement. 19.29 + * 19.30 + * @test 19.31 + * @run 19.32 + */ 19.33 + 19.34 +load(__DIR__ + "util.js"); 19.35 + 19.36 +printParse("if (js) { nashorn() }"); 19.37 +printParse("if (js) { nashorn() } else { java() }");
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/test/script/basic/parser/ifStat.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 20.3 @@ -0,0 +1,73 @@ 20.4 +{ 20.5 + "type": "Program", 20.6 + "body": [ 20.7 + { 20.8 + "type": "IfStatement", 20.9 + "test": { 20.10 + "type": "Identifier", 20.11 + "name": "js" 20.12 + }, 20.13 + "consequent": { 20.14 + "type": "BlockStatement", 20.15 + "body": [ 20.16 + { 20.17 + "type": "ExpressionStatement", 20.18 + "expression": { 20.19 + "type": "CallExpression", 20.20 + "callee": { 20.21 + "type": "Identifier", 20.22 + "name": "nashorn" 20.23 + }, 20.24 + "arguments": [] 20.25 + } 20.26 + } 20.27 + ] 20.28 + }, 20.29 + "alternate": null 20.30 + } 20.31 + ] 20.32 +} 20.33 +{ 20.34 + "type": "Program", 20.35 + "body": [ 20.36 + { 20.37 + "type": "IfStatement", 20.38 + "test": { 20.39 + "type": "Identifier", 20.40 + "name": "js" 20.41 + }, 20.42 + "consequent": { 20.43 + "type": "BlockStatement", 20.44 + "body": [ 20.45 + { 20.46 + "type": "ExpressionStatement", 20.47 + "expression": { 20.48 + "type": "CallExpression", 20.49 + "callee": { 20.50 + "type": "Identifier", 20.51 + "name": "nashorn" 20.52 + }, 20.53 + "arguments": [] 20.54 + } 20.55 + } 20.56 + ] 20.57 + }, 20.58 + "alternate": { 20.59 + "type": "BlockStatement", 20.60 + "body": [ 20.61 + { 20.62 + "type": "ExpressionStatement", 20.63 + "expression": { 20.64 + "type": "CallExpression", 20.65 + "callee": { 20.66 + "type": "Identifier", 20.67 + "name": "java" 20.68 + }, 20.69 + "arguments": [] 20.70 + } 20.71 + } 20.72 + ] 20.73 + } 20.74 + } 20.75 + ] 20.76 +}
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/test/script/basic/parser/labelledStat.js Thu Sep 12 22:16:40 2013 +0530 21.3 @@ -0,0 +1,34 @@ 21.4 +/* 21.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.7 + * 21.8 + * This code is free software; you can redistribute it and/or modify it 21.9 + * under the terms of the GNU General Public License version 2 only, as 21.10 + * published by the Free Software Foundation. 21.11 + * 21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21.15 + * version 2 for more details (a copy is included in the LICENSE file that 21.16 + * accompanied this code). 21.17 + * 21.18 + * You should have received a copy of the GNU General Public License version 21.19 + * 2 along with this work; if not, write to the Free Software Foundation, 21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21.21 + * 21.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21.23 + * or visit www.oracle.com if you need additional information or have any 21.24 + * questions. 21.25 + */ 21.26 + 21.27 +/** 21.28 + * Test for labelled statements. 21.29 + * 21.30 + * @test 21.31 + * @run 21.32 + */ 21.33 + 21.34 +load(__DIR__ + "util.js"); 21.35 + 21.36 +printParse("begin: { for (;;) break begin }"); 21.37 +printParse("begin: { while (true) break begin }");
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/test/script/basic/parser/labelledStat.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 22.3 @@ -0,0 +1,71 @@ 22.4 +{ 22.5 + "type": "Program", 22.6 + "body": [ 22.7 + { 22.8 + "type": "LabeledStatement", 22.9 + "label": { 22.10 + "type": "Identifier", 22.11 + "name": "begin" 22.12 + }, 22.13 + "body": { 22.14 + "type": "BlockStatement", 22.15 + "body": [ 22.16 + { 22.17 + "type": "ForStatement", 22.18 + "init": null, 22.19 + "test": null, 22.20 + "update": null, 22.21 + "body": { 22.22 + "type": "BlockStatement", 22.23 + "body": [ 22.24 + { 22.25 + "type": "BreakStatement", 22.26 + "label": { 22.27 + "type": "Identifier", 22.28 + "name": "begin" 22.29 + } 22.30 + } 22.31 + ] 22.32 + } 22.33 + } 22.34 + ] 22.35 + } 22.36 + } 22.37 + ] 22.38 +} 22.39 +{ 22.40 + "type": "Program", 22.41 + "body": [ 22.42 + { 22.43 + "type": "LabeledStatement", 22.44 + "label": { 22.45 + "type": "Identifier", 22.46 + "name": "begin" 22.47 + }, 22.48 + "body": { 22.49 + "type": "BlockStatement", 22.50 + "body": [ 22.51 + { 22.52 + "type": "WhileStatement", 22.53 + "test": { 22.54 + "type": "Literal", 22.55 + "value": true 22.56 + }, 22.57 + "body": { 22.58 + "type": "BlockStatement", 22.59 + "body": [ 22.60 + { 22.61 + "type": "BreakStatement", 22.62 + "label": { 22.63 + "type": "Identifier", 22.64 + "name": "begin" 22.65 + } 22.66 + } 22.67 + ] 22.68 + } 22.69 + } 22.70 + ] 22.71 + } 22.72 + } 22.73 + ] 22.74 +}
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 23.2 +++ b/test/script/basic/parser/lhsExpr.js Thu Sep 12 22:16:40 2013 +0530 23.3 @@ -0,0 +1,47 @@ 23.4 +/* 23.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 23.7 + * 23.8 + * This code is free software; you can redistribute it and/or modify it 23.9 + * under the terms of the GNU General Public License version 2 only, as 23.10 + * published by the Free Software Foundation. 23.11 + * 23.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 23.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 23.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 23.15 + * version 2 for more details (a copy is included in the LICENSE file that 23.16 + * accompanied this code). 23.17 + * 23.18 + * You should have received a copy of the GNU General Public License version 23.19 + * 2 along with this work; if not, write to the Free Software Foundation, 23.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23.21 + * 23.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23.23 + * or visit www.oracle.com if you need additional information or have any 23.24 + * questions. 23.25 + */ 23.26 + 23.27 +/** 23.28 + * Tests to check left-hand-side expressions 23.29 + * 23.30 + * @test 23.31 + * @run 23.32 + */ 23.33 + 23.34 +load(__DIR__ + "util.js"); 23.35 + 23.36 +printParse("a[3]"); 23.37 +printParse("a[b]"); 23.38 +printParse("a['foo']"); 23.39 +printParse("obj.foo"); 23.40 +printParse("obj.foo.bar"); 23.41 +printParse("new Type"); 23.42 +printParse("new Type()"); 23.43 +printParse("new Type(a, 'hello')"); 23.44 +printParse("new obj.Type"); 23.45 +printParse("new obj.Type()"); 23.46 +printParse("new obj.Type(a, 'hello')"); 23.47 +printParse("foo()") 23.48 +printParse("obj.foo()"); 23.49 +printParse("foo(a,b)"); 23.50 +printParse("obj.foo(a, b)");
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 24.2 +++ b/test/script/basic/parser/lhsExpr.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 24.3 @@ -0,0 +1,344 @@ 24.4 +{ 24.5 + "type": "Program", 24.6 + "body": [ 24.7 + { 24.8 + "type": "ExpressionStatement", 24.9 + "expression": { 24.10 + "type": "MemberExpression", 24.11 + "object": { 24.12 + "type": "Identifier", 24.13 + "name": "a" 24.14 + }, 24.15 + "property": { 24.16 + "type": "Literal", 24.17 + "value": 3 24.18 + }, 24.19 + "computed": true 24.20 + } 24.21 + } 24.22 + ] 24.23 +} 24.24 +{ 24.25 + "type": "Program", 24.26 + "body": [ 24.27 + { 24.28 + "type": "ExpressionStatement", 24.29 + "expression": { 24.30 + "type": "MemberExpression", 24.31 + "object": { 24.32 + "type": "Identifier", 24.33 + "name": "a" 24.34 + }, 24.35 + "property": { 24.36 + "type": "Identifier", 24.37 + "name": "b" 24.38 + }, 24.39 + "computed": true 24.40 + } 24.41 + } 24.42 + ] 24.43 +} 24.44 +{ 24.45 + "type": "Program", 24.46 + "body": [ 24.47 + { 24.48 + "type": "ExpressionStatement", 24.49 + "expression": { 24.50 + "type": "MemberExpression", 24.51 + "object": { 24.52 + "type": "Identifier", 24.53 + "name": "a" 24.54 + }, 24.55 + "property": { 24.56 + "type": "Literal", 24.57 + "value": "foo" 24.58 + }, 24.59 + "computed": true 24.60 + } 24.61 + } 24.62 + ] 24.63 +} 24.64 +{ 24.65 + "type": "Program", 24.66 + "body": [ 24.67 + { 24.68 + "type": "ExpressionStatement", 24.69 + "expression": { 24.70 + "type": "MemberExpression", 24.71 + "object": { 24.72 + "type": "Identifier", 24.73 + "name": "obj" 24.74 + }, 24.75 + "property": { 24.76 + "type": "Identifier", 24.77 + "name": "foo" 24.78 + }, 24.79 + "computed": false 24.80 + } 24.81 + } 24.82 + ] 24.83 +} 24.84 +{ 24.85 + "type": "Program", 24.86 + "body": [ 24.87 + { 24.88 + "type": "ExpressionStatement", 24.89 + "expression": { 24.90 + "type": "MemberExpression", 24.91 + "object": { 24.92 + "type": "MemberExpression", 24.93 + "object": { 24.94 + "type": "Identifier", 24.95 + "name": "obj" 24.96 + }, 24.97 + "property": { 24.98 + "type": "Identifier", 24.99 + "name": "foo" 24.100 + }, 24.101 + "computed": false 24.102 + }, 24.103 + "property": { 24.104 + "type": "Identifier", 24.105 + "name": "bar" 24.106 + }, 24.107 + "computed": false 24.108 + } 24.109 + } 24.110 + ] 24.111 +} 24.112 +{ 24.113 + "type": "Program", 24.114 + "body": [ 24.115 + { 24.116 + "type": "ExpressionStatement", 24.117 + "expression": { 24.118 + "type": "NewExpression", 24.119 + "callee": { 24.120 + "type": "Identifier", 24.121 + "name": "Type" 24.122 + }, 24.123 + "arguments": [] 24.124 + } 24.125 + } 24.126 + ] 24.127 +} 24.128 +{ 24.129 + "type": "Program", 24.130 + "body": [ 24.131 + { 24.132 + "type": "ExpressionStatement", 24.133 + "expression": { 24.134 + "type": "NewExpression", 24.135 + "callee": { 24.136 + "type": "Identifier", 24.137 + "name": "Type" 24.138 + }, 24.139 + "arguments": [] 24.140 + } 24.141 + } 24.142 + ] 24.143 +} 24.144 +{ 24.145 + "type": "Program", 24.146 + "body": [ 24.147 + { 24.148 + "type": "ExpressionStatement", 24.149 + "expression": { 24.150 + "type": "NewExpression", 24.151 + "callee": { 24.152 + "type": "Identifier", 24.153 + "name": "Type" 24.154 + }, 24.155 + "arguments": [ 24.156 + { 24.157 + "type": "Identifier", 24.158 + "name": "a" 24.159 + }, 24.160 + { 24.161 + "type": "Literal", 24.162 + "value": "hello" 24.163 + } 24.164 + ] 24.165 + } 24.166 + } 24.167 + ] 24.168 +} 24.169 +{ 24.170 + "type": "Program", 24.171 + "body": [ 24.172 + { 24.173 + "type": "ExpressionStatement", 24.174 + "expression": { 24.175 + "type": "NewExpression", 24.176 + "callee": { 24.177 + "type": "MemberExpression", 24.178 + "object": { 24.179 + "type": "Identifier", 24.180 + "name": "obj" 24.181 + }, 24.182 + "property": { 24.183 + "type": "Identifier", 24.184 + "name": "Type" 24.185 + }, 24.186 + "computed": false 24.187 + }, 24.188 + "arguments": [] 24.189 + } 24.190 + } 24.191 + ] 24.192 +} 24.193 +{ 24.194 + "type": "Program", 24.195 + "body": [ 24.196 + { 24.197 + "type": "ExpressionStatement", 24.198 + "expression": { 24.199 + "type": "NewExpression", 24.200 + "callee": { 24.201 + "type": "MemberExpression", 24.202 + "object": { 24.203 + "type": "Identifier", 24.204 + "name": "obj" 24.205 + }, 24.206 + "property": { 24.207 + "type": "Identifier", 24.208 + "name": "Type" 24.209 + }, 24.210 + "computed": false 24.211 + }, 24.212 + "arguments": [] 24.213 + } 24.214 + } 24.215 + ] 24.216 +} 24.217 +{ 24.218 + "type": "Program", 24.219 + "body": [ 24.220 + { 24.221 + "type": "ExpressionStatement", 24.222 + "expression": { 24.223 + "type": "NewExpression", 24.224 + "callee": { 24.225 + "type": "MemberExpression", 24.226 + "object": { 24.227 + "type": "Identifier", 24.228 + "name": "obj" 24.229 + }, 24.230 + "property": { 24.231 + "type": "Identifier", 24.232 + "name": "Type" 24.233 + }, 24.234 + "computed": false 24.235 + }, 24.236 + "arguments": [ 24.237 + { 24.238 + "type": "Identifier", 24.239 + "name": "a" 24.240 + }, 24.241 + { 24.242 + "type": "Literal", 24.243 + "value": "hello" 24.244 + } 24.245 + ] 24.246 + } 24.247 + } 24.248 + ] 24.249 +} 24.250 +{ 24.251 + "type": "Program", 24.252 + "body": [ 24.253 + { 24.254 + "type": "ExpressionStatement", 24.255 + "expression": { 24.256 + "type": "CallExpression", 24.257 + "callee": { 24.258 + "type": "Identifier", 24.259 + "name": "foo" 24.260 + }, 24.261 + "arguments": [] 24.262 + } 24.263 + } 24.264 + ] 24.265 +} 24.266 +{ 24.267 + "type": "Program", 24.268 + "body": [ 24.269 + { 24.270 + "type": "ExpressionStatement", 24.271 + "expression": { 24.272 + "type": "CallExpression", 24.273 + "callee": { 24.274 + "type": "MemberExpression", 24.275 + "object": { 24.276 + "type": "Identifier", 24.277 + "name": "obj" 24.278 + }, 24.279 + "property": { 24.280 + "type": "Identifier", 24.281 + "name": "foo" 24.282 + }, 24.283 + "computed": false 24.284 + }, 24.285 + "arguments": [] 24.286 + } 24.287 + } 24.288 + ] 24.289 +} 24.290 +{ 24.291 + "type": "Program", 24.292 + "body": [ 24.293 + { 24.294 + "type": "ExpressionStatement", 24.295 + "expression": { 24.296 + "type": "CallExpression", 24.297 + "callee": { 24.298 + "type": "Identifier", 24.299 + "name": "foo" 24.300 + }, 24.301 + "arguments": [ 24.302 + { 24.303 + "type": "Identifier", 24.304 + "name": "a" 24.305 + }, 24.306 + { 24.307 + "type": "Identifier", 24.308 + "name": "b" 24.309 + } 24.310 + ] 24.311 + } 24.312 + } 24.313 + ] 24.314 +} 24.315 +{ 24.316 + "type": "Program", 24.317 + "body": [ 24.318 + { 24.319 + "type": "ExpressionStatement", 24.320 + "expression": { 24.321 + "type": "CallExpression", 24.322 + "callee": { 24.323 + "type": "MemberExpression", 24.324 + "object": { 24.325 + "type": "Identifier", 24.326 + "name": "obj" 24.327 + }, 24.328 + "property": { 24.329 + "type": "Identifier", 24.330 + "name": "foo" 24.331 + }, 24.332 + "computed": false 24.333 + }, 24.334 + "arguments": [ 24.335 + { 24.336 + "type": "Identifier", 24.337 + "name": "a" 24.338 + }, 24.339 + { 24.340 + "type": "Identifier", 24.341 + "name": "b" 24.342 + } 24.343 + ] 24.344 + } 24.345 + } 24.346 + ] 24.347 +}
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/test/script/basic/parser/loopStat.js Thu Sep 12 22:16:40 2013 +0530 25.3 @@ -0,0 +1,37 @@ 25.4 +/* 25.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.7 + * 25.8 + * This code is free software; you can redistribute it and/or modify it 25.9 + * under the terms of the GNU General Public License version 2 only, as 25.10 + * published by the Free Software Foundation. 25.11 + * 25.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 25.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 25.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25.15 + * version 2 for more details (a copy is included in the LICENSE file that 25.16 + * accompanied this code). 25.17 + * 25.18 + * You should have received a copy of the GNU General Public License version 25.19 + * 2 along with this work; if not, write to the Free Software Foundation, 25.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 25.21 + * 25.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 25.23 + * or visit www.oracle.com if you need additional information or have any 25.24 + * questions. 25.25 + */ 25.26 + 25.27 +/** 25.28 + * Tests for loop statements. 25.29 + * 25.30 + * @test 25.31 + * @run 25.32 + */ 25.33 + 25.34 +load(__DIR__ + "util.js"); 25.35 + 25.36 +printParse("while(true) { print('hello') }") 25.37 +printParse("do { print('hello') } while(true)") 25.38 +printParse("for (i in obj) { print(obj[i]) }") 25.39 +printParse("for each (i in obj) { print(i) }") 25.40 +printParse("for (i = 0; i < 10; i++) { print(i) }")
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 26.2 +++ b/test/script/basic/parser/loopStat.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 26.3 @@ -0,0 +1,212 @@ 26.4 +{ 26.5 + "type": "Program", 26.6 + "body": [ 26.7 + { 26.8 + "type": "WhileStatement", 26.9 + "test": { 26.10 + "type": "Literal", 26.11 + "value": true 26.12 + }, 26.13 + "body": { 26.14 + "type": "BlockStatement", 26.15 + "body": [ 26.16 + { 26.17 + "type": "ExpressionStatement", 26.18 + "expression": { 26.19 + "type": "CallExpression", 26.20 + "callee": { 26.21 + "type": "Identifier", 26.22 + "name": "print" 26.23 + }, 26.24 + "arguments": [ 26.25 + { 26.26 + "type": "Literal", 26.27 + "value": "hello" 26.28 + } 26.29 + ] 26.30 + } 26.31 + } 26.32 + ] 26.33 + } 26.34 + } 26.35 + ] 26.36 +} 26.37 +{ 26.38 + "type": "Program", 26.39 + "body": [ 26.40 + { 26.41 + "type": "DoWhileStatement", 26.42 + "body": { 26.43 + "type": "BlockStatement", 26.44 + "body": [ 26.45 + { 26.46 + "type": "ExpressionStatement", 26.47 + "expression": { 26.48 + "type": "CallExpression", 26.49 + "callee": { 26.50 + "type": "Identifier", 26.51 + "name": "print" 26.52 + }, 26.53 + "arguments": [ 26.54 + { 26.55 + "type": "Literal", 26.56 + "value": "hello" 26.57 + } 26.58 + ] 26.59 + } 26.60 + } 26.61 + ] 26.62 + }, 26.63 + "test": { 26.64 + "type": "Literal", 26.65 + "value": true 26.66 + } 26.67 + } 26.68 + ] 26.69 +} 26.70 +{ 26.71 + "type": "Program", 26.72 + "body": [ 26.73 + { 26.74 + "type": "ForInStatement", 26.75 + "left": { 26.76 + "type": "Identifier", 26.77 + "name": "i" 26.78 + }, 26.79 + "right": { 26.80 + "type": "Identifier", 26.81 + "name": "obj" 26.82 + }, 26.83 + "body": { 26.84 + "type": "BlockStatement", 26.85 + "body": [ 26.86 + { 26.87 + "type": "ExpressionStatement", 26.88 + "expression": { 26.89 + "type": "CallExpression", 26.90 + "callee": { 26.91 + "type": "Identifier", 26.92 + "name": "print" 26.93 + }, 26.94 + "arguments": [ 26.95 + { 26.96 + "type": "MemberExpression", 26.97 + "object": { 26.98 + "type": "Identifier", 26.99 + "name": "obj" 26.100 + }, 26.101 + "property": { 26.102 + "type": "Identifier", 26.103 + "name": "i" 26.104 + }, 26.105 + "computed": true 26.106 + } 26.107 + ] 26.108 + } 26.109 + } 26.110 + ] 26.111 + }, 26.112 + "each": false 26.113 + } 26.114 + ] 26.115 +} 26.116 +{ 26.117 + "type": "Program", 26.118 + "body": [ 26.119 + { 26.120 + "type": "ForInStatement", 26.121 + "left": { 26.122 + "type": "Identifier", 26.123 + "name": "i" 26.124 + }, 26.125 + "right": { 26.126 + "type": "Identifier", 26.127 + "name": "obj" 26.128 + }, 26.129 + "body": { 26.130 + "type": "BlockStatement", 26.131 + "body": [ 26.132 + { 26.133 + "type": "ExpressionStatement", 26.134 + "expression": { 26.135 + "type": "CallExpression", 26.136 + "callee": { 26.137 + "type": "Identifier", 26.138 + "name": "print" 26.139 + }, 26.140 + "arguments": [ 26.141 + { 26.142 + "type": "Identifier", 26.143 + "name": "i" 26.144 + } 26.145 + ] 26.146 + } 26.147 + } 26.148 + ] 26.149 + }, 26.150 + "each": true 26.151 + } 26.152 + ] 26.153 +} 26.154 +{ 26.155 + "type": "Program", 26.156 + "body": [ 26.157 + { 26.158 + "type": "ForStatement", 26.159 + "init": { 26.160 + "type": "AssignmentExpression", 26.161 + "operator": "=", 26.162 + "left": { 26.163 + "type": "Identifier", 26.164 + "name": "i" 26.165 + }, 26.166 + "right": { 26.167 + "type": "Literal", 26.168 + "value": 0 26.169 + } 26.170 + }, 26.171 + "test": { 26.172 + "type": "BinaryExpression", 26.173 + "operator": "<", 26.174 + "left": { 26.175 + "type": "Identifier", 26.176 + "name": "i" 26.177 + }, 26.178 + "right": { 26.179 + "type": "Literal", 26.180 + "value": 10 26.181 + } 26.182 + }, 26.183 + "update": { 26.184 + "type": "UpdateExpression", 26.185 + "operator": "++", 26.186 + "prefix": false, 26.187 + "argument": { 26.188 + "type": "Identifier", 26.189 + "name": "i" 26.190 + } 26.191 + }, 26.192 + "body": { 26.193 + "type": "BlockStatement", 26.194 + "body": [ 26.195 + { 26.196 + "type": "ExpressionStatement", 26.197 + "expression": { 26.198 + "type": "CallExpression", 26.199 + "callee": { 26.200 + "type": "Identifier", 26.201 + "name": "print" 26.202 + }, 26.203 + "arguments": [ 26.204 + { 26.205 + "type": "Identifier", 26.206 + "name": "i" 26.207 + } 26.208 + ] 26.209 + } 26.210 + } 26.211 + ] 26.212 + } 26.213 + } 26.214 + ] 26.215 +}
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 27.2 +++ b/test/script/basic/parser/objectLitExpr.js Thu Sep 12 22:16:40 2013 +0530 27.3 @@ -0,0 +1,36 @@ 27.4 +/* 27.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 27.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 27.7 + * 27.8 + * This code is free software; you can redistribute it and/or modify it 27.9 + * under the terms of the GNU General Public License version 2 only, as 27.10 + * published by the Free Software Foundation. 27.11 + * 27.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 27.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 27.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 27.15 + * version 2 for more details (a copy is included in the LICENSE file that 27.16 + * accompanied this code). 27.17 + * 27.18 + * You should have received a copy of the GNU General Public License version 27.19 + * 2 along with this work; if not, write to the Free Software Foundation, 27.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 27.21 + * 27.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 27.23 + * or visit www.oracle.com if you need additional information or have any 27.24 + * questions. 27.25 + */ 27.26 + 27.27 +/** 27.28 + * Tests to check assignment e xyzpressions. 27.29 + * 27.30 + * @test 27.31 + * @run 27.32 + */ 27.33 + 27.34 +load(__DIR__ + "util.js"); 27.35 + 27.36 +printParse("obj = {}"); 27.37 +printParse("p = { x: 10, y: 2 }"); 27.38 +printParse("p = { 'x': 10, 'y': 2 }"); 27.39 +printParse("p = { get x() { return xValue }, get y() { return yValue } }");
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/test/script/basic/parser/objectLitExpr.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 28.3 @@ -0,0 +1,189 @@ 28.4 +{ 28.5 + "type": "Program", 28.6 + "body": [ 28.7 + { 28.8 + "type": "ExpressionStatement", 28.9 + "expression": { 28.10 + "type": "AssignmentExpression", 28.11 + "operator": "=", 28.12 + "left": { 28.13 + "type": "Identifier", 28.14 + "name": "obj" 28.15 + }, 28.16 + "right": { 28.17 + "type": "ObjectExpression", 28.18 + "properties": [] 28.19 + } 28.20 + } 28.21 + } 28.22 + ] 28.23 +} 28.24 +{ 28.25 + "type": "Program", 28.26 + "body": [ 28.27 + { 28.28 + "type": "ExpressionStatement", 28.29 + "expression": { 28.30 + "type": "AssignmentExpression", 28.31 + "operator": "=", 28.32 + "left": { 28.33 + "type": "Identifier", 28.34 + "name": "p" 28.35 + }, 28.36 + "right": { 28.37 + "type": "ObjectExpression", 28.38 + "properties": [ 28.39 + { 28.40 + "key": { 28.41 + "type": "Identifier", 28.42 + "name": "x" 28.43 + }, 28.44 + "value": { 28.45 + "type": "Literal", 28.46 + "value": 10 28.47 + }, 28.48 + "kind": "init" 28.49 + }, 28.50 + { 28.51 + "key": { 28.52 + "type": "Identifier", 28.53 + "name": "y" 28.54 + }, 28.55 + "value": { 28.56 + "type": "Literal", 28.57 + "value": 2 28.58 + }, 28.59 + "kind": "init" 28.60 + } 28.61 + ] 28.62 + } 28.63 + } 28.64 + } 28.65 + ] 28.66 +} 28.67 +{ 28.68 + "type": "Program", 28.69 + "body": [ 28.70 + { 28.71 + "type": "ExpressionStatement", 28.72 + "expression": { 28.73 + "type": "AssignmentExpression", 28.74 + "operator": "=", 28.75 + "left": { 28.76 + "type": "Identifier", 28.77 + "name": "p" 28.78 + }, 28.79 + "right": { 28.80 + "type": "ObjectExpression", 28.81 + "properties": [ 28.82 + { 28.83 + "key": { 28.84 + "type": "Literal", 28.85 + "value": "x" 28.86 + }, 28.87 + "value": { 28.88 + "type": "Literal", 28.89 + "value": 10 28.90 + }, 28.91 + "kind": "init" 28.92 + }, 28.93 + { 28.94 + "key": { 28.95 + "type": "Literal", 28.96 + "value": "y" 28.97 + }, 28.98 + "value": { 28.99 + "type": "Literal", 28.100 + "value": 2 28.101 + }, 28.102 + "kind": "init" 28.103 + } 28.104 + ] 28.105 + } 28.106 + } 28.107 + } 28.108 + ] 28.109 +} 28.110 +{ 28.111 + "type": "Program", 28.112 + "body": [ 28.113 + { 28.114 + "type": "ExpressionStatement", 28.115 + "expression": { 28.116 + "type": "AssignmentExpression", 28.117 + "operator": "=", 28.118 + "left": { 28.119 + "type": "Identifier", 28.120 + "name": "p" 28.121 + }, 28.122 + "right": { 28.123 + "type": "ObjectExpression", 28.124 + "properties": [ 28.125 + { 28.126 + "key": { 28.127 + "type": "Identifier", 28.128 + "name": "x" 28.129 + }, 28.130 + "value": { 28.131 + "type": "FunctionExpression", 28.132 + "id": { 28.133 + "type": "Identifier", 28.134 + "name": "get x" 28.135 + }, 28.136 + "params": [], 28.137 + "defaults": [], 28.138 + "rest": null, 28.139 + "body": { 28.140 + "type": "BlockStatement", 28.141 + "body": [ 28.142 + { 28.143 + "type": "ReturnStatement", 28.144 + "argument": { 28.145 + "type": "Identifier", 28.146 + "name": "xValue" 28.147 + } 28.148 + } 28.149 + ] 28.150 + }, 28.151 + "generator": false, 28.152 + "expression": false 28.153 + }, 28.154 + "kind": "get" 28.155 + }, 28.156 + { 28.157 + "key": { 28.158 + "type": "Identifier", 28.159 + "name": "y" 28.160 + }, 28.161 + "value": { 28.162 + "type": "FunctionExpression", 28.163 + "id": { 28.164 + "type": "Identifier", 28.165 + "name": "get y" 28.166 + }, 28.167 + "params": [], 28.168 + "defaults": [], 28.169 + "rest": null, 28.170 + "body": { 28.171 + "type": "BlockStatement", 28.172 + "body": [ 28.173 + { 28.174 + "type": "ReturnStatement", 28.175 + "argument": { 28.176 + "type": "Identifier", 28.177 + "name": "yValue" 28.178 + } 28.179 + } 28.180 + ] 28.181 + }, 28.182 + "generator": false, 28.183 + "expression": false 28.184 + }, 28.185 + "kind": "get" 28.186 + } 28.187 + ] 28.188 + } 28.189 + } 28.190 + } 28.191 + ] 28.192 +}
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/test/script/basic/parser/parenExpr.js Thu Sep 12 22:16:40 2013 +0530 29.3 @@ -0,0 +1,34 @@ 29.4 +/* 29.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.7 + * 29.8 + * This code is free software; you can redistribute it and/or modify it 29.9 + * under the terms of the GNU General Public License version 2 only, as 29.10 + * published by the Free Software Foundation. 29.11 + * 29.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 29.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 29.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 29.15 + * version 2 for more details (a copy is included in the LICENSE file that 29.16 + * accompanied this code). 29.17 + * 29.18 + * You should have received a copy of the GNU General Public License version 29.19 + * 2 along with this work; if not, write to the Free Software Foundation, 29.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 29.21 + * 29.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 29.23 + * or visit www.oracle.com if you need additional information or have any 29.24 + * questions. 29.25 + */ 29.26 + 29.27 +/** 29.28 + * Tests for parenthesis expressions. 29.29 + * 29.30 + * @test 29.31 + * @run 29.32 + */ 29.33 + 29.34 +load(__DIR__ + "util.js"); 29.35 + 29.36 +printParse("(2) + (1) + 4"); 29.37 +printParse("3 + (7) << (5)");
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 30.2 +++ b/test/script/basic/parser/parenExpr.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 30.3 @@ -0,0 +1,56 @@ 30.4 +{ 30.5 + "type": "Program", 30.6 + "body": [ 30.7 + { 30.8 + "type": "ExpressionStatement", 30.9 + "expression": { 30.10 + "type": "BinaryExpression", 30.11 + "operator": "+", 30.12 + "left": { 30.13 + "type": "BinaryExpression", 30.14 + "operator": "+", 30.15 + "left": { 30.16 + "type": "Literal", 30.17 + "value": 2 30.18 + }, 30.19 + "right": { 30.20 + "type": "Literal", 30.21 + "value": 1 30.22 + } 30.23 + }, 30.24 + "right": { 30.25 + "type": "Literal", 30.26 + "value": 4 30.27 + } 30.28 + } 30.29 + } 30.30 + ] 30.31 +} 30.32 +{ 30.33 + "type": "Program", 30.34 + "body": [ 30.35 + { 30.36 + "type": "ExpressionStatement", 30.37 + "expression": { 30.38 + "type": "BinaryExpression", 30.39 + "operator": "<<", 30.40 + "left": { 30.41 + "type": "BinaryExpression", 30.42 + "operator": "+", 30.43 + "left": { 30.44 + "type": "Literal", 30.45 + "value": 3 30.46 + }, 30.47 + "right": { 30.48 + "type": "Literal", 30.49 + "value": 7 30.50 + } 30.51 + }, 30.52 + "right": { 30.53 + "type": "Literal", 30.54 + "value": 5 30.55 + } 30.56 + } 30.57 + } 30.58 + ] 30.59 +}
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/test/script/basic/parser/primaryExpr.js Thu Sep 12 22:16:40 2013 +0530 31.3 @@ -0,0 +1,45 @@ 31.4 +/* 31.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.7 + * 31.8 + * This code is free software; you can redistribute it and/or modify it 31.9 + * under the terms of the GNU General Public License version 2 only, as 31.10 + * published by the Free Software Foundation. 31.11 + * 31.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 31.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 31.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 31.15 + * version 2 for more details (a copy is included in the LICENSE file that 31.16 + * accompanied this code). 31.17 + * 31.18 + * You should have received a copy of the GNU General Public License version 31.19 + * 2 along with this work; if not, write to the Free Software Foundation, 31.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 31.21 + * 31.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 31.23 + * or visit www.oracle.com if you need additional information or have any 31.24 + * questions. 31.25 + */ 31.26 + 31.27 +/** 31.28 + * Tests to check primary expressions. 31.29 + * 31.30 + * @test 31.31 + * @run 31.32 + */ 31.33 + 31.34 +load(__DIR__ + "util.js"); 31.35 + 31.36 +printParse("this"); 31.37 +printParse("foo"); 31.38 +printParse("null"); 31.39 +printParse("true"); 31.40 +printParse("false"); 31.41 +printParse("33"); 31.42 +printParse("3.14"); 31.43 +printParse("(10 + 3)*2"); 31.44 +printParse("({})"); 31.45 +printParse("({ x: 3 })"); 31.46 +printParse("[]"); 31.47 +printParse("[,,]"); 31.48 +printParse("[4, 5, 5]");
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 32.2 +++ b/test/script/basic/parser/primaryExpr.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 32.3 @@ -0,0 +1,199 @@ 32.4 +{ 32.5 + "type": "Program", 32.6 + "body": [ 32.7 + { 32.8 + "type": "ExpressionStatement", 32.9 + "expression": { 32.10 + "type": "ThisExpression" 32.11 + } 32.12 + } 32.13 + ] 32.14 +} 32.15 +{ 32.16 + "type": "Program", 32.17 + "body": [ 32.18 + { 32.19 + "type": "ExpressionStatement", 32.20 + "expression": { 32.21 + "type": "Identifier", 32.22 + "name": "foo" 32.23 + } 32.24 + } 32.25 + ] 32.26 +} 32.27 +{ 32.28 + "type": "Program", 32.29 + "body": [ 32.30 + { 32.31 + "type": "ExpressionStatement", 32.32 + "expression": { 32.33 + "type": "Literal", 32.34 + "value": null 32.35 + } 32.36 + } 32.37 + ] 32.38 +} 32.39 +{ 32.40 + "type": "Program", 32.41 + "body": [ 32.42 + { 32.43 + "type": "ExpressionStatement", 32.44 + "expression": { 32.45 + "type": "Literal", 32.46 + "value": true 32.47 + } 32.48 + } 32.49 + ] 32.50 +} 32.51 +{ 32.52 + "type": "Program", 32.53 + "body": [ 32.54 + { 32.55 + "type": "ExpressionStatement", 32.56 + "expression": { 32.57 + "type": "Literal", 32.58 + "value": false 32.59 + } 32.60 + } 32.61 + ] 32.62 +} 32.63 +{ 32.64 + "type": "Program", 32.65 + "body": [ 32.66 + { 32.67 + "type": "ExpressionStatement", 32.68 + "expression": { 32.69 + "type": "Literal", 32.70 + "value": 33 32.71 + } 32.72 + } 32.73 + ] 32.74 +} 32.75 +{ 32.76 + "type": "Program", 32.77 + "body": [ 32.78 + { 32.79 + "type": "ExpressionStatement", 32.80 + "expression": { 32.81 + "type": "Literal", 32.82 + "value": 3.14 32.83 + } 32.84 + } 32.85 + ] 32.86 +} 32.87 +{ 32.88 + "type": "Program", 32.89 + "body": [ 32.90 + { 32.91 + "type": "ExpressionStatement", 32.92 + "expression": { 32.93 + "type": "BinaryExpression", 32.94 + "operator": "*", 32.95 + "left": { 32.96 + "type": "BinaryExpression", 32.97 + "operator": "+", 32.98 + "left": { 32.99 + "type": "Literal", 32.100 + "value": 10 32.101 + }, 32.102 + "right": { 32.103 + "type": "Literal", 32.104 + "value": 3 32.105 + } 32.106 + }, 32.107 + "right": { 32.108 + "type": "Literal", 32.109 + "value": 2 32.110 + } 32.111 + } 32.112 + } 32.113 + ] 32.114 +} 32.115 +{ 32.116 + "type": "Program", 32.117 + "body": [ 32.118 + { 32.119 + "type": "ExpressionStatement", 32.120 + "expression": { 32.121 + "type": "ObjectExpression", 32.122 + "properties": [] 32.123 + } 32.124 + } 32.125 + ] 32.126 +} 32.127 +{ 32.128 + "type": "Program", 32.129 + "body": [ 32.130 + { 32.131 + "type": "ExpressionStatement", 32.132 + "expression": { 32.133 + "type": "ObjectExpression", 32.134 + "properties": [ 32.135 + { 32.136 + "key": { 32.137 + "type": "Identifier", 32.138 + "name": "x" 32.139 + }, 32.140 + "value": { 32.141 + "type": "Literal", 32.142 + "value": 3 32.143 + }, 32.144 + "kind": "init" 32.145 + } 32.146 + ] 32.147 + } 32.148 + } 32.149 + ] 32.150 +} 32.151 +{ 32.152 + "type": "Program", 32.153 + "body": [ 32.154 + { 32.155 + "type": "ExpressionStatement", 32.156 + "expression": { 32.157 + "type": "ArrayExpression", 32.158 + "elements": [] 32.159 + } 32.160 + } 32.161 + ] 32.162 +} 32.163 +{ 32.164 + "type": "Program", 32.165 + "body": [ 32.166 + { 32.167 + "type": "ExpressionStatement", 32.168 + "expression": { 32.169 + "type": "ArrayExpression", 32.170 + "elements": [ 32.171 + null, 32.172 + null 32.173 + ] 32.174 + } 32.175 + } 32.176 + ] 32.177 +} 32.178 +{ 32.179 + "type": "Program", 32.180 + "body": [ 32.181 + { 32.182 + "type": "ExpressionStatement", 32.183 + "expression": { 32.184 + "type": "ArrayExpression", 32.185 + "elements": [ 32.186 + { 32.187 + "type": "Literal", 32.188 + "value": 4 32.189 + }, 32.190 + { 32.191 + "type": "Literal", 32.192 + "value": 5 32.193 + }, 32.194 + { 32.195 + "type": "Literal", 32.196 + "value": 5 32.197 + } 32.198 + ] 32.199 + } 32.200 + } 32.201 + ] 32.202 +}
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 33.2 +++ b/test/script/basic/parser/returnStat.js Thu Sep 12 22:16:40 2013 +0530 33.3 @@ -0,0 +1,35 @@ 33.4 +/* 33.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 33.7 + * 33.8 + * This code is free software; you can redistribute it and/or modify it 33.9 + * under the terms of the GNU General Public License version 2 only, as 33.10 + * published by the Free Software Foundation. 33.11 + * 33.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 33.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 33.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 33.15 + * version 2 for more details (a copy is included in the LICENSE file that 33.16 + * accompanied this code). 33.17 + * 33.18 + * You should have received a copy of the GNU General Public License version 33.19 + * 2 along with this work; if not, write to the Free Software Foundation, 33.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 33.21 + * 33.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 33.23 + * or visit www.oracle.com if you need additional information or have any 33.24 + * questions. 33.25 + */ 33.26 + 33.27 +/** 33.28 + * Tests to check 'return' statement. 33.29 + * 33.30 + * @test 33.31 + * @run 33.32 + */ 33.33 + 33.34 +load(__DIR__ + "util.js"); 33.35 + 33.36 +printParse("(function() { return })"); 33.37 +printParse("(function() { return res })"); 33.38 +printParse("(function() { return foo() })");
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 34.2 +++ b/test/script/basic/parser/returnStat.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 34.3 @@ -0,0 +1,88 @@ 34.4 +{ 34.5 + "type": "Program", 34.6 + "body": [ 34.7 + { 34.8 + "type": "ExpressionStatement", 34.9 + "expression": { 34.10 + "type": "FunctionExpression", 34.11 + "id": null, 34.12 + "params": [], 34.13 + "defaults": [], 34.14 + "rest": null, 34.15 + "body": { 34.16 + "type": "BlockStatement", 34.17 + "body": [ 34.18 + { 34.19 + "type": "ReturnStatement", 34.20 + "argument": null 34.21 + } 34.22 + ] 34.23 + }, 34.24 + "generator": false, 34.25 + "expression": false 34.26 + } 34.27 + } 34.28 + ] 34.29 +} 34.30 +{ 34.31 + "type": "Program", 34.32 + "body": [ 34.33 + { 34.34 + "type": "ExpressionStatement", 34.35 + "expression": { 34.36 + "type": "FunctionExpression", 34.37 + "id": null, 34.38 + "params": [], 34.39 + "defaults": [], 34.40 + "rest": null, 34.41 + "body": { 34.42 + "type": "BlockStatement", 34.43 + "body": [ 34.44 + { 34.45 + "type": "ReturnStatement", 34.46 + "argument": { 34.47 + "type": "Identifier", 34.48 + "name": "res" 34.49 + } 34.50 + } 34.51 + ] 34.52 + }, 34.53 + "generator": false, 34.54 + "expression": false 34.55 + } 34.56 + } 34.57 + ] 34.58 +} 34.59 +{ 34.60 + "type": "Program", 34.61 + "body": [ 34.62 + { 34.63 + "type": "ExpressionStatement", 34.64 + "expression": { 34.65 + "type": "FunctionExpression", 34.66 + "id": null, 34.67 + "params": [], 34.68 + "defaults": [], 34.69 + "rest": null, 34.70 + "body": { 34.71 + "type": "BlockStatement", 34.72 + "body": [ 34.73 + { 34.74 + "type": "ReturnStatement", 34.75 + "argument": { 34.76 + "type": "CallExpression", 34.77 + "callee": { 34.78 + "type": "Identifier", 34.79 + "name": "foo" 34.80 + }, 34.81 + "arguments": [] 34.82 + } 34.83 + } 34.84 + ] 34.85 + }, 34.86 + "generator": false, 34.87 + "expression": false 34.88 + } 34.89 + } 34.90 + ] 34.91 +}
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 35.2 +++ b/test/script/basic/parser/switchStat.js Thu Sep 12 22:16:40 2013 +0530 35.3 @@ -0,0 +1,35 @@ 35.4 +/* 35.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 35.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 35.7 + * 35.8 + * This code is free software; you can redistribute it and/or modify it 35.9 + * under the terms of the GNU General Public License version 2 only, as 35.10 + * published by the Free Software Foundation. 35.11 + * 35.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 35.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 35.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 35.15 + * version 2 for more details (a copy is included in the LICENSE file that 35.16 + * accompanied this code). 35.17 + * 35.18 + * You should have received a copy of the GNU General Public License version 35.19 + * 2 along with this work; if not, write to the Free Software Foundation, 35.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 35.21 + * 35.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 35.23 + * or visit www.oracle.com if you need additional information or have any 35.24 + * questions. 35.25 + */ 35.26 + 35.27 +/** 35.28 + * Tests for switch statement. 35.29 + * 35.30 + * @test 35.31 + * @run 35.32 + */ 35.33 + 35.34 +load(__DIR__ + "util.js"); 35.35 + 35.36 +printParse("switch (key) {}"); 35.37 +printParse("switch (key) { case 2: hello(); break; }"); 35.38 +printParse("switch (key) { case 4: hello(); break; case 2: world(); break; default: break }");
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 36.2 +++ b/test/script/basic/parser/switchStat.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 36.3 @@ -0,0 +1,123 @@ 36.4 +{ 36.5 + "type": "Program", 36.6 + "body": [ 36.7 + { 36.8 + "type": "SwitchStatement", 36.9 + "discriminant": { 36.10 + "type": "Identifier", 36.11 + "name": "key" 36.12 + }, 36.13 + "cases": [] 36.14 + } 36.15 + ] 36.16 +} 36.17 +{ 36.18 + "type": "Program", 36.19 + "body": [ 36.20 + { 36.21 + "type": "SwitchStatement", 36.22 + "discriminant": { 36.23 + "type": "Identifier", 36.24 + "name": "key" 36.25 + }, 36.26 + "cases": [ 36.27 + { 36.28 + "type": "SwitchCase", 36.29 + "test": { 36.30 + "type": "Literal", 36.31 + "value": 2 36.32 + }, 36.33 + "consequent": [ 36.34 + { 36.35 + "type": "ExpressionStatement", 36.36 + "expression": { 36.37 + "type": "CallExpression", 36.38 + "callee": { 36.39 + "type": "Identifier", 36.40 + "name": "hello" 36.41 + }, 36.42 + "arguments": [] 36.43 + } 36.44 + }, 36.45 + { 36.46 + "type": "BreakStatement", 36.47 + "label": null 36.48 + } 36.49 + ] 36.50 + } 36.51 + ] 36.52 + } 36.53 + ] 36.54 +} 36.55 +{ 36.56 + "type": "Program", 36.57 + "body": [ 36.58 + { 36.59 + "type": "SwitchStatement", 36.60 + "discriminant": { 36.61 + "type": "Identifier", 36.62 + "name": "key" 36.63 + }, 36.64 + "cases": [ 36.65 + { 36.66 + "type": "SwitchCase", 36.67 + "test": { 36.68 + "type": "Literal", 36.69 + "value": 4 36.70 + }, 36.71 + "consequent": [ 36.72 + { 36.73 + "type": "ExpressionStatement", 36.74 + "expression": { 36.75 + "type": "CallExpression", 36.76 + "callee": { 36.77 + "type": "Identifier", 36.78 + "name": "hello" 36.79 + }, 36.80 + "arguments": [] 36.81 + } 36.82 + }, 36.83 + { 36.84 + "type": "BreakStatement", 36.85 + "label": null 36.86 + } 36.87 + ] 36.88 + }, 36.89 + { 36.90 + "type": "SwitchCase", 36.91 + "test": { 36.92 + "type": "Literal", 36.93 + "value": 2 36.94 + }, 36.95 + "consequent": [ 36.96 + { 36.97 + "type": "ExpressionStatement", 36.98 + "expression": { 36.99 + "type": "CallExpression", 36.100 + "callee": { 36.101 + "type": "Identifier", 36.102 + "name": "world" 36.103 + }, 36.104 + "arguments": [] 36.105 + } 36.106 + }, 36.107 + { 36.108 + "type": "BreakStatement", 36.109 + "label": null 36.110 + } 36.111 + ] 36.112 + }, 36.113 + { 36.114 + "type": "SwitchCase", 36.115 + "test": null, 36.116 + "consequent": [ 36.117 + { 36.118 + "type": "BreakStatement", 36.119 + "label": null 36.120 + } 36.121 + ] 36.122 + } 36.123 + ] 36.124 + } 36.125 + ] 36.126 +}
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 37.2 +++ b/test/script/basic/parser/throwStat.js Thu Sep 12 22:16:40 2013 +0530 37.3 @@ -0,0 +1,37 @@ 37.4 +/* 37.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 37.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 37.7 + * 37.8 + * This code is free software; you can redistribute it and/or modify it 37.9 + * under the terms of the GNU General Public License version 2 only, as 37.10 + * published by the Free Software Foundation. 37.11 + * 37.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 37.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 37.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 37.15 + * version 2 for more details (a copy is included in the LICENSE file that 37.16 + * accompanied this code). 37.17 + * 37.18 + * You should have received a copy of the GNU General Public License version 37.19 + * 2 along with this work; if not, write to the Free Software Foundation, 37.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 37.21 + * 37.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 37.23 + * or visit www.oracle.com if you need additional information or have any 37.24 + * questions. 37.25 + */ 37.26 + 37.27 +/** 37.28 + * Tests for throw statement. 37.29 + * 37.30 + * @test 37.31 + * @run 37.32 + */ 37.33 + 37.34 +load(__DIR__ + "util.js"); 37.35 + 37.36 +printParse("throw err"); 37.37 +printParse("throw 'wrong'"); 37.38 +printParse("throw new TypeError"); 37.39 +printParse("throw new TypeError('not an array')"); 37.40 +printParse("throw { msg: 'wrong!' }");
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 38.2 +++ b/test/script/basic/parser/throwStat.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 38.3 @@ -0,0 +1,85 @@ 38.4 +{ 38.5 + "type": "Program", 38.6 + "body": [ 38.7 + { 38.8 + "type": "ThrowStatement", 38.9 + "argument": { 38.10 + "type": "Identifier", 38.11 + "name": "err" 38.12 + } 38.13 + } 38.14 + ] 38.15 +} 38.16 +{ 38.17 + "type": "Program", 38.18 + "body": [ 38.19 + { 38.20 + "type": "ThrowStatement", 38.21 + "argument": { 38.22 + "type": "Literal", 38.23 + "value": "wrong" 38.24 + } 38.25 + } 38.26 + ] 38.27 +} 38.28 +{ 38.29 + "type": "Program", 38.30 + "body": [ 38.31 + { 38.32 + "type": "ThrowStatement", 38.33 + "argument": { 38.34 + "type": "NewExpression", 38.35 + "callee": { 38.36 + "type": "Identifier", 38.37 + "name": "TypeError" 38.38 + }, 38.39 + "arguments": [] 38.40 + } 38.41 + } 38.42 + ] 38.43 +} 38.44 +{ 38.45 + "type": "Program", 38.46 + "body": [ 38.47 + { 38.48 + "type": "ThrowStatement", 38.49 + "argument": { 38.50 + "type": "NewExpression", 38.51 + "callee": { 38.52 + "type": "Identifier", 38.53 + "name": "TypeError" 38.54 + }, 38.55 + "arguments": [ 38.56 + { 38.57 + "type": "Literal", 38.58 + "value": "not an array" 38.59 + } 38.60 + ] 38.61 + } 38.62 + } 38.63 + ] 38.64 +} 38.65 +{ 38.66 + "type": "Program", 38.67 + "body": [ 38.68 + { 38.69 + "type": "ThrowStatement", 38.70 + "argument": { 38.71 + "type": "ObjectExpression", 38.72 + "properties": [ 38.73 + { 38.74 + "key": { 38.75 + "type": "Identifier", 38.76 + "name": "msg" 38.77 + }, 38.78 + "value": { 38.79 + "type": "Literal", 38.80 + "value": "wrong!" 38.81 + }, 38.82 + "kind": "init" 38.83 + } 38.84 + ] 38.85 + } 38.86 + } 38.87 + ] 38.88 +}
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 39.2 +++ b/test/script/basic/parser/tryCatchStat.js Thu Sep 12 22:16:40 2013 +0530 39.3 @@ -0,0 +1,38 @@ 39.4 +/* 39.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 39.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 39.7 + * 39.8 + * This code is free software; you can redistribute it and/or modify it 39.9 + * under the terms of the GNU General Public License version 2 only, as 39.10 + * published by the Free Software Foundation. 39.11 + * 39.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 39.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 39.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 39.15 + * version 2 for more details (a copy is included in the LICENSE file that 39.16 + * accompanied this code). 39.17 + * 39.18 + * You should have received a copy of the GNU General Public License version 39.19 + * 2 along with this work; if not, write to the Free Software Foundation, 39.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 39.21 + * 39.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 39.23 + * or visit www.oracle.com if you need additional information or have any 39.24 + * questions. 39.25 + */ 39.26 + 39.27 +/** 39.28 + * Tests to check try..catch statements. 39.29 + * 39.30 + * @test 39.31 + * @run 39.32 + */ 39.33 + 39.34 +load(__DIR__ + "util.js"); 39.35 + 39.36 +printParse("try { } catch (e) { }"); 39.37 +printParse("try { } catch (e) { } finally {}"); 39.38 +printParse("try { } finally {}"); 39.39 +printParse("try { } catch (e) { handle() }"); 39.40 +printParse("try { that() } catch (e) { handle() } finally { clean() }"); 39.41 +printParse("try { that() } catch (e if e instanceof TypeError) { handle() } catch (e) { rest() }");
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 40.2 +++ b/test/script/basic/parser/tryCatchStat.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 40.3 @@ -0,0 +1,305 @@ 40.4 +{ 40.5 + "type": "Program", 40.6 + "body": [ 40.7 + { 40.8 + "type": "BlockStatement", 40.9 + "block": { 40.10 + "type": "BlockStatement", 40.11 + "body": [ 40.12 + { 40.13 + "type": "TryStatement", 40.14 + "block": { 40.15 + "type": "BlockStatement", 40.16 + "body": [] 40.17 + }, 40.18 + "guardedHandlers": [], 40.19 + "handler": { 40.20 + "type": "CatchClause", 40.21 + "param": { 40.22 + "type": "Identifier", 40.23 + "name": "e" 40.24 + }, 40.25 + "body": { 40.26 + "type": "BlockStatement", 40.27 + "body": [] 40.28 + } 40.29 + }, 40.30 + "finalizer": null 40.31 + } 40.32 + ] 40.33 + } 40.34 + } 40.35 + ] 40.36 +} 40.37 +{ 40.38 + "type": "Program", 40.39 + "body": [ 40.40 + { 40.41 + "type": "BlockStatement", 40.42 + "block": { 40.43 + "type": "BlockStatement", 40.44 + "body": [ 40.45 + { 40.46 + "type": "TryStatement", 40.47 + "block": { 40.48 + "type": "BlockStatement", 40.49 + "body": [] 40.50 + }, 40.51 + "guardedHandlers": [], 40.52 + "handler": { 40.53 + "type": "CatchClause", 40.54 + "param": { 40.55 + "type": "Identifier", 40.56 + "name": "e" 40.57 + }, 40.58 + "body": { 40.59 + "type": "BlockStatement", 40.60 + "body": [] 40.61 + } 40.62 + }, 40.63 + "finalizer": { 40.64 + "type": "BlockStatement", 40.65 + "body": [] 40.66 + } 40.67 + } 40.68 + ] 40.69 + } 40.70 + } 40.71 + ] 40.72 +} 40.73 +{ 40.74 + "type": "Program", 40.75 + "body": [ 40.76 + { 40.77 + "type": "BlockStatement", 40.78 + "block": { 40.79 + "type": "BlockStatement", 40.80 + "body": [ 40.81 + { 40.82 + "type": "TryStatement", 40.83 + "block": { 40.84 + "type": "BlockStatement", 40.85 + "body": [] 40.86 + }, 40.87 + "guardedHandlers": [], 40.88 + "handler": null, 40.89 + "finalizer": { 40.90 + "type": "BlockStatement", 40.91 + "body": [] 40.92 + } 40.93 + } 40.94 + ] 40.95 + } 40.96 + } 40.97 + ] 40.98 +} 40.99 +{ 40.100 + "type": "Program", 40.101 + "body": [ 40.102 + { 40.103 + "type": "BlockStatement", 40.104 + "block": { 40.105 + "type": "BlockStatement", 40.106 + "body": [ 40.107 + { 40.108 + "type": "TryStatement", 40.109 + "block": { 40.110 + "type": "BlockStatement", 40.111 + "body": [] 40.112 + }, 40.113 + "guardedHandlers": [], 40.114 + "handler": { 40.115 + "type": "CatchClause", 40.116 + "param": { 40.117 + "type": "Identifier", 40.118 + "name": "e" 40.119 + }, 40.120 + "body": { 40.121 + "type": "BlockStatement", 40.122 + "body": [ 40.123 + { 40.124 + "type": "ExpressionStatement", 40.125 + "expression": { 40.126 + "type": "CallExpression", 40.127 + "callee": { 40.128 + "type": "Identifier", 40.129 + "name": "handle" 40.130 + }, 40.131 + "arguments": [] 40.132 + } 40.133 + } 40.134 + ] 40.135 + } 40.136 + }, 40.137 + "finalizer": null 40.138 + } 40.139 + ] 40.140 + } 40.141 + } 40.142 + ] 40.143 +} 40.144 +{ 40.145 + "type": "Program", 40.146 + "body": [ 40.147 + { 40.148 + "type": "BlockStatement", 40.149 + "block": { 40.150 + "type": "BlockStatement", 40.151 + "body": [ 40.152 + { 40.153 + "type": "TryStatement", 40.154 + "block": { 40.155 + "type": "BlockStatement", 40.156 + "body": [ 40.157 + { 40.158 + "type": "ExpressionStatement", 40.159 + "expression": { 40.160 + "type": "CallExpression", 40.161 + "callee": { 40.162 + "type": "Identifier", 40.163 + "name": "that" 40.164 + }, 40.165 + "arguments": [] 40.166 + } 40.167 + } 40.168 + ] 40.169 + }, 40.170 + "guardedHandlers": [], 40.171 + "handler": { 40.172 + "type": "CatchClause", 40.173 + "param": { 40.174 + "type": "Identifier", 40.175 + "name": "e" 40.176 + }, 40.177 + "body": { 40.178 + "type": "BlockStatement", 40.179 + "body": [ 40.180 + { 40.181 + "type": "ExpressionStatement", 40.182 + "expression": { 40.183 + "type": "CallExpression", 40.184 + "callee": { 40.185 + "type": "Identifier", 40.186 + "name": "handle" 40.187 + }, 40.188 + "arguments": [] 40.189 + } 40.190 + } 40.191 + ] 40.192 + } 40.193 + }, 40.194 + "finalizer": { 40.195 + "type": "BlockStatement", 40.196 + "body": [ 40.197 + { 40.198 + "type": "ExpressionStatement", 40.199 + "expression": { 40.200 + "type": "CallExpression", 40.201 + "callee": { 40.202 + "type": "Identifier", 40.203 + "name": "clean" 40.204 + }, 40.205 + "arguments": [] 40.206 + } 40.207 + } 40.208 + ] 40.209 + } 40.210 + } 40.211 + ] 40.212 + } 40.213 + } 40.214 + ] 40.215 +} 40.216 +{ 40.217 + "type": "Program", 40.218 + "body": [ 40.219 + { 40.220 + "type": "BlockStatement", 40.221 + "block": { 40.222 + "type": "BlockStatement", 40.223 + "body": [ 40.224 + { 40.225 + "type": "TryStatement", 40.226 + "block": { 40.227 + "type": "BlockStatement", 40.228 + "body": [ 40.229 + { 40.230 + "type": "ExpressionStatement", 40.231 + "expression": { 40.232 + "type": "CallExpression", 40.233 + "callee": { 40.234 + "type": "Identifier", 40.235 + "name": "that" 40.236 + }, 40.237 + "arguments": [] 40.238 + } 40.239 + } 40.240 + ] 40.241 + }, 40.242 + "guardedHandlers": [ 40.243 + { 40.244 + "type": "CatchClause", 40.245 + "param": { 40.246 + "type": "Identifier", 40.247 + "name": "e" 40.248 + }, 40.249 + "guard": { 40.250 + "type": "BinaryExpression", 40.251 + "operator": "instanceof", 40.252 + "left": { 40.253 + "type": "Identifier", 40.254 + "name": "e" 40.255 + }, 40.256 + "right": { 40.257 + "type": "Identifier", 40.258 + "name": "TypeError" 40.259 + } 40.260 + }, 40.261 + "body": { 40.262 + "type": "BlockStatement", 40.263 + "body": [ 40.264 + { 40.265 + "type": "ExpressionStatement", 40.266 + "expression": { 40.267 + "type": "CallExpression", 40.268 + "callee": { 40.269 + "type": "Identifier", 40.270 + "name": "handle" 40.271 + }, 40.272 + "arguments": [] 40.273 + } 40.274 + } 40.275 + ] 40.276 + } 40.277 + } 40.278 + ], 40.279 + "handler": { 40.280 + "type": "CatchClause", 40.281 + "param": { 40.282 + "type": "Identifier", 40.283 + "name": "e" 40.284 + }, 40.285 + "body": { 40.286 + "type": "BlockStatement", 40.287 + "body": [ 40.288 + { 40.289 + "type": "ExpressionStatement", 40.290 + "expression": { 40.291 + "type": "CallExpression", 40.292 + "callee": { 40.293 + "type": "Identifier", 40.294 + "name": "rest" 40.295 + }, 40.296 + "arguments": [] 40.297 + } 40.298 + } 40.299 + ] 40.300 + } 40.301 + }, 40.302 + "finalizer": null 40.303 + } 40.304 + ] 40.305 + } 40.306 + } 40.307 + ] 40.308 +}
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 41.2 +++ b/test/script/basic/parser/unaryExpr.js Thu Sep 12 22:16:40 2013 +0530 41.3 @@ -0,0 +1,43 @@ 41.4 +/* 41.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 41.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 41.7 + * 41.8 + * This code is free software; you can redistribute it and/or modify it 41.9 + * under the terms of the GNU General Public License version 2 only, as 41.10 + * published by the Free Software Foundation. 41.11 + * 41.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 41.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 41.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 41.15 + * version 2 for more details (a copy is included in the LICENSE file that 41.16 + * accompanied this code). 41.17 + * 41.18 + * You should have received a copy of the GNU General Public License version 41.19 + * 2 along with this work; if not, write to the Free Software Foundation, 41.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 41.21 + * 41.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 41.23 + * or visit www.oracle.com if you need additional information or have any 41.24 + * questions. 41.25 + */ 41.26 + 41.27 +/** 41.28 + * Tests to check unary operators. 41.29 + * 41.30 + * @test 41.31 + * @run 41.32 + */ 41.33 + 41.34 +load(__DIR__ + "util.js"); 41.35 + 41.36 +printParse("x++"); 41.37 +printParse("x--"); 41.38 +printParse("delete x"); 41.39 +printParse("void x"); 41.40 +printParse("typeof x"); 41.41 +printParse("++x"); 41.42 +printParse("--x"); 41.43 +printParse("+x"); 41.44 +printParse("-x"); 41.45 +printParse("~x"); 41.46 +printParse("!x");
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 42.2 +++ b/test/script/basic/parser/unaryExpr.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 42.3 @@ -0,0 +1,187 @@ 42.4 +{ 42.5 + "type": "Program", 42.6 + "body": [ 42.7 + { 42.8 + "type": "ExpressionStatement", 42.9 + "expression": { 42.10 + "type": "UpdateExpression", 42.11 + "operator": "++", 42.12 + "prefix": false, 42.13 + "argument": { 42.14 + "type": "Identifier", 42.15 + "name": "x" 42.16 + } 42.17 + } 42.18 + } 42.19 + ] 42.20 +} 42.21 +{ 42.22 + "type": "Program", 42.23 + "body": [ 42.24 + { 42.25 + "type": "ExpressionStatement", 42.26 + "expression": { 42.27 + "type": "UpdateExpression", 42.28 + "operator": "--", 42.29 + "prefix": false, 42.30 + "argument": { 42.31 + "type": "Identifier", 42.32 + "name": "x" 42.33 + } 42.34 + } 42.35 + } 42.36 + ] 42.37 +} 42.38 +{ 42.39 + "type": "Program", 42.40 + "body": [ 42.41 + { 42.42 + "type": "ExpressionStatement", 42.43 + "expression": { 42.44 + "type": "UnaryExpression", 42.45 + "operator": "delete", 42.46 + "prefix": true, 42.47 + "argument": { 42.48 + "type": "Identifier", 42.49 + "name": "x" 42.50 + } 42.51 + } 42.52 + } 42.53 + ] 42.54 +} 42.55 +{ 42.56 + "type": "Program", 42.57 + "body": [ 42.58 + { 42.59 + "type": "ExpressionStatement", 42.60 + "expression": { 42.61 + "type": "UnaryExpression", 42.62 + "operator": "void", 42.63 + "prefix": true, 42.64 + "argument": { 42.65 + "type": "Identifier", 42.66 + "name": "x" 42.67 + } 42.68 + } 42.69 + } 42.70 + ] 42.71 +} 42.72 +{ 42.73 + "type": "Program", 42.74 + "body": [ 42.75 + { 42.76 + "type": "ExpressionStatement", 42.77 + "expression": { 42.78 + "type": "UnaryExpression", 42.79 + "operator": "typeof", 42.80 + "prefix": true, 42.81 + "argument": { 42.82 + "type": "Identifier", 42.83 + "name": "x" 42.84 + } 42.85 + } 42.86 + } 42.87 + ] 42.88 +} 42.89 +{ 42.90 + "type": "Program", 42.91 + "body": [ 42.92 + { 42.93 + "type": "ExpressionStatement", 42.94 + "expression": { 42.95 + "type": "UpdateExpression", 42.96 + "operator": "++", 42.97 + "prefix": true, 42.98 + "argument": { 42.99 + "type": "Identifier", 42.100 + "name": "x" 42.101 + } 42.102 + } 42.103 + } 42.104 + ] 42.105 +} 42.106 +{ 42.107 + "type": "Program", 42.108 + "body": [ 42.109 + { 42.110 + "type": "ExpressionStatement", 42.111 + "expression": { 42.112 + "type": "UpdateExpression", 42.113 + "operator": "--", 42.114 + "prefix": true, 42.115 + "argument": { 42.116 + "type": "Identifier", 42.117 + "name": "x" 42.118 + } 42.119 + } 42.120 + } 42.121 + ] 42.122 +} 42.123 +{ 42.124 + "type": "Program", 42.125 + "body": [ 42.126 + { 42.127 + "type": "ExpressionStatement", 42.128 + "expression": { 42.129 + "type": "UnaryExpression", 42.130 + "operator": "+", 42.131 + "prefix": true, 42.132 + "argument": { 42.133 + "type": "Identifier", 42.134 + "name": "x" 42.135 + } 42.136 + } 42.137 + } 42.138 + ] 42.139 +} 42.140 +{ 42.141 + "type": "Program", 42.142 + "body": [ 42.143 + { 42.144 + "type": "ExpressionStatement", 42.145 + "expression": { 42.146 + "type": "UnaryExpression", 42.147 + "operator": "-", 42.148 + "prefix": true, 42.149 + "argument": { 42.150 + "type": "Identifier", 42.151 + "name": "x" 42.152 + } 42.153 + } 42.154 + } 42.155 + ] 42.156 +} 42.157 +{ 42.158 + "type": "Program", 42.159 + "body": [ 42.160 + { 42.161 + "type": "ExpressionStatement", 42.162 + "expression": { 42.163 + "type": "UnaryExpression", 42.164 + "operator": "~", 42.165 + "prefix": true, 42.166 + "argument": { 42.167 + "type": "Identifier", 42.168 + "name": "x" 42.169 + } 42.170 + } 42.171 + } 42.172 + ] 42.173 +} 42.174 +{ 42.175 + "type": "Program", 42.176 + "body": [ 42.177 + { 42.178 + "type": "ExpressionStatement", 42.179 + "expression": { 42.180 + "type": "UnaryExpression", 42.181 + "operator": "!", 42.182 + "prefix": true, 42.183 + "argument": { 42.184 + "type": "Identifier", 42.185 + "name": "x" 42.186 + } 42.187 + } 42.188 + } 42.189 + ] 42.190 +}
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 43.2 +++ b/test/script/basic/parser/useStrict.js Thu Sep 12 22:16:40 2013 +0530 43.3 @@ -0,0 +1,34 @@ 43.4 +/* 43.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 43.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 43.7 + * 43.8 + * This code is free software; you can redistribute it and/or modify it 43.9 + * under the terms of the GNU General Public License version 2 only, as 43.10 + * published by the Free Software Foundation. 43.11 + * 43.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 43.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 43.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 43.15 + * version 2 for more details (a copy is included in the LICENSE file that 43.16 + * accompanied this code). 43.17 + * 43.18 + * You should have received a copy of the GNU General Public License version 43.19 + * 2 along with this work; if not, write to the Free Software Foundation, 43.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 43.21 + * 43.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 43.23 + * or visit www.oracle.com if you need additional information or have any 43.24 + * questions. 43.25 + */ 43.26 + 43.27 +/** 43.28 + * Tests to check if statement. 43.29 + * 43.30 + * @test 43.31 + * @run 43.32 + */ 43.33 + 43.34 +load(__DIR__ + "util.js"); 43.35 + 43.36 +printParse("'use strict'"); 43.37 +printParse("function f() { 'use strict' }");
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 44.2 +++ b/test/script/basic/parser/useStrict.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 44.3 @@ -0,0 +1,41 @@ 44.4 +{ 44.5 + "type": "Program", 44.6 + "body": [ 44.7 + { 44.8 + "type": "ExpressionStatement", 44.9 + "expression": { 44.10 + "type": "Literal", 44.11 + "value": "use strict" 44.12 + } 44.13 + } 44.14 + ] 44.15 +} 44.16 +{ 44.17 + "type": "Program", 44.18 + "body": [ 44.19 + { 44.20 + "type": "FunctionDeclaration", 44.21 + "id": { 44.22 + "type": "Identifier", 44.23 + "name": "f" 44.24 + }, 44.25 + "params": [], 44.26 + "defaults": [], 44.27 + "rest": null, 44.28 + "body": { 44.29 + "type": "BlockStatement", 44.30 + "body": [ 44.31 + { 44.32 + "type": "ExpressionStatement", 44.33 + "expression": { 44.34 + "type": "Literal", 44.35 + "value": "use strict" 44.36 + } 44.37 + } 44.38 + ] 44.39 + }, 44.40 + "generator": false, 44.41 + "expression": false 44.42 + } 44.43 + ] 44.44 +}
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 45.2 +++ b/test/script/basic/parser/util.js Thu Sep 12 22:16:40 2013 +0530 45.3 @@ -0,0 +1,33 @@ 45.4 +/* 45.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 45.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 45.7 + * 45.8 + * This code is free software; you can redistribute it and/or modify it 45.9 + * under the terms of the GNU General Public License version 2 only, as 45.10 + * published by the Free Software Foundation. 45.11 + * 45.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 45.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 45.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 45.15 + * version 2 for more details (a copy is included in the LICENSE file that 45.16 + * accompanied this code). 45.17 + * 45.18 + * You should have received a copy of the GNU General Public License version 45.19 + * 2 along with this work; if not, write to the Free Software Foundation, 45.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 45.21 + * 45.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 45.23 + * or visit www.oracle.com if you need additional information or have any 45.24 + * questions. 45.25 + */ 45.26 + 45.27 +/** 45.28 + * @subtest 45.29 + */ 45.30 + 45.31 +// utilitity for parser tests 45.32 + 45.33 +load("nashorn:parser.js"); 45.34 +function printParse(code) { 45.35 + print(JSON.stringify(parse(code), null, ' ')); 45.36 +}
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 46.2 +++ b/test/script/basic/parser/varDecl.js Thu Sep 12 22:16:40 2013 +0530 46.3 @@ -0,0 +1,39 @@ 46.4 +/* 46.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 46.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 46.7 + * 46.8 + * This code is free software; you can redistribute it and/or modify it 46.9 + * under the terms of the GNU General Public License version 2 only, as 46.10 + * published by the Free Software Foundation. 46.11 + * 46.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 46.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 46.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 46.15 + * version 2 for more details (a copy is included in the LICENSE file that 46.16 + * accompanied this code). 46.17 + * 46.18 + * You should have received a copy of the GNU General Public License version 46.19 + * 2 along with this work; if not, write to the Free Software Foundation, 46.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 46.21 + * 46.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 46.23 + * or visit www.oracle.com if you need additional information or have any 46.24 + * questions. 46.25 + */ 46.26 + 46.27 +/** 46.28 + * Tests to check variable declarations. 46.29 + * 46.30 + * @test 46.31 + * @run 46.32 + */ 46.33 + 46.34 +load(__DIR__ + "util.js"); 46.35 + 46.36 +// no initialization 46.37 +printParse("var a"); 46.38 +printParse("var a, b"); 46.39 + 46.40 +// init single, multiple 46.41 +printParse("var a = 'hello'"); 46.42 +printParse("var a = 1, b = 2, c = 3");
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 47.2 +++ b/test/script/basic/parser/varDecl.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 47.3 @@ -0,0 +1,123 @@ 47.4 +{ 47.5 + "type": "Program", 47.6 + "body": [ 47.7 + { 47.8 + "type": "VariableDeclaration", 47.9 + "declarations": [ 47.10 + { 47.11 + "type": "VariableDeclarator", 47.12 + "id": { 47.13 + "type": "Identifier", 47.14 + "name": "a" 47.15 + }, 47.16 + "init": null 47.17 + } 47.18 + ] 47.19 + } 47.20 + ] 47.21 +} 47.22 +{ 47.23 + "type": "Program", 47.24 + "body": [ 47.25 + { 47.26 + "type": "VariableDeclaration", 47.27 + "declarations": [ 47.28 + { 47.29 + "type": "VariableDeclarator", 47.30 + "id": { 47.31 + "type": "Identifier", 47.32 + "name": "a" 47.33 + }, 47.34 + "init": null 47.35 + } 47.36 + ] 47.37 + }, 47.38 + { 47.39 + "type": "VariableDeclaration", 47.40 + "declarations": [ 47.41 + { 47.42 + "type": "VariableDeclarator", 47.43 + "id": { 47.44 + "type": "Identifier", 47.45 + "name": "b" 47.46 + }, 47.47 + "init": null 47.48 + } 47.49 + ] 47.50 + } 47.51 + ] 47.52 +} 47.53 +{ 47.54 + "type": "Program", 47.55 + "body": [ 47.56 + { 47.57 + "type": "VariableDeclaration", 47.58 + "declarations": [ 47.59 + { 47.60 + "type": "VariableDeclarator", 47.61 + "id": { 47.62 + "type": "Identifier", 47.63 + "name": "a" 47.64 + }, 47.65 + "init": { 47.66 + "type": "Literal", 47.67 + "value": "hello" 47.68 + } 47.69 + } 47.70 + ] 47.71 + } 47.72 + ] 47.73 +} 47.74 +{ 47.75 + "type": "Program", 47.76 + "body": [ 47.77 + { 47.78 + "type": "VariableDeclaration", 47.79 + "declarations": [ 47.80 + { 47.81 + "type": "VariableDeclarator", 47.82 + "id": { 47.83 + "type": "Identifier", 47.84 + "name": "a" 47.85 + }, 47.86 + "init": { 47.87 + "type": "Literal", 47.88 + "value": 1 47.89 + } 47.90 + } 47.91 + ] 47.92 + }, 47.93 + { 47.94 + "type": "VariableDeclaration", 47.95 + "declarations": [ 47.96 + { 47.97 + "type": "VariableDeclarator", 47.98 + "id": { 47.99 + "type": "Identifier", 47.100 + "name": "b" 47.101 + }, 47.102 + "init": { 47.103 + "type": "Literal", 47.104 + "value": 2 47.105 + } 47.106 + } 47.107 + ] 47.108 + }, 47.109 + { 47.110 + "type": "VariableDeclaration", 47.111 + "declarations": [ 47.112 + { 47.113 + "type": "VariableDeclarator", 47.114 + "id": { 47.115 + "type": "Identifier", 47.116 + "name": "c" 47.117 + }, 47.118 + "init": { 47.119 + "type": "Literal", 47.120 + "value": 3 47.121 + } 47.122 + } 47.123 + ] 47.124 + } 47.125 + ] 47.126 +}
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 48.2 +++ b/test/script/basic/parser/withStat.js Thu Sep 12 22:16:40 2013 +0530 48.3 @@ -0,0 +1,33 @@ 48.4 +/* 48.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 48.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 48.7 + * 48.8 + * This code is free software; you can redistribute it and/or modify it 48.9 + * under the terms of the GNU General Public License version 2 only, as 48.10 + * published by the Free Software Foundation. 48.11 + * 48.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 48.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 48.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 48.15 + * version 2 for more details (a copy is included in the LICENSE file that 48.16 + * accompanied this code). 48.17 + * 48.18 + * You should have received a copy of the GNU General Public License version 48.19 + * 2 along with this work; if not, write to the Free Software Foundation, 48.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 48.21 + * 48.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 48.23 + * or visit www.oracle.com if you need additional information or have any 48.24 + * questions. 48.25 + */ 48.26 + 48.27 +/** 48.28 + * Tests for 'with' statement. 48.29 + * 48.30 + * @test 48.31 + * @run 48.32 + */ 48.33 + 48.34 +load(__DIR__ + "util.js"); 48.35 + 48.36 +printParse("with (scope) { x = y }");
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 49.2 +++ b/test/script/basic/parser/withStat.js.EXPECTED Thu Sep 12 22:16:40 2013 +0530 49.3 @@ -0,0 +1,32 @@ 49.4 +{ 49.5 + "type": "Program", 49.6 + "body": [ 49.7 + { 49.8 + "type": "WithStatement", 49.9 + "object": { 49.10 + "type": "Identifier", 49.11 + "name": "scope" 49.12 + }, 49.13 + "body": { 49.14 + "type": "BlockStatement", 49.15 + "body": [ 49.16 + { 49.17 + "type": "ExpressionStatement", 49.18 + "expression": { 49.19 + "type": "AssignmentExpression", 49.20 + "operator": "=", 49.21 + "left": { 49.22 + "type": "Identifier", 49.23 + "name": "x" 49.24 + }, 49.25 + "right": { 49.26 + "type": "Identifier", 49.27 + "name": "y" 49.28 + } 49.29 + } 49.30 + } 49.31 + ] 49.32 + } 49.33 + } 49.34 + ] 49.35 +}