Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/async-gen-private-method/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-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. (Async Generator method as a ClassDeclaration element)
8 esid: prod-AsyncGeneratorPrivateMethod
9 features: [async-iteration, class-methods-private]
10 flags: [generated, onlyStrict]
11 negative:
12 phase: parse
13 type: SyntaxError
14 info: |
15 ClassElement :
16 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 async *#gen() {
34 callCount += 1;
35 (function() {
36 var yield;
37 throw new Test262Error();
38 }())
39 }
40 get gen() { return this.#gen; }
41 }
42
43 const c = new C();
44
45 // Test the private fields do not appear as properties before set to value
46 assert(
47 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
48 "#gen does not appear as an own property on C prototype"
49 );
50 assert(
51 !Object.prototype.hasOwnProperty.call(C, "#gen"),
52 "#gen does not appear as an own property on C constructor"
53 );
54 assert(
55 !Object.prototype.hasOwnProperty.call(c, "#gen"),
56 "#gen does not appear as an own property on C instance"
57 );
58
59 var iter = c.gen();
60
61
62
63 assert.sameValue(callCount, 1);
64
65 // Test the private fields do not appear as properties after set to value
66 assert(
67 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
68 "#gen does not appear as an own property on C prototype"
69 );
70 assert(
71 !Object.prototype.hasOwnProperty.call(C, "#gen"),
72 "#gen does not appear as an own property on C constructor"
73 );
74 assert(
75 !Object.prototype.hasOwnProperty.call(c, "#gen"),
76 "#gen does not appear as an own property on C instance"
77 );