Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/syntax/valid/grammar-field-named-get-followed-by-generator-asi.js

raw
1 // Copyright (C) 2024 Igalia, S.L. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 description: ASI between a field named "get" and a generator method
5 esid: prod-ClassElement
6 features: [class-fields-public, class-static-fields-public, class, generators]
7 info: |
8 ClassElement :
9 MethodDefinition
10 FieldDefinition ;
11 static FieldDefinition ;
12 ;
13
14 MethodDefinition :
15 GeneratorMethod
16 get ClassElementName () { FunctionBody }
17
18 GeneratorMethod :
19 * ClassElementName ( UniqueFormalParameters ) { GeneratorBody }
20
21 FieldDefinition :
22 ClassElementName Initializer _opt
23
24 ClassElementName :
25 PropertyName
26 PrivateName
27
28 PropertyName :
29 LiteralPropertyName
30 ComputedPropertyName
31
32 LiteralPropertyName :
33 IdentifierName
34 StringLiteral
35 NumericLiteral
36 ---*/
37
38 class A {
39 get
40 *a() {}
41 }
42
43 class B {
44 static get
45 *a() {}
46 }
47
48 assert(
49 A.prototype.hasOwnProperty("a"),
50 "(A) The generator is installed on the prototype"
51 );
52 assert(
53 new A().hasOwnProperty("get"),
54 "(A) The field is installed on class instances"
55 );
56 assert(
57 B.prototype.hasOwnProperty("a"),
58 "(B) The generator is installed on the prototype"
59 );
60 assert(
61 B.hasOwnProperty("get"),
62 "(B) The field is installed on class"
63 );
64
65 reportCompare(0, 0);