From 08e2b0a15958a4adc86fa080bd4ad584c3ee79f4 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 24 Sep 2015 17:09:16 -0700 Subject: [PATCH] Added tests for dotted namespace declarations, object literal methods. --- .../docCommentTemplateClassDeclMethods01.ts | 7 +++ .../docCommentTemplateClassDeclMethods02.ts | 46 +++++++++++++++++++ ...cCommentTemplateNamespacesAndModules01.ts} | 0 ...ocCommentTemplateNamespacesAndModules02.ts | 36 +++++++++++++++ ...ocCommentTemplateObjectLiteralMethods01.ts | 46 +++++++++++++++++++ 5 files changed, 135 insertions(+) create mode 100644 tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts rename tests/cases/fourslash/{docCommentTemplateNamespaces01.ts => docCommentTemplateNamespacesAndModules01.ts} (100%) create mode 100644 tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts create mode 100644 tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts diff --git a/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts b/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts index 72f9ce10809..43881c92816 100644 --- a/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts +++ b/tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts @@ -39,6 +39,13 @@ confirmNormalizedJsDoc("0", Indentation.Standard, ` * */`); + +confirmNormalizedJsDoc("1", Indentation.Indented, + `/** + * + */`); + + confirmNormalizedJsDoc("2", Indentation.Indented, `/** * diff --git a/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts b/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts new file mode 100644 index 00000000000..99392cf3855 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateClassDeclMethods02.ts @@ -0,0 +1,46 @@ +/// + +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, indentation: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, indentation); +} + +const enum Indentation { + Indented = 12, +} + + +////class C { +//// /*0*/ +//// [Symbol.iterator]() { +//// return undefined; +//// } +//// /*1*/ +//// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { } +////} + +confirmNormalizedJsDoc("0", Indentation.Indented, + `/** + * + */`); + +confirmNormalizedJsDoc("1", Indentation.Indented, + `/** + * + * @param x + * @param y + * @param z + */`); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateNamespaces01.ts b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts similarity index 100% rename from tests/cases/fourslash/docCommentTemplateNamespaces01.ts rename to tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts diff --git a/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts new file mode 100644 index 00000000000..e59b16d6163 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateNamespacesAndModules02.ts @@ -0,0 +1,36 @@ +/// + +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, charOffset: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, charOffset); +} + +/////*top*/ +////namespace n1. +//// /*n2*/ n2. +//// /*n3*/ n3 { +////} + +confirmNormalizedJsDoc("top", /*indentation*/ 8, ` +/** + * + */`); + +goTo.marker("n2"); +verify.noDocCommentTemplate(); + +goTo.marker("n3"); +verify.noDocCommentTemplate(); \ No newline at end of file diff --git a/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts b/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts new file mode 100644 index 00000000000..4af1b60c698 --- /dev/null +++ b/tests/cases/fourslash/docCommentTemplateObjectLiteralMethods01.ts @@ -0,0 +1,46 @@ +/// + +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, indentation: number, template: string): void { + goTo.marker(markerName); + const normalized = useCRLFAndStripLeadingNewline(template); + verify.DocCommentTemplate(normalized, indentation); +} + +const enum Indentation { + Indented = 12, +} + + +////var x = { +//// /*0*/ +//// foo() { +//// return undefined; +//// } +//// /*1*/ +//// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { } +////} + +confirmNormalizedJsDoc("0", Indentation.Indented, + `/** + * + */`); + +confirmNormalizedJsDoc("1", Indentation.Indented, + `/** + * + * @param x + * @param y + * @param z + */`); \ No newline at end of file