diff --git a/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts b/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts index 6859d9aa1ec..b901919fa1f 100644 --- a/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts +++ b/tests/cases/fourslash/docCommentTemplateVariableStatements01.ts @@ -28,27 +28,43 @@ function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, templ ////const c = 30; //// /////*d*/ -////let d = function d(x, y, z) { -//// return +(x + y + z); +////let d = { +//// foo: 10, +//// bar: "20" ////}; //// /////*e*/ -////let e = class E { +////let e = function e(x, y, z) { +//// return +(x + y + z); +////}; +//// +/////*f*/ +////let f = class F { //// constructor(a, b, c) { //// this.a = a; //// this.b = b || (this.c = c); //// } ////} -//// -/////*f*/ -////let f = { -//// foo: 10, -//// bar: "20" -////}; -for (const varName of "abcdef".split("")) { +for (const varName of "abcd".split("")) { confirmNormalizedJsDoc(varName, /*newTextOffset*/ 8, ` /** * */`); } + +confirmNormalizedJsDoc("e", /*newTextOffset*/ 8, ` +/** + * + * @param x + * @param y + * @param z + */`); + +confirmNormalizedJsDoc("f", /*newTextOffset*/ 8, ` +/** + * + * @param a + * @param b + * @param c + */`); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts b/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts new file mode 100644 index 00000000000..e473cb798b7 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateVariableStatements03.ts @@ -0,0 +1,90 @@ +/// + +const CRLF = "\r\n"; +/** + * @returns the given value with '\n' normalized to '\r\n' and with no leading newline + */ +function useCRLFAndStripLeadingNewline(str: string): string { + str = str.replace(/\r?\n/g, CRLF); + if (str.indexOf(CRLF) === 0) { + str = str.slice(CRLF.length); + } + return str; +} + +function confirmNormalizedJsDoc(markerName: string, newTextOffset: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, newTextOffset); +} + +/////*a*/ +////var a = x => x +//// +/////*b*/ +////let b = (x,y,z) => x + y + z; +//// +/////*c*/ +////const c = ((x => +x)) +//// +/////*d*/ +////let d = (function () { }) +//// +/////*e*/ +////let e = function e([a,b,c]) { +//// return "hello" +////}; +//// +/////*f*/ +////let f = class { +////} +//// +/////*g*/ +////const g = ((class G { +//// constructor(private x); +//// constructor(x,y,z); +//// constructor(x,y,z, ...okayThatsEnough) { +//// } +////})) + +confirmNormalizedJsDoc("a", /*newTextOffset*/ 8, ` +/** + * + * @param x + */`); + +confirmNormalizedJsDoc("b", /*newTextOffset*/ 8, ` +/** + * + * @param x + * @param y + * @param z + */`); + +confirmNormalizedJsDoc("c", /*newTextOffset*/ 8, ` +/** + * + * @param x + */`); + +confirmNormalizedJsDoc("d", /*newTextOffset*/ 8, ` +/** + * + */`); + +confirmNormalizedJsDoc("e", /*newTextOffset*/ 8, ` +/** + * + * @param param0 + */`); + +confirmNormalizedJsDoc("f", /*newTextOffset*/ 8, ` +/** + * + */`); + +confirmNormalizedJsDoc("g", /*newTextOffset*/ 8, ` +/** + * + * @param x + */`); \ No newline at end of file