Class Fields: Remove templates that cause erroneous tests to be created.

This commit is contained in:
Rick Waldron 2018-07-30 18:10:35 -04:00 committed by Leo Balter
parent ac7bc64e73
commit 3996741ca0
22 changed files with 355 additions and 234 deletions

View File

@ -1,18 +0,0 @@
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: class fields forbid 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, class-fields-public]
template: propname-error
---*/
//- propname
constructor

View File

@ -1,23 +0,0 @@
// 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: no early error -- PropName of ComputedPropertyName not forbidden value
info: |
Static Semantics: PropName
...
ComputedPropertyName : [ AssignmentExpression ]
Return empty.
---*/
var x = "/*{ propname }*/";
class C {
[x];
}
var c = new C();
assert.sameValue(c.hasOwnProperty("/*{ propname }*/"), true);
assert.sameValue(C.hasOwnProperty("/*{ propname }*/"), false);

View File

@ -1,21 +0,0 @@
// 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: early error -- PropName of IdentifierName is forbidden value
negative:
type: SyntaxError
phase: parse
info: |
Static Semantics: PropName
LiteralPropertyName : IdentifierName
Return StringValue of IdentifierName.
---*/
throw "Test262: This statement should not be evaluated.";
class C {
/*{ propname }*/;
}

View File

@ -1,22 +0,0 @@
// 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: early error -- PropName of StringLiteral is forbidden value
negative:
type: SyntaxError
phase: parse
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 {
'/*{ propname }*/';
}

View File

@ -1,22 +0,0 @@
// 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-variable-name-
name: no early error -- PropName of ComputedPropertyName not forbidden value
info: |
Static Semantics: PropName
...
ComputedPropertyName : [ AssignmentExpression ]
Return empty.
---*/
var /*{ propname }*/ = 'foo';
class C {
/*{ static }*/ [/*{ propname }*/];
}
var c = new C();
assert.sameValue(c.hasOwnProperty("foo"), true);

View File

@ -1,23 +0,0 @@
// 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: no early error -- PropName of ComputedPropertyName not forbidden value
info: |
Static Semantics: PropName
...
ComputedPropertyName : [ AssignmentExpression ]
Return empty.
---*/
var x = "/*{ propname }*/";
var C = class {
[x];
};
var c = new C();
assert.sameValue(c.hasOwnProperty("/*{ propname }*/"), true);
assert.sameValue(C.hasOwnProperty("/*{ propname }*/"), false);

View File

@ -1,21 +0,0 @@
// 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: early error -- PropName of IdentifierName is forbidden
negative:
type: SyntaxError
phase: parse
info: |
Static Semantics: PropName
LiteralPropertyName : IdentifierName
Return StringValue of IdentifierName.
---*/
throw "Test262: This statement should not be evaluated.";
var C = class {
/*{ propname }*/;
};

View File

@ -1,22 +0,0 @@
// 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: early error -- PropName of StringLiteral is forbidden
negative:
type: SyntaxError
phase: parse
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 {
'/*{ propname }*/';
};

View File

@ -1,22 +0,0 @@
// 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-variable-name-
name: no early error -- PropName of ComputedPropertyName not forbidden value
info: |
Static Semantics: PropName
...
ComputedPropertyName : [ AssignmentExpression ]
Return empty.
---*/
var /*{ propname }*/ = 'foo';
var C = class {
/*{ static }*/ [/*{ propname }*/];
}
var c = new C();
assert.sameValue(c.hasOwnProperty("foo"), true);

View File

@ -1,20 +0,0 @@
// 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 forbid 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

@ -1,20 +0,0 @@
// 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 forbid 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

View File

@ -0,0 +1,35 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/init-err-contains-arguments.case
// - src/class-fields/initializer-error/cls-decl-fields-static-comp-name.template
/*---
description: Syntax error if `arguments` used in class field (static computed ClassElementName)
esid: sec-class-definitions-static-semantics-early-errors
features: [class, class-fields-public]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Static Semantics: Early Errors
FieldDefinition:
PropertyNameInitializeropt
- It is a Syntax Error if ContainsArguments of Initializer is true.
Static Semantics: ContainsArguments
IdentifierReference : Identifier
1. If the StringValue of Identifier is "arguments", return true.
...
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
---*/
throw "Test262: This statement should not be evaluated.";
var x = "string";
class C {
static [x] = arguments;
}

View File

@ -0,0 +1,28 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/init-err-contains-super.case
// - src/class-fields/initializer-error/cls-decl-fields-static-comp-name.template
/*---
description: Syntax error if `super()` used in class field (static computed ClassElementName)
esid: sec-class-definitions-static-semantics-early-errors
features: [class, class-fields-public]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Static Semantics: Early Errors
FieldDefinition:
PropertyNameInitializeropt
- It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true.
---*/
throw "Test262: This statement should not be evaluated.";
var x = "string";
class C {
static [x] = super();
}

View File

@ -0,0 +1,34 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/init-err-contains-arguments.case
// - src/class-fields/initializer-error/cls-decl-fields-static-literal-name.template
/*---
description: Syntax error if `arguments` used in class field (static literal ClassElementName)
esid: sec-class-definitions-static-semantics-early-errors
features: [class, class-fields-public]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Static Semantics: Early Errors
FieldDefinition:
PropertyNameInitializeropt
- It is a Syntax Error if ContainsArguments of Initializer is true.
Static Semantics: ContainsArguments
IdentifierReference : Identifier
1. If the StringValue of Identifier is "arguments", return true.
...
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
---*/
throw "Test262: This statement should not be evaluated.";
class C {
static x = arguments;
}

View File

@ -0,0 +1,27 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/init-err-contains-super.case
// - src/class-fields/initializer-error/cls-decl-fields-static-literal-name.template
/*---
description: Syntax error if `super()` used in class field (static literal ClassElementName)
esid: sec-class-definitions-static-semantics-early-errors
features: [class, class-fields-public]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Static Semantics: Early Errors
FieldDefinition:
PropertyNameInitializeropt
- It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true.
---*/
throw "Test262: This statement should not be evaluated.";
class C {
static x = super();
}

View File

@ -0,0 +1,34 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/init-err-contains-arguments.case
// - src/class-fields/initializer-error/cls-decl-fields-static-private-name.template
/*---
description: Syntax error if `arguments` used in class field (static PrivateName)
esid: sec-class-definitions-static-semantics-early-errors
features: [class, class-fields-public]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Static Semantics: Early Errors
FieldDefinition:
PropertyNameInitializeropt
- It is a Syntax Error if ContainsArguments of Initializer is true.
Static Semantics: ContainsArguments
IdentifierReference : Identifier
1. If the StringValue of Identifier is "arguments", return true.
...
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
---*/
throw "Test262: This statement should not be evaluated.";
class C {
static #x = arguments;
}

View File

@ -0,0 +1,27 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/init-err-contains-super.case
// - src/class-fields/initializer-error/cls-decl-fields-static-private-name.template
/*---
description: Syntax error if `super()` used in class field (static PrivateName)
esid: sec-class-definitions-static-semantics-early-errors
features: [class, class-fields-public]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Static Semantics: Early Errors
FieldDefinition:
PropertyNameInitializeropt
- It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true.
---*/
throw "Test262: This statement should not be evaluated.";
class C {
static #x = super();
}

View File

@ -0,0 +1,45 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/static-private-names.case
// - src/class-fields/default/cls-decl.template
/*---
description: literal private names (field definitions in a class declaration)
esid: prod-FieldDefinition
features: [class, class-fields-public]
flags: [generated]
info: |
ClassElement:
...
static FieldDefinition ;
FieldDefinition:
ClassElementName Initializer_opt
ClassElementName:
PrivateName
PrivateName:
# IdentifierName
---*/
class C {
static #x; static #y
}
// Test the private fields do not appear as properties before set to value
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
// Test if private fields can be sucessfully accessed and set to value
assert.sameValue(C.x(), 42, "test 7");
assert.sameValue(C.y(), 43, "test 8");
// Test the private fields do not appear as properties before after set to value
assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 9");
assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 10");

View File

@ -0,0 +1,34 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/init-err-contains-arguments.case
// - src/class-fields/initializer-error/cls-decl-fields-static-string-literal-name.template
/*---
description: Syntax error if `arguments` used in class field (static string literal ClassElementName)
esid: sec-class-definitions-static-semantics-early-errors
features: [class, class-fields-public]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Static Semantics: Early Errors
FieldDefinition:
PropertyNameInitializeropt
- It is a Syntax Error if ContainsArguments of Initializer is true.
Static Semantics: ContainsArguments
IdentifierReference : Identifier
1. If the StringValue of Identifier is "arguments", return true.
...
For all other grammatical productions, recurse on all nonterminals. If any piece returns true, then return true. Otherwise return false.
---*/
throw "Test262: This statement should not be evaluated.";
class C {
static 'x' = arguments;
}

View File

@ -0,0 +1,27 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/init-err-contains-super.case
// - src/class-fields/initializer-error/cls-decl-fields-static-string-literal-name.template
/*---
description: Syntax error if `super()` used in class field (static string literal ClassElementName)
esid: sec-class-definitions-static-semantics-early-errors
features: [class, class-fields-public]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Static Semantics: Early Errors
FieldDefinition:
PropertyNameInitializeropt
- It is a Syntax Error if Initializer is present and Initializer Contains SuperCall is true.
---*/
throw "Test262: This statement should not be evaluated.";
class C {
static 'x' = super();
}

View File

@ -0,0 +1,32 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/static-propname-constructor.case
// - src/class-fields/propname-error/cls-decl-string-name.template
/*---
description: static class field forbid PropName 'constructor' (early error -- PropName of StringLiteral is forbidden value)
esid: sec-class-definitions-static-semantics-early-errors
features: [class-fields]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Static Semantics: PropName
...
LiteralPropertyName : StringLiteral
Return the String value whose code units are the SV of the StringLiteral.
// 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".
---*/
throw "Test262: This statement should not be evaluated.";
class C {
'constructor';
}

View File

@ -0,0 +1,32 @@
// This file was procedurally generated from the following sources:
// - src/class-fields/static-propname-prototype.case
// - src/class-fields/propname-error/cls-decl-string-name.template
/*---
description: static class fields forbid PropName 'prototype' (early error -- PropName of StringLiteral is forbidden value)
esid: sec-class-definitions-static-semantics-early-errors
features: [class-fields]
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Static Semantics: PropName
...
LiteralPropertyName : StringLiteral
Return the String value whose code units are the SV of the StringLiteral.
// 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".
---*/
throw "Test262: This statement should not be evaluated.";
class C {
'prototype';
}