8156619: Unimplemented ES6 features should result in clear Error being thrown
Reviewed-by: sundar, attila
This commit is contained in:
parent
ba5943e1cc
commit
165429d978
nashorn
src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal
codegen
ir/visitor
parser
runtime/resources
test/script/basic/es6
@ -343,7 +343,7 @@ final class AssignSymbols extends SimpleNodeVisitor implements Loggable {
|
||||
symbol = null;
|
||||
} else if (symbol.isParam()) {
|
||||
// Duplicate parameter. Null return will force an error.
|
||||
throw new AssertionError("duplicate parameter");
|
||||
throwParserException(ECMAErrors.getMessage("syntax.error.duplicate.parameter", name), origin);
|
||||
}
|
||||
} else if (isVar) {
|
||||
if (isBlockScope) {
|
||||
|
@ -45,6 +45,7 @@ import jdk.nashorn.internal.ir.BreakNode;
|
||||
import jdk.nashorn.internal.ir.CallNode;
|
||||
import jdk.nashorn.internal.ir.CaseNode;
|
||||
import jdk.nashorn.internal.ir.CatchNode;
|
||||
import jdk.nashorn.internal.ir.ClassNode;
|
||||
import jdk.nashorn.internal.ir.ContinueNode;
|
||||
import jdk.nashorn.internal.ir.DebuggerNode;
|
||||
import jdk.nashorn.internal.ir.EmptyNode;
|
||||
@ -60,9 +61,11 @@ import jdk.nashorn.internal.ir.JumpToInlinedFinally;
|
||||
import jdk.nashorn.internal.ir.LabelNode;
|
||||
import jdk.nashorn.internal.ir.LexicalContext;
|
||||
import jdk.nashorn.internal.ir.LiteralNode;
|
||||
import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode;
|
||||
import jdk.nashorn.internal.ir.LiteralNode.PrimitiveLiteralNode;
|
||||
import jdk.nashorn.internal.ir.LoopNode;
|
||||
import jdk.nashorn.internal.ir.Node;
|
||||
import jdk.nashorn.internal.ir.ObjectNode;
|
||||
import jdk.nashorn.internal.ir.ReturnNode;
|
||||
import jdk.nashorn.internal.ir.RuntimeNode;
|
||||
import jdk.nashorn.internal.ir.Statement;
|
||||
@ -70,6 +73,7 @@ import jdk.nashorn.internal.ir.SwitchNode;
|
||||
import jdk.nashorn.internal.ir.Symbol;
|
||||
import jdk.nashorn.internal.ir.ThrowNode;
|
||||
import jdk.nashorn.internal.ir.TryNode;
|
||||
import jdk.nashorn.internal.ir.UnaryNode;
|
||||
import jdk.nashorn.internal.ir.VarNode;
|
||||
import jdk.nashorn.internal.ir.WhileNode;
|
||||
import jdk.nashorn.internal.ir.WithNode;
|
||||
@ -78,6 +82,8 @@ import jdk.nashorn.internal.ir.visitor.SimpleNodeVisitor;
|
||||
import jdk.nashorn.internal.parser.Token;
|
||||
import jdk.nashorn.internal.parser.TokenType;
|
||||
import jdk.nashorn.internal.runtime.Context;
|
||||
import jdk.nashorn.internal.runtime.ECMAErrors;
|
||||
import jdk.nashorn.internal.runtime.ErrorManager;
|
||||
import jdk.nashorn.internal.runtime.JSType;
|
||||
import jdk.nashorn.internal.runtime.Source;
|
||||
import jdk.nashorn.internal.runtime.logging.DebugLogger;
|
||||
@ -98,6 +104,7 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Lo
|
||||
|
||||
private final DebugLogger log;
|
||||
private final boolean es6;
|
||||
private final Source source;
|
||||
|
||||
// Conservative pattern to test if element names consist of characters valid for identifiers.
|
||||
// This matches any non-zero length alphanumeric string including _ and $ and not starting with a digit.
|
||||
@ -146,6 +153,7 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Lo
|
||||
|
||||
this.log = initLogger(compiler.getContext());
|
||||
this.es6 = compiler.getScriptEnvironment()._es6;
|
||||
this.source = compiler.getSource();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -241,6 +249,10 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Lo
|
||||
}
|
||||
}
|
||||
|
||||
if (es6 && expressionStatement.destructuringDeclarationType() != null) {
|
||||
throwNotImplementedYet("es6.destructuring", expressionStatement);
|
||||
}
|
||||
|
||||
return addStatement(node);
|
||||
}
|
||||
|
||||
@ -249,6 +261,14 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Lo
|
||||
return addStatement(blockStatement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enterForNode(final ForNode forNode) {
|
||||
if (es6 && (forNode.getInit() instanceof ObjectNode || forNode.getInit() instanceof ArrayLiteralNode)) {
|
||||
throwNotImplementedYet("es6.destructuring", forNode);
|
||||
}
|
||||
return super.enterForNode(forNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node leaveForNode(final ForNode forNode) {
|
||||
ForNode newForNode = forNode;
|
||||
@ -269,6 +289,37 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Lo
|
||||
return newForNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enterFunctionNode(final FunctionNode functionNode) {
|
||||
if (es6) {
|
||||
if (functionNode.getKind() == FunctionNode.Kind.MODULE) {
|
||||
throwNotImplementedYet("es6.module", functionNode);
|
||||
}
|
||||
|
||||
if (functionNode.getKind() == FunctionNode.Kind.GENERATOR) {
|
||||
throwNotImplementedYet("es6.generator", functionNode);
|
||||
}
|
||||
if (functionNode.usesSuper()) {
|
||||
throwNotImplementedYet("es6.super", functionNode);
|
||||
}
|
||||
|
||||
final int numParams = functionNode.getNumOfParams();
|
||||
if (numParams > 0) {
|
||||
final IdentNode lastParam = functionNode.getParameter(numParams - 1);
|
||||
if (lastParam.isRestParameter()) {
|
||||
throwNotImplementedYet("es6.rest.param", lastParam);
|
||||
}
|
||||
}
|
||||
for (final IdentNode param : functionNode.getParameters()) {
|
||||
if (param.isDestructuredParameter()) {
|
||||
throwNotImplementedYet("es6.destructuring", functionNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.enterFunctionNode(functionNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node leaveFunctionNode(final FunctionNode functionNode) {
|
||||
log.info("END FunctionNode: ", functionNode.getName());
|
||||
@ -577,6 +628,29 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Lo
|
||||
return tryNode.setCatchBlocks(lc, newCatchBlocks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enterUnaryNode(final UnaryNode unaryNode) {
|
||||
if (es6) {
|
||||
if (unaryNode.isTokenType(TokenType.YIELD) ||
|
||||
unaryNode.isTokenType(TokenType.YIELD_STAR)) {
|
||||
throwNotImplementedYet("es6.yield", unaryNode);
|
||||
} else if (unaryNode.isTokenType(TokenType.SPREAD_ARGUMENT) ||
|
||||
unaryNode.isTokenType(TokenType.SPREAD_ARRAY)) {
|
||||
throwNotImplementedYet("es6.spread", unaryNode);
|
||||
}
|
||||
}
|
||||
|
||||
return super.enterUnaryNode(unaryNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enterASSIGN(BinaryNode binaryNode) {
|
||||
if (es6 && (binaryNode.lhs() instanceof ObjectNode || binaryNode.lhs() instanceof ArrayLiteralNode)) {
|
||||
throwNotImplementedYet("es6.destructuring", binaryNode);
|
||||
}
|
||||
return super.enterASSIGN(binaryNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node leaveVarNode(final VarNode varNode) {
|
||||
addStatement(varNode);
|
||||
@ -608,6 +682,12 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Lo
|
||||
return addStatement(withNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enterClassNode(final ClassNode classNode) {
|
||||
throwNotImplementedYet("es6.class", classNode);
|
||||
return super.enterClassNode(classNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a function node that is a callee in a CallNode, replace it with
|
||||
* the appropriate marker function. This is used by {@link CodeGenerator}
|
||||
@ -766,4 +846,13 @@ final class Lower extends NodeOperatorVisitor<BlockLexicalContext> implements Lo
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void throwNotImplementedYet(final String msgId, final Node node) {
|
||||
final long token = node.getToken();
|
||||
final int line = source.getLine(node.getStart());
|
||||
final int column = source.getColumn(node.getStart());
|
||||
final String message = ECMAErrors.getMessage("unimplemented." + msgId);
|
||||
final String formatted = ErrorManager.format(message, source, line, column, token);
|
||||
throw new RuntimeException(formatted);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public abstract class NodeOperatorVisitor<T extends LexicalContext> extends Node
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean enterUnaryNode(final UnaryNode unaryNode) {
|
||||
public boolean enterUnaryNode(final UnaryNode unaryNode) {
|
||||
switch (unaryNode.tokenType()) {
|
||||
case ADD:
|
||||
return enterADD(unaryNode);
|
||||
|
@ -1962,6 +1962,18 @@ public class Parser extends AbstractParser implements Loggable {
|
||||
switch (type) {
|
||||
case SEMICOLON:
|
||||
// for (init; test; modify)
|
||||
if (varDeclList != null) {
|
||||
assert init == null;
|
||||
init = varDeclList.init;
|
||||
// late check for missing assignment, now we know it's a for (init; test; modify) loop
|
||||
if (varDeclList.missingAssignment != null) {
|
||||
if (varDeclList.missingAssignment instanceof IdentNode) {
|
||||
throw error(AbstractParser.message("missing.const.assignment", ((IdentNode)varDeclList.missingAssignment).getName()));
|
||||
} else {
|
||||
throw error(AbstractParser.message("missing.destructuring.assignment"), varDeclList.missingAssignment.getToken());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for each (init; test; modify) is invalid
|
||||
if ((flags & ForNode.IS_FOR_EACH) != 0) {
|
||||
|
@ -214,6 +214,7 @@ syntax.error.invalid.json=Invalid JSON: {0}
|
||||
syntax.error.strict.cant.delete=cannot delete "{0}" in strict mode
|
||||
syntax.error.redeclare.variable=Variable "{0}" has already been declared
|
||||
syntax.error.unprotected.switch.declaration=Unsupported {0} declaration in unprotected switch statement
|
||||
syntax.error.duplicate.parameter=Duplicate parameter name "{0}"
|
||||
|
||||
io.error.cant.write=cannot write "{0}"
|
||||
|
||||
@ -222,3 +223,12 @@ config.error.eagerCompilationConflictsWithOptimisticTypes={0}=false (eager compi
|
||||
|
||||
uri.error.bad.uri=Bad URI "{0}" near offset {1}
|
||||
list.adapter.null.global=Attempted to create the adapter from outside a JavaScript execution context.
|
||||
|
||||
unimplemented.es6.module=ES6 modules are not yet implemented
|
||||
unimplemented.es6.rest.param=ES6 function rest parameter declaration is not yet implemented
|
||||
unimplemented.es6.yield=ES6 yield and yield* are not yet implemented
|
||||
unimplemented.es6.spread=ES6 spread operator is not yet implemented
|
||||
unimplemented.es6.class=ES6 class declarations and expressions are not yet implemented
|
||||
unimplemented.es6.destructuring=ES6 destructuring is not yet implemented
|
||||
unimplemented.es6.generator=ES6 generator is not yet implemented
|
||||
unimplemented.es6.super=ES6 super keyword is not yet implemented
|
||||
|
36
nashorn/test/script/basic/es6/class.js
Normal file
36
nashorn/test/script/basic/es6/class.js
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Class declaration is not implemented
|
||||
*
|
||||
* @test
|
||||
* @run
|
||||
* @option --language=es6
|
||||
*/
|
||||
|
||||
try {
|
||||
eval("class Foo {}");
|
||||
} catch (e) {
|
||||
print(String(e).replace(/\\/g, "/"))
|
||||
}
|
3
nashorn/test/script/basic/es6/class.js.EXPECTED
Normal file
3
nashorn/test/script/basic/es6/class.js.EXPECTED
Normal file
@ -0,0 +1,3 @@
|
||||
java.lang.RuntimeException: test/script/basic/es6/class.js#33:3<eval>:1:0 ES6 class declarations and expressions are not yet implemented
|
||||
class Foo {}
|
||||
^
|
65
nashorn/test/script/basic/es6/destructuring.js
Normal file
65
nashorn/test/script/basic/es6/destructuring.js
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Destructuring is not implemented
|
||||
*
|
||||
* @test
|
||||
* @run
|
||||
* @option --language=es6
|
||||
*/
|
||||
|
||||
|
||||
function check(code) {
|
||||
try {
|
||||
eval(code);
|
||||
} catch (e) {
|
||||
print(String(e).replace(/\\/g, "/"))
|
||||
}
|
||||
}
|
||||
|
||||
check("var { x: y } = obj;");
|
||||
check("let { x: y } = obj;");
|
||||
check("const { x: y } = obj;");
|
||||
check("({ x: y }) = obj;");
|
||||
check("for (var { x: y } of obj) ;");
|
||||
check("for (let { x: y } of obj) ;");
|
||||
check("var { x, y } = obj;");
|
||||
check("let { x, y } = obj;");
|
||||
check("const { x, y } = obj;");
|
||||
check("({ x, y }) = obj;");
|
||||
check("for (var { x, y } of obj) ;");
|
||||
check("for (let { x, y } of obj) ;");
|
||||
check("var [a, b] = obj;");
|
||||
check("let [a, b] = obj;");
|
||||
check("const [a, b] = obj;");
|
||||
check("[a, b] = obj;");
|
||||
check("for ([a, b] of obj) ;");
|
||||
check("for (var [a, b] of obj) ;");
|
||||
check("for (let [a, b] of obj) ;");
|
||||
check("(function({ x: y }) { return x; })()");
|
||||
check("(function({ x }) { return x; })()");
|
||||
check("(function([x]) { return x; })()");
|
||||
check("for (var [[x, y, z] = [4, 5, 6]] = [7, 8, 9]; iterCount < 1; ) ;");
|
||||
check("for ([ arrow = () => {} ] of [[]]) ;");
|
||||
|
72
nashorn/test/script/basic/es6/destructuring.js.EXPECTED
Normal file
72
nashorn/test/script/basic/es6/destructuring.js.EXPECTED
Normal file
@ -0,0 +1,72 @@
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
|
||||
var { x: y } = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
|
||||
let { x: y } = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:6 ES6 destructuring is not yet implemented
|
||||
const { x: y } = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:1 ES6 destructuring is not yet implemented
|
||||
({ x: y }) = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
|
||||
for (var { x: y } of obj) ;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
|
||||
for (let { x: y } of obj) ;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
|
||||
var { x, y } = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
|
||||
let { x, y } = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:6 ES6 destructuring is not yet implemented
|
||||
const { x, y } = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:1 ES6 destructuring is not yet implemented
|
||||
({ x, y }) = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
|
||||
for (var { x, y } of obj) ;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
|
||||
for (let { x, y } of obj) ;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
|
||||
var [a, b] = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:4 ES6 destructuring is not yet implemented
|
||||
let [a, b] = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:6 ES6 destructuring is not yet implemented
|
||||
const [a, b] = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
|
||||
[a, b] = obj;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
|
||||
for ([a, b] of obj) ;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
|
||||
for (var [a, b] of obj) ;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
|
||||
for (let [a, b] of obj) ;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:9 ES6 destructuring is not yet implemented
|
||||
(function({ x: y }) { return x; })()
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:9 ES6 destructuring is not yet implemented
|
||||
(function({ x }) { return x; })()
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:9 ES6 destructuring is not yet implemented
|
||||
(function([x]) { return x; })()
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:9 ES6 destructuring is not yet implemented
|
||||
for (var [[x, y, z] = [4, 5, 6]] = [7, 8, 9]; iterCount < 1; ) ;
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/destructuring.js#35:6<eval>:1:0 ES6 destructuring is not yet implemented
|
||||
for ([ arrow = () => {} ] of [[]]) ;
|
||||
^
|
42
nashorn/test/script/basic/es6/generator.js
Normal file
42
nashorn/test/script/basic/es6/generator.js
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generators are not implemented
|
||||
*
|
||||
* @test
|
||||
* @run
|
||||
* @option --language=es6
|
||||
*/
|
||||
|
||||
function check(code) {
|
||||
try {
|
||||
eval(code);
|
||||
} catch (e) {
|
||||
print(String(e).replace(/\\/g, "/"))
|
||||
}
|
||||
}
|
||||
|
||||
check("function* func() { yield 1; }");
|
||||
check("({ * generatorMethod() { yield 1; } })");
|
||||
check("var func = function*() { yield 1; }");
|
9
nashorn/test/script/basic/es6/generator.js.EXPECTED
Normal file
9
nashorn/test/script/basic/es6/generator.js.EXPECTED
Normal file
@ -0,0 +1,9 @@
|
||||
java.lang.RuntimeException: test/script/basic/es6/generator.js#34:6<eval>:1:17 ES6 generator is not yet implemented
|
||||
function* func() { yield 1; }
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/generator.js#34:6<eval>:1:23 ES6 generator is not yet implemented
|
||||
({ * generatorMethod() { yield 1; } })
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/generator.js#34:6<eval>:1:23 ES6 generator is not yet implemented
|
||||
var func = function*() { yield 1; }
|
||||
^
|
46
nashorn/test/script/basic/es6/restparam.js
Normal file
46
nashorn/test/script/basic/es6/restparam.js
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ES6 rest params are not implemented
|
||||
*
|
||||
* @test
|
||||
* @run
|
||||
* @option --language=es6
|
||||
*/
|
||||
|
||||
|
||||
function check(code) {
|
||||
try {
|
||||
eval(code);
|
||||
} catch (e) {
|
||||
print(String(e).replace(/\\/g, "/"))
|
||||
}
|
||||
}
|
||||
|
||||
check("function func(...args) {}");
|
||||
check("function func(x, y, ...args) {}");
|
||||
check("({ meth(...args) {} })");
|
||||
check("({ meth(x, y, ...args) {} })");
|
||||
check("({ meth(x = 0, x) {} })");
|
||||
|
15
nashorn/test/script/basic/es6/restparam.js.EXPECTED
Normal file
15
nashorn/test/script/basic/es6/restparam.js.EXPECTED
Normal file
@ -0,0 +1,15 @@
|
||||
java.lang.RuntimeException: test/script/basic/es6/restparam.js#35:6<eval>:1:17 ES6 function rest parameter declaration is not yet implemented
|
||||
function func(...args) {}
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/restparam.js#35:6<eval>:1:23 ES6 function rest parameter declaration is not yet implemented
|
||||
function func(x, y, ...args) {}
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/restparam.js#35:6<eval>:1:11 ES6 function rest parameter declaration is not yet implemented
|
||||
({ meth(...args) {} })
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/restparam.js#35:6<eval>:1:17 ES6 function rest parameter declaration is not yet implemented
|
||||
({ meth(x, y, ...args) {} })
|
||||
^
|
||||
SyntaxError: test/script/basic/es6/restparam.js#35:6<eval>:1:15 Duplicate parameter name "x"
|
||||
({ meth(x = 0, x) {} })
|
||||
^
|
43
nashorn/test/script/basic/es6/spread.js
Normal file
43
nashorn/test/script/basic/es6/spread.js
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ES6 spread operator is not implemented
|
||||
*
|
||||
* @test
|
||||
* @run
|
||||
* @option --language=es6
|
||||
*/
|
||||
|
||||
function check(code) {
|
||||
try {
|
||||
eval(code);
|
||||
} catch (e) {
|
||||
print(String(e).replace(/\\/g, "/"))
|
||||
}
|
||||
}
|
||||
|
||||
check("var x = [...args]");
|
||||
check("var x = [1, 2, ...args]");
|
||||
check("var x = [...args, 3, 5]");
|
||||
check("var r = func(...arr)");
|
12
nashorn/test/script/basic/es6/spread.js.EXPECTED
Normal file
12
nashorn/test/script/basic/es6/spread.js.EXPECTED
Normal file
@ -0,0 +1,12 @@
|
||||
java.lang.RuntimeException: test/script/basic/es6/spread.js#34:8<eval>:1:9 ES6 spread operator is not yet implemented
|
||||
var x = [...args]
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/spread.js#34:8<eval>:1:15 ES6 spread operator is not yet implemented
|
||||
var x = [1, 2, ...args]
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/spread.js#34:8<eval>:1:9 ES6 spread operator is not yet implemented
|
||||
var x = [...args, 3, 5]
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/spread.js#34:8<eval>:1:13 ES6 spread operator is not yet implemented
|
||||
var r = func(...arr)
|
||||
^
|
42
nashorn/test/script/basic/es6/super.js
Normal file
42
nashorn/test/script/basic/es6/super.js
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ES6 super keyword is not implemented
|
||||
*
|
||||
* @test
|
||||
* @run
|
||||
* @option --language=es6
|
||||
*/
|
||||
|
||||
function check(code) {
|
||||
try {
|
||||
eval(code);
|
||||
} catch (e) {
|
||||
print(String(e).replace(/\\/g, "/"))
|
||||
}
|
||||
}
|
||||
|
||||
check("({ meth() { x = super.x } })");
|
||||
check("({ meth() { x = super.x() } })");
|
||||
check("({ meth() { x = super['x'] } })");
|
9
nashorn/test/script/basic/es6/super.js.EXPECTED
Normal file
9
nashorn/test/script/basic/es6/super.js.EXPECTED
Normal file
@ -0,0 +1,9 @@
|
||||
java.lang.RuntimeException: test/script/basic/es6/super.js#34:8<eval>:1:10 ES6 super keyword is not yet implemented
|
||||
({ meth() { x = super.x } })
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/super.js#34:8<eval>:1:10 ES6 super keyword is not yet implemented
|
||||
({ meth() { x = super.x() } })
|
||||
^
|
||||
java.lang.RuntimeException: test/script/basic/es6/super.js#34:8<eval>:1:10 ES6 super keyword is not yet implemented
|
||||
({ meth() { x = super['x'] } })
|
||||
^
|
Loading…
x
Reference in New Issue
Block a user