From da0a8e33f02884508c1dc0f15b5d45683a7450e4 Mon Sep 17 00:00:00 2001 From: jugglinmike Date: Fri, 8 Jul 2016 21:43:32 -0400 Subject: [PATCH] Improve coverage for section 14: Functions and Classes (#717) * Add tests for early errors in functions * Improve tests for class accessors Use the `propertyHelper.js` utility in order to functionally test the property descriptors of class methods. * Remove redundant tests The semantics of an IdentifierReference as a PropertyDefinition within an object initializer are exhaustively tested by the files in this directory whose name match the pattern `prop-def-id-*.js`. Delete the redundant tests in favor of the more descriptively-named and more exhaustive alternatives. * Rename tests * Update test names to be more descriptive * Add tests for property descriptors of accessors * Add tests for runtime error during method dfn * Add test for observable iteration --- .../function/early-body-super-call.js | 14 ++++++ .../function/early-body-super-prop.js | 14 ++++++ .../function/early-params-super-call.js | 12 +++++ .../function/early-params-super-prop.js | 12 +++++ .../language/expressions/object/descriptor.js | 14 ------ .../expressions/object/getter-prop-desc.js | 37 +++++++++++++++ .../{getter.js => getter-super-prop.js} | 0 ...dentifier-reference-property-get-access.js | 9 ---- .../expressions/object/setter-prop-desc.js | 37 +++++++++++++++ .../{setter.js => setter-super-prop.js} | 0 ...nstructor-inferred-observable-iteration.js | 47 +++++++++++++++++++ .../getters-non-configurable-err.js | 17 +++++++ .../{getters.js => getters-prop-desc.js} | 19 ++++---- ...getters-2.js => getters-restricted-ids.js} | 0 .../setters-non-configurable-err.js | 17 +++++++ .../{setters.js => setters-prop-desc.js} | 20 ++++---- ...setters-2.js => setters-restricted-ids.js} | 0 .../static-method-gen-non-configurable-err.js | 17 +++++++ .../static-method-non-configurable-err.js | 17 +++++++ .../function/early-body-super-call.js | 14 ++++++ .../function/early-body-super-prop.js | 14 ++++++ .../function/early-params-super-call.js | 12 +++++ .../function/early-params-super-prop.js | 12 +++++ 23 files changed, 314 insertions(+), 41 deletions(-) create mode 100644 test/language/expressions/function/early-body-super-call.js create mode 100644 test/language/expressions/function/early-body-super-prop.js create mode 100644 test/language/expressions/function/early-params-super-call.js create mode 100644 test/language/expressions/function/early-params-super-prop.js delete mode 100644 test/language/expressions/object/descriptor.js create mode 100644 test/language/expressions/object/getter-prop-desc.js rename test/language/expressions/object/{getter.js => getter-super-prop.js} (100%) delete mode 100644 test/language/expressions/object/identifier-reference-property-get-access.js create mode 100644 test/language/expressions/object/setter-prop-desc.js rename test/language/expressions/object/{setter.js => setter-super-prop.js} (100%) create mode 100644 test/language/statements/class/constructor-inferred-observable-iteration.js create mode 100644 test/language/statements/class/definition/getters-non-configurable-err.js rename test/language/statements/class/definition/{getters.js => getters-prop-desc.js} (85%) rename test/language/statements/class/definition/{getters-2.js => getters-restricted-ids.js} (100%) create mode 100644 test/language/statements/class/definition/setters-non-configurable-err.js rename test/language/statements/class/definition/{setters.js => setters-prop-desc.js} (86%) rename test/language/statements/class/definition/{setters-2.js => setters-restricted-ids.js} (100%) create mode 100644 test/language/statements/class/static-method-gen-non-configurable-err.js create mode 100644 test/language/statements/class/static-method-non-configurable-err.js create mode 100644 test/language/statements/function/early-body-super-call.js create mode 100644 test/language/statements/function/early-body-super-prop.js create mode 100644 test/language/statements/function/early-params-super-call.js create mode 100644 test/language/statements/function/early-params-super-prop.js diff --git a/test/language/expressions/function/early-body-super-call.js b/test/language/expressions/function/early-body-super-call.js new file mode 100644 index 0000000000..8b31bb32f4 --- /dev/null +++ b/test/language/expressions/function/early-body-super-call.js @@ -0,0 +1,14 @@ +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Body may not contain a "super" call +info: > + It is a Syntax Error if FunctionBody Contains SuperCall is true. +negative: SyntaxError +---*/ + +0, function() { + super(); +}; diff --git a/test/language/expressions/function/early-body-super-prop.js b/test/language/expressions/function/early-body-super-prop.js new file mode 100644 index 0000000000..05e2f4b828 --- /dev/null +++ b/test/language/expressions/function/early-body-super-prop.js @@ -0,0 +1,14 @@ +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Body may not contain a "super" property reference +info: > + It is a Syntax Error if FunctionBody Contains SuperProperty is true. +negative: SyntaxError +---*/ + +0, function() { + super.x; +}; diff --git a/test/language/expressions/function/early-params-super-call.js b/test/language/expressions/function/early-params-super-call.js new file mode 100644 index 0000000000..6cac1bc103 --- /dev/null +++ b/test/language/expressions/function/early-params-super-call.js @@ -0,0 +1,12 @@ +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Parameters may not contain a "super" call +info: > + It is a Syntax Error if FormalParameters Contains SuperProperty is true. +negative: SyntaxError +---*/ + +0, function(x = super()) {}; diff --git a/test/language/expressions/function/early-params-super-prop.js b/test/language/expressions/function/early-params-super-prop.js new file mode 100644 index 0000000000..8ae2945d7d --- /dev/null +++ b/test/language/expressions/function/early-params-super-prop.js @@ -0,0 +1,12 @@ +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Parameters may not contain a "super" property reference +info: > + It is a Syntax Error if FunctionBody Contains SuperProperty is true. +negative: SyntaxError +---*/ + +0, function(x = super.x) {}; diff --git a/test/language/expressions/object/descriptor.js b/test/language/expressions/object/descriptor.js deleted file mode 100644 index cda7eea0c3..0000000000 --- a/test/language/expressions/object/descriptor.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 12.2.5 -description: > - object literal property shorthand desciptor defaults ----*/ -var x = 1; -var object = {x}; -var desc = Object.getOwnPropertyDescriptor(object, 'x'); -assert.sameValue(desc.value, 1, "The value of `desc.value` is `1`, where `var desc = Object.getOwnPropertyDescriptor(object, 'x');`"); -assert.sameValue(desc.enumerable, true, "The value of `desc.enumerable` is `true`, where `var desc = Object.getOwnPropertyDescriptor(object, 'x');`"); -assert.sameValue(desc.writable, true, "The value of `desc.writable` is `true`, where `var desc = Object.getOwnPropertyDescriptor(object, 'x');`"); -assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`, where `var desc = Object.getOwnPropertyDescriptor(object, 'x');`"); diff --git a/test/language/expressions/object/getter-prop-desc.js b/test/language/expressions/object/getter-prop-desc.js new file mode 100644 index 0000000000..440aa359c5 --- /dev/null +++ b/test/language/expressions/object/getter-prop-desc.js @@ -0,0 +1,37 @@ +// 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-object-initializer-runtime-semantics-evaluation +es6id: 12.2.6.8 +description: Property descriptor of "set" accessor methods +info: | + ObjectLiteral: + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + 3. ReturnIfAbrupt(status). + 4. Return obj. + + 14.3.8 Runtime Semantics: PropertyDefinitionEvaluation + + MethodDefinition : get PropertyName ( ) { FunctionBody} + + [...] + 9. Let desc be the PropertyDescriptor{[[Get]]: closure, [[Enumerable]]: + enumerable, [[Configurable]]: true}. + [...] +includes: [propertyHelper.js] +---*/ + +var obj = { get m() { return 1234; } }; +var desc = Object.getOwnPropertyDescriptor(obj, 'm'); + +verifyEnumerable(obj, 'm'); +verifyConfigurable(obj, 'm'); +assert.sameValue(desc.value, undefined, '`value` field'); +assert.sameValue(desc.set, undefined, '`set` field'); +assert.sameValue(typeof desc.get, 'function', 'type of `get` field'); +assert.sameValue(desc.get(), 1234, '`get` function return value'); diff --git a/test/language/expressions/object/getter.js b/test/language/expressions/object/getter-super-prop.js similarity index 100% rename from test/language/expressions/object/getter.js rename to test/language/expressions/object/getter-super-prop.js diff --git a/test/language/expressions/object/identifier-reference-property-get-access.js b/test/language/expressions/object/identifier-reference-property-get-access.js deleted file mode 100644 index af3dbd59c2..0000000000 --- a/test/language/expressions/object/identifier-reference-property-get-access.js +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (C) 2015 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -es6id: 12.2.5 -description: > - Basic identifier reference property initialization ----*/ -var p = "1"; -var o = {p}; diff --git a/test/language/expressions/object/setter-prop-desc.js b/test/language/expressions/object/setter-prop-desc.js new file mode 100644 index 0000000000..1be523b2dc --- /dev/null +++ b/test/language/expressions/object/setter-prop-desc.js @@ -0,0 +1,37 @@ +// 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-object-initializer-runtime-semantics-evaluation +es6id: 12.2.6.8 +description: Property descriptor of "set" accessor methods +info: | + ObjectLiteral: + { PropertyDefinitionList } + { PropertyDefinitionList , } + + 1. Let obj be ObjectCreate(%ObjectPrototype%). + 2. Let status be the result of performing PropertyDefinitionEvaluation of + PropertyDefinitionList with arguments obj and true. + 3. ReturnIfAbrupt(status). + 4. Return obj. + + 14.3.8 Runtime Semantics: PropertyDefinitionEvaluation + + MethodDefinition : set PropertyName ( PropertySetParameterList ) { FunctionBody } + + [...] + 8. Let desc be the PropertyDescriptor{[[Set]]: closure, [[Enumerable]]: + enumerable, [[Configurable]]: true}. + [...] +includes: [propertyHelper.js] +---*/ + +var obj = { set m(x) { return x; } }; +var desc = Object.getOwnPropertyDescriptor(obj, 'm'); + +verifyEnumerable(obj, 'm'); +verifyConfigurable(obj, 'm'); +assert.sameValue(desc.value, undefined, '`value` field'); +assert.sameValue(desc.get, undefined, '`get` field'); +assert.sameValue(typeof desc.set, 'function', 'type of `set` field'); +assert.sameValue(desc.set(436), 436, '`set` function return value'); diff --git a/test/language/expressions/object/setter.js b/test/language/expressions/object/setter-super-prop.js similarity index 100% rename from test/language/expressions/object/setter.js rename to test/language/expressions/object/setter-super-prop.js diff --git a/test/language/statements/class/constructor-inferred-observable-iteration.js b/test/language/statements/class/constructor-inferred-observable-iteration.js new file mode 100644 index 0000000000..5513333b27 --- /dev/null +++ b/test/language/statements/class/constructor-inferred-observable-iteration.js @@ -0,0 +1,47 @@ +// 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-runtime-semantics-classdefinitionevaluation +es6id: 14.5.14 +description: > + Observable iteration of arguments during execution of "inferred" constructor +info: | + [...] + 10. If constructor is empty, then + a. If ClassHeritageopt is present and protoParent is not null, then + i. Let constructor be the result of parsing the source text + + constructor(... args){ super (...args);} + + using the syntactic grammar with the goal symbol MethodDefinition[~Yield]. +features: [Symbol.iterator] +---*/ + +var otherIterator = ['fifth', 'sixth', 'seventh'][Symbol.iterator](); +var spread, parentArgs; +function Parent() { + parentArgs = arguments; +} +class C extends Parent {} + +Array.prototype[Symbol.iterator] = function() { + spread = this; + return otherIterator; +}; + +new C('first', 'second', 'third', 'fourth'); + +assert.sameValue(Object.getPrototypeOf(spread), Array.prototype); +assert.sameValue(spread.length, 4); +assert.sameValue(spread[0], 'first'); +assert.sameValue(spread[1], 'second'); +assert.sameValue(spread[2], 'third'); +assert.sameValue(spread[3], 'fourth'); + +assert.sameValue( + typeof parentArgs, 'object', 'parent arguments object' +); +assert.sameValue(parentArgs.length, 3); +assert.sameValue(parentArgs[0], 'fifth'); +assert.sameValue(parentArgs[1], 'sixth'); +assert.sameValue(parentArgs[2], 'seventh'); diff --git a/test/language/statements/class/definition/getters-non-configurable-err.js b/test/language/statements/class/definition/getters-non-configurable-err.js new file mode 100644 index 0000000000..cafa78e514 --- /dev/null +++ b/test/language/statements/class/definition/getters-non-configurable-err.js @@ -0,0 +1,17 @@ +// 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-method-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.3.9 +description: Failure to define property for static method +info: | + [...] + 9. Let desc be the PropertyDescriptor{[[Get]]: closure, [[Enumerable]]: + enumerable, [[Configurable]]: true}. + 10. Return ? DefinePropertyOrThrow(object, propKey, desc). +features: [generators] +---*/ + +assert.throws(TypeError, function() { + class C { static get ['prototype']() {} } +}); diff --git a/test/language/statements/class/definition/getters.js b/test/language/statements/class/definition/getters-prop-desc.js similarity index 85% rename from test/language/statements/class/definition/getters.js rename to test/language/statements/class/definition/getters-prop-desc.js index 368eb14ddf..463614680b 100644 --- a/test/language/statements/class/definition/getters.js +++ b/test/language/statements/class/definition/getters-prop-desc.js @@ -1,15 +1,16 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-class-definitions es6id: 14.5 -description: > - class getters +description: Class methods - "get" accessors +includes: [propertyHelper.js] ---*/ function assertGetterDescriptor(object, name) { var desc = Object.getOwnPropertyDescriptor(object, name); - assert.sameValue(desc.configurable, true, "The value of `desc.configurable` is `true`"); - assert.sameValue(desc.enumerable, false, "The value of `desc.enumerable` is `false`"); + verifyNotEnumerable(object, name); + verifyConfigurable(object, name); assert.sameValue(typeof desc.get, 'function', "`typeof desc.get` is `'function'`"); assert.sameValue('prototype' in desc.get, false, "The result of `'prototype' in desc.get` is `false`"); assert.sameValue(desc.set, undefined, "The value of `desc.set` is `undefined`"); @@ -22,12 +23,12 @@ class C { static get staticY() { return 4; } } -assertGetterDescriptor(C.prototype, 'x'); -assertGetterDescriptor(C.prototype, 'y'); -assertGetterDescriptor(C, 'staticX'); -assertGetterDescriptor(C, 'staticY'); - assert.sameValue(new C().x, 1, "The value of `new C().x` is `1`. Defined as `get x() { return 1; }`"); assert.sameValue(C.staticX, 2, "The value of `C.staticX` is `2`. Defined as `static get staticX() { return 2; }`"); assert.sameValue(new C().y, 3, "The value of `new C().y` is `3`. Defined as `get y() { return 3; }`"); assert.sameValue(C.staticY, 4, "The value of `C.staticY` is `4`. Defined as `static get staticY() { return 4; }`"); + +assertGetterDescriptor(C.prototype, 'x'); +assertGetterDescriptor(C.prototype, 'y'); +assertGetterDescriptor(C, 'staticX'); +assertGetterDescriptor(C, 'staticY'); diff --git a/test/language/statements/class/definition/getters-2.js b/test/language/statements/class/definition/getters-restricted-ids.js similarity index 100% rename from test/language/statements/class/definition/getters-2.js rename to test/language/statements/class/definition/getters-restricted-ids.js diff --git a/test/language/statements/class/definition/setters-non-configurable-err.js b/test/language/statements/class/definition/setters-non-configurable-err.js new file mode 100644 index 0000000000..8c4e3a8892 --- /dev/null +++ b/test/language/statements/class/definition/setters-non-configurable-err.js @@ -0,0 +1,17 @@ +// 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-method-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.3.9 +description: Failure to define property for static method +info: | + [...] + 8. Let desc be the PropertyDescriptor{[[Set]]: closure, [[Enumerable]]: + enumerable, [[Configurable]]: true}. + 9. Return ? DefinePropertyOrThrow(object, propKey, desc). +features: [generators] +---*/ + +assert.throws(TypeError, function() { + class C { static set ['prototype'](_) {} } +}); diff --git a/test/language/statements/class/definition/setters.js b/test/language/statements/class/definition/setters-prop-desc.js similarity index 86% rename from test/language/statements/class/definition/setters.js rename to test/language/statements/class/definition/setters-prop-desc.js index 2ab3284542..055307aaea 100644 --- a/test/language/statements/class/definition/setters.js +++ b/test/language/statements/class/definition/setters-prop-desc.js @@ -1,14 +1,16 @@ // Copyright (C) 2014 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-class-definitions es6id: 14.5 -description: > - class setters +description: Class methods - "set" accessors +includes: [propertyHelper.js] ---*/ + function assertSetterDescriptor(object, name) { var descr = Object.getOwnPropertyDescriptor(object, name); - assert.sameValue(descr.configurable, true, "The value of `descr.configurable` is `true`"); - assert.sameValue(descr.enumerable, false, "The value of `descr.enumerable` is `false`"); + verifyNotEnumerable(object, name); + verifyConfigurable(object, name); assert.sameValue(typeof descr.set, 'function', "`typeof descr.set` is `'function'`"); assert.sameValue('prototype' in descr.set, false, "The result of `'prototype' in descr.set` is `false`"); assert.sameValue(descr.get, undefined, "The value of `descr.get` is `undefined`"); @@ -22,11 +24,6 @@ class C { static set staticY(v) { staticY = v; } } -assertSetterDescriptor(C.prototype, 'x'); -assertSetterDescriptor(C.prototype, 'y'); -assertSetterDescriptor(C, 'staticX'); -assertSetterDescriptor(C, 'staticY'); - assert.sameValue(new C().x = 1, 1, "`new C().x = 1` is `1`"); assert.sameValue(x, 1, "The value of `x` is `1`"); assert.sameValue(C.staticX = 2, 2, "`C.staticX = 2` is `2`"); @@ -35,3 +32,8 @@ assert.sameValue(new C().y = 3, 3, "`new C().y = 3` is `3`"); assert.sameValue(y, 3, "The value of `y` is `3`"); assert.sameValue(C.staticY = 4, 4, "`C.staticY = 4` is `4`"); assert.sameValue(staticY, 4, "The value of `staticY` is `4`"); + +assertSetterDescriptor(C.prototype, 'x'); +assertSetterDescriptor(C.prototype, 'y'); +assertSetterDescriptor(C, 'staticX'); +assertSetterDescriptor(C, 'staticY'); diff --git a/test/language/statements/class/definition/setters-2.js b/test/language/statements/class/definition/setters-restricted-ids.js similarity index 100% rename from test/language/statements/class/definition/setters-2.js rename to test/language/statements/class/definition/setters-restricted-ids.js diff --git a/test/language/statements/class/static-method-gen-non-configurable-err.js b/test/language/statements/class/static-method-gen-non-configurable-err.js new file mode 100644 index 0000000000..249f647d85 --- /dev/null +++ b/test/language/statements/class/static-method-gen-non-configurable-err.js @@ -0,0 +1,17 @@ +// 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-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.4.13 +description: Failure to define property for static generator method +info: | + [...] + 10. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: + true, [[Enumerable]]: enumerable, [[Configurable]]: true}. + 11. Return ? DefinePropertyOrThrow(object, propKey, desc). +features: [generators] +---*/ + +assert.throws(TypeError, function() { + class C { static *['prototype']() {} } +}); diff --git a/test/language/statements/class/static-method-non-configurable-err.js b/test/language/statements/class/static-method-non-configurable-err.js new file mode 100644 index 0000000000..d245b33ef5 --- /dev/null +++ b/test/language/statements/class/static-method-non-configurable-err.js @@ -0,0 +1,17 @@ +// 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-method-definitions-runtime-semantics-propertydefinitionevaluation +es6id: 14.3.9 +description: Failure to define property for static method +info: | + [...] + 10. Let desc be the PropertyDescriptor{[[Value]]: closure, [[Writable]]: + true, [[Enumerable]]: enumerable, [[Configurable]]: true}. + 11. Return ? DefinePropertyOrThrow(object, propKey, desc). +features: [generators] +---*/ + +assert.throws(TypeError, function() { + class C { static ['prototype']() {} } +}); diff --git a/test/language/statements/function/early-body-super-call.js b/test/language/statements/function/early-body-super-call.js new file mode 100644 index 0000000000..fa3c2a24d2 --- /dev/null +++ b/test/language/statements/function/early-body-super-call.js @@ -0,0 +1,14 @@ +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Body may not contain a "super" call +info: > + It is a Syntax Error if FunctionBody Contains SuperCall is true. +negative: SyntaxError +---*/ + +function f() { + super(); +} diff --git a/test/language/statements/function/early-body-super-prop.js b/test/language/statements/function/early-body-super-prop.js new file mode 100644 index 0000000000..b1602ff856 --- /dev/null +++ b/test/language/statements/function/early-body-super-prop.js @@ -0,0 +1,14 @@ +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Body may not contain a "super" property reference +info: > + It is a Syntax Error if FunctionBody Contains SuperProperty is true. +negative: SyntaxError +---*/ + +function f() { + super.x; +} diff --git a/test/language/statements/function/early-params-super-call.js b/test/language/statements/function/early-params-super-call.js new file mode 100644 index 0000000000..be1ff3d6e4 --- /dev/null +++ b/test/language/statements/function/early-params-super-call.js @@ -0,0 +1,12 @@ +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Parameters may not contain a "super" call +info: > + It is a Syntax Error if FormalParameters Contains SuperProperty is true. +negative: SyntaxError +---*/ + +function f(x = super()) {} diff --git a/test/language/statements/function/early-params-super-prop.js b/test/language/statements/function/early-params-super-prop.js new file mode 100644 index 0000000000..2dbe965d87 --- /dev/null +++ b/test/language/statements/function/early-params-super-prop.js @@ -0,0 +1,12 @@ +// 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-function-definitions-static-semantics-early-errors +es6id: 14.1.2 +description: Parameters may not contain a "super" property reference +info: > + It is a Syntax Error if FunctionBody Contains SuperProperty is true. +negative: SyntaxError +---*/ + +function f(x = super.x) {}