classfields: add tests for forbidden propertynames

This commit is contained in:
Valerie R Young 2017-10-20 20:03:09 -04:00
parent f8456c6dac
commit 458e33afe3
9 changed files with 188 additions and 0 deletions

View File

@ -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

View File

@ -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);

View File

@ -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 }*/;
}

View File

@ -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 }*/';
}

View File

@ -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);

View File

@ -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 }*/;
}

View File

@ -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 }*/';
}

View File

@ -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

View File

@ -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