-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decorators: add initial tests on class
- Loading branch information
1 parent
509363b
commit 6f8e0f6
Showing
27 changed files
with
1,045 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/class-elements/field-definition-accessor-no-line-terminator.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (C) 2022 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
desc: Valid accessor FieldDefinition, ClassElementName, PropertyName Syntax | ||
info: | | ||
FieldDefinition[Yield, Await] : | ||
accessor [no LineTerminator here] ClassElementName[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt | ||
|
||
template: default | ||
features: [decorators] | ||
---*/ | ||
|
||
//- elements | ||
accessor | ||
$; | ||
static accessor | ||
$; | ||
|
||
//- assertions | ||
let c = new C(); | ||
|
||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, 'accessor'), false); | ||
assert.sameValue(Object.hasOwnProperty.call(C.prototype, '$'), false); | ||
assert.sameValue(Object.hasOwnProperty.call(C, 'accessor'), true); | ||
assert.sameValue(Object.hasOwnProperty.call(C, '$'), true); | ||
assert.sameValue(Object.hasOwnProperty.call(c, 'accessor'), true); | ||
assert.sameValue(Object.hasOwnProperty.call(c, '$'), true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2022 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
desc: Valid accessor FieldDefinition, ClassElementName, PropertyName Syntax | ||
info: | | ||
FieldDefinition[Yield, Await] : | ||
ClassElementName[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt | ||
accessor [no LineTerminator here] ClassElementName[?Yield, ?Await] Initializer[+In, ?Yield, ?Await]opt | ||
|
||
template: syntax/valid | ||
features: [decorators] | ||
---*/ | ||
|
||
//- elements | ||
accessor $; | ||
accessor _; | ||
accessor \u{6F}; | ||
accessor \u2118; | ||
accessor ZW_\u200C_NJ; | ||
accessor ZW_\u200D_J; |
44 changes: 44 additions & 0 deletions
44
src/decorator/decorator-call-expr-identifier-reference.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (C) 2022 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
desc: > | ||
Decorator @ DecoratorCallExpression | ||
info: | | ||
DecoratorCallExpression[Yield, Await] : | ||
DecoratorMemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await] | ||
|
||
DecoratorMemberExpression[Yield, Await] : | ||
IdentifierReference[?Yield, ?Await] | ||
PrivateIdentifier | ||
DecoratorMemberExpression[?Yield, ?Await] . IdentifierName | ||
|
||
IdentifierReference[Yield, Await] : | ||
Identifier | ||
[~Yield] yield | ||
[~Await] await | ||
|
||
template: syntax/valid | ||
---*/ | ||
|
||
//- setup | ||
function decorator() { | ||
return () => {}; | ||
} | ||
var _ = decorator; | ||
var \u{6F} = decorator; | ||
var \u2118 = decorator; | ||
var ZW_\u200C_NJ = decorator; | ||
var ZW_\u200D_J = decorator; | ||
var yield = decorator; | ||
var await = decorator; | ||
|
||
//- decorators | ||
@$() | ||
@_() | ||
@\u{6F}() | ||
@\u2118() | ||
@ZW_\u200C_NJ() | ||
@ZW_\u200D_J() | ||
@yield() | ||
@await() |
36 changes: 36 additions & 0 deletions
36
src/decorator/decorator-member-expr-decorator-member-expr.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (C) 2022 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
desc: > | ||
Decorator @ DecoratorMemberExpression | ||
info: | | ||
DecoratorMemberExpression[Yield, Await] : | ||
IdentifierReference[?Yield, ?Await] | ||
PrivateIdentifier | ||
DecoratorMemberExpression[?Yield, ?Await] . IdentifierName | ||
|
||
template: syntax/valid | ||
---*/ | ||
|
||
//- setup | ||
let ns = { | ||
$() {} | ||
_() {} | ||
\u{6F}() {} | ||
\u2118() {} | ||
ZW_\u200C_NJ() {} | ||
ZW_\u200D_J() {} | ||
yield() {} | ||
await() {} | ||
} | ||
|
||
//- decorators | ||
@ns.$ | ||
@ns._ | ||
@ns.\u{6F} | ||
@ns.\u2118 | ||
@ns.ZW_\u200C_NJ | ||
@ns.ZW_\u200D_J | ||
@ns.yield | ||
@ns.await |
33 changes: 33 additions & 0 deletions
33
src/decorator/decorator-member-expr-identifier-reference.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (C) 2022 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
desc: > | ||
Decorator @ DecoratorMemberExpression | ||
info: | | ||
IdentifierReference[Yield, Await] : | ||
Identifier | ||
[~Yield] yield | ||
[~Await] await | ||
template: syntax/valid | ||
---*/ | ||
|
||
//- setup | ||
function $() {} | ||
function _() {} | ||
function \u{6F}() {} | ||
function \u2118() {} | ||
function ZW_\u200C_NJ() {} | ||
function ZW_\u200D_J() {} | ||
function yield() {} | ||
function await() {} | ||
|
||
//- decorators | ||
@$ | ||
@_ | ||
@\u{6F} | ||
@\u2118 | ||
@ZW_\u200C_NJ | ||
@ZW_\u200D_J | ||
@yield | ||
@await |
35 changes: 35 additions & 0 deletions
35
src/decorator/decorator-member-expr-private-identifier.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (C) 2022 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
desc: > | ||
Decorator @ DecoratorMemberExpression | ||
info: | | ||
DecoratorMemberExpression[Yield, Await] : | ||
PrivateIdentifier | ||
|
||
PrivateIdentifier :: | ||
# IdentifierName | ||
|
||
template: syntax/class-valid | ||
---*/ | ||
|
||
//- elements | ||
static #$() {} | ||
static #_() {} | ||
static #\u{6F}() {} | ||
static #\u2118() {} | ||
static #ZW_\u200C_NJ() {} | ||
static #ZW_\u200D_J() {} | ||
static #yield() {} | ||
static #await() {} | ||
|
||
//- decorators | ||
@#$ | ||
@#_ | ||
@#\u{6F} | ||
@#\u2118 | ||
@#ZW_\u200C_NJ | ||
@#ZW_\u200D_J | ||
@#yield | ||
@#await |
47 changes: 47 additions & 0 deletions
47
src/decorator/decorator-parenthesized-expr-identifier-reference.case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (C) 2022 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
desc: > | ||
Decorator @ DecoratorParenthesizedExpression | ||
info: | | ||
DecoratorParenthesizedExpression[Yield, Await] : | ||
( Expression[+In, ?Yield, ?Await] ) | ||
|
||
PrimaryExpression[Yield, Await] : | ||
this | ||
IdentifierReference[?Yield, ?Await] | ||
Literal | ||
ArrayLiteral[?Yield, ?Await] | ||
ObjectLiteral[?Yield, ?Await] | ||
FunctionExpression | ||
ClassExpression[?Yield, ?Await] | ||
GeneratorExpression | ||
AsyncFunctionExpression | ||
AsyncGeneratorExpression | ||
RegularExpressionLiteral | ||
TemplateLiteral[?Yield, ?Await, ~Tagged] | ||
CoverParenthesizedExpressionAndArrowParameterList[?Yield, ?Await] | ||
|
||
template: syntax/valid | ||
---*/ | ||
|
||
//- setup | ||
function $() {} | ||
function _() {} | ||
function \u{6F}() {} | ||
function \u2118() {} | ||
function ZW_\u200C_NJ() {} | ||
function ZW_\u200D_J() {} | ||
function yield() {} | ||
function await() {} | ||
|
||
//- decorators | ||
@($) | ||
@(_) | ||
@(\u{6F}) | ||
@(\u2118) | ||
@(ZW_\u200C_NJ) | ||
@(ZW_\u200D_J) | ||
@(yield) | ||
@(await) |
30 changes: 30 additions & 0 deletions
30
src/decorator/syntax/class-valid/cls-decl-decorators-valid-syntax.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (C) 2022 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: prod-ClassDeclaration | ||
name: Valid syntax for decorator on class declaration in class body. | ||
path: language/statements/class/decorator/syntax/class-valid/ | ||
info: | | ||
ClassDeclaration[Yield, Await, Default] : | ||
DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await] | ||
[+Default] DecoratorList[?Yield, ?Await]opt class ClassTail[?Yield, ?Await] | ||
|
||
DecoratorList[Yield, Await] : | ||
DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] | ||
|
||
Decorator[Yield, Await] : | ||
@ DecoratorMemberExpression[?Yield, ?Await] | ||
@ DecoratorParenthesizedExpression[?Yield, ?Await] | ||
@ DecoratorCallExpression[?Yield, ?Await] | ||
|
||
... | ||
features: [class, decorators] | ||
---*/ | ||
|
||
class C { | ||
/*{ elements }*/ | ||
static { | ||
/*{ decorators }*/ class C {} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/decorator/syntax/class-valid/cls-expr-decorators-valid-syntax.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) 2022 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: prod-ClassExpression | ||
name: Valid syntax for decorator on class expression in class body. | ||
path: language/expressions/class/decorator/syntax/class-valid/ | ||
info: | | ||
ClassExpression[Yield, Await] : | ||
DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await]opt ClassTail[?Yield, ?Await] | ||
|
||
DecoratorList[Yield, Await] : | ||
DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] | ||
|
||
Decorator[Yield, Await] : | ||
@ DecoratorMemberExpression[?Yield, ?Await] | ||
@ DecoratorParenthesizedExpression[?Yield, ?Await] | ||
@ DecoratorCallExpression[?Yield, ?Await] | ||
|
||
... | ||
features: [class, decorators] | ||
---*/ | ||
|
||
var C = class { | ||
/*{ elements }*/ | ||
static { | ||
var C = /*{ decorators }*/ class {} | ||
} | ||
}; |
25 changes: 25 additions & 0 deletions
25
src/decorator/syntax/valid/cls-decl-decorators-valid-syntax.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (C) 2022 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: prod-ClassDeclaration | ||
name: Valid syntax for decorator on class. | ||
path: language/statements/class/decorator/syntax/valid/ | ||
info: | | ||
ClassDeclaration[Yield, Await, Default] : | ||
DecoratorList[?Yield, ?Await]opt class BindingIdentifier[?Yield, ?Await] ClassTail[?Yield, ?Await] | ||
[+Default] DecoratorList[?Yield, ?Await]opt class ClassTail[?Yield, ?Await] | ||
|
||
DecoratorList[Yield, Await] : | ||
DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] | ||
|
||
Decorator[Yield, Await] : | ||
@ DecoratorMemberExpression[?Yield, ?Await] | ||
@ DecoratorParenthesizedExpression[?Yield, ?Await] | ||
@ DecoratorCallExpression[?Yield, ?Await] | ||
|
||
... | ||
features: [class, decorators] | ||
---*/ | ||
|
||
/*{ decorators }*/ class C {} |
34 changes: 34 additions & 0 deletions
34
src/decorator/syntax/valid/cls-element-decorators-valid-syntax.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (C) 2022 Chengzhong Wu. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: prod-ClassDeclaration | ||
name: Valid syntax for decorator on class. | ||
path: language/statements/class/decorator/syntax/valid/ | ||
info: | | ||
ClassElement[Yield, Await] : | ||
DecoratorList[?Yield, ?Await]opt MethodDefinition[?Yield, ?Await] | ||
DecoratorList[?Yield, ?Await]opt static MethodDefinition[?Yield, ?Await] | ||
DecoratorList[?Yield, ?Await]opt FieldDefinition[?Yield, ?Await] ; | ||
DecoratorList[?Yield, ?Await]opt static FieldDefinition[?Yield, ?Await] ; | ||
ClassStaticBlock | ||
; | ||
|
||
DecoratorList[Yield, Await] : | ||
DecoratorList[?Yield, ?Await]opt Decorator[?Yield, ?Await] | ||
|
||
Decorator[Yield, Await] : | ||
@ DecoratorMemberExpression[?Yield, ?Await] | ||
@ DecoratorParenthesizedExpression[?Yield, ?Await] | ||
@ DecoratorCallExpression[?Yield, ?Await] | ||
|
||
... | ||
features: [class, decorators] | ||
---*/ | ||
|
||
class C { | ||
/*{ decorators }*/ method() {} | ||
/*{ decorators }*/ static method() {} | ||
/*{ decorators }*/ field; | ||
/*{ decorators }*/ static field; | ||
} |
Oops, something went wrong.