Skip to content

Commit f8d6e26

Browse files
authored
Add tests and Update baselines (#10616)
Update tests and baselines Update tests and baselines Update tests for downlevel emit Add tests and update baselines Add tests and baselines Update baselines Update baselines
1 parent a370908 commit f8d6e26

12 files changed

+251
-12
lines changed

tests/baselines/reference/classExpressionWithStaticProperties1.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
//// [classExpressionWithStaticProperties1.ts]
2-
var v = class C { static a = 1; static b = 2 };
2+
var v = class C {
3+
static a = 1;
4+
static b = 2;
5+
static c = C.a + C.b;
6+
};
37

48
//// [classExpressionWithStaticProperties1.js]
59
var v = (_a = (function () {
@@ -9,5 +13,6 @@ var v = (_a = (function () {
913
}()),
1014
_a.a = 1,
1115
_a.b = 2,
16+
_a.c = _a.a + _a.b,
1217
_a);
1318
var _a;
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
=== tests/cases/compiler/classExpressionWithStaticProperties1.ts ===
2-
var v = class C { static a = 1; static b = 2 };
2+
var v = class C {
33
>v : Symbol(v, Decl(classExpressionWithStaticProperties1.ts, 0, 3))
4+
>C : Symbol(C, Decl(classExpressionWithStaticProperties1.ts, 0, 7))
5+
6+
static a = 1;
7+
>a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17))
8+
9+
static b = 2;
10+
>b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 1, 17))
11+
12+
static c = C.a + C.b;
13+
>c : Symbol(C.c, Decl(classExpressionWithStaticProperties1.ts, 2, 17))
14+
>C.a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17))
415
>C : Symbol(C, Decl(classExpressionWithStaticProperties1.ts, 0, 7))
516
>a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17))
6-
>b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 0, 31))
17+
>C.b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 1, 17))
18+
>C : Symbol(C, Decl(classExpressionWithStaticProperties1.ts, 0, 7))
19+
>b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 1, 17))
720

21+
};
Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
=== tests/cases/compiler/classExpressionWithStaticProperties1.ts ===
2-
var v = class C { static a = 1; static b = 2 };
2+
var v = class C {
33
>v : typeof C
4-
>class C { static a = 1; static b = 2 } : typeof C
4+
>class C { static a = 1; static b = 2; static c = C.a + C.b;} : typeof C
55
>C : typeof C
6+
7+
static a = 1;
68
>a : number
79
>1 : number
10+
11+
static b = 2;
812
>b : number
913
>2 : number
1014

15+
static c = C.a + C.b;
16+
>c : number
17+
>C.a + C.b : number
18+
>C.a : number
19+
>C : typeof C
20+
>a : number
21+
>C.b : number
22+
>C : typeof C
23+
>b : number
24+
25+
};
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
//// [classExpressionWithStaticProperties2.ts]
2-
var v = class C { static a = 1; static b };
2+
var v = class C {
3+
static a = 1;
4+
static b
5+
static c = {
6+
x: "hi"
7+
}
8+
static d = C.c.x + " world";
9+
};
310

411
//// [classExpressionWithStaticProperties2.js]
512
var v = (_a = (function () {
@@ -8,5 +15,9 @@ var v = (_a = (function () {
815
return C;
916
}()),
1017
_a.a = 1,
18+
_a.c = {
19+
x: "hi"
20+
},
21+
_a.d = _a.c.x + " world",
1122
_a);
1223
var _a;
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
=== tests/cases/compiler/classExpressionWithStaticProperties2.ts ===
2-
var v = class C { static a = 1; static b };
2+
var v = class C {
33
>v : Symbol(v, Decl(classExpressionWithStaticProperties2.ts, 0, 3))
44
>C : Symbol(C, Decl(classExpressionWithStaticProperties2.ts, 0, 7))
5+
6+
static a = 1;
57
>a : Symbol(C.a, Decl(classExpressionWithStaticProperties2.ts, 0, 17))
6-
>b : Symbol(C.b, Decl(classExpressionWithStaticProperties2.ts, 0, 31))
78

9+
static b
10+
>b : Symbol(C.b, Decl(classExpressionWithStaticProperties2.ts, 1, 17))
11+
12+
static c = {
13+
>c : Symbol(C.c, Decl(classExpressionWithStaticProperties2.ts, 2, 12))
14+
15+
x: "hi"
16+
>x : Symbol(x, Decl(classExpressionWithStaticProperties2.ts, 3, 16))
17+
}
18+
static d = C.c.x + " world";
19+
>d : Symbol(C.d, Decl(classExpressionWithStaticProperties2.ts, 5, 5))
20+
>C.c.x : Symbol(x, Decl(classExpressionWithStaticProperties2.ts, 3, 16))
21+
>C.c : Symbol(C.c, Decl(classExpressionWithStaticProperties2.ts, 2, 12))
22+
>C : Symbol(C, Decl(classExpressionWithStaticProperties2.ts, 0, 7))
23+
>c : Symbol(C.c, Decl(classExpressionWithStaticProperties2.ts, 2, 12))
24+
>x : Symbol(x, Decl(classExpressionWithStaticProperties2.ts, 3, 16))
25+
26+
};
Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
11
=== tests/cases/compiler/classExpressionWithStaticProperties2.ts ===
2-
var v = class C { static a = 1; static b };
2+
var v = class C {
33
>v : typeof C
4-
>class C { static a = 1; static b } : typeof C
4+
>class C { static a = 1; static b static c = { x: "hi" } static d = C.c.x + " world"; } : typeof C
55
>C : typeof C
6+
7+
static a = 1;
68
>a : number
79
>1 : number
10+
11+
static b
812
>b : any
913

14+
static c = {
15+
>c : { x: string; }
16+
>{ x: "hi" } : { x: string; }
17+
18+
x: "hi"
19+
>x : string
20+
>"hi" : string
21+
}
22+
static d = C.c.x + " world";
23+
>d : string
24+
>C.c.x + " world" : string
25+
>C.c.x : string
26+
>C.c : { x: string; }
27+
>C : typeof C
28+
>c : { x: string; }
29+
>x : string
30+
>" world" : string
31+
32+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//// [classExpressionWithStaticProperties3.ts]
2+
3+
declare var console: any;
4+
const arr: {y(): number}[] = [];
5+
for (let i = 0; i < 3; i++) {
6+
arr.push(class C {
7+
static x = i;
8+
static y = () => C.x * 2;
9+
});
10+
}
11+
arr.forEach(C => console.log(C.y()));
12+
13+
//// [classExpressionWithStaticProperties3.js]
14+
var arr = [];
15+
var _loop_1 = function (i) {
16+
arr.push((_a = (function () {
17+
function C() {
18+
}
19+
return C;
20+
}()),
21+
_a.x = i,
22+
_a.y = function () { return _a.x * 2; },
23+
_a));
24+
};
25+
for (var i = 0; i < 3; i++) {
26+
_loop_1(i);
27+
}
28+
arr.forEach(function (C) { return console.log(C.y()); });
29+
var _a;
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
=== tests/cases/compiler/classExpressionWithStaticProperties3.ts ===
2+
3+
declare var console: any;
4+
>console : Symbol(console, Decl(classExpressionWithStaticProperties3.ts, 1, 11))
5+
6+
const arr: {y(): number}[] = [];
7+
>arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 2, 5))
8+
>y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 2, 12))
9+
10+
for (let i = 0; i < 3; i++) {
11+
>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8))
12+
>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8))
13+
>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8))
14+
15+
arr.push(class C {
16+
>arr.push : Symbol(Array.push, Decl(lib.d.ts, --, --))
17+
>arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 2, 5))
18+
>push : Symbol(Array.push, Decl(lib.d.ts, --, --))
19+
>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 4, 13))
20+
21+
static x = i;
22+
>x : Symbol(C.x, Decl(classExpressionWithStaticProperties3.ts, 4, 22))
23+
>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8))
24+
25+
static y = () => C.x * 2;
26+
>y : Symbol(C.y, Decl(classExpressionWithStaticProperties3.ts, 5, 21))
27+
>C.x : Symbol(C.x, Decl(classExpressionWithStaticProperties3.ts, 4, 22))
28+
>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 4, 13))
29+
>x : Symbol(C.x, Decl(classExpressionWithStaticProperties3.ts, 4, 22))
30+
31+
});
32+
}
33+
arr.forEach(C => console.log(C.y()));
34+
>arr.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --))
35+
>arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 2, 5))
36+
>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --))
37+
>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 9, 12))
38+
>console : Symbol(console, Decl(classExpressionWithStaticProperties3.ts, 1, 11))
39+
>C.y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 2, 12))
40+
>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 9, 12))
41+
>y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 2, 12))
42+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
=== tests/cases/compiler/classExpressionWithStaticProperties3.ts ===
2+
3+
declare var console: any;
4+
>console : any
5+
6+
const arr: {y(): number}[] = [];
7+
>arr : { y(): number; }[]
8+
>y : () => number
9+
>[] : undefined[]
10+
11+
for (let i = 0; i < 3; i++) {
12+
>i : number
13+
>0 : number
14+
>i < 3 : boolean
15+
>i : number
16+
>3 : number
17+
>i++ : number
18+
>i : number
19+
20+
arr.push(class C {
21+
>arr.push(class C { static x = i; static y = () => C.x * 2; }) : number
22+
>arr.push : (...items: { y(): number; }[]) => number
23+
>arr : { y(): number; }[]
24+
>push : (...items: { y(): number; }[]) => number
25+
>class C { static x = i; static y = () => C.x * 2; } : typeof C
26+
>C : typeof C
27+
28+
static x = i;
29+
>x : number
30+
>i : number
31+
32+
static y = () => C.x * 2;
33+
>y : () => number
34+
>() => C.x * 2 : () => number
35+
>C.x * 2 : number
36+
>C.x : number
37+
>C : typeof C
38+
>x : number
39+
>2 : number
40+
41+
});
42+
}
43+
arr.forEach(C => console.log(C.y()));
44+
>arr.forEach(C => console.log(C.y())) : void
45+
>arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void
46+
>arr : { y(): number; }[]
47+
>forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void
48+
>C => console.log(C.y()) : (C: { y(): number; }) => any
49+
>C : { y(): number; }
50+
>console.log(C.y()) : any
51+
>console.log : any
52+
>console : any
53+
>log : any
54+
>C.y() : number
55+
>C.y : () => number
56+
>C : { y(): number; }
57+
>y : () => number
58+
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
var v = class C { static a = 1; static b = 2 };
1+
var v = class C {
2+
static a = 1;
3+
static b = 2;
4+
static c = C.a + C.b;
5+
};

0 commit comments

Comments
 (0)