Skip to content

Commit d16e846

Browse files
committed
ES8/ES2017 target tests
1 parent 2c46f9b commit d16e846

File tree

6 files changed

+338
-2
lines changed

6 files changed

+338
-2
lines changed

src/harness/unittests/commandLineParsing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ namespace ts {
165165
start: undefined,
166166
length: undefined,
167167
}, {
168-
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015'",
168+
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es8', 'es2015', 'es2017'",
169169
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
170170
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
171171

src/harness/unittests/convertCompilerOptionsFromJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ namespace ts {
176176
file: undefined,
177177
start: 0,
178178
length: 0,
179-
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015'",
179+
messageText: "Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es8', 'es2015', 'es2017'",
180180
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
181181
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
182182
}]
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
//// [es8-async.ts]
2+
3+
async (): Promise<void> => {
4+
await 0;
5+
}
6+
7+
async function asyncFunc() {
8+
await 0;
9+
}
10+
11+
const asycnArrowFunc = async (): Promise<void> => {
12+
await 0;
13+
}
14+
15+
async function asyncIIFE() {
16+
await 0;
17+
18+
await (async function(): Promise<void> {
19+
await 1;
20+
})();
21+
22+
await (async function asyncNamedFunc(): Promise<void> {
23+
await 1;
24+
})();
25+
26+
await (async (): Promise<void> => {
27+
await 1;
28+
})();
29+
}
30+
31+
class AsyncClass {
32+
asyncPropFunc = async function(): Promise<void> {
33+
await 2;
34+
}
35+
36+
asyncPropNamedFunc = async function namedFunc(): Promise<void> {
37+
await 2;
38+
}
39+
40+
asyncPropArrowFunc = async (): Promise<void> => {
41+
await 2;
42+
}
43+
44+
async asyncMethod(): Promise<void> {
45+
await 2;
46+
}
47+
}
48+
49+
50+
//// [es8-async.js]
51+
async () => {
52+
await 0;
53+
};
54+
async function asyncFunc() {
55+
await 0;
56+
}
57+
const asycnArrowFunc = async () => {
58+
await 0;
59+
};
60+
async function asyncIIFE() {
61+
await 0;
62+
await (async function () {
63+
await 1;
64+
})();
65+
await (async function asyncNamedFunc() {
66+
await 1;
67+
})();
68+
await (async () => {
69+
await 1;
70+
})();
71+
}
72+
class AsyncClass {
73+
constructor() {
74+
this.asyncPropFunc = async function () {
75+
await 2;
76+
};
77+
this.asyncPropNamedFunc = async function namedFunc() {
78+
await 2;
79+
};
80+
this.asyncPropArrowFunc = async () => {
81+
await 2;
82+
};
83+
}
84+
async asyncMethod() {
85+
await 2;
86+
}
87+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
=== tests/cases/compiler/es8-async.ts ===
2+
3+
async (): Promise<void> => {
4+
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
5+
6+
await 0;
7+
}
8+
9+
async function asyncFunc() {
10+
>asyncFunc : Symbol(asyncFunc, Decl(es8-async.ts, 3, 1))
11+
12+
await 0;
13+
}
14+
15+
const asycnArrowFunc = async (): Promise<void> => {
16+
>asycnArrowFunc : Symbol(asycnArrowFunc, Decl(es8-async.ts, 9, 5))
17+
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
18+
19+
await 0;
20+
}
21+
22+
async function asyncIIFE() {
23+
>asyncIIFE : Symbol(asyncIIFE, Decl(es8-async.ts, 11, 1))
24+
25+
await 0;
26+
27+
await (async function(): Promise<void> {
28+
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
29+
30+
await 1;
31+
})();
32+
33+
await (async function asyncNamedFunc(): Promise<void> {
34+
>asyncNamedFunc : Symbol(asyncNamedFunc, Decl(es8-async.ts, 20, 11))
35+
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
36+
37+
await 1;
38+
})();
39+
40+
await (async (): Promise<void> => {
41+
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
42+
43+
await 1;
44+
})();
45+
}
46+
47+
class AsyncClass {
48+
>AsyncClass : Symbol(AsyncClass, Decl(es8-async.ts, 27, 1))
49+
50+
asyncPropFunc = async function(): Promise<void> {
51+
>asyncPropFunc : Symbol(AsyncClass.asyncPropFunc, Decl(es8-async.ts, 29, 18))
52+
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
53+
54+
await 2;
55+
}
56+
57+
asyncPropNamedFunc = async function namedFunc(): Promise<void> {
58+
>asyncPropNamedFunc : Symbol(AsyncClass.asyncPropNamedFunc, Decl(es8-async.ts, 32, 5))
59+
>namedFunc : Symbol(namedFunc, Decl(es8-async.ts, 34, 24))
60+
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
61+
62+
await 2;
63+
}
64+
65+
asyncPropArrowFunc = async (): Promise<void> => {
66+
>asyncPropArrowFunc : Symbol(AsyncClass.asyncPropArrowFunc, Decl(es8-async.ts, 36, 5))
67+
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
68+
69+
await 2;
70+
}
71+
72+
async asyncMethod(): Promise<void> {
73+
>asyncMethod : Symbol(AsyncClass.asyncMethod, Decl(es8-async.ts, 40, 5))
74+
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
75+
76+
await 2;
77+
}
78+
}
79+
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
=== tests/cases/compiler/es8-async.ts ===
2+
3+
async (): Promise<void> => {
4+
>async (): Promise<void> => { await 0;} : () => Promise<void>
5+
>Promise : Promise<T>
6+
7+
await 0;
8+
>await 0 : 0
9+
>0 : 0
10+
}
11+
12+
async function asyncFunc() {
13+
>asyncFunc : () => Promise<void>
14+
15+
await 0;
16+
>await 0 : 0
17+
>0 : 0
18+
}
19+
20+
const asycnArrowFunc = async (): Promise<void> => {
21+
>asycnArrowFunc : () => Promise<void>
22+
>async (): Promise<void> => { await 0;} : () => Promise<void>
23+
>Promise : Promise<T>
24+
25+
await 0;
26+
>await 0 : 0
27+
>0 : 0
28+
}
29+
30+
async function asyncIIFE() {
31+
>asyncIIFE : () => Promise<void>
32+
33+
await 0;
34+
>await 0 : 0
35+
>0 : 0
36+
37+
await (async function(): Promise<void> {
38+
>await (async function(): Promise<void> { await 1; })() : void
39+
>(async function(): Promise<void> { await 1; })() : Promise<void>
40+
>(async function(): Promise<void> { await 1; }) : () => Promise<void>
41+
>async function(): Promise<void> { await 1; } : () => Promise<void>
42+
>Promise : Promise<T>
43+
44+
await 1;
45+
>await 1 : 1
46+
>1 : 1
47+
48+
})();
49+
50+
await (async function asyncNamedFunc(): Promise<void> {
51+
>await (async function asyncNamedFunc(): Promise<void> { await 1; })() : void
52+
>(async function asyncNamedFunc(): Promise<void> { await 1; })() : Promise<void>
53+
>(async function asyncNamedFunc(): Promise<void> { await 1; }) : () => Promise<void>
54+
>async function asyncNamedFunc(): Promise<void> { await 1; } : () => Promise<void>
55+
>asyncNamedFunc : () => Promise<void>
56+
>Promise : Promise<T>
57+
58+
await 1;
59+
>await 1 : 1
60+
>1 : 1
61+
62+
})();
63+
64+
await (async (): Promise<void> => {
65+
>await (async (): Promise<void> => { await 1; })() : void
66+
>(async (): Promise<void> => { await 1; })() : Promise<void>
67+
>(async (): Promise<void> => { await 1; }) : () => Promise<void>
68+
>async (): Promise<void> => { await 1; } : () => Promise<void>
69+
>Promise : Promise<T>
70+
71+
await 1;
72+
>await 1 : 1
73+
>1 : 1
74+
75+
})();
76+
}
77+
78+
class AsyncClass {
79+
>AsyncClass : AsyncClass
80+
81+
asyncPropFunc = async function(): Promise<void> {
82+
>asyncPropFunc : () => Promise<void>
83+
>async function(): Promise<void> { await 2; } : () => Promise<void>
84+
>Promise : Promise<T>
85+
86+
await 2;
87+
>await 2 : 2
88+
>2 : 2
89+
}
90+
91+
asyncPropNamedFunc = async function namedFunc(): Promise<void> {
92+
>asyncPropNamedFunc : () => Promise<void>
93+
>async function namedFunc(): Promise<void> { await 2; } : () => Promise<void>
94+
>namedFunc : () => Promise<void>
95+
>Promise : Promise<T>
96+
97+
await 2;
98+
>await 2 : 2
99+
>2 : 2
100+
}
101+
102+
asyncPropArrowFunc = async (): Promise<void> => {
103+
>asyncPropArrowFunc : () => Promise<void>
104+
>async (): Promise<void> => { await 2; } : () => Promise<void>
105+
>Promise : Promise<T>
106+
107+
await 2;
108+
>await 2 : 2
109+
>2 : 2
110+
}
111+
112+
async asyncMethod(): Promise<void> {
113+
>asyncMethod : () => Promise<void>
114+
>Promise : Promise<T>
115+
116+
await 2;
117+
>await 2 : 2
118+
>2 : 2
119+
}
120+
}
121+

tests/cases/compiler/es8-async.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// @target: es8
2+
// @lib: es2017
3+
// @noEmitHelpers: true
4+
5+
async (): Promise<void> => {
6+
await 0;
7+
}
8+
9+
async function asyncFunc() {
10+
await 0;
11+
}
12+
13+
const asycnArrowFunc = async (): Promise<void> => {
14+
await 0;
15+
}
16+
17+
async function asyncIIFE() {
18+
await 0;
19+
20+
await (async function(): Promise<void> {
21+
await 1;
22+
})();
23+
24+
await (async function asyncNamedFunc(): Promise<void> {
25+
await 1;
26+
})();
27+
28+
await (async (): Promise<void> => {
29+
await 1;
30+
})();
31+
}
32+
33+
class AsyncClass {
34+
asyncPropFunc = async function(): Promise<void> {
35+
await 2;
36+
}
37+
38+
asyncPropNamedFunc = async function namedFunc(): Promise<void> {
39+
await 2;
40+
}
41+
42+
asyncPropArrowFunc = async (): Promise<void> => {
43+
await 2;
44+
}
45+
46+
async asyncMethod(): Promise<void> {
47+
await 2;
48+
}
49+
}

0 commit comments

Comments
 (0)