Skip to content

Commit 32d8a22

Browse files
author
vilicvane
committed
Add tests for issue microsoft#4603
1 parent 856f2d8 commit 32d8a22

8 files changed

+120
-10
lines changed

tests/baselines/reference/castExpressionParentheses.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ declare var a;
77
(<any>[1,3,]);
88
(<any>"string");
99
(<any>23.0);
10+
(<any>1);
11+
(<any>1.).foo;
12+
(<any>1.0).foo;
13+
(<any>12e+34).foo;
14+
(<any>0xff).foo;
1015
(<any>/regexp/g);
1116
(<any>false);
1217
(<any>true);
@@ -23,6 +28,8 @@ declare var a;
2328
declare var A;
2429

2530
// should keep the parentheses in emit
31+
(<any>1).foo;
32+
(<any>(1.0)).foo;
2633
(<any>new A).foo;
2734
(<any>typeof A).x;
2835
(<any>-A).x;
@@ -46,6 +53,11 @@ new (<any>A());
4653
[1, 3,];
4754
"string";
4855
23.0;
56+
1;
57+
1..foo;
58+
1.0.foo;
59+
12e+34.foo;
60+
0xff.foo;
4961
/regexp/g;
5062
false;
5163
true;
@@ -59,6 +71,8 @@ a[0];
5971
a.b["0"];
6072
a().x;
6173
// should keep the parentheses in emit
74+
(1).foo;
75+
(1.0).foo;
6276
(new A).foo;
6377
(typeof A).x;
6478
(-A).x;

tests/baselines/reference/castExpressionParentheses.symbols

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ declare var a;
1010
(<any>[1,3,]);
1111
(<any>"string");
1212
(<any>23.0);
13+
(<any>1);
14+
(<any>1.).foo;
15+
(<any>1.0).foo;
16+
(<any>12e+34).foo;
17+
(<any>0xff).foo;
1318
(<any>/regexp/g);
1419
(<any>false);
1520
(<any>true);
@@ -33,36 +38,38 @@ declare var a;
3338
>a : Symbol(a, Decl(castExpressionParentheses.ts, 0, 11))
3439

3540
declare var A;
36-
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
41+
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
3742

3843
// should keep the parentheses in emit
44+
(<any>1).foo;
45+
(<any>(1.0)).foo;
3946
(<any>new A).foo;
40-
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
47+
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
4148

4249
(<any>typeof A).x;
43-
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
50+
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
4451

4552
(<any>-A).x;
46-
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
53+
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
4754

4855
new (<any>A());
49-
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
56+
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
5057

5158
(<Tany>()=> {})();
52-
>Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 28, 2))
59+
>Tany : Symbol(Tany, Decl(castExpressionParentheses.ts, 35, 2))
5360

5461
(<any>function foo() { })();
55-
>foo : Symbol(foo, Decl(castExpressionParentheses.ts, 29, 6))
62+
>foo : Symbol(foo, Decl(castExpressionParentheses.ts, 36, 6))
5663

5764
(<any><number><any>-A).x;
58-
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
65+
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
5966

6067
// nested cast, should keep one pair of parenthese
6168
(<any><number>(<any>-A)).x;
62-
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
69+
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
6370

6471
// nested parenthesized expression, should keep one pair of parenthese
6572
(<any>(A))
66-
>A : Symbol(A, Decl(castExpressionParentheses.ts, 21, 11))
73+
>A : Symbol(A, Decl(castExpressionParentheses.ts, 26, 11))
6774

6875

tests/baselines/reference/castExpressionParentheses.types

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,39 @@ declare var a;
2828
><any>23.0 : any
2929
>23.0 : number
3030

31+
(<any>1);
32+
>(<any>1) : any
33+
><any>1 : any
34+
>1 : number
35+
36+
(<any>1.).foo;
37+
>(<any>1.).foo : any
38+
>(<any>1.) : any
39+
><any>1. : any
40+
>1. : number
41+
>foo : any
42+
43+
(<any>1.0).foo;
44+
>(<any>1.0).foo : any
45+
>(<any>1.0) : any
46+
><any>1.0 : any
47+
>1.0 : number
48+
>foo : any
49+
50+
(<any>12e+34).foo;
51+
>(<any>12e+34).foo : any
52+
>(<any>12e+34) : any
53+
><any>12e+34 : any
54+
>12e+34 : number
55+
>foo : any
56+
57+
(<any>0xff).foo;
58+
>(<any>0xff).foo : any
59+
>(<any>0xff) : any
60+
><any>0xff : any
61+
>0xff : number
62+
>foo : any
63+
3164
(<any>/regexp/g);
3265
>(<any>/regexp/g) : any
3366
><any>/regexp/g : any
@@ -104,6 +137,21 @@ declare var A;
104137
>A : any
105138

106139
// should keep the parentheses in emit
140+
(<any>1).foo;
141+
>(<any>1).foo : any
142+
>(<any>1) : any
143+
><any>1 : any
144+
>1 : number
145+
>foo : any
146+
147+
(<any>(1.0)).foo;
148+
>(<any>(1.0)).foo : any
149+
>(<any>(1.0)) : any
150+
><any>(1.0) : any
151+
>(1.0) : number
152+
>1.0 : number
153+
>foo : any
154+
107155
(<any>new A).foo;
108156
>(<any>new A).foo : any
109157
>(<any>new A) : any
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//// [castExpressionParentheses_ES6.ts]
2+
3+
// parentheses should be omitted
4+
// numeric literal
5+
(<any>0o123).foo;
6+
7+
8+
//// [castExpressionParentheses_ES6.js]
9+
// parentheses should be omitted
10+
// numeric literal
11+
0o123.foo;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
=== tests/cases/compiler/castExpressionParentheses_ES6.ts ===
2+
3+
No type information for this code.// parentheses should be omitted
4+
No type information for this code.// numeric literal
5+
No type information for this code.(<any>0o123).foo;
6+
No type information for this code.
7+
No type information for this code.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
=== tests/cases/compiler/castExpressionParentheses_ES6.ts ===
2+
3+
// parentheses should be omitted
4+
// numeric literal
5+
(<any>0o123).foo;
6+
>(<any>0o123).foo : any
7+
>(<any>0o123) : any
8+
><any>0o123 : any
9+
>0o123 : number
10+
>foo : any
11+

tests/cases/compiler/castExpressionParentheses.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ declare var a;
66
(<any>[1,3,]);
77
(<any>"string");
88
(<any>23.0);
9+
(<any>1);
10+
(<any>1.).foo;
11+
(<any>1.0).foo;
12+
(<any>12e+34).foo;
13+
(<any>0xff).foo;
914
(<any>/regexp/g);
1015
(<any>false);
1116
(<any>true);
@@ -22,6 +27,8 @@ declare var a;
2227
declare var A;
2328

2429
// should keep the parentheses in emit
30+
(<any>1).foo;
31+
(<any>(1.0)).foo;
2532
(<any>new A).foo;
2633
(<any>typeof A).x;
2734
(<any>-A).x;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// @target: es6
2+
3+
// parentheses should be omitted
4+
// numeric literal
5+
(<any>0o123).foo;

0 commit comments

Comments
 (0)