changeset 563:5683eca2967a

Merge
author sundar
date Fri, 13 Sep 2013 17:50:18 +0530
parents aa86166c6770 (current diff) 8b0914b25430 (diff)
children 38378024a332
files
diffstat 60 files changed, 4612 insertions(+), 129 deletions(-) [+]
line wrap: on
line diff
--- a/make/build.xml	Wed Sep 11 22:53:03 2013 +0530
+++ b/make/build.xml	Fri Sep 13 17:50:18 2013 +0530
@@ -230,6 +230,10 @@
         <compilerarg value="-Xlint:deprecation"/>
     </javac>
 
+    <copy todir="${build.test.classes.dir}/META-INF/services">
+       <fileset dir="${test.src.dir}/META-INF/services/"/>
+    </copy>
+
     <!-- tests that check nashorn internals and internal API -->
     <jar jarfile="${nashorn.internal.tests.jar}">
       <fileset dir="${build.test.classes.dir}" excludes="**/api/**"/>
@@ -238,6 +242,7 @@
     <!-- tests that check nashorn script engine (jsr-223) API -->
     <jar jarfile="${nashorn.api.tests.jar}">
       <fileset dir="${build.test.classes.dir}" includes="**/api/**"/>
+      <fileset dir="${build.test.classes.dir}" includes="**/META-INF/**"/>
     </jar>
 
   </target>
@@ -264,6 +269,13 @@
     permission java.util.PropertyPermission "nashorn.test.*", "read";
 };
 
+grant codeBase "file:/${basedir}/test/script/basic/parser/*" {
+    permission java.io.FilePermission "${basedir}/test/script/-", "read";
+    permission java.io.FilePermission "$${user.dir}", "read";
+    permission java.util.PropertyPermission "user.dir", "read";
+    permission java.util.PropertyPermission "nashorn.test.*", "read";
+};
+
 grant codeBase "file:/${basedir}/test/script/basic/JDK-8010946-privileged.js" {
     permission java.util.PropertyPermission "java.security.policy", "read";
 };
--- a/src/jdk/nashorn/internal/ir/debug/JSONWriter.java	Wed Sep 11 22:53:03 2013 +0530
+++ b/src/jdk/nashorn/internal/ir/debug/JSONWriter.java	Fri Sep 13 17:50:18 2013 +0530
@@ -27,6 +27,7 @@
 
 import java.util.Arrays;
 import java.util.List;
+import java.util.ArrayList;
 import jdk.nashorn.internal.codegen.CompilerConstants;
 import jdk.nashorn.internal.ir.AccessNode;
 import jdk.nashorn.internal.ir.BinaryNode;
@@ -197,10 +198,10 @@
         comma();
 
         final IdentNode label = breakNode.getLabel();
+        property("label");
         if (label != null) {
-            property("label", label.getName());
+            label.accept(this);
         } else {
-            property("label");
             nullValue();
         }
 
@@ -256,13 +257,11 @@
         comma();
 
         final Node guard = catchNode.getExceptionCondition();
-        property("guard");
         if (guard != null) {
+            property("guard");
             guard.accept(this);
-        } else {
-            nullValue();
+            comma();
         }
-        comma();
 
         property("body");
         catchNode.getBody().accept(this);
@@ -278,10 +277,10 @@
         comma();
 
         final IdentNode label = continueNode.getLabel();
+        property("label");
         if (label != null) {
-            property("label", label.getName());
+            label.accept(this);
         } else {
-            property("label");
             nullValue();
         }
 
@@ -299,13 +298,20 @@
 
     @Override
     public boolean enterExpressionStatement(final ExpressionStatement expressionStatement) {
+        // handle debugger statement
+        final Node expression = expressionStatement.getExpression();
+        if (expression instanceof RuntimeNode) {
+            expression.accept(this);
+            return false;
+        }
+
         enterDefault(expressionStatement);
 
         type("ExpressionStatement");
         comma();
 
         property("expression");
-        expressionStatement.getExpression().accept(this);
+        expression.accept(this);
 
         return leave();
     }
@@ -388,13 +394,14 @@
 
     @Override
     public boolean enterFunctionNode(final FunctionNode functionNode) {
-        enterDefault(functionNode);
+        final boolean program = functionNode.isProgram();
+        if (program) {
+            return emitProgram(functionNode);
+        }
 
-        final boolean program = functionNode.isProgram();
+        enterDefault(functionNode);
         final String name;
-        if (program) {
-            name = "Program";
-        } else if (functionNode.isDeclared()) {
+        if (functionNode.isDeclared()) {
             name = "FunctionDeclaration";
         } else {
             name = "FunctionExpression";
@@ -402,24 +409,41 @@
         type(name);
         comma();
 
-        if (! program) {
-            property("id");
-            if (functionNode.isAnonymous()) {
-                nullValue();
-            } else {
-                functionNode.getIdent().accept(this);
-            }
-            comma();
+        property("id");
+        if (functionNode.isAnonymous()) {
+            nullValue();
+        } else {
+            functionNode.getIdent().accept(this);
         }
+        comma();
+
+        array("params", functionNode.getParameters());
+        comma();
+
+        arrayStart("defaults");
+        arrayEnd();
+        comma();
 
         property("rest");
         nullValue();
         comma();
 
-        if (!program) {
-            array("params", functionNode.getParameters());
-            comma();
-        }
+        property("body");
+        functionNode.getBody().accept(this);
+        comma();
+
+        property("generator", false);
+        comma();
+
+        property("expression", false);
+
+        return leave();
+    }
+
+    private boolean emitProgram(final FunctionNode functionNode) {
+        enterDefault(functionNode);
+        type("Program");
+        comma();
 
         // body consists of nested functions and statements
         final List<Statement> stats = functionNode.getBody().getStatements();
@@ -730,7 +754,31 @@
         tryNode.getBody().accept(this);
         comma();
 
-        array("handlers", tryNode.getCatches());
+
+        final List<? extends Node> catches = tryNode.getCatches();
+        final List<CatchNode> guarded = new ArrayList<>();
+        CatchNode unguarded = null;
+        if (catches != null) {
+            for (Node n : catches) {
+                CatchNode cn = (CatchNode)n;
+                if (cn.getExceptionCondition() != null) {
+                    guarded.add(cn);
+                } else {
+                    assert unguarded == null: "too many unguarded?";
+                    unguarded = cn;
+                }
+            }
+        }
+
+        array("guardedHandlers", guarded);
+        comma();
+
+        property("handler");
+        if (unguarded != null) {
+            unguarded.accept(this);
+        } else {
+            nullValue();
+        }
         comma();
 
         property("finalizer");
@@ -760,8 +808,8 @@
 
             array("arguments", callNode.getArgs());
         } else {
+            final String operator;
             final boolean prefix;
-            final String operator;
             switch (tokenType) {
             case INCPOSTFIX:
                 prefix = false;
@@ -780,8 +828,9 @@
                 prefix = true;
                 break;
             default:
-                prefix = false;
+                prefix = true;
                 operator = tokenType.getName();
+                break;
             }
 
             type(unaryNode.isAssignment()? "UpdateExpression" : "UnaryExpression");
@@ -802,6 +851,14 @@
 
     @Override
     public boolean enterVarNode(final VarNode varNode) {
+        final Node init = varNode.getInit();
+        if (init instanceof FunctionNode && ((FunctionNode)init).isDeclared()) {
+            // function declaration - don't emit VariableDeclaration instead
+            // just emit FunctionDeclaration using 'init' Node.
+            init.accept(this);
+            return false;
+        }
+
         enterDefault(varNode);
 
         type("VariableDeclaration");
@@ -816,11 +873,11 @@
         type("VariableDeclarator");
         comma();
 
-        property("id", varNode.getName().toString());
+        property("id");
+        varNode.getName().accept(this);
         comma();
 
         property("init");
-        final Node init = varNode.getInit();
         if (init != null) {
             init.accept(this);
         } else {
@@ -855,7 +912,7 @@
             whileNode.getTest().accept(this);
             comma();
 
-            property("block");
+            property("body");
             whileNode.getBody().accept(this);
         }
 
@@ -894,23 +951,27 @@
         return buf.toString();
     }
 
-    private void property(final String key, final String value) {
+    private void property(final String key, final String value, final boolean escape) {
         buf.append('"');
         buf.append(key);
         buf.append("\":");
         if (value != null) {
-            buf.append('"');
+            if (escape) buf.append('"');
             buf.append(value);
-            buf.append('"');
+            if (escape) buf.append('"');
         }
     }
 
+    private void property(final String key, final String value) {
+        property(key, value, true);
+    }
+
     private void property(final String key, final boolean value) {
-        property(key, Boolean.toString(value));
+        property(key, Boolean.toString(value), false);
     }
 
     private void property(final String key, final int value) {
-        property(key, Integer.toString(value));
+        property(key, Integer.toString(value), false);
     }
 
     private void property(final String key) {
--- a/src/jdk/nashorn/internal/runtime/Context.java	Wed Sep 11 22:53:03 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/Context.java	Fri Sep 13 17:50:18 2013 +0530
@@ -236,6 +236,10 @@
     private static final ClassLoader myLoader = Context.class.getClassLoader();
     private static final StructureLoader sharedLoader;
 
+    /*package-private*/ ClassLoader getSharedLoader() {
+        return sharedLoader;
+    }
+
     private static AccessControlContext createNoPermAccCtxt() {
         return new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, new Permissions()) });
     }
@@ -254,7 +258,7 @@
         sharedLoader = AccessController.doPrivileged(new PrivilegedAction<StructureLoader>() {
             @Override
             public StructureLoader run() {
-                return new StructureLoader(myLoader, null);
+                return new StructureLoader(myLoader);
             }
         }, CREATE_LOADER_ACC_CTXT);
     }
@@ -599,7 +603,7 @@
      * @throws ClassNotFoundException if structure class cannot be resolved
      */
     public static Class<?> forStructureClass(final String fullName) throws ClassNotFoundException {
-        if (System.getSecurityManager() != null && !NashornLoader.isStructureClass(fullName)) {
+        if (System.getSecurityManager() != null && !StructureLoader.isStructureClass(fullName)) {
             throw new ClassNotFoundException(fullName);
         }
         return Class.forName(fullName, true, sharedLoader);
@@ -792,12 +796,11 @@
     static Context fromClass(final Class<?> clazz) {
         final ClassLoader loader = clazz.getClassLoader();
 
-        Context context = null;
-        if (loader instanceof NashornLoader) {
-            context = ((NashornLoader)loader).getContext();
+        if (loader instanceof ScriptLoader) {
+            return ((ScriptLoader)loader).getContext();
         }
 
-        return (context != null) ? context : Context.getContextTrusted();
+        return Context.getContextTrusted();
     }
 
     private Object evaluateSource(final Source source, final ScriptObject scope, final ScriptObject thiz) {
@@ -899,7 +902,7 @@
              new PrivilegedAction<ScriptLoader>() {
                 @Override
                 public ScriptLoader run() {
-                    return new ScriptLoader(sharedLoader, Context.this);
+                    return new ScriptLoader(appLoader, Context.this);
                 }
              }, CREATE_LOADER_ACC_CTXT);
     }
--- a/src/jdk/nashorn/internal/runtime/JSType.java	Wed Sep 11 22:53:03 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/JSType.java	Fri Sep 13 17:50:18 2013 +0530
@@ -29,7 +29,6 @@
 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError;
 
 import java.lang.invoke.MethodHandles;
-import java.util.Locale;
 import jdk.internal.dynalink.beans.StaticClass;
 import jdk.nashorn.internal.codegen.CompilerConstants.Call;
 import jdk.nashorn.internal.parser.Lexer;
@@ -40,25 +39,28 @@
  */
 public enum JSType {
     /** The undefined type */
-    UNDEFINED,
+    UNDEFINED("undefined"),
 
     /** The null type */
-    NULL,
+    NULL("object"),
 
     /** The boolean type */
-    BOOLEAN,
+    BOOLEAN("boolean"),
 
     /** The number type */
-    NUMBER,
+    NUMBER("number"),
 
     /** The string type */
-    STRING,
+    STRING("string"),
 
     /** The object type */
-    OBJECT,
+    OBJECT("object"),
 
     /** The function type */
-    FUNCTION;
+    FUNCTION("function");
+
+    /** The type name as returned by ECMAScript "typeof" operator*/
+    private final String typeName;
 
     /** Max value for an uint32 in JavaScript */
     public static final long MAX_UINT = 0xFFFF_FFFFL;
@@ -110,13 +112,21 @@
     private static final double INT32_LIMIT = 4294967296.0;
 
     /**
+     * Constructor
+     *
+     * @param typeName the type name
+     */
+    private JSType(final String typeName) {
+        this.typeName = typeName;
+    }
+
+    /**
      * The external type name as returned by ECMAScript "typeof" operator
      *
      * @return type name for this type
      */
     public final String typeName() {
-        // For NULL, "object" has to be returned!
-        return ((this == NULL) ? OBJECT : this).name().toLowerCase(Locale.ENGLISH);
+        return this.typeName;
     }
 
     /**
@@ -127,31 +137,32 @@
      * @return the JSType for the object
      */
     public static JSType of(final Object obj) {
-        if (obj == ScriptRuntime.UNDEFINED) {
-            return JSType.UNDEFINED;
+        // Order of these statements is tuned for performance (see JDK-8024476)
+        if (obj == null) {
+            return JSType.NULL;
         }
 
-        if (obj == null) {
-            return JSType.NULL;
+        if (obj instanceof ScriptObject) {
+            return (obj instanceof ScriptFunction) ? JSType.FUNCTION : JSType.OBJECT;
         }
 
         if (obj instanceof Boolean) {
             return JSType.BOOLEAN;
         }
 
+        if (obj instanceof String || obj instanceof ConsString) {
+            return JSType.STRING;
+        }
+
         if (obj instanceof Number) {
             return JSType.NUMBER;
         }
 
-        if (obj instanceof String || obj instanceof ConsString) {
-            return JSType.STRING;
+        if (obj == ScriptRuntime.UNDEFINED) {
+            return JSType.UNDEFINED;
         }
 
-        if (Bootstrap.isCallable(obj)) {
-            return JSType.FUNCTION;
-        }
-
-        return JSType.OBJECT;
+        return Bootstrap.isCallable(obj) ? JSType.FUNCTION : JSType.OBJECT;
     }
 
     /**
--- a/src/jdk/nashorn/internal/runtime/NashornLoader.java	Wed Sep 11 22:53:03 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/NashornLoader.java	Fri Sep 13 17:50:18 2013 +0530
@@ -38,10 +38,7 @@
 import jdk.nashorn.tools.Shell;
 
 /**
- * Superclass for Nashorn class loader classes. This stores Context
- * instance as an instance field. The current context can be
- * efficiently accessed from a given Class via it's ClassLoader.
- *
+ * Superclass for Nashorn class loader classes.
  */
 abstract class NashornLoader extends SecureClassLoader {
     private static final String OBJECTS_PKG        = "jdk.nashorn.internal.objects";
@@ -69,27 +66,8 @@
         };
     }
 
-    private final Context context;
-
-    final Context getContext() {
-        return context;
-    }
-
-    NashornLoader(final ClassLoader parent, final Context context) {
+    NashornLoader(final ClassLoader parent) {
         super(parent);
-        this.context = context;
-    }
-
-
-    /**
-     * Called by subclass after package access check is done
-     * @param name name of the class to be loaded
-     * @param resolve whether the class should be resolved or not
-     * @return Class object
-     * @throws ClassNotFoundException if class cannot be loaded
-     */
-    protected final Class<?> loadClassTrusted(final String name, final boolean resolve) throws ClassNotFoundException {
-        return super.loadClass(name, resolve);
     }
 
     protected static void checkPackageAccess(final String name) {
@@ -122,10 +100,6 @@
         return permCollection;
     }
 
-    static boolean isStructureClass(final String fullName) {
-        return fullName.startsWith(SCRIPTS_PKG);
-    }
-
     /**
      * Create a secure URL class loader for the given classpath
      * @param classPath classpath for the loader to search from
--- a/src/jdk/nashorn/internal/runtime/ScriptLoader.java	Wed Sep 11 22:53:03 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/ScriptLoader.java	Fri Sep 13 17:50:18 2013 +0530
@@ -33,17 +33,42 @@
  *
  */
 final class ScriptLoader extends NashornLoader {
+    private static final String NASHORN_PKG_PREFIX = "jdk.nashorn.internal.";
+
+    private final Context context;
+
+    /*package-private*/ Context getContext() {
+        return context;
+    }
+
     /**
      * Constructor.
      */
-    ScriptLoader(final StructureLoader parent, final Context context) {
-        super(parent, context);
+    ScriptLoader(final ClassLoader parent, final Context context) {
+        super(parent);
+        this.context = context;
     }
 
     @Override
     protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
         checkPackageAccess(name);
-        return super.loadClassTrusted(name, resolve);
+        try {
+            return super.loadClass(name, resolve);
+        } catch (final ClassNotFoundException | SecurityException e) {
+            // We'll get ClassNotFoundException for Nashorn 'struct' classes.
+            // Also, we'll get SecurityException for jdk.nashorn.internal.*
+            // classes. So, load these using to context's 'shared' loader.
+            // All these classes start with "jdk.nashorn.internal." prefix.
+            try {
+                if (name.startsWith(NASHORN_PKG_PREFIX)) {
+                    return context.getSharedLoader().loadClass(name);
+                }
+            } catch (final ClassNotFoundException ignored) {
+            }
+
+            // throw the original exception from here
+            throw e;
+        }
     }
 
     // package-private and private stuff below this point
--- a/src/jdk/nashorn/internal/runtime/StructureLoader.java	Wed Sep 11 22:53:03 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/StructureLoader.java	Fri Sep 13 17:50:18 2013 +0530
@@ -34,7 +34,6 @@
 
 /**
  * Responsible for on the fly construction of structure classes.
- *
  */
 final class StructureLoader extends NashornLoader {
     private static final String JS_OBJECT_PREFIX_EXTERNAL = binaryName(SCRIPTS_PACKAGE) + '.' + JS_OBJECT_PREFIX.symbolName();
@@ -42,27 +41,17 @@
     /**
      * Constructor.
      */
-    StructureLoader(final ClassLoader parent, final Context context) {
-        super(parent, context);
+    StructureLoader(final ClassLoader parent) {
+        super(parent);
     }
 
-    @Override
-    protected synchronized Class<?> loadClass(final String name, final boolean resolve) throws ClassNotFoundException {
-        // check the cache first
-        final Class<?> loadedClass = findLoadedClass(name);
-        if (loadedClass != null) {
-            if (resolve) {
-                resolveClass(loadedClass);
-            }
-            return loadedClass;
-        }
-
-        return super.loadClassTrusted(name, resolve);
+    static boolean isStructureClass(final String name) {
+        return name.startsWith(JS_OBJECT_PREFIX_EXTERNAL);
     }
 
     @Override
     protected Class<?> findClass(final String name) throws ClassNotFoundException {
-        if (name.startsWith(JS_OBJECT_PREFIX_EXTERNAL)) {
+        if (isStructureClass(name)) {
             return generateClass(name, name.substring(JS_OBJECT_PREFIX_EXTERNAL.length()));
         }
         return super.findClass(name);
@@ -75,11 +64,7 @@
      * @return Generated class.
      */
     private Class<?> generateClass(final String name, final String descriptor) {
-        Context context = getContext();
-
-        if (context == null) {
-            context = Context.getContextTrusted();
-        }
+        final Context context = Context.getContextTrusted();
 
         final byte[] code = new ObjectClassGenerator(context).generate(descriptor);
         return defineClass(name, code, 0, code.length, new ProtectionDomain(null, getPermissions(null)));
--- a/src/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java	Wed Sep 11 22:53:03 2013 +0530
+++ b/src/jdk/nashorn/internal/runtime/regexp/RegExpScanner.java	Fri Sep 13 17:50:18 2013 +0530
@@ -263,15 +263,6 @@
         }
 
         if (atom()) {
-            // Check for character classes that never or always match
-            if (sb.toString().endsWith("[]")) {
-                sb.setLength(sb.length() - 1);
-                sb.append("^\\s\\S]");
-            } else if (sb.toString().endsWith("[^]")) {
-                sb.setLength(sb.length() - 2);
-                sb.append("\\s\\S]");
-            }
-
             quantifier();
             return true;
         }
@@ -767,7 +758,18 @@
 
                 if (classRanges() && ch0 == ']') {
                     pop(']');
-                    return commit(1);
+                    commit(1);
+
+                    // Substitute empty character classes [] and [^] that never or always match
+                    if (position == startIn + 2) {
+                        sb.setLength(sb.length() - 1);
+                        sb.append("^\\s\\S]");
+                    } else if (position == startIn + 3 && inNegativeClass) {
+                        sb.setLength(sb.length() - 2);
+                        sb.append("\\s\\S]");
+                    }
+
+                    return true;
                 }
             } finally {
                 inCharClass = false;  // no nested character classes in JavaScript
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8024512.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8024512: Regex /[^\[]/ doesn't match
+ *
+ * @test
+ * @run
+ */
+
+print("[M]".match(/(\[[^\[]*\])/));
+print("[[]".match(/(\[[^\[]*\])/));
+
+print("[M]".match(/(\[[^\[^]*\])/));
+print("[[]".match(/(\[[^\[^]*\])/));
+print("[^]".match(/(\[[^\[^]*\])/));
+
+print("[M]".match(/(\[[^\[]\])/));
+print("[[]".match(/(\[[^\[]\])/));
+
+print("[M]".match(/(\[[^\[^]\])/));
+print("[[]".match(/(\[[^\[^]\])/));
+print("[^]".match(/(\[[^\[^]\])/));
+
+print("M".match(/[^\[]/));
+print("[".match(/[^\[]/));
+print("^".match(/[^\[]/));
+
+// Repeat above without escaping inner square bracket
+print("[M]".match(/(\[[^[]\])/));
+print("[[]".match(/(\[[^[]\])/));
+
+print("[M]".match(/(\[[^[^]\])/));
+print("[[]".match(/(\[[^[^]\])/));
+print("[^]".match(/(\[[^[^]\])/));
+
+print("M".match(/[^[]/));
+print("[".match(/[^[]/));
+print("^".match(/[^[]/));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8024512.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,21 @@
+[M],[M]
+[],[]
+[M],[M]
+[],[]
+null
+[M],[M]
+null
+[M],[M]
+null
+null
+M
+null
+^
+[M],[M]
+null
+[M],[M]
+null
+null
+M
+null
+^
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/JDK-8024619.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * JDK-8024619: JDBC java.sql.DriverManager is not usable from JS script
+ *
+ * @test
+ * @run
+ */
+
+var DriverManager = Java.type("java.sql.DriverManager");
+var e = DriverManager.getDrivers();
+
+var driverFound = false;
+// check for Nashorn SQL driver
+while (e.hasMoreElements()) {
+    var driver = e.nextElement();
+    if (driver.acceptsURL("jdbc:nashorn:")) {
+        driverFound = true;
+        break;
+    }
+}
+
+if (! driverFound) {
+    fail("Nashorn JDBC Driver not found!");
+}
--- a/test/script/basic/NASHORN-737.js	Wed Sep 11 22:53:03 2013 +0530
+++ b/test/script/basic/NASHORN-737.js	Fri Sep 13 17:50:18 2013 +0530
@@ -30,4 +30,4 @@
 
 load("nashorn:parser.js");
 var ast = parse("label: while(true) break label;");
-print(JSON.stringify(ast));
+print(JSON.stringify(ast, null, "    "));
--- a/test/script/basic/NASHORN-737.js.EXPECTED	Wed Sep 11 22:53:03 2013 +0530
+++ b/test/script/basic/NASHORN-737.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -1,1 +1,36 @@
-{"type":"Program","rest":null,"body":[{"type":"LabeledStatement","label":{"type":"Identifier","name":"label"},"body":{"type":"BlockStatement","body":[{"type":"WhileStatement","test":{"type":"Literal","value":true},"block":{"type":"BlockStatement","body":[{"type":"BreakStatement","label":"label"}]}}]}}]}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "LabeledStatement",
+            "label": {
+                "type": "Identifier",
+                "name": "label"
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "WhileStatement",
+                        "test": {
+                            "type": "Literal",
+                            "value": true
+                        },
+                        "body": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "BreakStatement",
+                                    "label": {
+                                        "type": "Identifier",
+                                        "name": "label"
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/assignmentExpr.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check assignment e xyzpressions.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("xyz = 314");
+printParse("xyz += 314");
+printParse("xyz -= 314");
+printParse("xyz *= 314");
+printParse("xyz /= 314");
+printParse("xyz %= 314");
+printParse("xyz <<= 314");
+printParse("xyz >>= 314");
+printParse("xyz >>>= 314");
+printParse("xyz &= 314");
+printParse("xyz ^= 314");
+printParse("xyz |= 314");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/assignmentExpr.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,240 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "+=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "-=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "*=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "/=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "%=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "<<=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": ">>=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": ">>>=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "&=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "^=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "|=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "xyz"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 314
+                }
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/binaryExpr.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check binary operators.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("a * b")
+printParse("a / b");
+printParse("a % b");
+printParse("a + b");
+printParse("a - b");
+printParse("a << b");
+printParse("a >> b");
+printParse("a >>> b");
+printParse("a < b");
+printParse("a > b");
+printParse("a <= b");
+printParse("a >= b");
+printParse("a instanceof b");
+printParse("a == b");
+printParse("a != b");
+printParse("a === b");
+printParse("a !== b");
+printParse("a & b");
+printParse("a ^ b");
+printParse("a | b");
+printParse("a && b");
+printParse("a || b");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/binaryExpr.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,440 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "*",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "/",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "%",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "+",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "-",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "<<",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": ">>",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": ">>>",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "<",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": ">",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "<=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": ">=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "instanceof",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "==",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "!=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "===",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "!==",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "&",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "^",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "|",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "LogicalExpression",
+                "operator": "&&",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "LogicalExpression",
+                "operator": "||",
+                "left": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "right": {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/breakStat.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check 'break' statement.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("while (true) { break; }");
+printParse("loop: { while (true) { break loop } }");
+printParse("loop: { for (;;) { break loop } }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/breakStat.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,92 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "WhileStatement",
+            "test": {
+                "type": "Literal",
+                "value": true
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "BreakStatement",
+                        "label": null
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "LabeledStatement",
+            "label": {
+                "type": "Identifier",
+                "name": "loop"
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "WhileStatement",
+                        "test": {
+                            "type": "Literal",
+                            "value": true
+                        },
+                        "body": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "BreakStatement",
+                                    "label": {
+                                        "type": "Identifier",
+                                        "name": "loop"
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "LabeledStatement",
+            "label": {
+                "type": "Identifier",
+                "name": "loop"
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ForStatement",
+                        "init": null,
+                        "test": null,
+                        "update": null,
+                        "body": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "BreakStatement",
+                                    "label": {
+                                        "type": "Identifier",
+                                        "name": "loop"
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/condExpr.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check ternary operator.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("a? b : c");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/condExpr.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,23 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "ConditionalExpression",
+                "test": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "consequent": {
+                    "type": "Identifier",
+                    "name": "b"
+                },
+                "alternate": {
+                    "type": "Identifier",
+                    "name": "c"
+                }
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/continueStat.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check 'continue' statement.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("while (true) { continue; }");
+printParse("begin: { while (true) { continue begin; } }");
+printParse("start: { for(;;) { continue start; } }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/continueStat.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,92 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "WhileStatement",
+            "test": {
+                "type": "Literal",
+                "value": true
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ContinueStatement",
+                        "label": null
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "LabeledStatement",
+            "label": {
+                "type": "Identifier",
+                "name": "begin"
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "WhileStatement",
+                        "test": {
+                            "type": "Literal",
+                            "value": true
+                        },
+                        "body": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "ContinueStatement",
+                                    "label": {
+                                        "type": "Identifier",
+                                        "name": "begin"
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "LabeledStatement",
+            "label": {
+                "type": "Identifier",
+                "name": "start"
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ForStatement",
+                        "init": null,
+                        "test": null,
+                        "update": null,
+                        "body": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "ContinueStatement",
+                                    "label": {
+                                        "type": "Identifier",
+                                        "name": "start"
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/debuggerStat.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check debugger statement.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("debugger");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/debuggerStat.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,8 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "DebuggerStatement"
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/functions.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check 'function' statements and expressions.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("function hello() { print('hello') }")
+printParse("function hello(a) { print(a) }")
+printParse("function hello(a, b) { print(a, b) }")
+printParse("var hello = function() { print('hello') };")
+printParse("var hello = function hello() { print('hello') };")
+printParse("(function(){})")
+printParse("function test() { 'use strict' }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/functions.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,279 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "FunctionDeclaration",
+            "id": {
+                "type": "Identifier",
+                "name": "hello"
+            },
+            "params": [],
+            "defaults": [],
+            "rest": null,
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "print"
+                            },
+                            "arguments": [
+                                {
+                                    "type": "Literal",
+                                    "value": "hello"
+                                }
+                            ]
+                        }
+                    }
+                ]
+            },
+            "generator": false,
+            "expression": false
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "FunctionDeclaration",
+            "id": {
+                "type": "Identifier",
+                "name": "hello"
+            },
+            "params": [
+                {
+                    "type": "Identifier",
+                    "name": "a"
+                }
+            ],
+            "defaults": [],
+            "rest": null,
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "print"
+                            },
+                            "arguments": [
+                                {
+                                    "type": "Identifier",
+                                    "name": "a"
+                                }
+                            ]
+                        }
+                    }
+                ]
+            },
+            "generator": false,
+            "expression": false
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "FunctionDeclaration",
+            "id": {
+                "type": "Identifier",
+                "name": "hello"
+            },
+            "params": [
+                {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                {
+                    "type": "Identifier",
+                    "name": "b"
+                }
+            ],
+            "defaults": [],
+            "rest": null,
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "print"
+                            },
+                            "arguments": [
+                                {
+                                    "type": "Identifier",
+                                    "name": "a"
+                                },
+                                {
+                                    "type": "Identifier",
+                                    "name": "b"
+                                }
+                            ]
+                        }
+                    }
+                ]
+            },
+            "generator": false,
+            "expression": false
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "VariableDeclaration",
+            "declarations": [
+                {
+                    "type": "VariableDeclarator",
+                    "id": {
+                        "type": "Identifier",
+                        "name": "hello"
+                    },
+                    "init": {
+                        "type": "FunctionExpression",
+                        "id": null,
+                        "params": [],
+                        "defaults": [],
+                        "rest": null,
+                        "body": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "ExpressionStatement",
+                                    "expression": {
+                                        "type": "CallExpression",
+                                        "callee": {
+                                            "type": "Identifier",
+                                            "name": "print"
+                                        },
+                                        "arguments": [
+                                            {
+                                                "type": "Literal",
+                                                "value": "hello"
+                                            }
+                                        ]
+                                    }
+                                }
+                            ]
+                        },
+                        "generator": false,
+                        "expression": false
+                    }
+                }
+            ]
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "VariableDeclaration",
+            "declarations": [
+                {
+                    "type": "VariableDeclarator",
+                    "id": {
+                        "type": "Identifier",
+                        "name": "hello"
+                    },
+                    "init": {
+                        "type": "FunctionExpression",
+                        "id": {
+                            "type": "Identifier",
+                            "name": "hello"
+                        },
+                        "params": [],
+                        "defaults": [],
+                        "rest": null,
+                        "body": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "ExpressionStatement",
+                                    "expression": {
+                                        "type": "CallExpression",
+                                        "callee": {
+                                            "type": "Identifier",
+                                            "name": "print"
+                                        },
+                                        "arguments": [
+                                            {
+                                                "type": "Literal",
+                                                "value": "hello"
+                                            }
+                                        ]
+                                    }
+                                }
+                            ]
+                        },
+                        "generator": false,
+                        "expression": false
+                    }
+                }
+            ]
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "FunctionExpression",
+                "id": null,
+                "params": [],
+                "defaults": [],
+                "rest": null,
+                "body": {
+                    "type": "BlockStatement",
+                    "body": []
+                },
+                "generator": false,
+                "expression": false
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "FunctionDeclaration",
+            "id": {
+                "type": "Identifier",
+                "name": "test"
+            },
+            "params": [],
+            "defaults": [],
+            "rest": null,
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "Literal",
+                            "value": "use strict"
+                        }
+                    }
+                ]
+            },
+            "generator": false,
+            "expression": false
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/ifStat.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check 'if' statement.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("if (js) { nashorn() }");
+printParse("if (js) { nashorn() } else { java() }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/ifStat.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,73 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "IfStatement",
+            "test": {
+                "type": "Identifier",
+                "name": "js"
+            },
+            "consequent": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "nashorn"
+                            },
+                            "arguments": []
+                        }
+                    }
+                ]
+            },
+            "alternate": null
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "IfStatement",
+            "test": {
+                "type": "Identifier",
+                "name": "js"
+            },
+            "consequent": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "nashorn"
+                            },
+                            "arguments": []
+                        }
+                    }
+                ]
+            },
+            "alternate": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "java"
+                            },
+                            "arguments": []
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/labelledStat.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Test for labelled statements.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("begin: { for (;;) break begin }");
+printParse("begin: { while (true) break begin }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/labelledStat.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,71 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "LabeledStatement",
+            "label": {
+                "type": "Identifier",
+                "name": "begin"
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ForStatement",
+                        "init": null,
+                        "test": null,
+                        "update": null,
+                        "body": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "BreakStatement",
+                                    "label": {
+                                        "type": "Identifier",
+                                        "name": "begin"
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "LabeledStatement",
+            "label": {
+                "type": "Identifier",
+                "name": "begin"
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "WhileStatement",
+                        "test": {
+                            "type": "Literal",
+                            "value": true
+                        },
+                        "body": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "BreakStatement",
+                                    "label": {
+                                        "type": "Identifier",
+                                        "name": "begin"
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/lhsExpr.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check left-hand-side expressions
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("a[3]");
+printParse("a[b]");
+printParse("a['foo']");
+printParse("obj.foo");
+printParse("obj.foo.bar");
+printParse("new Type");
+printParse("new Type()");
+printParse("new Type(a, 'hello')");
+printParse("new obj.Type");
+printParse("new obj.Type()");
+printParse("new obj.Type(a, 'hello')");
+printParse("foo()")
+printParse("obj.foo()");
+printParse("foo(a,b)");
+printParse("obj.foo(a, b)");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/lhsExpr.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,344 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "MemberExpression",
+                "object": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "property": {
+                    "type": "Literal",
+                    "value": 3
+                },
+                "computed": true
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "MemberExpression",
+                "object": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "property": {
+                    "type": "Identifier",
+                    "name": "b"
+                },
+                "computed": true
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "MemberExpression",
+                "object": {
+                    "type": "Identifier",
+                    "name": "a"
+                },
+                "property": {
+                    "type": "Literal",
+                    "value": "foo"
+                },
+                "computed": true
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "MemberExpression",
+                "object": {
+                    "type": "Identifier",
+                    "name": "obj"
+                },
+                "property": {
+                    "type": "Identifier",
+                    "name": "foo"
+                },
+                "computed": false
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "MemberExpression",
+                "object": {
+                    "type": "MemberExpression",
+                    "object": {
+                        "type": "Identifier",
+                        "name": "obj"
+                    },
+                    "property": {
+                        "type": "Identifier",
+                        "name": "foo"
+                    },
+                    "computed": false
+                },
+                "property": {
+                    "type": "Identifier",
+                    "name": "bar"
+                },
+                "computed": false
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "NewExpression",
+                "callee": {
+                    "type": "Identifier",
+                    "name": "Type"
+                },
+                "arguments": []
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "NewExpression",
+                "callee": {
+                    "type": "Identifier",
+                    "name": "Type"
+                },
+                "arguments": []
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "NewExpression",
+                "callee": {
+                    "type": "Identifier",
+                    "name": "Type"
+                },
+                "arguments": [
+                    {
+                        "type": "Identifier",
+                        "name": "a"
+                    },
+                    {
+                        "type": "Literal",
+                        "value": "hello"
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "NewExpression",
+                "callee": {
+                    "type": "MemberExpression",
+                    "object": {
+                        "type": "Identifier",
+                        "name": "obj"
+                    },
+                    "property": {
+                        "type": "Identifier",
+                        "name": "Type"
+                    },
+                    "computed": false
+                },
+                "arguments": []
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "NewExpression",
+                "callee": {
+                    "type": "MemberExpression",
+                    "object": {
+                        "type": "Identifier",
+                        "name": "obj"
+                    },
+                    "property": {
+                        "type": "Identifier",
+                        "name": "Type"
+                    },
+                    "computed": false
+                },
+                "arguments": []
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "NewExpression",
+                "callee": {
+                    "type": "MemberExpression",
+                    "object": {
+                        "type": "Identifier",
+                        "name": "obj"
+                    },
+                    "property": {
+                        "type": "Identifier",
+                        "name": "Type"
+                    },
+                    "computed": false
+                },
+                "arguments": [
+                    {
+                        "type": "Identifier",
+                        "name": "a"
+                    },
+                    {
+                        "type": "Literal",
+                        "value": "hello"
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "CallExpression",
+                "callee": {
+                    "type": "Identifier",
+                    "name": "foo"
+                },
+                "arguments": []
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "CallExpression",
+                "callee": {
+                    "type": "MemberExpression",
+                    "object": {
+                        "type": "Identifier",
+                        "name": "obj"
+                    },
+                    "property": {
+                        "type": "Identifier",
+                        "name": "foo"
+                    },
+                    "computed": false
+                },
+                "arguments": []
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "CallExpression",
+                "callee": {
+                    "type": "Identifier",
+                    "name": "foo"
+                },
+                "arguments": [
+                    {
+                        "type": "Identifier",
+                        "name": "a"
+                    },
+                    {
+                        "type": "Identifier",
+                        "name": "b"
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "CallExpression",
+                "callee": {
+                    "type": "MemberExpression",
+                    "object": {
+                        "type": "Identifier",
+                        "name": "obj"
+                    },
+                    "property": {
+                        "type": "Identifier",
+                        "name": "foo"
+                    },
+                    "computed": false
+                },
+                "arguments": [
+                    {
+                        "type": "Identifier",
+                        "name": "a"
+                    },
+                    {
+                        "type": "Identifier",
+                        "name": "b"
+                    }
+                ]
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/loopStat.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests for loop statements.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("while(true) { print('hello') }")
+printParse("do { print('hello') } while(true)")
+printParse("for (i in obj) { print(obj[i]) }")
+printParse("for each (i in obj) { print(i) }")
+printParse("for (i = 0; i < 10; i++) { print(i) }")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/loopStat.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,212 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "WhileStatement",
+            "test": {
+                "type": "Literal",
+                "value": true
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "print"
+                            },
+                            "arguments": [
+                                {
+                                    "type": "Literal",
+                                    "value": "hello"
+                                }
+                            ]
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "DoWhileStatement",
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "print"
+                            },
+                            "arguments": [
+                                {
+                                    "type": "Literal",
+                                    "value": "hello"
+                                }
+                            ]
+                        }
+                    }
+                ]
+            },
+            "test": {
+                "type": "Literal",
+                "value": true
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ForInStatement",
+            "left": {
+                "type": "Identifier",
+                "name": "i"
+            },
+            "right": {
+                "type": "Identifier",
+                "name": "obj"
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "print"
+                            },
+                            "arguments": [
+                                {
+                                    "type": "MemberExpression",
+                                    "object": {
+                                        "type": "Identifier",
+                                        "name": "obj"
+                                    },
+                                    "property": {
+                                        "type": "Identifier",
+                                        "name": "i"
+                                    },
+                                    "computed": true
+                                }
+                            ]
+                        }
+                    }
+                ]
+            },
+            "each": false
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ForInStatement",
+            "left": {
+                "type": "Identifier",
+                "name": "i"
+            },
+            "right": {
+                "type": "Identifier",
+                "name": "obj"
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "print"
+                            },
+                            "arguments": [
+                                {
+                                    "type": "Identifier",
+                                    "name": "i"
+                                }
+                            ]
+                        }
+                    }
+                ]
+            },
+            "each": true
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ForStatement",
+            "init": {
+                "type": "AssignmentExpression",
+                "operator": "=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "i"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 0
+                }
+            },
+            "test": {
+                "type": "BinaryExpression",
+                "operator": "<",
+                "left": {
+                    "type": "Identifier",
+                    "name": "i"
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 10
+                }
+            },
+            "update": {
+                "type": "UpdateExpression",
+                "operator": "++",
+                "prefix": false,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "i"
+                }
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "CallExpression",
+                            "callee": {
+                                "type": "Identifier",
+                                "name": "print"
+                            },
+                            "arguments": [
+                                {
+                                    "type": "Identifier",
+                                    "name": "i"
+                                }
+                            ]
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/objectLitExpr.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check assignment e xyzpressions.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("obj = {}");
+printParse("p = { x: 10, y: 2 }");
+printParse("p = { 'x': 10, 'y': 2 }");
+printParse("p = { get x() { return xValue }, get y() { return yValue } }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/objectLitExpr.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,189 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "obj"
+                },
+                "right": {
+                    "type": "ObjectExpression",
+                    "properties": []
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "p"
+                },
+                "right": {
+                    "type": "ObjectExpression",
+                    "properties": [
+                        {
+                            "key": {
+                                "type": "Identifier",
+                                "name": "x"
+                            },
+                            "value": {
+                                "type": "Literal",
+                                "value": 10
+                            },
+                            "kind": "init"
+                        },
+                        {
+                            "key": {
+                                "type": "Identifier",
+                                "name": "y"
+                            },
+                            "value": {
+                                "type": "Literal",
+                                "value": 2
+                            },
+                            "kind": "init"
+                        }
+                    ]
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "p"
+                },
+                "right": {
+                    "type": "ObjectExpression",
+                    "properties": [
+                        {
+                            "key": {
+                                "type": "Literal",
+                                "value": "x"
+                            },
+                            "value": {
+                                "type": "Literal",
+                                "value": 10
+                            },
+                            "kind": "init"
+                        },
+                        {
+                            "key": {
+                                "type": "Literal",
+                                "value": "y"
+                            },
+                            "value": {
+                                "type": "Literal",
+                                "value": 2
+                            },
+                            "kind": "init"
+                        }
+                    ]
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "AssignmentExpression",
+                "operator": "=",
+                "left": {
+                    "type": "Identifier",
+                    "name": "p"
+                },
+                "right": {
+                    "type": "ObjectExpression",
+                    "properties": [
+                        {
+                            "key": {
+                                "type": "Identifier",
+                                "name": "x"
+                            },
+                            "value": {
+                                "type": "FunctionExpression",
+                                "id": {
+                                    "type": "Identifier",
+                                    "name": "get x"
+                                },
+                                "params": [],
+                                "defaults": [],
+                                "rest": null,
+                                "body": {
+                                    "type": "BlockStatement",
+                                    "body": [
+                                        {
+                                            "type": "ReturnStatement",
+                                            "argument": {
+                                                "type": "Identifier",
+                                                "name": "xValue"
+                                            }
+                                        }
+                                    ]
+                                },
+                                "generator": false,
+                                "expression": false
+                            },
+                            "kind": "get"
+                        },
+                        {
+                            "key": {
+                                "type": "Identifier",
+                                "name": "y"
+                            },
+                            "value": {
+                                "type": "FunctionExpression",
+                                "id": {
+                                    "type": "Identifier",
+                                    "name": "get y"
+                                },
+                                "params": [],
+                                "defaults": [],
+                                "rest": null,
+                                "body": {
+                                    "type": "BlockStatement",
+                                    "body": [
+                                        {
+                                            "type": "ReturnStatement",
+                                            "argument": {
+                                                "type": "Identifier",
+                                                "name": "yValue"
+                                            }
+                                        }
+                                    ]
+                                },
+                                "generator": false,
+                                "expression": false
+                            },
+                            "kind": "get"
+                        }
+                    ]
+                }
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/parenExpr.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests for parenthesis expressions.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("(2) + (1) + 4");
+printParse("3 + (7) << (5)");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/parenExpr.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,56 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "+",
+                "left": {
+                    "type": "BinaryExpression",
+                    "operator": "+",
+                    "left": {
+                        "type": "Literal",
+                        "value": 2
+                    },
+                    "right": {
+                        "type": "Literal",
+                        "value": 1
+                    }
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 4
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "<<",
+                "left": {
+                    "type": "BinaryExpression",
+                    "operator": "+",
+                    "left": {
+                        "type": "Literal",
+                        "value": 3
+                    },
+                    "right": {
+                        "type": "Literal",
+                        "value": 7
+                    }
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 5
+                }
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/primaryExpr.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check primary expressions.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("this");
+printParse("foo");
+printParse("null");
+printParse("true");
+printParse("false");
+printParse("33");
+printParse("3.14");
+printParse("(10 + 3)*2");
+printParse("({})");
+printParse("({ x: 3 })");
+printParse("[]");
+printParse("[,,]");
+printParse("[4, 5, 5]");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/primaryExpr.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,199 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "ThisExpression"
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "Identifier",
+                "name": "foo"
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "Literal",
+                "value": null
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "Literal",
+                "value": true
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "Literal",
+                "value": false
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "Literal",
+                "value": 33
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "Literal",
+                "value": 3.14
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "BinaryExpression",
+                "operator": "*",
+                "left": {
+                    "type": "BinaryExpression",
+                    "operator": "+",
+                    "left": {
+                        "type": "Literal",
+                        "value": 10
+                    },
+                    "right": {
+                        "type": "Literal",
+                        "value": 3
+                    }
+                },
+                "right": {
+                    "type": "Literal",
+                    "value": 2
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "ObjectExpression",
+                "properties": []
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "ObjectExpression",
+                "properties": [
+                    {
+                        "key": {
+                            "type": "Identifier",
+                            "name": "x"
+                        },
+                        "value": {
+                            "type": "Literal",
+                            "value": 3
+                        },
+                        "kind": "init"
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "ArrayExpression",
+                "elements": []
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "ArrayExpression",
+                "elements": [
+                    null,
+                    null
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "ArrayExpression",
+                "elements": [
+                    {
+                        "type": "Literal",
+                        "value": 4
+                    },
+                    {
+                        "type": "Literal",
+                        "value": 5
+                    },
+                    {
+                        "type": "Literal",
+                        "value": 5
+                    }
+                ]
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/returnStat.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check 'return' statement.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("(function() { return })");
+printParse("(function() { return res })");
+printParse("(function() { return foo() })");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/returnStat.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,88 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "FunctionExpression",
+                "id": null,
+                "params": [],
+                "defaults": [],
+                "rest": null,
+                "body": {
+                    "type": "BlockStatement",
+                    "body": [
+                        {
+                            "type": "ReturnStatement",
+                            "argument": null
+                        }
+                    ]
+                },
+                "generator": false,
+                "expression": false
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "FunctionExpression",
+                "id": null,
+                "params": [],
+                "defaults": [],
+                "rest": null,
+                "body": {
+                    "type": "BlockStatement",
+                    "body": [
+                        {
+                            "type": "ReturnStatement",
+                            "argument": {
+                                "type": "Identifier",
+                                "name": "res"
+                            }
+                        }
+                    ]
+                },
+                "generator": false,
+                "expression": false
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "FunctionExpression",
+                "id": null,
+                "params": [],
+                "defaults": [],
+                "rest": null,
+                "body": {
+                    "type": "BlockStatement",
+                    "body": [
+                        {
+                            "type": "ReturnStatement",
+                            "argument": {
+                                "type": "CallExpression",
+                                "callee": {
+                                    "type": "Identifier",
+                                    "name": "foo"
+                                },
+                                "arguments": []
+                            }
+                        }
+                    ]
+                },
+                "generator": false,
+                "expression": false
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/switchStat.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests for switch statement.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("switch (key) {}");
+printParse("switch (key) { case 2: hello(); break; }");
+printParse("switch (key) { case 4: hello(); break; case 2: world(); break; default: break }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/switchStat.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,123 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "SwitchStatement",
+            "discriminant": {
+                "type": "Identifier",
+                "name": "key"
+            },
+            "cases": []
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "SwitchStatement",
+            "discriminant": {
+                "type": "Identifier",
+                "name": "key"
+            },
+            "cases": [
+                {
+                    "type": "SwitchCase",
+                    "test": {
+                        "type": "Literal",
+                        "value": 2
+                    },
+                    "consequent": [
+                        {
+                            "type": "ExpressionStatement",
+                            "expression": {
+                                "type": "CallExpression",
+                                "callee": {
+                                    "type": "Identifier",
+                                    "name": "hello"
+                                },
+                                "arguments": []
+                            }
+                        },
+                        {
+                            "type": "BreakStatement",
+                            "label": null
+                        }
+                    ]
+                }
+            ]
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "SwitchStatement",
+            "discriminant": {
+                "type": "Identifier",
+                "name": "key"
+            },
+            "cases": [
+                {
+                    "type": "SwitchCase",
+                    "test": {
+                        "type": "Literal",
+                        "value": 4
+                    },
+                    "consequent": [
+                        {
+                            "type": "ExpressionStatement",
+                            "expression": {
+                                "type": "CallExpression",
+                                "callee": {
+                                    "type": "Identifier",
+                                    "name": "hello"
+                                },
+                                "arguments": []
+                            }
+                        },
+                        {
+                            "type": "BreakStatement",
+                            "label": null
+                        }
+                    ]
+                },
+                {
+                    "type": "SwitchCase",
+                    "test": {
+                        "type": "Literal",
+                        "value": 2
+                    },
+                    "consequent": [
+                        {
+                            "type": "ExpressionStatement",
+                            "expression": {
+                                "type": "CallExpression",
+                                "callee": {
+                                    "type": "Identifier",
+                                    "name": "world"
+                                },
+                                "arguments": []
+                            }
+                        },
+                        {
+                            "type": "BreakStatement",
+                            "label": null
+                        }
+                    ]
+                },
+                {
+                    "type": "SwitchCase",
+                    "test": null,
+                    "consequent": [
+                        {
+                            "type": "BreakStatement",
+                            "label": null
+                        }
+                    ]
+                }
+            ]
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/throwStat.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests for throw statement.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("throw err");
+printParse("throw 'wrong'");
+printParse("throw new TypeError");
+printParse("throw new TypeError('not an array')");
+printParse("throw { msg: 'wrong!' }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/throwStat.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,85 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ThrowStatement",
+            "argument": {
+                "type": "Identifier",
+                "name": "err"
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ThrowStatement",
+            "argument": {
+                "type": "Literal",
+                "value": "wrong"
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ThrowStatement",
+            "argument": {
+                "type": "NewExpression",
+                "callee": {
+                    "type": "Identifier",
+                    "name": "TypeError"
+                },
+                "arguments": []
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ThrowStatement",
+            "argument": {
+                "type": "NewExpression",
+                "callee": {
+                    "type": "Identifier",
+                    "name": "TypeError"
+                },
+                "arguments": [
+                    {
+                        "type": "Literal",
+                        "value": "not an array"
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ThrowStatement",
+            "argument": {
+                "type": "ObjectExpression",
+                "properties": [
+                    {
+                        "key": {
+                            "type": "Identifier",
+                            "name": "msg"
+                        },
+                        "value": {
+                            "type": "Literal",
+                            "value": "wrong!"
+                        },
+                        "kind": "init"
+                    }
+                ]
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/tryCatchStat.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check try..catch statements.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("try { } catch (e) { }");
+printParse("try { } catch (e) { } finally {}");
+printParse("try { } finally {}");
+printParse("try { } catch (e) { handle() }");
+printParse("try { that() } catch (e) { handle() } finally { clean() }");
+printParse("try { that() } catch (e if e instanceof TypeError) { handle() } catch (e) { rest() }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/tryCatchStat.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,305 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "BlockStatement",
+            "block": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "TryStatement",
+                        "block": {
+                            "type": "BlockStatement",
+                            "body": []
+                        },
+                        "guardedHandlers": [],
+                        "handler": {
+                            "type": "CatchClause",
+                            "param": {
+                                "type": "Identifier",
+                                "name": "e"
+                            },
+                            "body": {
+                                "type": "BlockStatement",
+                                "body": []
+                            }
+                        },
+                        "finalizer": null
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "BlockStatement",
+            "block": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "TryStatement",
+                        "block": {
+                            "type": "BlockStatement",
+                            "body": []
+                        },
+                        "guardedHandlers": [],
+                        "handler": {
+                            "type": "CatchClause",
+                            "param": {
+                                "type": "Identifier",
+                                "name": "e"
+                            },
+                            "body": {
+                                "type": "BlockStatement",
+                                "body": []
+                            }
+                        },
+                        "finalizer": {
+                            "type": "BlockStatement",
+                            "body": []
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "BlockStatement",
+            "block": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "TryStatement",
+                        "block": {
+                            "type": "BlockStatement",
+                            "body": []
+                        },
+                        "guardedHandlers": [],
+                        "handler": null,
+                        "finalizer": {
+                            "type": "BlockStatement",
+                            "body": []
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "BlockStatement",
+            "block": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "TryStatement",
+                        "block": {
+                            "type": "BlockStatement",
+                            "body": []
+                        },
+                        "guardedHandlers": [],
+                        "handler": {
+                            "type": "CatchClause",
+                            "param": {
+                                "type": "Identifier",
+                                "name": "e"
+                            },
+                            "body": {
+                                "type": "BlockStatement",
+                                "body": [
+                                    {
+                                        "type": "ExpressionStatement",
+                                        "expression": {
+                                            "type": "CallExpression",
+                                            "callee": {
+                                                "type": "Identifier",
+                                                "name": "handle"
+                                            },
+                                            "arguments": []
+                                        }
+                                    }
+                                ]
+                            }
+                        },
+                        "finalizer": null
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "BlockStatement",
+            "block": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "TryStatement",
+                        "block": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "ExpressionStatement",
+                                    "expression": {
+                                        "type": "CallExpression",
+                                        "callee": {
+                                            "type": "Identifier",
+                                            "name": "that"
+                                        },
+                                        "arguments": []
+                                    }
+                                }
+                            ]
+                        },
+                        "guardedHandlers": [],
+                        "handler": {
+                            "type": "CatchClause",
+                            "param": {
+                                "type": "Identifier",
+                                "name": "e"
+                            },
+                            "body": {
+                                "type": "BlockStatement",
+                                "body": [
+                                    {
+                                        "type": "ExpressionStatement",
+                                        "expression": {
+                                            "type": "CallExpression",
+                                            "callee": {
+                                                "type": "Identifier",
+                                                "name": "handle"
+                                            },
+                                            "arguments": []
+                                        }
+                                    }
+                                ]
+                            }
+                        },
+                        "finalizer": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "ExpressionStatement",
+                                    "expression": {
+                                        "type": "CallExpression",
+                                        "callee": {
+                                            "type": "Identifier",
+                                            "name": "clean"
+                                        },
+                                        "arguments": []
+                                    }
+                                }
+                            ]
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "BlockStatement",
+            "block": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "TryStatement",
+                        "block": {
+                            "type": "BlockStatement",
+                            "body": [
+                                {
+                                    "type": "ExpressionStatement",
+                                    "expression": {
+                                        "type": "CallExpression",
+                                        "callee": {
+                                            "type": "Identifier",
+                                            "name": "that"
+                                        },
+                                        "arguments": []
+                                    }
+                                }
+                            ]
+                        },
+                        "guardedHandlers": [
+                            {
+                                "type": "CatchClause",
+                                "param": {
+                                    "type": "Identifier",
+                                    "name": "e"
+                                },
+                                "guard": {
+                                    "type": "BinaryExpression",
+                                    "operator": "instanceof",
+                                    "left": {
+                                        "type": "Identifier",
+                                        "name": "e"
+                                    },
+                                    "right": {
+                                        "type": "Identifier",
+                                        "name": "TypeError"
+                                    }
+                                },
+                                "body": {
+                                    "type": "BlockStatement",
+                                    "body": [
+                                        {
+                                            "type": "ExpressionStatement",
+                                            "expression": {
+                                                "type": "CallExpression",
+                                                "callee": {
+                                                    "type": "Identifier",
+                                                    "name": "handle"
+                                                },
+                                                "arguments": []
+                                            }
+                                        }
+                                    ]
+                                }
+                            }
+                        ],
+                        "handler": {
+                            "type": "CatchClause",
+                            "param": {
+                                "type": "Identifier",
+                                "name": "e"
+                            },
+                            "body": {
+                                "type": "BlockStatement",
+                                "body": [
+                                    {
+                                        "type": "ExpressionStatement",
+                                        "expression": {
+                                            "type": "CallExpression",
+                                            "callee": {
+                                                "type": "Identifier",
+                                                "name": "rest"
+                                            },
+                                            "arguments": []
+                                        }
+                                    }
+                                ]
+                            }
+                        },
+                        "finalizer": null
+                    }
+                ]
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/unaryExpr.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check unary operators.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("x++");
+printParse("x--");
+printParse("delete x");
+printParse("void x");
+printParse("typeof x");
+printParse("++x");
+printParse("--x");
+printParse("+x");
+printParse("-x");
+printParse("~x");
+printParse("!x");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/unaryExpr.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,187 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "UpdateExpression",
+                "operator": "++",
+                "prefix": false,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "x"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "UpdateExpression",
+                "operator": "--",
+                "prefix": false,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "x"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "UnaryExpression",
+                "operator": "delete",
+                "prefix": true,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "x"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "UnaryExpression",
+                "operator": "void",
+                "prefix": true,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "x"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "UnaryExpression",
+                "operator": "typeof",
+                "prefix": true,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "x"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "UpdateExpression",
+                "operator": "++",
+                "prefix": true,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "x"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "UpdateExpression",
+                "operator": "--",
+                "prefix": true,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "x"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "UnaryExpression",
+                "operator": "+",
+                "prefix": true,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "x"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "UnaryExpression",
+                "operator": "-",
+                "prefix": true,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "x"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "UnaryExpression",
+                "operator": "~",
+                "prefix": true,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "x"
+                }
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "UnaryExpression",
+                "operator": "!",
+                "prefix": true,
+                "argument": {
+                    "type": "Identifier",
+                    "name": "x"
+                }
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/useStrict.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check if statement.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("'use strict'");
+printParse("function f() { 'use strict' }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/useStrict.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,41 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "ExpressionStatement",
+            "expression": {
+                "type": "Literal",
+                "value": "use strict"
+            }
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "FunctionDeclaration",
+            "id": {
+                "type": "Identifier",
+                "name": "f"
+            },
+            "params": [],
+            "defaults": [],
+            "rest": null,
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "Literal",
+                            "value": "use strict"
+                        }
+                    }
+                ]
+            },
+            "generator": false,
+            "expression": false
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/util.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @subtest
+ */
+
+// utilitity for parser tests
+
+load("nashorn:parser.js");
+function printParse(code) {
+    print(JSON.stringify(parse(code), null, '    '));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/varDecl.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests to check variable declarations.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+// no initialization
+printParse("var a");
+printParse("var a, b");
+
+// init single, multiple
+printParse("var a = 'hello'");
+printParse("var a = 1, b = 2, c = 3");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/varDecl.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,123 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "VariableDeclaration",
+            "declarations": [
+                {
+                    "type": "VariableDeclarator",
+                    "id": {
+                        "type": "Identifier",
+                        "name": "a"
+                    },
+                    "init": null
+                }
+            ]
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "VariableDeclaration",
+            "declarations": [
+                {
+                    "type": "VariableDeclarator",
+                    "id": {
+                        "type": "Identifier",
+                        "name": "a"
+                    },
+                    "init": null
+                }
+            ]
+        },
+        {
+            "type": "VariableDeclaration",
+            "declarations": [
+                {
+                    "type": "VariableDeclarator",
+                    "id": {
+                        "type": "Identifier",
+                        "name": "b"
+                    },
+                    "init": null
+                }
+            ]
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "VariableDeclaration",
+            "declarations": [
+                {
+                    "type": "VariableDeclarator",
+                    "id": {
+                        "type": "Identifier",
+                        "name": "a"
+                    },
+                    "init": {
+                        "type": "Literal",
+                        "value": "hello"
+                    }
+                }
+            ]
+        }
+    ]
+}
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "VariableDeclaration",
+            "declarations": [
+                {
+                    "type": "VariableDeclarator",
+                    "id": {
+                        "type": "Identifier",
+                        "name": "a"
+                    },
+                    "init": {
+                        "type": "Literal",
+                        "value": 1
+                    }
+                }
+            ]
+        },
+        {
+            "type": "VariableDeclaration",
+            "declarations": [
+                {
+                    "type": "VariableDeclarator",
+                    "id": {
+                        "type": "Identifier",
+                        "name": "b"
+                    },
+                    "init": {
+                        "type": "Literal",
+                        "value": 2
+                    }
+                }
+            ]
+        },
+        {
+            "type": "VariableDeclaration",
+            "declarations": [
+                {
+                    "type": "VariableDeclarator",
+                    "id": {
+                        "type": "Identifier",
+                        "name": "c"
+                    },
+                    "init": {
+                        "type": "Literal",
+                        "value": 3
+                    }
+                }
+            ]
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/withStat.js	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ * 
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ * 
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ * 
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ * 
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Tests for 'with' statement.
+ *
+ * @test
+ * @run
+ */
+
+load(__DIR__ + "util.js");
+
+printParse("with (scope) { x = y }");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/script/basic/parser/withStat.js.EXPECTED	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,32 @@
+{
+    "type": "Program",
+    "body": [
+        {
+            "type": "WithStatement",
+            "object": {
+                "type": "Identifier",
+                "name": "scope"
+            },
+            "body": {
+                "type": "BlockStatement",
+                "body": [
+                    {
+                        "type": "ExpressionStatement",
+                        "expression": {
+                            "type": "AssignmentExpression",
+                            "operator": "=",
+                            "left": {
+                                "type": "Identifier",
+                                "name": "x"
+                            },
+                            "right": {
+                                "type": "Identifier",
+                                "name": "y"
+                            }
+                        }
+                    }
+                ]
+            }
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/META-INF/services/java.sql.Driver	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,1 @@
+jdk.nashorn.api.NashornSQLDriver
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/src/jdk/nashorn/api/NashornSQLDriver.java	Fri Sep 13 17:50:18 2013 +0530
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.nashorn.api;
+
+import java.sql.*;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+/**
+ * A dummy SQL driver for testing purpose.
+ */
+public final class NashornSQLDriver implements Driver {
+    static {
+        try {
+            DriverManager.registerDriver(new NashornSQLDriver(), null);
+        } catch (SQLException se) {
+            throw new RuntimeException(se);
+        }
+    }
+
+    @Override
+    public boolean acceptsURL(String url) {
+        return url.startsWith("jdbc:nashorn:");
+    }
+
+    @Override
+    public Connection connect(String url, Properties info) {
+        throw new UnsupportedOperationException("I am a dummy!!");
+    }
+
+    @Override
+    public int getMajorVersion() {
+        return -1;
+    }
+
+    @Override
+    public int getMinorVersion() {
+        return -1;
+    }
+
+    @Override
+    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {
+        return new DriverPropertyInfo[0];
+    }
+
+    @Override
+    public boolean jdbcCompliant() {
+        // no way!
+        return false;
+    }
+
+    @Override
+    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+        throw new SQLFeatureNotSupportedException();
+    }
+}