Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/async-gen-private-method-static/yield-identifier-spread-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-spread-strict.case
5 // - src/async-generators/default/async-class-decl-static-private-method.template
6 /*---
7 description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static async generator method as a ClassDeclaration element)
8 esid: prod-AsyncGeneratorPrivateMethod
9 features: [object-spread, 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 Spread Properties
28
29 PropertyDefinition[Yield]:
30 (...)
31 ...AssignmentExpression[In, ?Yield]
32
33 ---*/
34 $DONOTEVALUATE();
35
36
37 var callCount = 0;
38
39 class C {
40 static async *#gen() {
41 callCount += 1;
42 return {
43 ...(function() {
44 var yield;
45 throw new Test262Error();
46 }()),
47 }
48 }
49 static get gen() { return this.#gen; }
50 }
51
52 // Test the private fields do not appear as properties before set to value
53 assert(
54 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
55 "#gen does not appear as an own property on C prototype"
56 );
57 assert(
58 !Object.prototype.hasOwnProperty.call(C, "#gen"),
59 "#gen does not appear as an own property on C constructor"
60 );
61
62 var iter = C.gen();
63
64
65
66 assert.sameValue(callCount, 1);
67
68 // Test the private fields do not appear as properties after set to value
69 assert(
70 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"),
71 "#gen does not appear as an own property on C prototype"
72 );
73 assert(
74 !Object.prototype.hasOwnProperty.call(C, "#gen"),
75 "#gen does not appear as an own property on C constructor"
76 );