Add test for asi between `get`/`set` field and generator (#4189)

Co-authored-by: André Bargull <andre.bargull@gmail.com>
Co-authored-by: Linus Groh <mail@linusgroh.de>
This commit is contained in:
Nicolò Ribaudo 2024-09-02 17:39:12 +02:00 committed by GitHub
parent d62fa93c8f
commit d012a4d0ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 126 additions and 0 deletions

View File

@ -0,0 +1,63 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ASI between a field named "get" and a generator method
esid: prod-ClassElement
features: [class-fields-public, class-static-fields-public, class, generators]
info: |
ClassElement :
MethodDefinition
FieldDefinition ;
static FieldDefinition ;
;
MethodDefinition :
GeneratorMethod
get ClassElementName () { FunctionBody }
GeneratorMethod :
* ClassElementName ( UniqueFormalParameters ) { GeneratorBody }
FieldDefinition :
ClassElementName Initializer _opt
ClassElementName :
PropertyName
PrivateName
PropertyName :
LiteralPropertyName
ComputedPropertyName
LiteralPropertyName :
IdentifierName
StringLiteral
NumericLiteral
---*/
class A {
get
*a() {}
}
class B {
static get
*a() {}
}
assert(
A.prototype.hasOwnProperty("a"),
"(A) The generator is installed on the prototype"
);
assert(
new A().hasOwnProperty("get"),
"(A) The field is installed on class instances"
);
assert(
B.prototype.hasOwnProperty("a"),
"(B) The generator is installed on the prototype"
);
assert(
B.hasOwnProperty("get"),
"(B) The field is installed on class"
);

View File

@ -0,0 +1,63 @@
// Copyright (C) 2024 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ASI between a field named "set" and a generator method
esid: prod-ClassElement
features: [class-fields-public, class]
info: |
ClassElement :
MethodDefinition
FieldDefinition ;
static FieldDefinition ;
;
MethodDefinition :
GeneratorMethod
set ClassElementName ( PropertySetParameterList ) { FunctionBody }
GeneratorMethod :
* ClassElementName ( UniqueFormalParameters ) { GeneratorBody }
FieldDefinition :
ClassElementName Initializer _opt
ClassElementName :
PropertyName
PrivateName
PropertyName :
LiteralPropertyName
ComputedPropertyName
LiteralPropertyName :
IdentifierName
StringLiteral
NumericLiteral
---*/
class A {
set
*a(x) {}
}
class B {
static set
*a(x) {}
}
assert(
A.prototype.hasOwnProperty("a"),
"(A) The generator is installed on the prototype"
);
assert(
new A().hasOwnProperty("set"),
"(A) The field is installed on class instances"
);
assert(
B.prototype.hasOwnProperty("a"),
"(B) The generator is installed on the prototype"
);
assert(
B.hasOwnProperty("set"),
"(B) The field is installed on class"
);