Add tests for valid identifier names also listed as reserved words

Ref #2285
This commit is contained in:
Leo Balter 2019-08-14 16:40:35 -04:00
parent 65fd8d30a3
commit cf32265765
8 changed files with 226 additions and 0 deletions

View File

@ -0,0 +1,12 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: default is a valid identifier name, using extended escape
template: default
---*/
//- declareWith
def\u{61}ult
//- referenceWith
default

View File

@ -0,0 +1,12 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: default is a valid identifier name, using escape
template: default
---*/
//- declareWith
def\u0061ult
//- referenceWith
default

View File

@ -0,0 +1,12 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: default is a valid identifier name
template: default
---*/
//- declareWith
default
//- referenceWith
default

View File

@ -0,0 +1,44 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/class/ident-name-method-def-
name: MethodDefinition
esid: prod-PropertyDefinition
info: |
ObjectLiteral :
{ PropertyDefinitionList }
{ PropertyDefinitionList , }
PropertyDefinitionList:
PropertyDefinition
PropertyDefinitionList , PropertyDefinition
PropertyDefinition:
MethodDefinition
...
MethodDefinition:
PropertyName ( UniqueFormalParameters ){ FunctionBody }
PropertyName:
LiteralPropertyName
...
LiteralPropertyName:
IdentifierName
...
Reserved Words
A reserved word is an IdentifierName that cannot be used as an Identifier.
features: [class]
---*/
var C = class {
/*{ declareWith }*/() { return 42; }
}
var obj = new C();
assert.sameValue(obj['/*{ referenceWith }*/'](), 42, 'property exists');

View File

@ -0,0 +1,44 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/statements/class/ident-name-method-def-
name: MethodDefinition
esid: prod-PropertyDefinition
info: |
ObjectLiteral :
{ PropertyDefinitionList }
{ PropertyDefinitionList , }
PropertyDefinitionList:
PropertyDefinition
PropertyDefinitionList , PropertyDefinition
PropertyDefinition:
MethodDefinition
...
MethodDefinition:
PropertyName ( UniqueFormalParameters ){ FunctionBody }
PropertyName:
LiteralPropertyName
...
LiteralPropertyName:
IdentifierName
...
Reserved Words
A reserved word is an IdentifierName that cannot be used as an Identifier.
features: [class]
---*/
class C {
/*{ declareWith }*/() { return 42; }
}
var obj = new C();
assert.sameValue(obj['/*{ referenceWith }*/'](), 42, 'property exists');

View File

@ -0,0 +1,21 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/assignment/member-expr-ident-name-
name: MemberExpression IdentifierName
esid: prod-PropertyDefinition
info: |
MemberExpression:
...
MemberExpression . IdentifierName
Reserved Words
A reserved word is an IdentifierName that cannot be used as an Identifier.
---*/
var obj = {};
obj./*{ declareWith }*/ = 42;
assert.sameValue(obj['/*{ referenceWith }*/'], 42, 'property exists');

View File

@ -0,0 +1,41 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/object/ident-name-method-def-
name: MethodDefinition
esid: prod-PropertyDefinition
info: |
ObjectLiteral :
{ PropertyDefinitionList }
{ PropertyDefinitionList , }
PropertyDefinitionList:
PropertyDefinition
PropertyDefinitionList , PropertyDefinition
PropertyDefinition:
MethodDefinition
...
MethodDefinition:
PropertyName ( UniqueFormalParameters ){ FunctionBody }
PropertyName:
LiteralPropertyName
...
LiteralPropertyName:
IdentifierName
...
Reserved Words
A reserved word is an IdentifierName that cannot be used as an Identifier.
---*/
var obj = {
/*{ declareWith }*/() { return 42; }
};
assert.sameValue(obj['/*{ referenceWith }*/'](), 42, 'property exists');

View File

@ -0,0 +1,40 @@
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/object/ident-name-prop-name-literal-
name: PropertyName
esid: prod-PropertyDefinition
info: |
ObjectLiteral :
{ PropertyDefinitionList }
{ PropertyDefinitionList , }
PropertyDefinitionList:
PropertyDefinition
PropertyDefinitionList , PropertyDefinition
PropertyDefinition:
IdentifierReference
PropertyName : AssignmentExpression
MethodDefinition
... AssignmentExpression
...
PropertyName:
LiteralPropertyName
...
LiteralPropertyName:
IdentifierName
...
Reserved Words
A reserved word is an IdentifierName that cannot be used as an Identifier.
---*/
var obj = {
/*{ declareWith }*/: 42
};
assert.sameValue(obj['/*{ referenceWith }*/'], 42, 'property exists');