Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/after-same-line-static-async-gen-computed-names.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/class-elements/computed-names.case
4 // - src/class-elements/productions/cls-decl-after-same-line-static-async-gen.template
5 /*---
6 description: Computed property names (field definitions after a static async generator in the same line)
7 esid: prod-FieldDefinition
8 features: [class-fields-public, computed-property-names, class, async-iteration]
9 flags: [generated, async]
10 includes: [propertyHelper.js]
11 info: |
12 ClassElement:
13 ...
14 FieldDefinition ;
15
16 FieldDefinition:
17 ClassElementName Initializer_opt
18
19 ClassElementName:
20 PropertyName
21
22 ---*/
23 var x = "b";
24
25
26
27 class C {
28 static async *m() { return 42; } [x] = 42; [10] = "meep"; ["not initialized"];
29
30 }
31
32 var c = new C();
33
34 assert(
35 !Object.prototype.hasOwnProperty.call(c, "m"),
36 "m doesn't appear as an own property on the C instance"
37 );
38 assert(
39 !Object.prototype.hasOwnProperty.call(C.prototype, "m"),
40 "m doesn't appear as an own property on the C prototype"
41 );
42
43 verifyProperty(C, "m", {
44 enumerable: false,
45 configurable: true,
46 writable: true,
47 }, {restore: true});
48
49 C.m().next().then(function(v) {
50 assert.sameValue(v.value, 42);
51 assert.sameValue(v.done, true);
52
53 function assertions() {
54 // Cover $DONE handler for async cases.
55 function $DONE(error) {
56 if (error) {
57 throw new Test262Error('Test262:AsyncTestFailure')
58 }
59 }
60 assert(
61 !Object.prototype.hasOwnProperty.call(C.prototype, "b"),
62 "b doesn't appear as an own property on C prototype"
63 );
64 assert(
65 !Object.prototype.hasOwnProperty.call(C, "b"),
66 "b doesn't appear as an own property on C constructor"
67 );
68
69 verifyProperty(c, "b", {
70 value: 42,
71 enumerable: true,
72 writable: true,
73 configurable: true
74 });
75
76 assert(
77 !Object.prototype.hasOwnProperty.call(C.prototype, "x"),
78 "x doesn't appear as an own property on C prototype"
79 );
80 assert(
81 !Object.prototype.hasOwnProperty.call(C, "x"),
82 "x doesn't appear as an own property on C constructor"
83 );
84 assert(
85 !Object.prototype.hasOwnProperty.call(c, "x"),
86 "x doesn't appear as an own property on C instance"
87 );
88
89 assert(
90 !Object.prototype.hasOwnProperty.call(C.prototype, "10"),
91 "10 doesn't appear as an own property on C prototype"
92 );
93 assert(
94 !Object.prototype.hasOwnProperty.call(C, "10"),
95 "10 doesn't appear as an own property on C constructor"
96 );
97
98 verifyProperty(c, "10", {
99 value: "meep",
100 enumerable: true,
101 writable: true,
102 configurable: true
103 });
104
105 assert(
106 !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"),
107 "'not initialized' doesn't appear as an own property on C prototype"
108 );
109 assert(
110 !Object.prototype.hasOwnProperty.call(C, "not initialized"),
111 "'not initialized' doesn't appear as an own property on C constructor"
112 );
113
114 verifyProperty(c, "not initialized", {
115 value: undefined,
116 enumerable: true,
117 writable: true,
118 configurable: true
119 });
120 }
121
122 return Promise.resolve(assertions());
123 }).then($DONE, $DONE);