Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/class/fields-same-line-async-method-private-names.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/class-fields/private-names.case
3 // - src/class-fields/productions/cls-expr-after-same-line-async-method.template
4 /*---
5 description: static literal private names (field definitions after an async method in the same line)
6 esid: prod-FieldDefinition
7 features: [class-fields-private, class, class-fields-public, async-functions]
8 flags: [generated, async]
9 includes: [propertyHelper.js]
10 info: |
11 ClassElement:
12 ...
13 FieldDefinition ;
14
15 FieldDefinition:
16 ClassElementName Initializer_opt
17
18 ClassElementName:
19 PrivateName
20
21 PrivateName:
22 #IdentifierName
23
24 ---*/
25
26
27 var C = class {
28 async m() { return 42; } #x; #y;
29 x() {
30 this.#x = 42;
31 return this.#x;
32 }
33 y() {
34 this.#y = 43;
35 return this.#y;
36 }
37 }
38
39 var c = new C();
40
41 assert.sameValue(Object.hasOwnProperty.call(c, "m"), false);
42 assert.sameValue(c.m, C.prototype.m);
43
44 verifyProperty(C.prototype, "m", {
45 enumerable: false,
46 configurable: true,
47 writable: true,
48 }, {restore: true});
49
50 // Test the private fields do not appear as properties before set to value
51 assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#x"), false, "test 1");
52 assert.sameValue(Object.hasOwnProperty.call(C, "#x"), false, "test 2");
53 assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 3");
54
55 assert.sameValue(Object.hasOwnProperty.call(C.prototype, "#y"), false, "test 4");
56 assert.sameValue(Object.hasOwnProperty.call(C, "#y"), false, "test 5");
57 assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 6");
58
59 // Test if private fields can be sucessfully accessed and set to value
60 assert.sameValue(c.x(), 42, "test 7");
61 assert.sameValue(c.y(), 43, "test 8");
62
63 // Test the private fields do not appear as properties before after set to value
64 assert.sameValue(Object.hasOwnProperty.call(c, "#x"), false, "test 9");
65 assert.sameValue(Object.hasOwnProperty.call(c, "#y"), false, "test 10");
66
67 c.m().then(function(v) {
68 assert.sameValue(v, 42);
69 }, $DONE).then($DONE, $DONE);