Debian Codegraph @

js/src/tests/test262/language/statements/class/elements/same-line-async-method-literal-names.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/class-elements/literal-names.case
4 // - src/class-elements/productions/cls-decl-after-same-line-async-method.template
5 /*---
6 description: Literal property names (field definitions after an async method in the same line)
7 esid: prod-FieldDefinition
8 features: [class-fields-public, class, async-functions]
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 const fn = function() {}
24
25
26
27 class C {
28 async m() { return 42; } a; b = 42;
29 c = fn;
30
31 }
32
33 var c = new C();
34
35 assert(
36 !Object.prototype.hasOwnProperty.call(c, "m"),
37 "m doesn't appear as an own property on the C instance"
38 );
39 assert.sameValue(c.m, C.prototype.m);
40
41 verifyProperty(C.prototype, "m", {
42 enumerable: false,
43 configurable: true,
44 writable: true,
45 }, {restore: true});
46
47 c.m().then(function(v) {
48 assert.sameValue(v, 42);
49
50 function assertions() {
51 // Cover $DONE handler for async cases.
52 function $DONE(error) {
53 if (error) {
54 throw new Test262Error('Test262:AsyncTestFailure')
55 }
56 }
57 assert(
58 !Object.prototype.hasOwnProperty.call(C.prototype, "a"),
59 "a doesn't appear as an own property on C prototype"
60 );
61 assert(
62 !Object.prototype.hasOwnProperty.call(C, "a"),
63 "a doesn't appear as an own property on C constructor"
64 );
65
66 verifyProperty(c, "a", {
67 value: undefined,
68 enumerable: true,
69 writable: true,
70 configurable: true
71 });
72
73 assert(
74 !Object.prototype.hasOwnProperty.call(C.prototype, "b"),
75 "b doesn't appear as an own property on C prototype"
76 );
77 assert(
78 !Object.prototype.hasOwnProperty.call(C, "b"),
79 "b doesn't appear as an own property on C constructor"
80 );
81
82 verifyProperty(c, "b", {
83 value: 42,
84 enumerable: true,
85 writable: true,
86 configurable: true
87 });
88
89 assert(
90 !Object.prototype.hasOwnProperty.call(C.prototype, "c"),
91 "c doesn't appear as an own property on C prototype"
92 );
93 assert(
94 !Object.prototype.hasOwnProperty.call(C, "c"),
95 "c doesn't appear as an own property on C constructor"
96 );
97
98 verifyProperty(c, "c", {
99 value: fn,
100 enumerable: true,
101 writable: true,
102 configurable: true
103 });
104
105 }
106
107 return Promise.resolve(assertions());
108 }).then($DONE, $DONE);