Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-identifier-strict-strict.js

raw
1 // |reftest| error:SyntaxError
2 'use strict';
3 // This file was procedurally generated from the following sources:
4 // - src/async-generators/yield-identifier-strict.case
5 // - src/async-generators/default/async-class-decl-static-private-method.template
6 /*---
7 description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Static async generator method as a ClassDeclaration element)
8 esid: prod-AsyncGeneratorPrivateMethod
9 features: [async-iteration, class-static-methods-private]
10 flags: [generated, onlyStrict]
11 negative:
12 phase: parse
13 type: SyntaxError
14 info: |
15 ClassElement :
16 static PrivateMethodDefinition
17
18 MethodDefinition :
19 AsyncGeneratorMethod
20
21 Async Generator Function Definitions
22
23 AsyncGeneratorMethod :
24 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters ) { AsyncGeneratorBody }
25
26 ---*/
27 $DONOTEVALUATE();
28
29
30 var callCount = 0;
31
32 class C {
33 static async *#gen() {
34 callCount += 1;
35 (function() {
36 var yield;
37 throw new Test262Error();
38 }())
39 }
40 static get gen() { return this.#gen; }
41 }
42
43 // Test the private fields do not appear as properties before set to value
44 assert(
45 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
46 "#gen does not appear as an own property on C prototype"
47 );
48 assert(
49 !Object.prototype.hasOwnProperty.call(C, "#gen"),
50 "#gen does not appear as an own property on C constructor"
51 );
52
53 var iter = C.gen();
54
55
56
57 assert.sameValue(callCount, 1);
58
59 // Test the private fields do not appear as properties after set to value
60 assert(
61 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
62 "#gen does not appear as an own property on C prototype"
63 );
64 assert(
65 !Object.prototype.hasOwnProperty.call(C, "#gen"),
66 "#gen does not appear as an own property on C constructor"
67 );