diff --git a/src/class-fields/propname-constructor.case b/src/class-fields/propname-constructor.case new file mode 100644 index 0000000000..a700e99119 --- /dev/null +++ b/src/class-fields/propname-constructor.case @@ -0,0 +1,18 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Static class fields cannot have PropName 'constructor' +info: | + + // This test file tests the following early error: + Static Semantics: Early Errors + + ClassElement : FieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "constructor". +features: [class-fields] +template: propname-error +---*/ + +//- propname +constructor diff --git a/src/class-fields/propname-error/cls-decl-computed-name.template b/src/class-fields/propname-error/cls-decl-computed-name.template new file mode 100644 index 0000000000..72e252f808 --- /dev/null +++ b/src/class-fields/propname-error/cls-decl-computed-name.template @@ -0,0 +1,22 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions-static-semantics-early-errors +path: language/statements/class/fields-computed-name- +name: computed +info: | + Static Semantics: PropName + ... + ComputedPropertyName : [ AssignmentExpression ] + Return empty. +---*/ + +var x = "/*{ propname }*/"; +class C { + /*{ static }*/ [x]; +} + +var c = new C(); + +assert.sameValue(c.hasOwnProperty("/*{ propname }*/"), true); diff --git a/src/class-fields/propname-error/cls-decl-literal-name.template b/src/class-fields/propname-error/cls-decl-literal-name.template new file mode 100644 index 0000000000..b51b78ef20 --- /dev/null +++ b/src/class-fields/propname-error/cls-decl-literal-name.template @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions-static-semantics-early-errors +path: language/statements/class/fields-literal-name- +name: literal name +negative: + type: SyntaxError + phase: early +info: | + Static Semantics: PropName + LiteralPropertyName : IdentifierName + Return StringValue of IdentifierName. +---*/ + +throw "Test262: This statement should not be evaluated."; + +class C { + /*{ static }*/ /*{ propname }*/; +} diff --git a/src/class-fields/propname-error/cls-decl-string-name.template b/src/class-fields/propname-error/cls-decl-string-name.template new file mode 100644 index 0000000000..173990f660 --- /dev/null +++ b/src/class-fields/propname-error/cls-decl-string-name.template @@ -0,0 +1,22 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions-static-semantics-early-errors +path: language/statements/class/fields-string-name- +name: string name +negative: + type: SyntaxError + phase: early +info: | + Static Semantics: PropName + ... + LiteralPropertyName:StringLiteral + Return the String value whose code units are the SV of the StringLiteral. +---*/ + +throw "Test262: This statement should not be evaluated."; + +class C { + /*{ static }*/ '/*{ propname }*/'; +} diff --git a/src/class-fields/propname-error/cls-expr-computed-name.template b/src/class-fields/propname-error/cls-expr-computed-name.template new file mode 100644 index 0000000000..dc37681833 --- /dev/null +++ b/src/class-fields/propname-error/cls-expr-computed-name.template @@ -0,0 +1,22 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions-static-semantics-early-errors +path: language/expressions/class/fields-computed-name- +name: computed +info: | + Static Semantics: PropName + ... + ComputedPropertyName : [ AssignmentExpression ] + Return empty. +---*/ + +var x = "/*{ propname }*/"; +var C = class { + /*{ static }*/ [x]; +} + +var c = new C(); + +assert.sameValue(c.hasOwnProperty("/*{ propname }*/"), true); diff --git a/src/class-fields/propname-error/cls-expr-literal-name.template b/src/class-fields/propname-error/cls-expr-literal-name.template new file mode 100644 index 0000000000..84d8310abb --- /dev/null +++ b/src/class-fields/propname-error/cls-expr-literal-name.template @@ -0,0 +1,21 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions-static-semantics-early-errors +path: language/expressions/class/fields-literal-name- +name: literal name +negative: + type: SyntaxError + phase: early +info: | + Static Semantics: PropName + LiteralPropertyName : IdentifierName + Return StringValue of IdentifierName. +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class { + /*{ static }*/ /*{ propname }*/; +} diff --git a/src/class-fields/propname-error/cls-expr-string-name.template b/src/class-fields/propname-error/cls-expr-string-name.template new file mode 100644 index 0000000000..b6a3af65c2 --- /dev/null +++ b/src/class-fields/propname-error/cls-expr-string-name.template @@ -0,0 +1,22 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-class-definitions-static-semantics-early-errors +path: language/expressions/class/fields-string-name- +name: string name +negative: + type: SyntaxError + phase: early +info: | + Static Semantics: PropName + ... + LiteralPropertyName:StringLiteral + Return the String value whose code units are the SV of the StringLiteral. +---*/ + +throw "Test262: This statement should not be evaluated."; + +var C = class { + /*{ static }*/ '/*{ propname }*/'; +} diff --git a/src/class-fields/static-propname-constructor.case b/src/class-fields/static-propname-constructor.case new file mode 100644 index 0000000000..ffa6754e20 --- /dev/null +++ b/src/class-fields/static-propname-constructor.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Static class field cannot have PropName 'constructor' +info: | + + // This test file tests the following early error: + Static Semantics: Early Errors + + ClassElement : staticFieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". +features: [class-fields] +template: propname-error +---*/ + +//- static +static +//- propname +constructor diff --git a/src/class-fields/static-propname-prototype.case b/src/class-fields/static-propname-prototype.case new file mode 100644 index 0000000000..9b2e9ab331 --- /dev/null +++ b/src/class-fields/static-propname-prototype.case @@ -0,0 +1,20 @@ +// Copyright (C) 2017 Valerie Young. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +desc: Static class fields cannot have PropName 'prototype' +info: | + + // This test file tests the following early error: + Static Semantics: Early Errors + + ClassElement : staticFieldDefinition; + It is a Syntax Error if PropName of FieldDefinition is "prototype" or "constructor". +features: [class-fields] +template: propname-error +---*/ + +//- static +static +//- propname +prototype