diff --git a/tests/cases/fourslash/indentationInArrays.ts b/tests/cases/fourslash/indentationInArrays.ts new file mode 100644 index 00000000000..9468ff43a08 --- /dev/null +++ b/tests/cases/fourslash/indentationInArrays.ts @@ -0,0 +1,21 @@ +/// + +//// function foo() { +//// [/*8_0*/1,2,3]; +//// [1/*8_1*/,2,3]; +//// [1,/*8_2*/2,3]; +//// [ +//// 1,/*8_3*/2,3]; +//// [1,2,3/*8_4*/]; +//// [ +//// 1,2,3/*8_5*/]; +//// [1,2,3]/*8_6*/; +//// [ +//// 1,2,3]/*8_7*/; +//// } + +for (let i = 0; i < 8; ++i) { + goTo.marker(`8_${i}`); + edit.insertLine(""); + verify.indentationIs(8); +} diff --git a/tests/cases/fourslash/indentationInAssignment.ts b/tests/cases/fourslash/indentationInAssignment.ts new file mode 100644 index 00000000000..253cb30cf38 --- /dev/null +++ b/tests/cases/fourslash/indentationInAssignment.ts @@ -0,0 +1,37 @@ +/// + +//// var v0 = /*4_0*/ +//// 1; +//// +//// let v1 = 1 /*4_1*/ +//// + 10; +//// +//// let v2 = 1 + /*4_2*/ +//// 1; +//// +//// let v3 = 1 + (function /*0_0*/(x: number, y: number) { return x || y; })(0, 1); +//// +//// let v4 = 1 + (function (x: number, /*4_3*/y: number) { return x || y; })(0, 1); +//// +//// let v5 = 1 + (function (x: number, y: number) { /*4_4*/return x || y; })(0, 1); +//// +//// let v6 = 1 + (function (x: number, y: number) { return x || y;/*0_1*/})(0, 1); +//// +//// let v7 = 1 + (function (x: number, y: number) { +//// return x || y;/*4_5*/ +//// })(0, 1); +//// +//// let v8 = 1 + (function (x: number, y: number) { return x || y; })(0, /*4_6*/1); + + +for (let i = 0; i < 2; ++i) { + goTo.marker(`0_${i}`); + edit.insertLine(""); + verify.indentationIs(0); +} + +for (let i = 0; i < 7; ++i) { + goTo.marker(`4_${i}`); + edit.insertLine(""); + verify.indentationIs(4); +} \ No newline at end of file diff --git a/tests/cases/fourslash/indentationInAsyncExpressions.ts b/tests/cases/fourslash/indentationInAsyncExpressions.ts new file mode 100644 index 00000000000..5273dcbd97a --- /dev/null +++ b/tests/cases/fourslash/indentationInAsyncExpressions.ts @@ -0,0 +1,16 @@ +/// + + +//// async function* foo() { +//// yield /*8_0*/await 1; +//// yield await /*8_1*/1; +//// yield +//// await /*8_2*/1; +//// yield await 1/*8_3*/; +//// } + +for (let i = 0; i < 4; ++i) { + goTo.marker(`8_${i}`); + edit.insertLine(""); + verify.indentationIs(8); +} \ No newline at end of file diff --git a/tests/cases/fourslash/indentationInClassExpression.ts b/tests/cases/fourslash/indentationInClassExpression.ts new file mode 100644 index 00000000000..77ac668790a --- /dev/null +++ b/tests/cases/fourslash/indentationInClassExpression.ts @@ -0,0 +1,31 @@ +/// + +////function foo() { +//// let x: any; +//// x = /*8_0*/class { constructor(public x: number) { } }; +//// x = class /*4_0*/{ constructor(public x: number) { } }; +//// x = class { /*8_1*/constructor(public x: number) { } }; +//// x = class { constructor(/*12_0*/public x: number) { } }; +//// x = class { constructor(public /*12_1*/x: number) { } }; +//// x = class { constructor(public x: number) {/*8_2*/ } }; +//// x = class { +//// constructor(/*12_2*/public x: number) { } +//// }; +//// x = class { +//// constructor(public x: number) {/*8_3*/ } +//// }; +//// x = class { +//// constructor(public x: number) { }/*4_1*/}; +////} + +function verifyIndentation(level: number, count: number) { + for (let i = 0; i < count; ++i) { + goTo.marker(`${level}_${i}`); + edit.insertLine(""); + verify.indentationIs(level); + } +} + +verifyIndentation(4, 2); +verifyIndentation(8, 4); +verifyIndentation(12, 3); \ No newline at end of file diff --git a/tests/cases/fourslash/indentationInObject.ts b/tests/cases/fourslash/indentationInObject.ts new file mode 100644 index 00000000000..2acb651c933 --- /dev/null +++ b/tests/cases/fourslash/indentationInObject.ts @@ -0,0 +1,30 @@ +/// + +//// function foo() { +//// {/*8_0*/x:1;y:2;z:3}; +//// {x:1/*12_0*/;y:2;z:3}; +//// {x:1;/*8_1*/y:2;z:3}; +//// { +//// x:1;/*8_2*/y:2;z:3}; +//// {x:1;y:2;z:3/*4_0*/}; +//// { +//// x:1;y:2;z:3/*4_1*/}; +//// {x:1;y:2;z:3}/*4_2*/; +//// { +//// x:1;y:2;z:3}/*4_3*/; +//// } + +for (let i = 0; i < 4; ++i) { + goTo.marker(`4_${i}`); + edit.insertLine(""); + verify.indentationIs(4); +} +for (let i = 0; i < 3; ++i) { + goTo.marker(`8_${i}`); + edit.insertLine(""); + verify.indentationIs(8); +} + + goTo.marker(`12_0`); + edit.insertLine(""); + verify.indentationIs(12);