Skip to content

Commit dc3add2

Browse files
committed
tests
1 parent 3529e3f commit dc3add2

File tree

4 files changed

+168
-8
lines changed

4 files changed

+168
-8
lines changed

tests/cases/fourslash/formattingOnChainedCallbacks.ts

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,50 @@
2020
//// /*n2*/
2121
//// .then();
2222

23+
// @Filename: listSmart.ts
24+
////Promise
25+
//// .resolve().then(
26+
//// /*listSmart1*/
27+
//// 3,
28+
//// /*listSmart2*/
29+
//// [
30+
//// 3
31+
//// /*listSmart3*/
32+
//// ]
33+
//// /*listSmart4*/
34+
//// );
35+
36+
// @Filename: listZeroIndent.ts
37+
////Promise.resolve([
38+
////]).then(
39+
//// /*listZeroIndent1*/
40+
//// [
41+
//// /*listZeroIndent2*/
42+
//// 3
43+
//// ]
44+
//// );
45+
46+
// @Filename: listTypeParameter1.ts
47+
////foo.then
48+
//// <
49+
//// /*listTypeParameter1*/
50+
//// void
51+
//// /*listTypeParameter2*/
52+
//// >(
53+
//// function (): void {
54+
//// },
55+
//// function (): void {
56+
//// }
57+
//// );
58+
59+
// @Filename: listComment.ts
60+
////Promise
61+
//// .then(
62+
//// // euphonium
63+
//// "k"
64+
//// // oboe
65+
//// );
66+
2367

2468
goTo.marker('1');
2569
edit.insertLine('');
@@ -49,4 +93,68 @@ verify.currentLineContentIs(' });');
4993
goTo.marker('n1');
5094
verify.indentationIs(8);
5195
goTo.marker('n2');
52-
verify.indentationIs(4);
96+
verify.indentationIs(4);
97+
98+
goTo.file(1);
99+
format.document();
100+
verify.currentFileContentIs(`Promise
101+
.resolve().then(
102+
103+
3,
104+
105+
[
106+
3
107+
108+
]
109+
110+
);`);
111+
goTo.marker("listSmart1");
112+
verify.indentationIs(8);
113+
goTo.marker("listSmart2");
114+
verify.indentationIs(8);
115+
goTo.marker("listSmart3");
116+
verify.indentationIs(12);
117+
goTo.marker("listSmart4");
118+
verify.indentationIs(8);
119+
120+
goTo.file(2);
121+
format.document();
122+
verify.currentFileContentIs(`Promise.resolve([
123+
]).then(
124+
125+
[
126+
127+
3
128+
]
129+
);`);
130+
goTo.marker("listZeroIndent1");
131+
verify.indentationIs(4);
132+
goTo.marker("listZeroIndent2");
133+
verify.indentationIs(8);
134+
135+
goTo.file(3);
136+
format.document();
137+
verify.currentFileContentIs(`foo.then
138+
<
139+
140+
void
141+
142+
>(
143+
function(): void {
144+
},
145+
function(): void {
146+
}
147+
);`);
148+
goTo.marker("listTypeParameter1");
149+
verify.indentationIs(8);
150+
goTo.marker("listTypeParameter2");
151+
verify.indentationIs(8);
152+
153+
goTo.file(4);
154+
format.document();
155+
verify.currentFileContentIs(`Promise
156+
.then(
157+
// euphonium
158+
"k"
159+
// oboe
160+
);`)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////function _uniteVertices<p extends string, a>(
4+
//// minority: Pinned<p, Vertex<a>>,
5+
//// majorityCounter: number,
6+
//// majority: Pinned<p, Vertex<a>>
7+
////): {
8+
//// /*start*/
9+
//// majorityCounter: number;
10+
//// vertecis: Pinned<p, {
11+
//// oldVertexId: VertexId;
12+
//// vertex: Vertex<a>;
13+
//// }>;
14+
//// /*end*/
15+
//// } {
16+
////}
17+
18+
format.document();
19+
verify.currentFileContentIs(`function _uniteVertices<p extends string, a>(
20+
minority: Pinned<p, Vertex<a>>,
21+
majorityCounter: number,
22+
majority: Pinned<p, Vertex<a>>
23+
): {
24+
25+
majorityCounter: number;
26+
vertecis: Pinned<p, {
27+
oldVertexId: VertexId;
28+
vertex: Vertex<a>;
29+
}>;
30+
31+
} {
32+
}`);
33+
34+
goTo.marker("start");
35+
verify.indentationIs(4);
36+
goTo.marker("end");
37+
verify.indentationIs(4);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
////var a = []
4+
/////*1*/
5+
////| {}
6+
/////*2*/
7+
////| "";
8+
9+
goTo.marker("1");
10+
verify.indentationIs(4)
11+
goTo.marker("2");
12+
verify.indentationIs(4)

tests/cases/fourslash/smartIndentOnUnclosedFunctionDeclaration04.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
////function f<A,B,C>/*1*/(/*2*/a: A, /*3*/b:/*4*/B, c/*5*/, d: C/*6*/
44

55

6-
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
6+
function verifyIndentationAfterNewLine(marker: string, indentation: number, positionWorkaround: number, expectedText: string): void {
77
goTo.marker(marker);
88
edit.insert("\r\n");
9+
// The next two lines are to workaround #13433
10+
goTo.position(positionWorkaround);
11+
verify.textAtCaretIs(expectedText);
912
verify.indentationIs(indentation);
1013
}
1114

12-
verifyIndentationAfterNewLine("1", 4);
13-
verifyIndentationAfterNewLine("2", 4);
14-
verifyIndentationAfterNewLine("3", 4);
15-
verifyIndentationAfterNewLine("4", 8);
16-
verifyIndentationAfterNewLine("5", 4);
17-
verifyIndentationAfterNewLine("6", 4);
15+
verifyIndentationAfterNewLine("1", 4, 25, '(');
16+
verifyIndentationAfterNewLine("2", 8, 36, 'a');
17+
verifyIndentationAfterNewLine("3", 8, 51, 'b');
18+
verifyIndentationAfterNewLine("4", 12, 67, 'B');
19+
verifyIndentationAfterNewLine("5", 8, 81, ',');
20+
verifyIndentationAfterNewLine("6", 8, 89, '');

0 commit comments

Comments
 (0)