Skip to content
Snippets Groups Projects
Commit 458e33af authored by Valerie R Young's avatar Valerie R Young
Browse files

classfields: add tests for forbidden propertynames

parent f8456c6d
No related branches found
No related tags found
No related merge requests found
// 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
// 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);
// 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 }*/;
}
// 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 }*/';
}
// 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);
// 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 }*/;
}
// 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 }*/';
}
// 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
// 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment