Merge
This commit is contained in:
commit
57f8c70159
@ -329,7 +329,7 @@
|
|||||||
fork="true"
|
fork="true"
|
||||||
dir=".">
|
dir=".">
|
||||||
<jvmarg line="${ext.class.path}"/>
|
<jvmarg line="${ext.class.path}"/>
|
||||||
<jvmarg line="${run.test.jvmargs.octane}"/>
|
<jvmarg line="${run.test.jvmargs.octane} -Xms${run.test.xms} -Xmx${run.test.xmx}"/>
|
||||||
<arg value="${octane-test-sys-prop.test.js.framework}"/>
|
<arg value="${octane-test-sys-prop.test.js.framework}"/>
|
||||||
<arg value="--"/>
|
<arg value="--"/>
|
||||||
<arg value="${octane-tests}"/>
|
<arg value="${octane-tests}"/>
|
||||||
@ -357,7 +357,7 @@
|
|||||||
classpath="${run.test.classpath}"
|
classpath="${run.test.classpath}"
|
||||||
fork="true"
|
fork="true"
|
||||||
dir=".">
|
dir=".">
|
||||||
<jvmarg line="${run.test.jvmargs.octane}"/>
|
<jvmarg line="${run.test.jvmargs.octane} -Xms${run.test.xms} -Xmx${run.test.xmx}"/>
|
||||||
<arg value="${octane-test-sys-prop.test.js.framework}"/>
|
<arg value="${octane-test-sys-prop.test.js.framework}"/>
|
||||||
<arg value="${octane-tests}"/>
|
<arg value="${octane-tests}"/>
|
||||||
<arg value="--runtime"/>
|
<arg value="--runtime"/>
|
||||||
@ -391,7 +391,7 @@
|
|||||||
fork="true"
|
fork="true"
|
||||||
dir=".">
|
dir=".">
|
||||||
<jvmarg line="${ext.class.path}"/>
|
<jvmarg line="${ext.class.path}"/>
|
||||||
<jvmarg line="${run.test.jvmargs}"/>
|
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
|
||||||
<arg value="-timezone=PST"/>
|
<arg value="-timezone=PST"/>
|
||||||
<arg value="--class-cache-size=50"/>
|
<arg value="--class-cache-size=50"/>
|
||||||
<arg value="${sunspider-test-sys-prop.test.js.framework}"/>
|
<arg value="${sunspider-test-sys-prop.test.js.framework}"/>
|
||||||
@ -415,7 +415,7 @@
|
|||||||
classpath="${run.test.classpath}"
|
classpath="${run.test.classpath}"
|
||||||
fork="true"
|
fork="true"
|
||||||
dir=".">
|
dir=".">
|
||||||
<jvmarg line="${run.test.jvmargs}"/>
|
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
|
||||||
<arg value="${sunspider-test-sys-prop.test.js.framework}"/>
|
<arg value="${sunspider-test-sys-prop.test.js.framework}"/>
|
||||||
<arg value="${sunspider-tests}/"/>
|
<arg value="${sunspider-tests}/"/>
|
||||||
</java>
|
</java>
|
||||||
|
@ -66,6 +66,8 @@
|
|||||||
|
|
||||||
<echo message="run.test.jvmargs=${run.test.jvmargs}"/>
|
<echo message="run.test.jvmargs=${run.test.jvmargs}"/>
|
||||||
<echo message="run.test.jvmargs.octane=${run.test.jvmargs.octane}"/>
|
<echo message="run.test.jvmargs.octane=${run.test.jvmargs.octane}"/>
|
||||||
|
<echo message="run.test.xms=${run.test.xms}"/>
|
||||||
|
<echo message="run.test.xmx=${run.test.xmx}"/>
|
||||||
|
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
@ -320,7 +322,7 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" {
|
|||||||
<testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
|
<testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
|
||||||
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
|
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
|
||||||
<jvmarg line="${ext.class.path}"/>
|
<jvmarg line="${ext.class.path}"/>
|
||||||
<jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
|
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
|
||||||
<propertyset>
|
<propertyset>
|
||||||
<propertyref prefix="test-sys-prop."/>
|
<propertyref prefix="test-sys-prop."/>
|
||||||
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
<mapper from="test-sys-prop.*" to="*" type="glob"/>
|
||||||
@ -336,7 +338,7 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" {
|
|||||||
<!-- use just build.test.classes.dir to avoid referring to TestNG -->
|
<!-- use just build.test.classes.dir to avoid referring to TestNG -->
|
||||||
<java classname="${parallel.test.runner}" dir="${basedir}" classpath="${build.test.classes.dir}" failonerror="true" fork="true">
|
<java classname="${parallel.test.runner}" dir="${basedir}" classpath="${build.test.classes.dir}" failonerror="true" fork="true">
|
||||||
<jvmarg line="${ext.class.path}"/>
|
<jvmarg line="${ext.class.path}"/>
|
||||||
<jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
|
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
|
||||||
<syspropertyset>
|
<syspropertyset>
|
||||||
<propertyref prefix="test-sys-prop."/>
|
<propertyref prefix="test-sys-prop."/>
|
||||||
<mapper type="glob" from="test-sys-prop.*" to="*"/>
|
<mapper type="glob" from="test-sys-prop.*" to="*"/>
|
||||||
@ -352,7 +354,7 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" {
|
|||||||
<testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
|
<testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
|
||||||
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
|
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
|
||||||
<jvmarg line="${ext.class.path}"/>
|
<jvmarg line="${ext.class.path}"/>
|
||||||
<jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
|
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
|
||||||
<propertyset>
|
<propertyset>
|
||||||
<propertyref prefix="test262-test-sys-prop."/>
|
<propertyref prefix="test262-test-sys-prop."/>
|
||||||
<mapper from="test262-test-sys-prop.*" to="*" type="glob"/>
|
<mapper from="test262-test-sys-prop.*" to="*" type="glob"/>
|
||||||
@ -369,7 +371,7 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" {
|
|||||||
<!-- use just build.test.classes.dir to avoid referring to TestNG -->
|
<!-- use just build.test.classes.dir to avoid referring to TestNG -->
|
||||||
<java classname="${parallel.test.runner}" dir="${basedir}" fork="true">
|
<java classname="${parallel.test.runner}" dir="${basedir}" fork="true">
|
||||||
<jvmarg line="${ext.class.path}"/>
|
<jvmarg line="${ext.class.path}"/>
|
||||||
<jvmarg line="${run.test.jvmargs} ${run.test.jvmsecurityargs}"/>
|
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}"/>
|
||||||
<classpath>
|
<classpath>
|
||||||
<pathelement path="${run.test.classpath}"/>
|
<pathelement path="${run.test.classpath}"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
@ -387,7 +389,7 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" {
|
|||||||
description="Run the shell with a sample script">
|
description="Run the shell with a sample script">
|
||||||
<java classname="${nashorn.shell.tool}" fork="true" dir="samples">
|
<java classname="${nashorn.shell.tool}" fork="true" dir="samples">
|
||||||
<jvmarg line="${ext.class.path}"/>
|
<jvmarg line="${ext.class.path}"/>
|
||||||
<jvmarg line="${run.test.jvmargs}"/>
|
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
|
||||||
<arg value="-dump-on-error"/>
|
<arg value="-dump-on-error"/>
|
||||||
<arg value="test.js"/>
|
<arg value="test.js"/>
|
||||||
</java>
|
</java>
|
||||||
@ -397,7 +399,7 @@ grant codeBase "file:/${basedir}/test/script/basic/classloader.js" {
|
|||||||
description="Debug the shell with a sample script">
|
description="Debug the shell with a sample script">
|
||||||
<java classname="${nashorn.shell.tool}" fork="true" dir="samples">
|
<java classname="${nashorn.shell.tool}" fork="true" dir="samples">
|
||||||
<jvmarg line="${ext.class.path}"/>
|
<jvmarg line="${ext.class.path}"/>
|
||||||
<jvmarg line="${run.test.jvmargs}"/>
|
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx}"/>
|
||||||
<arg value="--print-code"/>
|
<arg value="--print-code"/>
|
||||||
<arg value="--verify-code"/>
|
<arg value="--verify-code"/>
|
||||||
<arg value="--print-symbols"/>
|
<arg value="--print-symbols"/>
|
||||||
|
@ -216,13 +216,14 @@ run.test.classpath=\
|
|||||||
src.dir=src
|
src.dir=src
|
||||||
test.src.dir=test/src
|
test.src.dir=test/src
|
||||||
|
|
||||||
|
# -Xmx is used for all tests, -Xms only for octane benchmark
|
||||||
run.test.xmx=3G
|
run.test.xmx=3G
|
||||||
run.test.xms=2G
|
run.test.xms=2G
|
||||||
|
|
||||||
run.test.user.language=tr
|
run.test.user.language=tr
|
||||||
run.test.user.country=TR
|
run.test.user.country=TR
|
||||||
|
|
||||||
run.test.jvmargs.common=-server -Xmx${run.test.xmx} -XX:+TieredCompilation -Dfile.encoding=UTF-8 -Duser.language=${run.test.user.language} -Duser.country=${run.test.user.country} -XX:+HeapDumpOnOutOfMemoryError
|
run.test.jvmargs.common=-server -XX:+TieredCompilation -Dfile.encoding=UTF-8 -Duser.language=${run.test.user.language} -Duser.country=${run.test.user.country} -XX:+HeapDumpOnOutOfMemoryError
|
||||||
|
|
||||||
#-XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M
|
#-XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M
|
||||||
# -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMethods
|
# -XX:+PrintCompilation -XX:+UnlockDiagnosticVMOptions -XX:+PrintNMethods
|
||||||
@ -231,12 +232,12 @@ run.test.jvmargs.common=-server -Xmx${run.test.xmx} -XX:+TieredCompilation -Dfil
|
|||||||
run.test.jvmargs.main=${run.test.jvmargs.common} -ea
|
run.test.jvmargs.main=${run.test.jvmargs.common} -ea
|
||||||
|
|
||||||
#-XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M
|
#-XX:-UseCompressedKlassPointers -XX:+PrintHeapAtGC -XX:ClassMetaspaceSize=300M
|
||||||
run.test.jvmargs.octane.main=-Xms${run.test.xms} ${run.test.jvmargs.common}
|
run.test.jvmargs.octane.main=${run.test.jvmargs.common}
|
||||||
|
|
||||||
run.test.jvmsecurityargs=-Xverify:all -Djava.security.properties=${basedir}/make/java.security.override -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
|
run.test.jvmsecurityargs=-Xverify:all -Djava.security.properties=${basedir}/make/java.security.override -Djava.security.manager -Djava.security.policy=${basedir}/build/nashorn.policy
|
||||||
|
|
||||||
# VM options for script tests with @fork option
|
# VM options for script tests with @fork option
|
||||||
test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} ${run.test.jvmsecurityargs}
|
test-sys-prop.test.fork.jvm.options=${run.test.jvmargs.main} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs}
|
||||||
|
|
||||||
# path of rhino.jar for benchmarks
|
# path of rhino.jar for benchmarks
|
||||||
rhino.jar=
|
rhino.jar=
|
||||||
|
@ -185,21 +185,12 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object eval(final Reader reader, final ScriptContext ctxt) throws ScriptException {
|
public Object eval(final Reader reader, final ScriptContext ctxt) throws ScriptException {
|
||||||
try {
|
return evalImpl(makeSource(reader, ctxt), ctxt);
|
||||||
if (reader instanceof URLReader) {
|
|
||||||
final URL url = ((URLReader)reader).getURL();
|
|
||||||
final Charset cs = ((URLReader)reader).getCharset();
|
|
||||||
return evalImpl(compileImpl(new Source(url.toString(), url, cs), ctxt), ctxt);
|
|
||||||
}
|
|
||||||
return evalImpl(Source.readFully(reader), ctxt);
|
|
||||||
} catch (final IOException e) {
|
|
||||||
throw new ScriptException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object eval(final String script, final ScriptContext ctxt) throws ScriptException {
|
public Object eval(final String script, final ScriptContext ctxt) throws ScriptException {
|
||||||
return evalImpl(script.toCharArray(), ctxt);
|
return evalImpl(makeSource(script, ctxt), ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -221,16 +212,12 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompiledScript compile(final Reader reader) throws ScriptException {
|
public CompiledScript compile(final Reader reader) throws ScriptException {
|
||||||
try {
|
return asCompiledScript(makeSource(reader, context));
|
||||||
return asCompiledScript(compileImpl(Source.readFully(reader), context));
|
|
||||||
} catch (final IOException e) {
|
|
||||||
throw new ScriptException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompiledScript compile(final String str) throws ScriptException {
|
public CompiledScript compile(final String str) throws ScriptException {
|
||||||
return asCompiledScript(compileImpl(str.toCharArray(), context));
|
return asCompiledScript(makeSource(str, context));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invocable methods
|
// Invocable methods
|
||||||
@ -292,6 +279,29 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
|
|||||||
|
|
||||||
// Implementation only below this point
|
// Implementation only below this point
|
||||||
|
|
||||||
|
private static Source makeSource(final Reader reader, final ScriptContext ctxt) throws ScriptException {
|
||||||
|
try {
|
||||||
|
if (reader instanceof URLReader) {
|
||||||
|
final URL url = ((URLReader)reader).getURL();
|
||||||
|
final Charset cs = ((URLReader)reader).getCharset();
|
||||||
|
return new Source(url.toString(), url, cs);
|
||||||
|
} else {
|
||||||
|
return new Source(getScriptName(ctxt), Source.readFully(reader));
|
||||||
|
}
|
||||||
|
} catch (final IOException ioExp) {
|
||||||
|
throw new ScriptException(ioExp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Source makeSource(final String src, final ScriptContext ctxt) {
|
||||||
|
return new Source(getScriptName(ctxt), src);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getScriptName(final ScriptContext ctxt) {
|
||||||
|
final Object val = ctxt.getAttribute(ScriptEngine.FILENAME);
|
||||||
|
return (val != null) ? val.toString() : "<eval>";
|
||||||
|
}
|
||||||
|
|
||||||
private <T> T getInterfaceInner(final Object thiz, final Class<T> clazz) {
|
private <T> T getInterfaceInner(final Object thiz, final Class<T> clazz) {
|
||||||
if (clazz == null || !clazz.isInterface()) {
|
if (clazz == null || !clazz.isInterface()) {
|
||||||
throw new IllegalArgumentException(getMessage("interface.class.expected"));
|
throw new IllegalArgumentException(getMessage("interface.class.expected"));
|
||||||
@ -429,7 +439,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
|
|||||||
// current ScriptContext exposed as "context"
|
// current ScriptContext exposed as "context"
|
||||||
// "context" is non-writable from script - but script engine still
|
// "context" is non-writable from script - but script engine still
|
||||||
// needs to set it and so save the context Property object
|
// needs to set it and so save the context Property object
|
||||||
contextProperty = newGlobal.addOwnProperty("context", NON_ENUMERABLE_CONSTANT, null);
|
contextProperty = newGlobal.addOwnProperty("context", NON_ENUMERABLE_CONSTANT, ctxt);
|
||||||
// current ScriptEngine instance exposed as "engine". We added @SuppressWarnings("LeakingThisInConstructor") as
|
// current ScriptEngine instance exposed as "engine". We added @SuppressWarnings("LeakingThisInConstructor") as
|
||||||
// NetBeans identifies this assignment as such a leak - this is a false positive as we're setting this property
|
// NetBeans identifies this assignment as such a leak - this is a false positive as we're setting this property
|
||||||
// in the Global of a Context we just created - both the Context and the Global were just created and can not be
|
// in the Global of a Context we just created - both the Context and the Global were just created and can not be
|
||||||
@ -509,8 +519,8 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
|
|||||||
throw new IllegalArgumentException(getMessage("interface.on.non.script.object"));
|
throw new IllegalArgumentException(getMessage("interface.on.non.script.object"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object evalImpl(final char[] buf, final ScriptContext ctxt) throws ScriptException {
|
private Object evalImpl(final Source src, final ScriptContext ctxt) throws ScriptException {
|
||||||
return evalImpl(compileImpl(buf, ctxt), ctxt);
|
return evalImpl(compileImpl(src, ctxt), ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object evalImpl(final ScriptFunction script, final ScriptContext ctxt) throws ScriptException {
|
private Object evalImpl(final ScriptFunction script, final ScriptContext ctxt) throws ScriptException {
|
||||||
@ -561,11 +571,20 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CompiledScript asCompiledScript(final ScriptFunction script) {
|
private CompiledScript asCompiledScript(final Source source) throws ScriptException {
|
||||||
|
final ScriptFunction func = compileImpl(source, context);
|
||||||
return new CompiledScript() {
|
return new CompiledScript() {
|
||||||
@Override
|
@Override
|
||||||
public Object eval(final ScriptContext ctxt) throws ScriptException {
|
public Object eval(final ScriptContext ctxt) throws ScriptException {
|
||||||
return evalImpl(script, ctxt);
|
final ScriptObject global = getNashornGlobalFrom(ctxt);
|
||||||
|
// Are we running the script in the correct global?
|
||||||
|
if (func.getScope() == global) {
|
||||||
|
return evalImpl(func, ctxt, global);
|
||||||
|
} else {
|
||||||
|
// ScriptContext with a different global. Compile again!
|
||||||
|
// Note that we may still hit per-global compilation cache.
|
||||||
|
return evalImpl(compileImpl(source, ctxt), ctxt, global);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ScriptEngine getEngine() {
|
public ScriptEngine getEngine() {
|
||||||
@ -574,12 +593,6 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScriptFunction compileImpl(final char[] buf, final ScriptContext ctxt) throws ScriptException {
|
|
||||||
final Object val = ctxt.getAttribute(ScriptEngine.FILENAME);
|
|
||||||
final String fileName = (val != null) ? val.toString() : "<eval>";
|
|
||||||
return compileImpl(new Source(fileName, buf), ctxt);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ScriptFunction compileImpl(final Source source, final ScriptContext ctxt) throws ScriptException {
|
private ScriptFunction compileImpl(final Source source, final ScriptContext ctxt) throws ScriptException {
|
||||||
return compileImpl(source, getNashornGlobalFrom(ctxt));
|
return compileImpl(source, getNashornGlobalFrom(ctxt));
|
||||||
}
|
}
|
||||||
|
@ -807,9 +807,11 @@ final class Attr extends NodeOperatorVisitor<LexicalContext> {
|
|||||||
type = Type.OBJECT;
|
type = Type.OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
type = Type.widest(type, newCaseNode.getTest().getType());
|
final Type newCaseType = newCaseNode.getTest().getType();
|
||||||
if (type.isBoolean()) {
|
if (newCaseType.isBoolean()) {
|
||||||
type = Type.OBJECT; //booleans and integers aren't assignment compatible
|
type = Type.OBJECT; //booleans and integers aren't assignment compatible
|
||||||
|
} else {
|
||||||
|
type = Type.widest(type, newCaseType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -852,7 +852,6 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
|
|||||||
final Label loopLabel = new Label("loop");
|
final Label loopLabel = new Label("loop");
|
||||||
|
|
||||||
final Expression init = forNode.getInit();
|
final Expression init = forNode.getInit();
|
||||||
assert init instanceof IdentNode;
|
|
||||||
|
|
||||||
load(modify);
|
load(modify);
|
||||||
assert modify.getType().isObject();
|
assert modify.getType().isObject();
|
||||||
@ -2175,8 +2174,9 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
|
|||||||
method.invoke(ScriptRuntime.OPEN_WITH);
|
method.invoke(ScriptRuntime.OPEN_WITH);
|
||||||
method.storeCompilerConstant(SCOPE);
|
method.storeCompilerConstant(SCOPE);
|
||||||
} else {
|
} else {
|
||||||
// We just loaded the expression for its side effect; discard it
|
// We just loaded the expression for its side effect and to check
|
||||||
method.pop();
|
// for null or undefined value.
|
||||||
|
globalCheckObjectCoercible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3258,6 +3258,10 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
|
|||||||
return method.invokestatic(GLOBAL_OBJECT, "isEval", methodDescriptor(boolean.class, Object.class));
|
return method.invokestatic(GLOBAL_OBJECT, "isEval", methodDescriptor(boolean.class, Object.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private MethodEmitter globalCheckObjectCoercible() {
|
||||||
|
return method.invokestatic(GLOBAL_OBJECT, "checkObjectCoercible", methodDescriptor(void.class, Object.class));
|
||||||
|
}
|
||||||
|
|
||||||
private MethodEmitter globalDirectEval() {
|
private MethodEmitter globalDirectEval() {
|
||||||
return method.invokestatic(GLOBAL_OBJECT, "directEval",
|
return method.invokestatic(GLOBAL_OBJECT, "directEval",
|
||||||
methodDescriptor(Object.class, Object.class, Object.class, Object.class, Object.class, Object.class));
|
methodDescriptor(Object.class, Object.class, Object.class, Object.class, Object.class, Object.class));
|
||||||
|
@ -79,13 +79,12 @@ public final class WhileNode extends LoopNode {
|
|||||||
if (visitor.enterWhileNode(this)) {
|
if (visitor.enterWhileNode(this)) {
|
||||||
if (isDoWhile()) {
|
if (isDoWhile()) {
|
||||||
return visitor.leaveWhileNode(
|
return visitor.leaveWhileNode(
|
||||||
setTest(lc, (Expression)test.accept(visitor)).
|
setBody(lc, (Block)body.accept(visitor)).
|
||||||
setBody(lc, (Block)body.accept(visitor)));
|
setTest(lc, (Expression)test.accept(visitor)));
|
||||||
}
|
}
|
||||||
return visitor.leaveWhileNode(
|
return visitor.leaveWhileNode(
|
||||||
setBody(lc, (Block)body.accept(visitor)).
|
setTest(lc, (Expression)test.accept(visitor)).
|
||||||
setTest(lc, (Expression)test.accept(visitor)));
|
setBody(lc, (Block)body.accept(visitor)));
|
||||||
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,8 @@ public final class JSONWriter extends NodeVisitor<LexicalContext> {
|
|||||||
comma();
|
comma();
|
||||||
|
|
||||||
property("id");
|
property("id");
|
||||||
if (functionNode.isAnonymous()) {
|
final FunctionNode.Kind kind = functionNode.getKind();
|
||||||
|
if (functionNode.isAnonymous() || kind == FunctionNode.Kind.GETTER || kind == FunctionNode.Kind.SETTER) {
|
||||||
nullValue();
|
nullValue();
|
||||||
} else {
|
} else {
|
||||||
functionNode.getIdent().accept(this);
|
functionNode.getIdent().accept(this);
|
||||||
|
@ -33,6 +33,7 @@ import java.io.IOException;
|
|||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.lang.invoke.MethodHandle;
|
import java.lang.invoke.MethodHandle;
|
||||||
import java.lang.invoke.MethodHandles;
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.ref.ReferenceQueue;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -691,17 +692,41 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
|
|||||||
* Cache for compiled script classes.
|
* Cache for compiled script classes.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
private static class ClassCache extends LinkedHashMap<Source, SoftReference<Class<?>>> {
|
private static class ClassCache extends LinkedHashMap<Source, ClassReference> {
|
||||||
private final int size;
|
private final int size;
|
||||||
|
private final ReferenceQueue<Class<?>> queue;
|
||||||
|
|
||||||
ClassCache(int size) {
|
ClassCache(int size) {
|
||||||
super(size, 0.75f, true);
|
super(size, 0.75f, true);
|
||||||
this.size = size;
|
this.size = size;
|
||||||
|
this.queue = new ReferenceQueue<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void cache(final Source source, final Class<?> clazz) {
|
||||||
|
put(source, new ClassReference(clazz, queue, source));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean removeEldestEntry(final Map.Entry<Source, SoftReference<Class<?>>> eldest) {
|
protected boolean removeEldestEntry(final Map.Entry<Source, ClassReference> eldest) {
|
||||||
return size() >= size;
|
return size() > size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassReference get(Object key) {
|
||||||
|
for (ClassReference ref; (ref = (ClassReference)queue.poll()) != null; ) {
|
||||||
|
remove(ref.source);
|
||||||
|
}
|
||||||
|
return super.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ClassReference extends SoftReference<Class<?>> {
|
||||||
|
private final Source source;
|
||||||
|
|
||||||
|
ClassReference(final Class<?> clazz, final ReferenceQueue<Class<?>> queue, final Source source) {
|
||||||
|
super(clazz, queue);
|
||||||
|
this.source = source;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,22 +734,14 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
|
|||||||
@Override
|
@Override
|
||||||
public Class<?> findCachedClass(final Source source) {
|
public Class<?> findCachedClass(final Source source) {
|
||||||
assert classCache != null : "Class cache used without being initialized";
|
assert classCache != null : "Class cache used without being initialized";
|
||||||
SoftReference<Class<?>> ref = classCache.get(source);
|
ClassReference ref = classCache.get(source);
|
||||||
if (ref != null) {
|
return ref != null ? ref.get() : null;
|
||||||
final Class<?> clazz = ref.get();
|
|
||||||
if (clazz == null) {
|
|
||||||
classCache.remove(source);
|
|
||||||
}
|
|
||||||
return clazz;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cacheClass(final Source source, final Class<?> clazz) {
|
public void cacheClass(final Source source, final Class<?> clazz) {
|
||||||
assert classCache != null : "Class cache used without being initialized";
|
assert classCache != null : "Class cache used without being initialized";
|
||||||
classCache.put(source, new SoftReference<Class<?>>(clazz));
|
classCache.cache(source, clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> T getLazilyCreatedValue(final Object key, final Callable<T> creator, final Map<Object, T> map) {
|
private static <T> T getLazilyCreatedValue(final Object key, final Callable<T> creator, final Map<Object, T> map) {
|
||||||
|
@ -75,11 +75,11 @@ public final class NativeDate extends ScriptObject {
|
|||||||
private static final int FORMAT_LOCAL_TIME = 5;
|
private static final int FORMAT_LOCAL_TIME = 5;
|
||||||
|
|
||||||
// Constants defined in ECMA 15.9.1.10
|
// Constants defined in ECMA 15.9.1.10
|
||||||
private static final double hoursPerDay = 24;
|
private static final int hoursPerDay = 24;
|
||||||
private static final double minutesPerHour = 60;
|
private static final int minutesPerHour = 60;
|
||||||
private static final double secondsPerMinute = 60;
|
private static final int secondsPerMinute = 60;
|
||||||
private static final double msPerSecond = 1_000;
|
private static final int msPerSecond = 1_000;
|
||||||
private static final double msPerMinute = 60_000;
|
private static final int msPerMinute = 60_000;
|
||||||
private static final double msPerHour = 3_600_000;
|
private static final double msPerHour = 3_600_000;
|
||||||
private static final double msPerDay = 86_400_000;
|
private static final double msPerDay = 86_400_000;
|
||||||
|
|
||||||
@ -926,13 +926,13 @@ public final class NativeDate extends ScriptObject {
|
|||||||
case FORMAT_DATE :
|
case FORMAT_DATE :
|
||||||
case FORMAT_LOCAL_DATE_TIME:
|
case FORMAT_LOCAL_DATE_TIME:
|
||||||
// EEE MMM dd yyyy
|
// EEE MMM dd yyyy
|
||||||
sb.append(weekDays[(int) weekDay(t)])
|
sb.append(weekDays[weekDay(t)])
|
||||||
.append(' ')
|
.append(' ')
|
||||||
.append(months[(int) monthFromTime(t)])
|
.append(months[monthFromTime(t)])
|
||||||
.append(' ');
|
.append(' ');
|
||||||
zeroPad(sb, (int) dayFromTime(t), 2);
|
zeroPad(sb, dayFromTime(t), 2);
|
||||||
sb.append(' ');
|
sb.append(' ');
|
||||||
zeroPad(sb, (int) yearFromTime(t), 4);
|
zeroPad(sb, yearFromTime(t), 4);
|
||||||
if (format == FORMAT_DATE) {
|
if (format == FORMAT_DATE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -948,11 +948,11 @@ public final class NativeDate extends ScriptObject {
|
|||||||
offset = (offset / 60) * 100 + offset % 60;
|
offset = (offset / 60) * 100 + offset % 60;
|
||||||
|
|
||||||
// HH:mm:ss GMT+HHmm
|
// HH:mm:ss GMT+HHmm
|
||||||
zeroPad(sb, (int) hourFromTime(t), 2);
|
zeroPad(sb, hourFromTime(t), 2);
|
||||||
sb.append(':');
|
sb.append(':');
|
||||||
zeroPad(sb, (int) minFromTime(t), 2);
|
zeroPad(sb, minFromTime(t), 2);
|
||||||
sb.append(':');
|
sb.append(':');
|
||||||
zeroPad(sb, (int) secFromTime(t), 2);
|
zeroPad(sb, secFromTime(t), 2);
|
||||||
sb.append(" GMT")
|
sb.append(" GMT")
|
||||||
.append(offset < 0 ? '-' : '+');
|
.append(offset < 0 ? '-' : '+');
|
||||||
zeroPad(sb, Math.abs(offset), 4);
|
zeroPad(sb, Math.abs(offset), 4);
|
||||||
@ -963,20 +963,20 @@ public final class NativeDate extends ScriptObject {
|
|||||||
|
|
||||||
case FORMAT_LOCAL_DATE:
|
case FORMAT_LOCAL_DATE:
|
||||||
// yyyy-MM-dd
|
// yyyy-MM-dd
|
||||||
zeroPad(sb, (int) yearFromTime(t), 4);
|
zeroPad(sb, yearFromTime(t), 4);
|
||||||
sb.append('-');
|
sb.append('-');
|
||||||
zeroPad(sb, (int) monthFromTime(t) + 1, 2);
|
zeroPad(sb, monthFromTime(t) + 1, 2);
|
||||||
sb.append('-');
|
sb.append('-');
|
||||||
zeroPad(sb, (int) dayFromTime(t), 2);
|
zeroPad(sb, dayFromTime(t), 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FORMAT_LOCAL_TIME:
|
case FORMAT_LOCAL_TIME:
|
||||||
// HH:mm:ss
|
// HH:mm:ss
|
||||||
zeroPad(sb, (int) hourFromTime(t), 2);
|
zeroPad(sb, hourFromTime(t), 2);
|
||||||
sb.append(':');
|
sb.append(':');
|
||||||
zeroPad(sb, (int) minFromTime(t), 2);
|
zeroPad(sb, minFromTime(t), 2);
|
||||||
sb.append(':');
|
sb.append(':');
|
||||||
zeroPad(sb, (int) secFromTime(t), 2);
|
zeroPad(sb, secFromTime(t), 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -996,19 +996,19 @@ public final class NativeDate extends ScriptObject {
|
|||||||
final StringBuilder sb = new StringBuilder(29);
|
final StringBuilder sb = new StringBuilder(29);
|
||||||
final double t = nd.getTime();
|
final double t = nd.getTime();
|
||||||
// EEE, dd MMM yyyy HH:mm:ss z
|
// EEE, dd MMM yyyy HH:mm:ss z
|
||||||
sb.append(weekDays[(int) weekDay(t)])
|
sb.append(weekDays[weekDay(t)])
|
||||||
.append(", ");
|
.append(", ");
|
||||||
zeroPad(sb, (int) dayFromTime(t), 2);
|
zeroPad(sb, dayFromTime(t), 2);
|
||||||
sb.append(' ')
|
sb.append(' ')
|
||||||
.append(months[(int) monthFromTime(t)])
|
.append(months[monthFromTime(t)])
|
||||||
.append(' ');
|
.append(' ');
|
||||||
zeroPad(sb, (int) yearFromTime(t), 4);
|
zeroPad(sb, yearFromTime(t), 4);
|
||||||
sb.append(' ');
|
sb.append(' ');
|
||||||
zeroPad(sb, (int) hourFromTime(t), 2);
|
zeroPad(sb, hourFromTime(t), 2);
|
||||||
sb.append(':');
|
sb.append(':');
|
||||||
zeroPad(sb, (int) minFromTime(t), 2);
|
zeroPad(sb, minFromTime(t), 2);
|
||||||
sb.append(':');
|
sb.append(':');
|
||||||
zeroPad(sb, (int) secFromTime(t), 2);
|
zeroPad(sb, secFromTime(t), 2);
|
||||||
sb.append(" GMT");
|
sb.append(" GMT");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@ -1023,19 +1023,19 @@ public final class NativeDate extends ScriptObject {
|
|||||||
final StringBuilder sb = new StringBuilder(24);
|
final StringBuilder sb = new StringBuilder(24);
|
||||||
final double t = nd.getTime();
|
final double t = nd.getTime();
|
||||||
// yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
|
// yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
|
||||||
zeroPad(sb, (int) yearFromTime(t), 4);
|
zeroPad(sb, yearFromTime(t), 4);
|
||||||
sb.append('-');
|
sb.append('-');
|
||||||
zeroPad(sb, (int) monthFromTime(t) + 1, 2);
|
zeroPad(sb, monthFromTime(t) + 1, 2);
|
||||||
sb.append('-');
|
sb.append('-');
|
||||||
zeroPad(sb, (int) dayFromTime(t), 2);
|
zeroPad(sb, dayFromTime(t), 2);
|
||||||
sb.append('T');
|
sb.append('T');
|
||||||
zeroPad(sb, (int) hourFromTime(t), 2);
|
zeroPad(sb, hourFromTime(t), 2);
|
||||||
sb.append(':');
|
sb.append(':');
|
||||||
zeroPad(sb, (int) minFromTime(t), 2);
|
zeroPad(sb, minFromTime(t), 2);
|
||||||
sb.append(':');
|
sb.append(':');
|
||||||
zeroPad(sb, (int) secFromTime(t), 2);
|
zeroPad(sb, secFromTime(t), 2);
|
||||||
sb.append('.');
|
sb.append('.');
|
||||||
zeroPad(sb, (int) msFromTime(t), 3);
|
zeroPad(sb, msFromTime(t), 3);
|
||||||
sb.append("Z");
|
sb.append("Z");
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@ -1072,29 +1072,30 @@ public final class NativeDate extends ScriptObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ECMA 15.9.1.3 Year Number
|
// ECMA 15.9.1.3 Year Number
|
||||||
private static double timeFromYear(final double y) {
|
private static double timeFromYear(final int y) {
|
||||||
return dayFromYear(y) * msPerDay;
|
return dayFromYear(y) * msPerDay;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double yearFromTime(final double t) {
|
// ECMA 15.9.1.3 Year Number
|
||||||
double y = Math.floor(t / (msPerDay * 365.2425)) + 1970;
|
private static int yearFromTime(final double t) {
|
||||||
|
int y = (int) Math.floor(t / (msPerDay * 365.2425)) + 1970;
|
||||||
final double t2 = timeFromYear(y);
|
final double t2 = timeFromYear(y);
|
||||||
if (t2 > t) {
|
if (t2 > t) {
|
||||||
y--;
|
y--;
|
||||||
} else if (t2 + msPerDay * daysInYear((int) y) <= t) {
|
} else if (t2 + msPerDay * daysInYear(y) <= t) {
|
||||||
y++;
|
y++;
|
||||||
}
|
}
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double dayWithinYear(final double t, final double year) {
|
private static int dayWithinYear(final double t, final int year) {
|
||||||
return day(t) - dayFromYear(year);
|
return (int) (day(t) - dayFromYear(year));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double monthFromTime(final double t) {
|
private static int monthFromTime(final double t) {
|
||||||
final double year = yearFromTime(t);
|
final int year = yearFromTime(t);
|
||||||
final double day = dayWithinYear(t, year);
|
final int day = dayWithinYear(t, year);
|
||||||
final int[] firstDay = firstDayInMonth[isLeapYear((int) year) ? 1 : 0];
|
final int[] firstDay = firstDayInMonth[isLeapYear(year) ? 1 : 0];
|
||||||
int month = 0;
|
int month = 0;
|
||||||
|
|
||||||
while (month < 11 && firstDay[month + 1] <= day) {
|
while (month < 11 && firstDay[month + 1] <= day) {
|
||||||
@ -1103,10 +1104,10 @@ public final class NativeDate extends ScriptObject {
|
|||||||
return month;
|
return month;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double dayFromTime(final double t) {
|
private static int dayFromTime(final double t) {
|
||||||
final double year = yearFromTime(t);
|
final int year = yearFromTime(t);
|
||||||
final double day = dayWithinYear(t, year);
|
final int day = dayWithinYear(t, year);
|
||||||
final int[] firstDay = firstDayInMonth[isLeapYear((int) year) ? 1 : 0];
|
final int[] firstDay = firstDayInMonth[isLeapYear(year) ? 1 : 0];
|
||||||
int month = 0;
|
int month = 0;
|
||||||
|
|
||||||
while (month < 11 && firstDay[month + 1] <= day) {
|
while (month < 11 && firstDay[month + 1] <= day) {
|
||||||
@ -1121,11 +1122,8 @@ public final class NativeDate extends ScriptObject {
|
|||||||
return firstDay[month];
|
return firstDay[month];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double weekDay(final double time) {
|
private static int weekDay(final double time) {
|
||||||
if (isNaN(time)) {
|
final int day = (int) (day(time) + 4) % 7;
|
||||||
return NaN;
|
|
||||||
}
|
|
||||||
final double day = (day(time) + 4) % 7;
|
|
||||||
return day < 0 ? day + 7 : day;
|
return day < 0 ? day + 7 : day;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1140,26 +1138,26 @@ public final class NativeDate extends ScriptObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ECMA 15.9.1.10 Hours, Minutes, Second, and Milliseconds
|
// ECMA 15.9.1.10 Hours, Minutes, Second, and Milliseconds
|
||||||
private static double hourFromTime(final double t) {
|
private static int hourFromTime(final double t) {
|
||||||
final double h = Math.floor(t / msPerHour) % hoursPerDay;
|
final int h = (int) (Math.floor(t / msPerHour) % hoursPerDay);
|
||||||
return h < 0 ? h + hoursPerDay: h;
|
return h < 0 ? h + hoursPerDay: h;
|
||||||
}
|
}
|
||||||
private static double minFromTime(final double t) {
|
private static int minFromTime(final double t) {
|
||||||
final double m = Math.floor(t / msPerMinute) % minutesPerHour;
|
final int m = (int) (Math.floor(t / msPerMinute) % minutesPerHour);
|
||||||
return m < 0 ? m + minutesPerHour : m;
|
return m < 0 ? m + minutesPerHour : m;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double secFromTime(final double t) {
|
private static int secFromTime(final double t) {
|
||||||
final double s = Math.floor(t / msPerSecond) % secondsPerMinute;
|
final int s = (int) (Math.floor(t / msPerSecond) % secondsPerMinute);
|
||||||
return s < 0 ? s + secondsPerMinute : s;
|
return s < 0 ? s + secondsPerMinute : s;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double msFromTime(final double t) {
|
private static int msFromTime(final double t) {
|
||||||
final double m = t % msPerSecond;
|
final int m = (int) (t % msPerSecond);
|
||||||
return m < 0 ? m + msPerSecond : m;
|
return m < 0 ? m + msPerSecond : m;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double valueFromTime(final int unit, final double t) {
|
private static int valueFromTime(final int unit, final double t) {
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
case YEAR: return yearFromTime(t);
|
case YEAR: return yearFromTime(t);
|
||||||
case MONTH: return monthFromTime(t);
|
case MONTH: return monthFromTime(t);
|
||||||
@ -1180,12 +1178,12 @@ public final class NativeDate extends ScriptObject {
|
|||||||
// ECMA 15.9.1.12 MakeDay (year, month, date)
|
// ECMA 15.9.1.12 MakeDay (year, month, date)
|
||||||
private static double makeDay(final double year, final double month, final double date) {
|
private static double makeDay(final double year, final double month, final double date) {
|
||||||
final double y = year + Math.floor(month / 12);
|
final double y = year + Math.floor(month / 12);
|
||||||
double m = month % 12;
|
int m = (int) (month % 12);
|
||||||
if (m < 0) {
|
if (m < 0) {
|
||||||
m += 12;
|
m += 12;
|
||||||
}
|
}
|
||||||
double d = Math.floor(dayFromYear(y));
|
double d = dayFromYear(y);
|
||||||
d += dayFromMonth((int) m, (int) y);
|
d += dayFromMonth(m, (int) y);
|
||||||
|
|
||||||
return d + date - 1;
|
return d + date - 1;
|
||||||
}
|
}
|
||||||
@ -1257,13 +1255,13 @@ public final class NativeDate extends ScriptObject {
|
|||||||
nullReturn = true;
|
nullReturn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! nullReturn) {
|
if (!nullReturn && !isNaN(time)) {
|
||||||
d[i - start] = valueFromTime(i, time);
|
d[i - start] = valueFromTime(i, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullReturn? null : d;
|
return nullReturn ? null : d;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ECMA 15.9.1.14 TimeClip (time)
|
// ECMA 15.9.1.14 TimeClip (time)
|
||||||
|
@ -162,22 +162,27 @@ public final class NativeJSON extends ScriptObject {
|
|||||||
|
|
||||||
String gap;
|
String gap;
|
||||||
|
|
||||||
if (space instanceof Number || space instanceof NativeNumber) {
|
// modifiable 'space' - parameter is final
|
||||||
int indent;
|
Object modSpace = space;
|
||||||
if (space instanceof NativeNumber) {
|
if (modSpace instanceof NativeNumber) {
|
||||||
indent = ((NativeNumber)space).intValue();
|
modSpace = JSType.toNumber(JSType.toPrimitive(modSpace, Number.class));
|
||||||
|
} else if (modSpace instanceof NativeString) {
|
||||||
|
modSpace = JSType.toString(JSType.toPrimitive(modSpace, String.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modSpace instanceof Number) {
|
||||||
|
int indent = Math.min(10, JSType.toInteger(modSpace));
|
||||||
|
if (indent < 1) {
|
||||||
|
gap = "";
|
||||||
} else {
|
} else {
|
||||||
indent = ((Number)space).intValue();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < indent; i++) {
|
||||||
|
sb.append(' ');
|
||||||
|
}
|
||||||
|
gap = sb.toString();
|
||||||
}
|
}
|
||||||
|
} else if (modSpace instanceof String || modSpace instanceof ConsString) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final String str = modSpace.toString();
|
||||||
for (int i = 0; i < Math.min(10, indent); i++) {
|
|
||||||
sb.append(' ');
|
|
||||||
}
|
|
||||||
gap = sb.toString();
|
|
||||||
|
|
||||||
} else if (space instanceof String || space instanceof ConsString || space instanceof NativeString) {
|
|
||||||
final String str = (space instanceof String) ? (String)space : space.toString();
|
|
||||||
gap = str.substring(0, Math.min(10, str.length()));
|
gap = str.substring(0, Math.min(10, str.length()));
|
||||||
} else {
|
} else {
|
||||||
gap = "";
|
gap = "";
|
||||||
|
@ -191,23 +191,21 @@ public final class NativeRegExp extends ScriptObject {
|
|||||||
public static NativeRegExp newRegExp(final Object regexp, final Object flags) {
|
public static NativeRegExp newRegExp(final Object regexp, final Object flags) {
|
||||||
String patternString = "";
|
String patternString = "";
|
||||||
String flagString = "";
|
String flagString = "";
|
||||||
boolean flagsDefined = false;
|
|
||||||
|
|
||||||
if (flags != UNDEFINED) {
|
|
||||||
flagsDefined = true;
|
|
||||||
flagString = JSType.toString(flags);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regexp != UNDEFINED) {
|
if (regexp != UNDEFINED) {
|
||||||
if (regexp instanceof NativeRegExp) {
|
if (regexp instanceof NativeRegExp) {
|
||||||
if (!flagsDefined) {
|
if (flags != UNDEFINED) {
|
||||||
return (NativeRegExp)regexp; // 15.10.3.1 - undefined flags and regexp as
|
throw typeError("regex.cant.supply.flags");
|
||||||
}
|
}
|
||||||
throw typeError("regex.cant.supply.flags");
|
return (NativeRegExp)regexp; // 15.10.3.1 - undefined flags and regexp as
|
||||||
}
|
}
|
||||||
patternString = JSType.toString(regexp);
|
patternString = JSType.toString(regexp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags != UNDEFINED) {
|
||||||
|
flagString = JSType.toString(flags);
|
||||||
|
}
|
||||||
|
|
||||||
return new NativeRegExp(patternString, flagString);
|
return new NativeRegExp(patternString, flagString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,8 +695,13 @@ public final class NativeRegExp extends ScriptObject {
|
|||||||
appendReplacement(matcher, string, replacement, sb);
|
appendReplacement(matcher, string, replacement, sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ECMA 15.5.4.10 String.prototype.match(regexp)
|
|
||||||
thisIndex = matcher.end();
|
thisIndex = matcher.end();
|
||||||
|
if (thisIndex == string.length() && matcher.start() == matcher.end()) {
|
||||||
|
// Avoid getting empty match at end of string twice
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ECMA 15.5.4.10 String.prototype.match(regexp)
|
||||||
if (thisIndex == previousLastIndex) {
|
if (thisIndex == previousLastIndex) {
|
||||||
setLastIndex(thisIndex + 1);
|
setLastIndex(thisIndex + 1);
|
||||||
previousLastIndex = thisIndex + 1;
|
previousLastIndex = thisIndex + 1;
|
||||||
@ -883,7 +886,7 @@ public final class NativeRegExp extends ScriptObject {
|
|||||||
* @return last index property as int
|
* @return last index property as int
|
||||||
*/
|
*/
|
||||||
public int getLastIndex() {
|
public int getLastIndex() {
|
||||||
return JSType.toInt32(lastIndex);
|
return JSType.toInteger(lastIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,6 +349,10 @@ loop:
|
|||||||
|
|
||||||
case COMMARIGHT:
|
case COMMARIGHT:
|
||||||
next();
|
next();
|
||||||
|
// check for trailing comma - not allowed in JSON
|
||||||
|
if (type == RBRACKET) {
|
||||||
|
throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -388,6 +392,10 @@ loop:
|
|||||||
|
|
||||||
case COMMARIGHT:
|
case COMMARIGHT:
|
||||||
next();
|
next();
|
||||||
|
// check for trailing comma - not allowed in JSON
|
||||||
|
if (type == RBRACE) {
|
||||||
|
throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -59,6 +59,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import jdk.internal.dynalink.support.NameCodec;
|
||||||
import jdk.nashorn.internal.codegen.CompilerConstants;
|
import jdk.nashorn.internal.codegen.CompilerConstants;
|
||||||
import jdk.nashorn.internal.codegen.Namespace;
|
import jdk.nashorn.internal.codegen.Namespace;
|
||||||
import jdk.nashorn.internal.ir.AccessNode;
|
import jdk.nashorn.internal.ir.AccessNode;
|
||||||
@ -2108,7 +2109,7 @@ loop:
|
|||||||
case "get":
|
case "get":
|
||||||
final PropertyKey getIdent = propertyName();
|
final PropertyKey getIdent = propertyName();
|
||||||
final String getterName = getIdent.getPropertyName();
|
final String getterName = getIdent.getPropertyName();
|
||||||
final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + getterName);
|
final IdentNode getNameNode = new IdentNode(((Node)getIdent).getToken(), finish, "get " + NameCodec.encode(getterName));
|
||||||
expect(LPAREN);
|
expect(LPAREN);
|
||||||
expect(RPAREN);
|
expect(RPAREN);
|
||||||
functionNode = functionBody(getSetToken, getNameNode, new ArrayList<IdentNode>(), FunctionNode.Kind.GETTER);
|
functionNode = functionBody(getSetToken, getNameNode, new ArrayList<IdentNode>(), FunctionNode.Kind.GETTER);
|
||||||
@ -2117,7 +2118,7 @@ loop:
|
|||||||
case "set":
|
case "set":
|
||||||
final PropertyKey setIdent = propertyName();
|
final PropertyKey setIdent = propertyName();
|
||||||
final String setterName = setIdent.getPropertyName();
|
final String setterName = setIdent.getPropertyName();
|
||||||
final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + setterName);
|
final IdentNode setNameNode = new IdentNode(((Node)setIdent).getToken(), finish, "set " + NameCodec.encode(setterName));
|
||||||
expect(LPAREN);
|
expect(LPAREN);
|
||||||
final IdentNode argIdent = getIdent();
|
final IdentNode argIdent = getIdent();
|
||||||
verifyStrictIdent(argIdent, "setter argument");
|
verifyStrictIdent(argIdent, "setter argument");
|
||||||
|
@ -90,6 +90,7 @@ public final class GlobalFunctions {
|
|||||||
public static double parseInt(final Object self, final Object string, final Object rad) {
|
public static double parseInt(final Object self, final Object string, final Object rad) {
|
||||||
final String str = JSType.trimLeft(JSType.toString(string));
|
final String str = JSType.trimLeft(JSType.toString(string));
|
||||||
final int length = str.length();
|
final int length = str.length();
|
||||||
|
int radix = JSType.toInt32(rad);
|
||||||
|
|
||||||
// empty string is not valid
|
// empty string is not valid
|
||||||
if (length == 0) {
|
if (length == 0) {
|
||||||
@ -113,7 +114,6 @@ public final class GlobalFunctions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean stripPrefix = true;
|
boolean stripPrefix = true;
|
||||||
int radix = JSType.toInt32(rad);
|
|
||||||
|
|
||||||
if (radix != 0) {
|
if (radix != 0) {
|
||||||
if (radix < 2 || radix > 36) {
|
if (radix < 2 || radix > 36) {
|
||||||
@ -211,7 +211,7 @@ loop:
|
|||||||
switch (ch) {
|
switch (ch) {
|
||||||
case '.':
|
case '.':
|
||||||
// dot allowed only once
|
// dot allowed only once
|
||||||
if (dotSeen) {
|
if (exponentOffset != -1 || dotSeen) {
|
||||||
break loop;
|
break loop;
|
||||||
}
|
}
|
||||||
dotSeen = true;
|
dotSeen = true;
|
||||||
|
@ -169,7 +169,7 @@ public final class Source {
|
|||||||
|
|
||||||
final Source src = (Source)obj;
|
final Source src = (Source)obj;
|
||||||
// Only compare content as a last resort measure
|
// Only compare content as a last resort measure
|
||||||
return length == src.length && Objects.equals(name, src.name) && Arrays.equals(content, src.content);
|
return length == src.length && Objects.equals(url, src.url) && Objects.equals(name, src.name) && Arrays.equals(content, src.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,6 +57,7 @@ parser.error.missing.catch.or.finally=Missing catch or finally after try
|
|||||||
parser.error.regex.unsupported.flag=Unsupported RegExp flag: {0}
|
parser.error.regex.unsupported.flag=Unsupported RegExp flag: {0}
|
||||||
parser.error.regex.repeated.flag=Repeated RegExp flag: {0}
|
parser.error.regex.repeated.flag=Repeated RegExp flag: {0}
|
||||||
parser.error.regex.syntax={0}
|
parser.error.regex.syntax={0}
|
||||||
|
parser.error.trailing.comma.in.json=Trailing comma is not allowed in JSON
|
||||||
|
|
||||||
# strict mode error messages
|
# strict mode error messages
|
||||||
parser.error.strict.no.with="with" statement cannot be used in strict mode
|
parser.error.strict.no.with="with" statement cannot be used in strict mode
|
||||||
|
43
nashorn/test/script/basic/JDK-8024972.js
Normal file
43
nashorn/test/script/basic/JDK-8024972.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDK-8024972: for (LeftHandSideExpression in Expression) crashes the compiler
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
var obj = {};
|
||||||
|
|
||||||
|
var arr = [2, 45, -1, 445];
|
||||||
|
for (obj.x in arr) {
|
||||||
|
print(obj.x + "->"+ arr[obj.x]);
|
||||||
|
}
|
||||||
|
|
||||||
|
var abc = { foo: 'bar', hello: 'world' };
|
||||||
|
for (obj.x in abc) {
|
||||||
|
print(obj.x + "->" + abc[obj.x]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (obj.x in 0) {}
|
6
nashorn/test/script/basic/JDK-8024972.js.EXPECTED
Normal file
6
nashorn/test/script/basic/JDK-8024972.js.EXPECTED
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
0->2
|
||||||
|
1->45
|
||||||
|
2->-1
|
||||||
|
3->445
|
||||||
|
foo->bar
|
||||||
|
hello->world
|
36
nashorn/test/script/basic/JDK-8025048-2.js
Normal file
36
nashorn/test/script/basic/JDK-8025048-2.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDK-8025048: true as case label results in ClassCastException
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
function func(x) {
|
||||||
|
switch(x) {
|
||||||
|
case 8: break; case false:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
36
nashorn/test/script/basic/JDK-8025048.js
Normal file
36
nashorn/test/script/basic/JDK-8025048.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDK-8025048: true as case label results in ClassCastException
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
function func(x) {
|
||||||
|
switch(x) {
|
||||||
|
case 8: break; case true:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
43
nashorn/test/script/basic/JDK-8025080.js
Normal file
43
nashorn/test/script/basic/JDK-8025080.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDK-8025080: Object literal getter, setter function with number format property name results in ClassFormatError
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
var obj = {
|
||||||
|
get 1e81() { print("1e81 getter"); },
|
||||||
|
set 1e81(x) { print("1e81 setter"); },
|
||||||
|
get 3.14e-2() { print("3.14e-2 getter");},
|
||||||
|
set 3.14e-2(x) { print("3.14e-2 setter"); }
|
||||||
|
};
|
||||||
|
|
||||||
|
obj[1e81];
|
||||||
|
obj[1e81] = 23;
|
||||||
|
|
||||||
|
obj[3.14e-2];
|
||||||
|
obj[3.14e-2] = 42;
|
||||||
|
|
4
nashorn/test/script/basic/JDK-8025080.js.EXPECTED
Normal file
4
nashorn/test/script/basic/JDK-8025080.js.EXPECTED
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
1e81 getter
|
||||||
|
1e81 setter
|
||||||
|
3.14e-2 getter
|
||||||
|
3.14e-2 setter
|
35
nashorn/test/script/basic/JDK-8025090.js
Normal file
35
nashorn/test/script/basic/JDK-8025090.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDK-8025090: 'while' statement with 'test' using var before being declared in body results in VerifyError
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
// The following used to result in VerifyError
|
||||||
|
function f() {
|
||||||
|
while (x += 2) { var x = 44 }
|
||||||
|
}
|
||||||
|
|
48
nashorn/test/script/basic/JDK-8025111.js
Normal file
48
nashorn/test/script/basic/JDK-8025111.js
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* 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-8025111: undefined or null 'with' expression in empty with block should throw TypeError
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
function check(callback, arg) {
|
||||||
|
try {
|
||||||
|
callback(arg);
|
||||||
|
fail("should have thrown TypeError: " + callback + " on " + arg);
|
||||||
|
} catch (e) {
|
||||||
|
if (! (e instanceof TypeError)) {
|
||||||
|
fail("Expected TypeError, got " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function func(obj) {
|
||||||
|
with(obj) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
check(func);
|
||||||
|
check(func, undefined);
|
||||||
|
check(func, null);
|
41
nashorn/test/script/basic/JDK-8025147.js
Normal file
41
nashorn/test/script/basic/JDK-8025147.js
Normal file
@ -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-8025147: Trailing comma is not allowed in JSONArray and JSONObject
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
function check(str) {
|
||||||
|
try {
|
||||||
|
JSON.parse(str);
|
||||||
|
fail("should have thrown SyntaxError for " + str);
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
check("{ \"a\": 333, }");
|
||||||
|
check("[ 4343, ]");
|
6
nashorn/test/script/basic/JDK-8025147.js.EXPECTED
Normal file
6
nashorn/test/script/basic/JDK-8025147.js.EXPECTED
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
SyntaxError: Invalid JSON: <json>:1:12 Trailing comma is not allowed in JSON
|
||||||
|
{ "a": 333, }
|
||||||
|
^
|
||||||
|
SyntaxError: Invalid JSON: <json>:1:8 Trailing comma is not allowed in JSON
|
||||||
|
[ 4343, ]
|
||||||
|
^
|
47
nashorn/test/script/basic/JDK-8025149.js
Normal file
47
nashorn/test/script/basic/JDK-8025149.js
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDK-8025149: JSON.stringify does not handle 'space' argument as per the spec.
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
print(JSON.stringify({ foo : 23, bar: { x : 22} }, undefined ,new Number(Infinity)));
|
||||||
|
|
||||||
|
print(JSON.stringify({ foo : 23, bar: { x : 22} }, undefined ,new Number(-Infinity)));
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSON.stringify({},[],
|
||||||
|
(n = new Number(0), n.valueOf = function() { throw ("inside n.valueOf") }, n));
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
JSON.stringify({},[],
|
||||||
|
(s = new String(""), s.toString = function() { throw ("inside s.toString") }, s));
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
}
|
9
nashorn/test/script/basic/JDK-8025149.js.EXPECTED
Normal file
9
nashorn/test/script/basic/JDK-8025149.js.EXPECTED
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"foo": 23,
|
||||||
|
"bar": {
|
||||||
|
"x": 22
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{"foo":23,"bar":{"x":22}}
|
||||||
|
inside n.valueOf
|
||||||
|
inside s.toString
|
39
nashorn/test/script/basic/JDK-8025163.js
Normal file
39
nashorn/test/script/basic/JDK-8025163.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDK-8025163: Date methods should not return -0
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
print(1 / (new Date(0, 0, 1)).getYear());
|
||||||
|
print(1 / (new Date(1969, 1, 2)).getDay());
|
||||||
|
print(1 / (new Date(1969, 0, 1)).getHours());
|
||||||
|
print(1 / (new Date(1969, 0, 1)).getHours());
|
||||||
|
print(1 / (new Date(1969, 0, 1)).getMinutes());
|
||||||
|
print(1 / (new Date(1969, 0, 1)).getSeconds());
|
||||||
|
print(1 / (new Date(1969, 0, 1)).getMilliseconds());
|
||||||
|
print(1 / (new Date(1969, 0, 1)).getMilliseconds());
|
||||||
|
|
8
nashorn/test/script/basic/JDK-8025163.js.EXPECTED
Normal file
8
nashorn/test/script/basic/JDK-8025163.js.EXPECTED
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
Infinity
|
||||||
|
Infinity
|
||||||
|
Infinity
|
||||||
|
Infinity
|
||||||
|
Infinity
|
||||||
|
Infinity
|
||||||
|
Infinity
|
||||||
|
Infinity
|
37
nashorn/test/script/basic/JDK-8025197.js
Normal file
37
nashorn/test/script/basic/JDK-8025197.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDK-8025197: String replace method fails with regexp /$/gi
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
print('dog'.replace(/$/gi, 's'));
|
||||||
|
print('dog'.replace(/(?:g)$/gi, 's'));
|
||||||
|
print('dog'.replace(/(?:a)$/gi, 's'));
|
||||||
|
print('dog'.replace(/(?!g)$/gi, 's'));
|
||||||
|
print('dog'.replace(/(?!a)$/gi, 's'));
|
||||||
|
print('dog'.replace(/g?$/gi, 's'));
|
||||||
|
print('dog'.replace(/.?$/gi, 's'));
|
7
nashorn/test/script/basic/JDK-8025197.js.EXPECTED
Normal file
7
nashorn/test/script/basic/JDK-8025197.js.EXPECTED
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
dogs
|
||||||
|
dos
|
||||||
|
dog
|
||||||
|
dogs
|
||||||
|
dogs
|
||||||
|
doss
|
||||||
|
doss
|
35
nashorn/test/script/basic/JDK-8025312.js
Normal file
35
nashorn/test/script/basic/JDK-8025312.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDK-8025312: parseInt should convert 'radix' argument to ToInt32 even if empty string is parsed
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
parseInt("", {
|
||||||
|
valueOf: function() {
|
||||||
|
print("inside valueOf of 'radix'");
|
||||||
|
}
|
||||||
|
});
|
1
nashorn/test/script/basic/JDK-8025312.js.EXPECTED
Normal file
1
nashorn/test/script/basic/JDK-8025312.js.EXPECTED
Normal file
@ -0,0 +1 @@
|
|||||||
|
inside valueOf of 'radix'
|
35
nashorn/test/script/basic/JDK-8025325.js
Normal file
35
nashorn/test/script/basic/JDK-8025325.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDK-8025325: parseFloat does not handle '.' in exponent part
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
print(parseFloat("2e2."));
|
||||||
|
print(parseFloat("2e2.3"));
|
||||||
|
print(parseFloat("2e2.fdgdf"));
|
||||||
|
print(parseFloat("2e2. gdfgdf"));
|
||||||
|
print(parseFloat("2e2. "));
|
5
nashorn/test/script/basic/JDK-8025325.js.EXPECTED
Normal file
5
nashorn/test/script/basic/JDK-8025325.js.EXPECTED
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
200
|
||||||
|
200
|
||||||
|
200
|
||||||
|
200
|
||||||
|
200
|
66
nashorn/test/script/basic/JDK-8025434.js
Normal file
66
nashorn/test/script/basic/JDK-8025434.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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-8025434: RegExp lastIndex can exceed int range
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
var r = /a/g;
|
||||||
|
|
||||||
|
r.lastIndex = 0x100000000;
|
||||||
|
if (r.test("a")) {
|
||||||
|
throw new Error("Expected no match");
|
||||||
|
}
|
||||||
|
|
||||||
|
r.lastIndex = 0x100000000000000;
|
||||||
|
if (r.test("a")) {
|
||||||
|
throw new Error("Expected no match");
|
||||||
|
}
|
||||||
|
|
||||||
|
r.lastIndex = -0x100000000;
|
||||||
|
if (r.test("a")) {
|
||||||
|
throw new Error("Expected match");
|
||||||
|
}
|
||||||
|
|
||||||
|
r.lastIndex = -0x100000000000000;
|
||||||
|
if (r.test("a")) {
|
||||||
|
throw new Error("Expected no match");
|
||||||
|
}
|
||||||
|
|
||||||
|
r.lastIndex = 1;
|
||||||
|
if (r.test("a")) {
|
||||||
|
throw new Error("Expected no match");
|
||||||
|
}
|
||||||
|
|
||||||
|
r.lastIndex = -1;
|
||||||
|
if (r.test("a")) {
|
||||||
|
throw new Error("Expected no match");
|
||||||
|
}
|
||||||
|
|
||||||
|
r.lastIndex = 0;
|
||||||
|
if (!r.test("a")) {
|
||||||
|
throw new Error("Expected match");
|
||||||
|
}
|
55
nashorn/test/script/basic/JDK-8025486.js
Normal file
55
nashorn/test/script/basic/JDK-8025486.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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-8025486: RegExp constructor arguments are not evaluated in right order
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
* @run
|
||||||
|
*/
|
||||||
|
|
||||||
|
new RegExp({
|
||||||
|
toString: function() {
|
||||||
|
print("source");
|
||||||
|
return "a";
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
toString: function() {
|
||||||
|
print("flags");
|
||||||
|
return "g";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
new RegExp(/asdf/, {
|
||||||
|
toString: function() {
|
||||||
|
fail("toString should not be called");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fail("expected TypeError");
|
||||||
|
} catch (e) {
|
||||||
|
if (!(e instanceof TypeError)) {
|
||||||
|
fail("expected TypeError");
|
||||||
|
}
|
||||||
|
print(e);
|
||||||
|
}
|
3
nashorn/test/script/basic/JDK-8025486.js.EXPECTED
Normal file
3
nashorn/test/script/basic/JDK-8025486.js.EXPECTED
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
source
|
||||||
|
flags
|
||||||
|
TypeError: Cannot supply flags when constructing one RegExp from another
|
@ -126,10 +126,7 @@
|
|||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
"type": "FunctionExpression",
|
"type": "FunctionExpression",
|
||||||
"id": {
|
"id": null,
|
||||||
"type": "Identifier",
|
|
||||||
"name": "get x"
|
|
||||||
},
|
|
||||||
"params": [],
|
"params": [],
|
||||||
"defaults": [],
|
"defaults": [],
|
||||||
"rest": null,
|
"rest": null,
|
||||||
@ -157,10 +154,7 @@
|
|||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
"type": "FunctionExpression",
|
"type": "FunctionExpression",
|
||||||
"id": {
|
"id": null,
|
||||||
"type": "Identifier",
|
|
||||||
"name": "get y"
|
|
||||||
},
|
|
||||||
"params": [],
|
"params": [],
|
||||||
"defaults": [],
|
"defaults": [],
|
||||||
"rest": null,
|
"rest": null,
|
||||||
|
@ -54,6 +54,6 @@ try {
|
|||||||
fail("Expected SecurityException from script!");
|
fail("Expected SecurityException from script!");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (! (e instanceof SecurityException)) {
|
if (! (e instanceof SecurityException)) {
|
||||||
faile("Expected SecurityException, but got " + e);
|
fail("Expected SecurityException, but got " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,10 +37,12 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import javax.script.Compilable;
|
import javax.script.Compilable;
|
||||||
import javax.script.CompiledScript;
|
import javax.script.CompiledScript;
|
||||||
|
import javax.script.ScriptContext;
|
||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
import javax.script.ScriptEngineFactory;
|
import javax.script.ScriptEngineFactory;
|
||||||
import javax.script.ScriptEngineManager;
|
import javax.script.ScriptEngineManager;
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
|
import javax.script.SimpleScriptContext;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,6 +232,17 @@ public class ScriptEngineTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void compileAndEvalInDiffContextTest() throws ScriptException {
|
||||||
|
final ScriptEngineManager m = new ScriptEngineManager();
|
||||||
|
final ScriptEngine engine = m.getEngineByName("js");
|
||||||
|
final Compilable compilable = (Compilable) engine;
|
||||||
|
final CompiledScript compiledScript = compilable.compile("foo");
|
||||||
|
final ScriptContext ctxt = new SimpleScriptContext();
|
||||||
|
ctxt.setAttribute("foo", "hello", ScriptContext.ENGINE_SCOPE);
|
||||||
|
assertEquals(compiledScript.eval(ctxt), "hello");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void accessGlobalTest() {
|
public void accessGlobalTest() {
|
||||||
final ScriptEngineManager m = new ScriptEngineManager();
|
final ScriptEngineManager m = new ScriptEngineManager();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user