diff --git a/test/language/eval-code/direct/super-call-arrow.js b/test/language/eval-code/direct/super-call-arrow.js new file mode 100644 index 0000000000..a86e1d67ae --- /dev/null +++ b/test/language/eval-code/direct/super-call-arrow.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: > + A direct eval in the functon code of an ArrowFunction may not contain + SuperCall +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. +features: [super, arrow-function] +---*/ + +var caught; +var f = () => eval('super();'); + +try { + f(); +} catch (err) { + caught = err; +} + +assert.sameValue(typeof caught, 'object'); +assert.sameValue(caught.constructor, SyntaxError); diff --git a/test/language/eval-code/direct/super-call-fn.js b/test/language/eval-code/direct/super-call-fn.js new file mode 100644 index 0000000000..542343d6c0 --- /dev/null +++ b/test/language/eval-code/direct/super-call-fn.js @@ -0,0 +1,26 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: > + A direct eval in the functon code of a non-ArrowFunction may contain + SuperCall +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. +features: [super] +---*/ + +var executed = false; +function f() { + eval('executed = true; super();'); +} + +assert.throws(ReferenceError, function() { + f(); +}); + +assert.sameValue(executed, true); diff --git a/test/language/eval-code/direct/super-call.js b/test/language/eval-code/direct/super-call.js new file mode 100644 index 0000000000..10cef4b42d --- /dev/null +++ b/test/language/eval-code/direct/super-call.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: A direct eval in global code may not contain SuperCall +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. +features: [super] +---*/ + +var caught; + +try { + eval('super();'); +} catch (err) { + caught = err; +} + +assert.sameValue(typeof caught, 'object'); +assert.sameValue(caught.constructor, SyntaxError); diff --git a/test/language/eval-code/direct/super-prop-arrow.js b/test/language/eval-code/direct/super-prop-arrow.js new file mode 100644 index 0000000000..d0aa710681 --- /dev/null +++ b/test/language/eval-code/direct/super-prop-arrow.js @@ -0,0 +1,27 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: > + A direct eval in the functon code of an ArrowFunction may not contain + SuperProperty +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. +features: [super, arrow-function] +---*/ + +var caught; +var f = () => eval('super.property;'); + +try { + f(); +} catch (err) { + caught = err; +} + +assert.sameValue(typeof caught, 'object'); +assert.sameValue(caught.constructor, SyntaxError); diff --git a/test/language/eval-code/direct/super-prop-method.js b/test/language/eval-code/direct/super-prop-method.js new file mode 100644 index 0000000000..f7a6f5c953 --- /dev/null +++ b/test/language/eval-code/direct/super-prop-method.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: > + A direct eval in the functon code of a non-ArrowFunction may contain + SuperProperty +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. +features: [super] +---*/ + +var superProp = null; +var o = { + test262: null, + method() { + superProp = eval('super.test262;'); + } +}; + +o.method(); + +assert.sameValue(superProp, undefined); + +Object.setPrototypeOf(o, { test262: 262 }); + +o.method(); + +assert.sameValue(superProp, 262); diff --git a/test/language/eval-code/direct/super-prop.js b/test/language/eval-code/direct/super-prop.js new file mode 100644 index 0000000000..99780e7d28 --- /dev/null +++ b/test/language/eval-code/direct/super-prop.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: A direct eval in global code may not contain SuperProperty +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. +features: [super] +---*/ + +var caught; + +try { + eval('super.property;'); +} catch (err) { + caught = err; +} + +assert.sameValue(typeof caught, 'object'); +assert.sameValue(caught.constructor, SyntaxError); diff --git a/test/language/eval-code/indirect/super-call.js b/test/language/eval-code/indirect/super-call.js new file mode 100644 index 0000000000..ad00384b0b --- /dev/null +++ b/test/language/eval-code/indirect/super-call.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: > + An indirect eval may not contain SuperCall +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. +features: [super] +---*/ + +var caught; + +try { + (0,eval)('super();'); +} catch (err) { + caught = err; +} + +assert.sameValue(typeof caught, 'object', 'object value thrown (global code)'); +assert.sameValue( + caught.constructor, SyntaxError, 'SyntaxError thrown (global code)' +); + +caught = null; + +try { + ({ + m() { + (0,eval)('super();'); + } + }).m(); +} catch (err) { + caught = err; +} + +assert.sameValue( + typeof caught, 'object', 'object value thrown (function code)' +); +assert.sameValue( + caught.constructor, SyntaxError, 'SyntaxError thrown (function code)' +); diff --git a/test/language/eval-code/indirect/super-prop.js b/test/language/eval-code/indirect/super-prop.js new file mode 100644 index 0000000000..93e76e579b --- /dev/null +++ b/test/language/eval-code/indirect/super-prop.js @@ -0,0 +1,46 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: > + An indirect eval may not contain SuperProperty +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. +features: [super] +---*/ + +var caught; + +try { + (0,eval)('super.property;'); +} catch (err) { + caught = err; +} + +assert.sameValue(typeof caught, 'object', 'object value thrown (global code)'); +assert.sameValue( + caught.constructor, SyntaxError, 'SyntaxError thrown (global code)' +); + +caught = null; + +try { + ({ + m() { + (0,eval)('super.property;'); + } + }).m(); +} catch (err) { + caught = err; +} + +assert.sameValue( + typeof caught, 'object', 'object value thrown (function code)' +); +assert.sameValue( + caught.constructor, SyntaxError, 'SyntaxError thrown (function code)' +); diff --git a/test/language/global-code/return.js b/test/language/global-code/return.js new file mode 100644 index 0000000000..e9d3383426 --- /dev/null +++ b/test/language/global-code/return.js @@ -0,0 +1,18 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts +es6id: 15.1 +description: ReturnStatement may not be used directly within global code +info: | + Syntax + + Script : + ScriptBodyopt + + ScriptBody : + StatementList[~Yield, ~Return] +negative: SyntaxError +---*/ + +return; diff --git a/test/language/global-code/super-call-arrow.js b/test/language/global-code/super-call-arrow.js new file mode 100644 index 0000000000..a61130413d --- /dev/null +++ b/test/language/global-code/super-call-arrow.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: An ArrowFunction in global code may not contain SuperCall +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. + + 14.2.3 Static Semantics: Contains + + With parameter symbol. + + ArrowFunction : ArrowParameters => ConciseBody + + 1. If symbol is not one of NewTarget, SuperProperty, SuperCall, super or + this, return false. + 2. If ArrowParameters Contains symbol is true, return true. + 3. Return ConciseBody Contains symbol. + + NOTE Normally, Contains does not look inside most function forms. However, + Contains is used to detect new.target, this, and super usage within an + ArrowFunction. +features: [super, arrow-function] +negative: SyntaxError +---*/ + +() => { + super(); +}; diff --git a/test/language/global-code/super-call.js b/test/language/global-code/super-call.js new file mode 100644 index 0000000000..fc5f87a1bb --- /dev/null +++ b/test/language/global-code/super-call.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: Global code may not contain SuperCall +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. +negative: SyntaxError +features: [super] +---*/ + +super(); diff --git a/test/language/global-code/super-prop-arrow.js b/test/language/global-code/super-prop-arrow.js new file mode 100644 index 0000000000..30f85698d8 --- /dev/null +++ b/test/language/global-code/super-prop-arrow.js @@ -0,0 +1,33 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: An ArrowFunction in global code may not contain SuperProperty +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. + + 14.2.3 Static Semantics: Contains + + With parameter symbol. + + ArrowFunction : ArrowParameters => ConciseBody + + 1. If symbol is not one of NewTarget, SuperProperty, SuperCall, super or + this, return false. + 2. If ArrowParameters Contains symbol is true, return true. + 3. Return ConciseBody Contains symbol. + + NOTE Normally, Contains does not look inside most function forms. However, + Contains is used to detect new.target, this, and super usage within an + ArrowFunction. +features: [super, arrow-function] +negative: SyntaxError +---*/ + +() => { + super.property; +}; diff --git a/test/language/global-code/super-prop.js b/test/language/global-code/super-prop.js new file mode 100644 index 0000000000..b91d67cb4f --- /dev/null +++ b/test/language/global-code/super-prop.js @@ -0,0 +1,16 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts-static-semantics-early-errors +es6id: 15.1.1 +description: Global code may not contain SuperProperty +info: | + - It is a Syntax Error if StatementList Contains super unless the source code + containing super is eval code that is being processed by a direct eval that + is contained in function code that is not the function code of an + ArrowFunction. +negative: SyntaxError +features: [super] +---*/ + +super.property; diff --git a/test/language/global-code/yield-non-strict.js b/test/language/global-code/yield-non-strict.js new file mode 100644 index 0000000000..72c063f083 --- /dev/null +++ b/test/language/global-code/yield-non-strict.js @@ -0,0 +1,24 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts +es6id: 15.1 +description: > + The `yield` token is interpreted as an Identifier when it appears in global + code (non-strict mode) +info: | + Syntax + + Script : + ScriptBodyopt + + ScriptBody : + StatementList[~Yield, ~Return] +flags: [noStrict] +---*/ + +// Avoid test failures in cases where the host has defined a `yield` property +// on the global object. +try { + yield = 0; +} catch (_) {} diff --git a/test/language/global-code/yield-strict.js b/test/language/global-code/yield-strict.js new file mode 100644 index 0000000000..24e912bb5a --- /dev/null +++ b/test/language/global-code/yield-strict.js @@ -0,0 +1,21 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-scripts +es6id: 15.1 +description: > + The `yield` token is interpreted as an Identifier when it appears in global + code (strict mode) +info: | + Syntax + + Script : + ScriptBodyopt + + ScriptBody : + StatementList[~Yield, ~Return] +flags: [onlyStrict] +negative: SyntaxError +---*/ + +yield; diff --git a/test/language/module-code/parse-err-return.js b/test/language/module-code/parse-err-return.js new file mode 100644 index 0000000000..e51e894a8d --- /dev/null +++ b/test/language/module-code/parse-err-return.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-modules +es6id: 15.2 +description: ReturnStatement may not be used directly within ModuleBody +info: | + Syntax + + Module : + ModuleBodyopt + + ModuleBody : + ModuleItemList + + ModuleItemList : + ModuleItem + ModuleItemList ModuleItem + + ModuleItem: + ImportDeclaration + ExportDeclaration + StatementListItem[~Yield, ~Return] +flags: [module] +negative: SyntaxError +---*/ + +return; diff --git a/test/language/module-code/parse-err-yield.js b/test/language/module-code/parse-err-yield.js new file mode 100644 index 0000000000..34600568a2 --- /dev/null +++ b/test/language/module-code/parse-err-yield.js @@ -0,0 +1,28 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-modules +es6id: 15.2 +description: YieldExpression may not be used directly within ModuleBody +info: | + Syntax + + Module : + ModuleBodyopt + + ModuleBody : + ModuleItemList + + ModuleItemList : + ModuleItem + ModuleItemList ModuleItem + + ModuleItem: + ImportDeclaration + ExportDeclaration + StatementListItem[~Yield, ~Return] +flags: [module] +negative: SyntaxError +---*/ + +yield;