Skip to content

Commit 08e2b0a

Browse files
Added tests for dotted namespace declarations, object literal methods.
1 parent 67b44b5 commit 08e2b0a

5 files changed

Lines changed: 135 additions & 0 deletions

tests/cases/fourslash/docCommentTemplateClassDeclMethods01.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ confirmNormalizedJsDoc("0", Indentation.Standard, `
3939
*
4040
*/`);
4141

42+
43+
confirmNormalizedJsDoc("1", Indentation.Indented,
44+
`/**
45+
*
46+
*/`);
47+
48+
4249
confirmNormalizedJsDoc("2", Indentation.Indented,
4350
`/**
4451
*
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
const CRLF = "\r\n";
4+
/**
5+
* @returns the given value with '\n' normalized to '\r\n' and with no leading newline
6+
*/
7+
function useCRLFAndStripLeadingNewline(str: string): string {
8+
str = str.replace(/\r?\n/g, CRLF);
9+
if (str.indexOf(CRLF) === 0) {
10+
str = str.slice(CRLF.length);
11+
}
12+
return str;
13+
}
14+
15+
function confirmNormalizedJsDoc(markerName: string, indentation: number, template: string): void {
16+
goTo.marker(markerName);
17+
const normalized = useCRLFAndStripLeadingNewline(template);
18+
verify.DocCommentTemplate(normalized, indentation);
19+
}
20+
21+
const enum Indentation {
22+
Indented = 12,
23+
}
24+
25+
26+
////class C {
27+
//// /*0*/
28+
//// [Symbol.iterator]() {
29+
//// return undefined;
30+
//// }
31+
//// /*1*/
32+
//// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { }
33+
////}
34+
35+
confirmNormalizedJsDoc("0", Indentation.Indented,
36+
`/**
37+
*
38+
*/`);
39+
40+
confirmNormalizedJsDoc("1", Indentation.Indented,
41+
`/**
42+
*
43+
* @param x
44+
* @param y
45+
* @param z
46+
*/`);

tests/cases/fourslash/docCommentTemplateNamespaces01.ts renamed to tests/cases/fourslash/docCommentTemplateNamespacesAndModules01.ts

File renamed without changes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
const CRLF = "\r\n";
4+
/**
5+
* @returns the given value with '\n' normalized to '\r\n' and with no leading newline
6+
*/
7+
function useCRLFAndStripLeadingNewline(str: string): string {
8+
str = str.replace(/\r?\n/g, CRLF);
9+
if (str.indexOf(CRLF) === 0) {
10+
str = str.slice(CRLF.length);
11+
}
12+
return str;
13+
}
14+
15+
function confirmNormalizedJsDoc(markerName: string, charOffset: number, template: string): void {
16+
goTo.marker(markerName);
17+
const normalized = useCRLFAndStripLeadingNewline(template);
18+
verify.DocCommentTemplate(normalized, charOffset);
19+
}
20+
21+
/////*top*/
22+
////namespace n1.
23+
//// /*n2*/ n2.
24+
//// /*n3*/ n3 {
25+
////}
26+
27+
confirmNormalizedJsDoc("top", /*indentation*/ 8, `
28+
/**
29+
*
30+
*/`);
31+
32+
goTo.marker("n2");
33+
verify.noDocCommentTemplate();
34+
35+
goTo.marker("n3");
36+
verify.noDocCommentTemplate();
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
const CRLF = "\r\n";
4+
/**
5+
* @returns the given value with '\n' normalized to '\r\n' and with no leading newline
6+
*/
7+
function useCRLFAndStripLeadingNewline(str: string): string {
8+
str = str.replace(/\r?\n/g, CRLF);
9+
if (str.indexOf(CRLF) === 0) {
10+
str = str.slice(CRLF.length);
11+
}
12+
return str;
13+
}
14+
15+
function confirmNormalizedJsDoc(markerName: string, indentation: number, template: string): void {
16+
goTo.marker(markerName);
17+
const normalized = useCRLFAndStripLeadingNewline(template);
18+
verify.DocCommentTemplate(normalized, indentation);
19+
}
20+
21+
const enum Indentation {
22+
Indented = 12,
23+
}
24+
25+
26+
////var x = {
27+
//// /*0*/
28+
//// foo() {
29+
//// return undefined;
30+
//// }
31+
//// /*1*/
32+
//// [1 + 2 + 3 + Math.rand()](x: number, y: string, z = true) { }
33+
////}
34+
35+
confirmNormalizedJsDoc("0", Indentation.Indented,
36+
`/**
37+
*
38+
*/`);
39+
40+
confirmNormalizedJsDoc("1", Indentation.Indented,
41+
`/**
42+
*
43+
* @param x
44+
* @param y
45+
* @param z
46+
*/`);

0 commit comments

Comments
 (0)