This commit is contained in:
Athijegannathan Sundararajan 2013-07-02 18:39:41 +05:30
commit f76da2a387
29 changed files with 591 additions and 82 deletions

@ -124,7 +124,7 @@
<echo message="release=${nashorn.version}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true"/>
</target>
<target name="jar" depends="compile, run-nasgen, generate-cc-template" description="Creates nashorn.jar">
<target name="jar" depends="compile, run-nasgen, generate-cc-template" description="Creates nashorn.jar" unless="compile.suppress.jar">
<jar jarfile="${dist.jar}" manifest="${meta.inf.dir}/MANIFEST.MF" index="true" filesetmanifest="merge">
<fileset dir="${build.classes.dir}"/>
<manifest>
@ -139,7 +139,13 @@
</manifest>
</jar>
</target>
<target name="use-promoted-nashorn" depends="init">
<delete file="${dist.dir}/nashorn.jar"/>
<copy file="${java.home}/lib/ext/nashorn.jar" todir="${dist.dir}"/>
<property name="compile.suppress.jar" value="defined"/>
</target>
<target name="build-fxshell" depends="jar">
<description>Builds the javafx shell.</description>
<mkdir dir="${fxshell.classes.dir}"/>
@ -238,7 +244,7 @@
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
<echo message="};" file="${build.dir}/nashorn.policy" append="true"/>
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
<!-- TestNG framework jar needs AllPermission -->
<echo message="grant codeBase &quot;file:/${basedir}/${file.reference.testng.jar}&quot; {" file="${build.dir}/nashorn.policy" append="true"/>
<echo message="" file="${build.dir}/nashorn.policy" append="true"/>
@ -462,24 +468,24 @@
<!-- get all external test scripts -->
<target name="externals" depends="init, check-external-tests, get-test262, get-octane, get-sunspider">
<!-- make external test dir -->
<mkdir dir="${test.external.dir}"/>
<mkdir dir="${test.external.dir}"/>
<!-- jquery -->
<mkdir dir="${test.external.dir}/jquery"/>
<mkdir dir="${test.external.dir}/jquery"/>
<get src="http://code.jquery.com/jquery-1.7.2.js" dest="${test.external.dir}/jquery" skipexisting="true" ignoreerrors="true"/>
<get src="http://code.jquery.com/jquery-1.7.2.min.js" dest="${test.external.dir}/jquery" skipexisting="true" ignoreerrors="true"/>
<!-- prototype -->
<mkdir dir="${test.external.dir}/prototype"/>
<mkdir dir="${test.external.dir}/prototype"/>
<get src="http://ajax.googleapis.com/ajax/libs/prototype/1.7.0/prototype.js" dest="${test.external.dir}/prototype" usetimestamp="true" skipexisting="true" ignoreerrors="true"/>
<!-- underscorejs -->
<mkdir dir="${test.external.dir}/underscore"/>
<mkdir dir="${test.external.dir}/underscore"/>
<get src="http://underscorejs.org/underscore.js" dest="${test.external.dir}/underscore" skipexisting="true" ignoreerrors="true"/>
<get src="http://underscorejs.org/underscore-min.js" dest="${test.external.dir}/underscore" skipexisting="true" ignoreerrors="true"/>
<!-- yui -->
<mkdir dir="${test.external.dir}/yui"/>
<mkdir dir="${test.external.dir}/yui"/>
<get src="http://yui.yahooapis.com/3.5.1/build/yui/yui.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/>
<get src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js" dest="${test.external.dir}/yui" skipexisting="true" ignoreerrors="true"/>

@ -172,12 +172,13 @@ public abstract class NashornException extends RuntimeException {
final StringBuilder buf = new StringBuilder();
final StackTraceElement[] frames = getScriptFrames((Throwable)exception);
for (final StackTraceElement st : frames) {
buf.append("\tat ");
buf.append(st.getMethodName());
buf.append(" @ ");
buf.append(" (");
buf.append(st.getFileName());
buf.append(':');
buf.append(st.getLineNumber());
buf.append('\n');
buf.append(")\n");
}
final int len = buf.length();
// remove trailing '\n'

@ -1110,7 +1110,7 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
* @return the method generator that was used
*/
private MethodEmitter loadArray(final ArrayLiteralNode arrayLiteralNode, final ArrayType arrayType) {
assert arrayType == Type.INT_ARRAY || arrayType == Type.NUMBER_ARRAY || arrayType == Type.OBJECT_ARRAY;
assert arrayType == Type.INT_ARRAY || arrayType == Type.LONG_ARRAY || arrayType == Type.NUMBER_ARRAY || arrayType == Type.OBJECT_ARRAY;
final Node[] nodes = arrayLiteralNode.getValue();
final Object presets = arrayLiteralNode.getPresets();
@ -1462,7 +1462,9 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
rhs = tmp;
}
if (isNullLiteral(rhs)) {
// this is a null literal check, so if there is implicit coercion
// involved like {D}x=null, we will fail - this is very rare
if (isNullLiteral(rhs) && lhs.getType().isObject()) {
final Label trueLabel = new Label("trueLabel");
final Label falseLabel = new Label("falseLabel");
final Label endLabel = new Label("end");
@ -1845,7 +1847,8 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
// If expression not int see if we can convert, if not use deflt to trigger default.
if (!type.isInteger()) {
method.load(deflt);
method.invoke(staticCallNoLookup(ScriptRuntime.class, "switchTagAsInt", int.class, type.getTypeClass(), int.class));
final Class exprClass = type.getTypeClass();
method.invoke(staticCallNoLookup(ScriptRuntime.class, "switchTagAsInt", int.class, exprClass.isPrimitive()? exprClass : Object.class, int.class));
}
// If reasonable size and not too sparse (80%), use table otherwise use lookup.

@ -36,6 +36,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.DUP_X2;
import static jdk.internal.org.objectweb.asm.Opcodes.IALOAD;
import static jdk.internal.org.objectweb.asm.Opcodes.IASTORE;
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESTATIC;
import static jdk.internal.org.objectweb.asm.Opcodes.LALOAD;
import static jdk.internal.org.objectweb.asm.Opcodes.LASTORE;
import static jdk.internal.org.objectweb.asm.Opcodes.NEWARRAY;
import static jdk.internal.org.objectweb.asm.Opcodes.POP;
@ -43,6 +44,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.POP2;
import static jdk.internal.org.objectweb.asm.Opcodes.SWAP;
import static jdk.internal.org.objectweb.asm.Opcodes.T_DOUBLE;
import static jdk.internal.org.objectweb.asm.Opcodes.T_INT;
import static jdk.internal.org.objectweb.asm.Opcodes.T_LONG;
import java.lang.invoke.MethodHandle;
import java.util.Collections;
@ -729,19 +731,19 @@ public abstract class Type implements Comparable<Type>, BytecodeOps {
@Override
public Type aload(final MethodVisitor method) {
method.visitInsn(IALOAD);
return INT;
method.visitInsn(LALOAD);
return LONG;
}
@Override
public Type newarray(final MethodVisitor method) {
method.visitIntInsn(NEWARRAY, T_INT);
method.visitIntInsn(NEWARRAY, T_LONG);
return this;
}
@Override
public Type getElementType() {
return INT;
return LONG;
}
};

@ -621,8 +621,10 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
elementType = Type.INT;
analyzeElements();
if (elementType == Type.INT) {
if (elementType.isInteger()) {
presetIntArray();
} else if (elementType.isLong()) {
presetLongArray();
} else if (elementType.isNumeric()) {
presetNumberArray();
} else {
@ -649,6 +651,25 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
postsets = Arrays.copyOf(computed, nComputed);
}
private void presetLongArray() {
final long[] array = new long[value.length];
final int[] computed = new int[value.length];
int nComputed = 0;
for (int i = 0; i < value.length; i++) {
final Object element = objectAsConstant(value[i]);
if (element instanceof Number) {
array[i] = ((Number)element).longValue();
} else {
computed[nComputed++] = i;
}
}
presets = array;
postsets = Arrays.copyOf(computed, nComputed);
}
private void presetNumberArray() {
final double[] array = new double[value.length];
final int[] computed = new int[value.length];
@ -746,6 +767,8 @@ public abstract class LiteralNode<T> extends Node implements PropertyKey {
public Type getType() {
if (elementType.isInteger()) {
return Type.INT_ARRAY;
} else if (elementType.isLong()) {
return Type.LONG_ARRAY;
} else if (elementType.isNumeric()) {
return Type.NUMBER_ARRAY;
} else {

@ -30,10 +30,7 @@ import static jdk.nashorn.internal.lookup.Lookup.MH;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.List;
import jdk.nashorn.api.scripting.NashornException;
import jdk.nashorn.internal.codegen.CompilerConstants;
import jdk.nashorn.internal.lookup.MethodHandleFactory;
import jdk.nashorn.internal.objects.annotations.Attribute;
import jdk.nashorn.internal.objects.annotations.Constructor;
@ -41,7 +38,6 @@ import jdk.nashorn.internal.objects.annotations.Function;
import jdk.nashorn.internal.objects.annotations.Property;
import jdk.nashorn.internal.objects.annotations.ScriptClass;
import jdk.nashorn.internal.objects.annotations.Where;
import jdk.nashorn.internal.runtime.ECMAErrors;
import jdk.nashorn.internal.runtime.ECMAException;
import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyMap;
@ -123,13 +119,14 @@ public final class NativeError extends ScriptObject {
* Nashorn extension: Error.captureStackTrace. Capture stack trace at the point of call into the Error object provided.
*
* @param self self reference
* @return undefined
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static Object captureStackTrace(final Object self, final Object errorObj) {
Global.checkObject(errorObj);
final ScriptObject sobj = (ScriptObject)errorObj;
final ECMAException exp = new ECMAException(sobj, null);
sobj.set("stack", NashornException.getScriptStackString(exp), false);
sobj.set("stack", getScriptStackString(sobj, exp), false);
return UNDEFINED;
}
@ -288,7 +285,7 @@ public final class NativeError extends ScriptObject {
final Object exception = ECMAException.getException(sobj);
if (exception instanceof Throwable) {
return NashornException.getScriptStackString((Throwable)exception);
return getScriptStackString(sobj, (Throwable)exception);
} else {
return "";
}
@ -362,4 +359,8 @@ public final class NativeError extends ScriptObject {
throw new MethodHandleFactory.LookupException(e);
}
}
private static String getScriptStackString(final ScriptObject sobj, final Throwable exp) {
return JSType.toString(sobj) + "\n" + NashornException.getScriptStackString(exp);
}
}

@ -61,6 +61,11 @@ public final class NativeRegExpExecResult extends ScriptObject {
this.input = result.getInput();
}
@Override
public String getClassName() {
return "Array";
}
/**
* Length getter
* @param self self reference

@ -535,15 +535,12 @@ loop:
if (!(lhs instanceof AccessNode ||
lhs instanceof IndexNode ||
lhs instanceof IdentNode)) {
if (env._early_lvalue_error) {
throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
}
return referenceError(lhs, rhs);
return referenceError(lhs, rhs, env._early_lvalue_error);
}
if (lhs instanceof IdentNode) {
if (!checkIdentLValue((IdentNode)lhs)) {
return referenceError(lhs, rhs);
return referenceError(lhs, rhs, false);
}
verifyStrictIdent((IdentNode)lhs, "assignment");
}
@ -767,8 +764,6 @@ loop:
case LBRACE:
block();
break;
case RBRACE:
break;
case VAR:
variableStatement(true);
break;
@ -1267,6 +1262,7 @@ loop:
case RBRACE:
case SEMICOLON:
case EOL:
case EOF:
break;
default:
@ -1314,6 +1310,7 @@ loop:
case RBRACE:
case SEMICOLON:
case EOL:
case EOF:
break;
default:
@ -1368,6 +1365,7 @@ loop:
case RBRACE:
case SEMICOLON:
case EOL:
case EOF:
break;
default:
@ -1403,6 +1401,7 @@ loop:
case RBRACE:
case SEMICOLON:
case EOL:
case EOF:
break;
default:
@ -1928,7 +1927,7 @@ loop:
// Object context.
// Prepare to accumulate elements.
// final List<Node> elements = new ArrayList<>();
// final List<Node> elements = new ArrayList<>();
final Map<String, PropertyNode> map = new LinkedHashMap<>();
// Create a block for the object literal.
@ -1941,6 +1940,9 @@ loop:
break loop;
case COMMARIGHT:
if (commaSeen) {
throw error(AbstractParser.message("expected.property.id", type.getNameOrType()));
}
next();
commaSeen = true;
break;
@ -2566,7 +2568,7 @@ loop:
*/
// just expression as function body
final Node expr = expression();
final Node expr = assignmentExpression(true);
assert lc.getCurrentBlock() == lc.getFunctionBody(functionNode);
// create a return statement - this creates code in itself and does not need to be
// wrapped into an ExecuteNode
@ -2612,7 +2614,10 @@ loop:
}
}
private static RuntimeNode referenceError(final Node lhs, final Node rhs) {
private RuntimeNode referenceError(final Node lhs, final Node rhs, final boolean earlyError) {
if (earlyError) {
throw error(JSErrorType.REFERENCE_ERROR, AbstractParser.message("invalid.lvalue"), lhs.getToken());
}
final ArrayList<Node> args = new ArrayList<>();
args.add(lhs);
if (rhs == null) {
@ -2690,18 +2695,18 @@ loop:
final Node lhs = leftHandSideExpression();
// ++, -- without operand..
if (lhs == null) {
// error would have been issued when looking for 'lhs'
return null;
throw error(AbstractParser.message("expected.lvalue", type.getNameOrType()));
}
if (!(lhs instanceof AccessNode ||
lhs instanceof IndexNode ||
lhs instanceof IdentNode)) {
return referenceError(lhs, null);
return referenceError(lhs, null, env._early_lvalue_error);
}
if (lhs instanceof IdentNode) {
if (!checkIdentLValue((IdentNode)lhs)) {
return referenceError(lhs, null);
return referenceError(lhs, null, false);
}
verifyStrictIdent((IdentNode)lhs, "operand for " + opType.getName() + " operator");
}
@ -2720,16 +2725,21 @@ loop:
case DECPREFIX:
final TokenType opType = type;
final Node lhs = expression;
// ++, -- without operand..
if (lhs == null) {
throw error(AbstractParser.message("expected.lvalue", type.getNameOrType()));
}
if (!(lhs instanceof AccessNode ||
lhs instanceof IndexNode ||
lhs instanceof IdentNode)) {
next();
return referenceError(lhs, null);
return referenceError(lhs, null, env._early_lvalue_error);
}
if (lhs instanceof IdentNode) {
if (!checkIdentLValue((IdentNode)lhs)) {
next();
return referenceError(lhs, null);
return referenceError(lhs, null, false);
}
verifyStrictIdent((IdentNode)lhs, "operand for " + opType.getName() + " operator");
}

@ -51,7 +51,7 @@ public final class ECMAException extends NashornException {
/** Field handle to the{@link ECMAException#thrown} field, so that it can be accessed from generated code */
public static final FieldAccess THROWN = virtualField(ECMAException.class, "thrown", Object.class);
public static final String EXCEPTION_PROPERTY = "nashornException";
private static final String EXCEPTION_PROPERTY = "nashornException";
/** Object thrown. */
public final Object thrown;

@ -911,7 +911,7 @@ public enum JSType {
for (int i = start; i < length ; i++) {
if (digit(chars[i], radix) == -1) {
break;
return Double.NaN;
}
pos++;
}

@ -120,6 +120,17 @@ public final class ScriptRuntime {
return deflt;
}
/**
* Converts a switch tag value to a simple integer. deflt value if it can't.
*
* @param tag Switch statement tag value.
* @param deflt default to use if not convertible.
* @return int tag value (or deflt.)
*/
public static int switchTagAsInt(final boolean tag, final int deflt) {
return deflt;
}
/**
* Converts a switch tag value to a simple integer. deflt value if it can't.
*

@ -42,6 +42,8 @@ parser.error.expected.literal=Expected a literal but found {0}
parser.error.expected.operand=Expected an operand but found {0}
parser.error.expected.stmt=Expected statement but found {0}
parser.error.expected.comma=Expected comma but found {0}
parser.error.expected.property.id=Expected property id but found {0}
parser.error.expected.lvalue=Expected l-value but found {0}
parser.error.expected=Expected {0} but found {1}
parser.error.invalid.return=Invalid return statement
parser.error.no.func.decl.here=Function declarations can only occur at program or function body level. You should use a function expression here instead.

@ -1,3 +1,4 @@
MyError @ test/script/basic/JDK-8014781.js:32
func @ test/script/basic/JDK-8014781.js:36
<program> @ test/script/basic/JDK-8014781.js:39
[object Object]
at MyError (test/script/basic/JDK-8014781.js:32)
at func (test/script/basic/JDK-8014781.js:36)
at <program> (test/script/basic/JDK-8014781.js:39)

@ -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.
*/
/**
* Regression test for erroneous shortcut optimization for object null checks
*
* @test
* @run
*/
function toto() {
var friends = 1;
(joe = friends) == null;
}

@ -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.
*/
/**
* Long array literals were broken
*
* @test
* @run
*/
function f() {
var z= c>>e>>>0;
var x = [z];
}

@ -1,4 +1,5 @@
func @ test/script/basic/JDK-8017950.js:33
f @ test/script/basic/JDK-8017950.js:40
g @ test/script/basic/JDK-8017950.js:44
<program> @ test/script/basic/JDK-8017950.js:47
Error
at func (test/script/basic/JDK-8017950.js:33)
at f (test/script/basic/JDK-8017950.js:40)
at g (test/script/basic/JDK-8017950.js:44)
at <program> (test/script/basic/JDK-8017950.js:47)

@ -30,7 +30,7 @@
function func1() { func2() }
function func2() { throw new Error() }
function func2() { throw new Error("failed!") }
try {
func1()

@ -1,3 +1,4 @@
func2 @ test/script/basic/JDK-8019226.js:33
func1 @ test/script/basic/JDK-8019226.js:31
<program> @ test/script/basic/JDK-8019226.js:36
Error: failed!
at func2 (test/script/basic/JDK-8019226.js:33)
at func1 (test/script/basic/JDK-8019226.js:31)
at <program> (test/script/basic/JDK-8019226.js:36)

@ -0,0 +1,62 @@
/*
* 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-8019473: Parser issues related to functions and blocks
*
* @test
* @run
*/
function checkNoError(code) {
try {
Function(code);
} catch (e) {
print("no error expected for: " + code + " , got " + e);
}
}
// implicit newlines at EOF should be accepted
checkNoError("for(;;) continue")
checkNoError("return")
checkNoError("yield")
checkNoError("for(;;) break")
function checkError(code) {
try {
eval(code);
print("SyntaxError expected for: " + code);
} catch (e) {
if (! (e instanceof SyntaxError)) {
fail("SyntaxError expected, got " + e);
}
}
}
checkError("function f() { case0: }");
checkError("function f() { if(0) }");
checkError("function f() { if(0); else }");
checkError("function f() { while(0) }");
// comma expression as closure expression
checkError("function sq(x) x, x*x");

@ -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.
*/
/**
* JDK-8019478: Object.prototype.toString.call(/a/.exec("a")) === "[object Array]" should be true
*
* @test
* @run
*/
if (Object.prototype.toString.call(/a/.exec("a")) !== "[object Array]") {
fail("Object.prototype.toString.call(/a/.exec('a')) !== '[object Array]'");
}

@ -0,0 +1,41 @@
/*
* 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-8019482: Number("0x0.0p0") should evaluate to NaN
*
* @test
* @run
*/
function checkHexLiteral(str) {
if (! isNaN(Number(str))) {
fail("Number(" + str + ") is not NaN");
}
}
checkHexLiteral("0x0.0");
checkHexLiteral("0x0.0p");
checkHexLiteral("0x12tu");
checkHexLiteral("0x12.2e22");
checkHexLiteral("0xtu");

@ -0,0 +1,68 @@
/*
* 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-8019488: switch on literals result in NoSuchMethodError or VerifyError
*
* @test
* @run
*/
switch("") {
case 0:
break
}
switch(true) {
case 0:
print("0"); break;
case 1:
print("1"); break;
}
switch(false) {
case 0:
print("0"); break;
case 1:
print("1"); break;
}
switch([]) {
case 1:
print("1");
}
switch (undefined) {
case 0:
print("0");
}
switch (null) {
case 0:
print("0");
}
switch({}) {
case 1:
print("1");
}

@ -0,0 +1,56 @@
/*
* 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-8019508: Comma handling in object literal parsing is wrong
*
* @test
* @run
*/
function checkObjLiteral(str) {
try {
eval(str);
fail("SyntaxError expected for: " + str);
} catch (e) {
if (! (e instanceof SyntaxError)) {
fail("expected SyntaxError, got " + e);
}
print(e.message.replace(/\\/g, '/'));
}
}
// only comma
checkObjLiteral("({,})");
// starting with comma
checkObjLiteral("({, a:2 })");
// consecutive commas
checkObjLiteral("({a:3,,})");
// missing comma
checkObjLiteral("({a:3 b:2}");
// single trailing comma is okay!
var obj = { a: 3, };

@ -0,0 +1,12 @@
test/script/basic/JDK-8019508.js#33<eval>:1:2 Expected property id but found ,
({,})
^
test/script/basic/JDK-8019508.js#33<eval>:1:2 Expected property id but found ,
({, a:2 })
^
test/script/basic/JDK-8019508.js#33<eval>:1:6 Expected property id but found ,
({a:3,,})
^
test/script/basic/JDK-8019508.js#33<eval>:1:6 Expected comma but found ident
({a:3 b:2}
^

@ -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.
*/
/**
* JDK-8019553: NPE on illegal l-value for increment and decrement
*
* @test
* @run
*/
function check(str) {
try {
eval(str);
fail("SyntaxError expected for: " + str);
} catch (e) {
print(e.toString().replace(/\\/g, '/'));
}
}
check("++ +3");
check("++ -7");
check("-- +2");
check("-- -8");

@ -0,0 +1,12 @@
SyntaxError: test/script/basic/JDK-8019553.js#33<eval>:1:3 Expected l-value but found +
++ +3
^
SyntaxError: test/script/basic/JDK-8019553.js#33<eval>:1:3 Expected l-value but found -
++ -7
^
SyntaxError: test/script/basic/JDK-8019553.js#33<eval>:1:3 Expected l-value but found +
-- +2
^
SyntaxError: test/script/basic/JDK-8019553.js#33<eval>:1:3 Expected l-value but found -
-- -8
^

@ -35,28 +35,28 @@ for (i in literals) {
eval(literals[i] + "++");
print("ERROR!! post increment : " + literals[i]);
} catch (e) {
print(e);
print(e.toString().replace(/\\/g, '/'));
}
try {
eval(literals[i] + "--");
print("ERROR!! post decrement : " + literals[i]);
} catch (e) {
print(e);
print(e.toString().replace(/\\/g, '/'));
}
try {
eval("++" + literals[i]);
print("ERROR!! pre increment : " + literals[i]);
} catch (e) {
print(e);
print(e.toString().replace(/\\/g, '/'));
}
try {
eval("--" + literals[i]);
print("ERROR!! pre decrement : " + literals[i]);
} catch (e) {
print(e);
print(e.toString().replace(/\\/g, '/'));
}
}

@ -1,24 +1,72 @@
ReferenceError: "1" can not be used as the left-hand side of assignment
ReferenceError: "1" can not be used as the left-hand side of assignment
ReferenceError: "1" can not be used as the left-hand side of assignment
ReferenceError: "1" can not be used as the left-hand side of assignment
ReferenceError: "0" can not be used as the left-hand side of assignment
ReferenceError: "0" can not be used as the left-hand side of assignment
ReferenceError: "0" can not be used as the left-hand side of assignment
ReferenceError: "0" can not be used as the left-hand side of assignment
ReferenceError: "3.14" can not be used as the left-hand side of assignment
ReferenceError: "3.14" can not be used as the left-hand side of assignment
ReferenceError: "3.14" can not be used as the left-hand side of assignment
ReferenceError: "3.14" can not be used as the left-hand side of assignment
ReferenceError: "true" can not be used as the left-hand side of assignment
ReferenceError: "true" can not be used as the left-hand side of assignment
ReferenceError: "true" can not be used as the left-hand side of assignment
ReferenceError: "true" can not be used as the left-hand side of assignment
ReferenceError: "false" can not be used as the left-hand side of assignment
ReferenceError: "false" can not be used as the left-hand side of assignment
ReferenceError: "false" can not be used as the left-hand side of assignment
ReferenceError: "false" can not be used as the left-hand side of assignment
ReferenceError: "null" can not be used as the left-hand side of assignment
ReferenceError: "null" can not be used as the left-hand side of assignment
ReferenceError: "null" can not be used as the left-hand side of assignment
ReferenceError: "null" can not be used as the left-hand side of assignment
ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
1++
^
ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
1--
^
ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
++1
^
ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
--1
^
ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
0++
^
ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
0--
^
ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
++0
^
ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
--0
^
ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
3.14++
^
ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
3.14--
^
ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
++3.14
^
ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
--3.14
^
ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
true++
^
ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
true--
^
ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
++true
^
ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
--true
^
ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
false++
^
ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
false--
^
ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
++false
^
ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
--false
^
ReferenceError: test/script/basic/NASHORN-51.js#35<eval>:1:0 Invalid left hand side for assignment
null++
^
ReferenceError: test/script/basic/NASHORN-51.js#42<eval>:1:0 Invalid left hand side for assignment
null--
^
ReferenceError: test/script/basic/NASHORN-51.js#49<eval>:1:2 Invalid left hand side for assignment
++null
^
ReferenceError: test/script/basic/NASHORN-51.js#56<eval>:1:2 Invalid left hand side for assignment
--null
^

@ -1,3 +1,3 @@
test/script/error/NASHORN-57.js:35:2 Expected statement but found ;
test/script/error/NASHORN-57.js:35:2 Expected l-value but found ;
++;
^