Debian Codegraph @

js/src/tests/non262/async-functions/methods.js

raw
1 // |reftest| skip-if(!xulRuntime.shell) -- needs drainJobQueue
2 var BUGNUMBER = 1185106;
3 var summary = "async methods semantics";
4
5 print(BUGNUMBER + ": " + summary);
6
7 class X {
8 constructor() {
9 this.value = 42;
10 }
11 async getValue() {
12 return this.value;
13 }
14 setValue(value) {
15 this.value = value;
16 }
17 async increment() {
18 var value = await this.getValue();
19 this.setValue(value + 1);
20 return this.getValue();
21 }
22 async getBaseClassName() {
23 return 'X';
24 }
25 static async getStaticValue() {
26 return 44;
27 }
28 async 10() {
29 return 46;
30 }
31 async ["foo"]() {
32 return 47;
33 }
34 }
35
36 class Y extends X {
37 async getBaseClassName() {
38 return super.getBaseClassName();
39 }
40 }
41
42 var objLiteral = {
43 async get() {
44 return 45;
45 },
46 someStuff: 5
47 };
48
49 var x = new X();
50 var y = new Y();
51
52 assertEventuallyEq(x.getValue(), 42);
53 assertEventuallyEq(x.increment(), 43);
54 assertEventuallyEq(x[10](), 46);
55 assertEventuallyEq(x.foo(), 47);
56 assertEventuallyEq(X.getStaticValue(), 44);
57 assertEventuallyEq(objLiteral.get(), 45);
58 assertEventuallyEq(y.getBaseClassName(), 'X');
59
60 if (typeof reportCompare === "function")
61 reportCompare(true, true);