mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-12 03:51:47 -06:00
tests
This commit is contained in:
parent
ac517336c4
commit
90d5413ccb
@ -20,6 +20,50 @@
|
||||
//// /*n2*/
|
||||
//// .then();
|
||||
|
||||
// @Filename: listSmart.ts
|
||||
////Promise
|
||||
//// .resolve().then(
|
||||
//// /*listSmart1*/
|
||||
//// 3,
|
||||
//// /*listSmart2*/
|
||||
//// [
|
||||
//// 3
|
||||
//// /*listSmart3*/
|
||||
//// ]
|
||||
//// /*listSmart4*/
|
||||
//// );
|
||||
|
||||
// @Filename: listZeroIndent.ts
|
||||
////Promise.resolve([
|
||||
////]).then(
|
||||
//// /*listZeroIndent1*/
|
||||
//// [
|
||||
//// /*listZeroIndent2*/
|
||||
//// 3
|
||||
//// ]
|
||||
//// );
|
||||
|
||||
// @Filename: listTypeParameter1.ts
|
||||
////foo.then
|
||||
//// <
|
||||
//// /*listTypeParameter1*/
|
||||
//// void
|
||||
//// /*listTypeParameter2*/
|
||||
//// >(
|
||||
//// function (): void {
|
||||
//// },
|
||||
//// function (): void {
|
||||
//// }
|
||||
//// );
|
||||
|
||||
// @Filename: listComment.ts
|
||||
////Promise
|
||||
//// .then(
|
||||
//// // euphonium
|
||||
//// "k"
|
||||
//// // oboe
|
||||
//// );
|
||||
|
||||
|
||||
goTo.marker('1');
|
||||
edit.insertLine('');
|
||||
@ -49,4 +93,68 @@ verify.currentLineContentIs(' });');
|
||||
goTo.marker('n1');
|
||||
verify.indentationIs(8);
|
||||
goTo.marker('n2');
|
||||
verify.indentationIs(4);
|
||||
verify.indentationIs(4);
|
||||
|
||||
goTo.file(1);
|
||||
format.document();
|
||||
verify.currentFileContentIs(`Promise
|
||||
.resolve().then(
|
||||
|
||||
3,
|
||||
|
||||
[
|
||||
3
|
||||
|
||||
]
|
||||
|
||||
);`);
|
||||
goTo.marker("listSmart1");
|
||||
verify.indentationIs(8);
|
||||
goTo.marker("listSmart2");
|
||||
verify.indentationIs(8);
|
||||
goTo.marker("listSmart3");
|
||||
verify.indentationIs(12);
|
||||
goTo.marker("listSmart4");
|
||||
verify.indentationIs(8);
|
||||
|
||||
goTo.file(2);
|
||||
format.document();
|
||||
verify.currentFileContentIs(`Promise.resolve([
|
||||
]).then(
|
||||
|
||||
[
|
||||
|
||||
3
|
||||
]
|
||||
);`);
|
||||
goTo.marker("listZeroIndent1");
|
||||
verify.indentationIs(4);
|
||||
goTo.marker("listZeroIndent2");
|
||||
verify.indentationIs(8);
|
||||
|
||||
goTo.file(3);
|
||||
format.document();
|
||||
verify.currentFileContentIs(`foo.then
|
||||
<
|
||||
|
||||
void
|
||||
|
||||
>(
|
||||
function(): void {
|
||||
},
|
||||
function(): void {
|
||||
}
|
||||
);`);
|
||||
goTo.marker("listTypeParameter1");
|
||||
verify.indentationIs(8);
|
||||
goTo.marker("listTypeParameter2");
|
||||
verify.indentationIs(8);
|
||||
|
||||
goTo.file(4);
|
||||
format.document();
|
||||
verify.currentFileContentIs(`Promise
|
||||
.then(
|
||||
// euphonium
|
||||
"k"
|
||||
// oboe
|
||||
);`)
|
||||
|
||||
37
tests/cases/fourslash/formattingOnTypeLiteral.ts
Normal file
37
tests/cases/fourslash/formattingOnTypeLiteral.ts
Normal file
@ -0,0 +1,37 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////function _uniteVertices<p extends string, a>(
|
||||
//// minority: Pinned<p, Vertex<a>>,
|
||||
//// majorityCounter: number,
|
||||
//// majority: Pinned<p, Vertex<a>>
|
||||
////): {
|
||||
//// /*start*/
|
||||
//// majorityCounter: number;
|
||||
//// vertecis: Pinned<p, {
|
||||
//// oldVertexId: VertexId;
|
||||
//// vertex: Vertex<a>;
|
||||
//// }>;
|
||||
//// /*end*/
|
||||
//// } {
|
||||
////}
|
||||
|
||||
format.document();
|
||||
verify.currentFileContentIs(`function _uniteVertices<p extends string, a>(
|
||||
minority: Pinned<p, Vertex<a>>,
|
||||
majorityCounter: number,
|
||||
majority: Pinned<p, Vertex<a>>
|
||||
): {
|
||||
|
||||
majorityCounter: number;
|
||||
vertecis: Pinned<p, {
|
||||
oldVertexId: VertexId;
|
||||
vertex: Vertex<a>;
|
||||
}>;
|
||||
|
||||
} {
|
||||
}`);
|
||||
|
||||
goTo.marker("start");
|
||||
verify.indentationIs(4);
|
||||
goTo.marker("end");
|
||||
verify.indentationIs(4);
|
||||
12
tests/cases/fourslash/smartIndentOnListEnd.ts
Normal file
12
tests/cases/fourslash/smartIndentOnListEnd.ts
Normal file
@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////var a = []
|
||||
/////*1*/
|
||||
////| {}
|
||||
/////*2*/
|
||||
////| "";
|
||||
|
||||
goTo.marker("1");
|
||||
verify.indentationIs(4)
|
||||
goTo.marker("2");
|
||||
verify.indentationIs(4)
|
||||
@ -3,15 +3,18 @@
|
||||
////function f<A,B,C>/*1*/(/*2*/a: A, /*3*/b:/*4*/B, c/*5*/, d: C/*6*/
|
||||
|
||||
|
||||
function verifyIndentationAfterNewLine(marker: string, indentation: number): void {
|
||||
function verifyIndentationAfterNewLine(marker: string, indentation: number, positionWorkaround: number, expectedText: string): void {
|
||||
goTo.marker(marker);
|
||||
edit.insert("\n");
|
||||
// The next two lines are to workaround #13433
|
||||
goTo.position(positionWorkaround);
|
||||
verify.textAtCaretIs(expectedText);
|
||||
verify.indentationIs(indentation);
|
||||
}
|
||||
|
||||
verifyIndentationAfterNewLine("1", 4);
|
||||
verifyIndentationAfterNewLine("2", 4);
|
||||
verifyIndentationAfterNewLine("3", 4);
|
||||
verifyIndentationAfterNewLine("4", 8);
|
||||
verifyIndentationAfterNewLine("5", 4);
|
||||
verifyIndentationAfterNewLine("6", 4);
|
||||
verifyIndentationAfterNewLine("1", 4, 24, '(');
|
||||
verifyIndentationAfterNewLine("2", 8, 34, 'a');
|
||||
verifyIndentationAfterNewLine("3", 8, 48, 'b');
|
||||
verifyIndentationAfterNewLine("4", 12, 63, 'B');
|
||||
verifyIndentationAfterNewLine("5", 8, 76, ',');
|
||||
verifyIndentationAfterNewLine("6", 8, 83, '');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user