Skip to content

Commit 9832f62

Browse files
committed
Split commentsFunction test into expr/decl
And renumber.
1 parent 6bf5f11 commit 9832f62

3 files changed

Lines changed: 152 additions & 157 deletions

File tree

tests/cases/fourslash/commentsFunction.ts

Lines changed: 0 additions & 157 deletions
This file was deleted.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
/////** This comment should appear for foo*/
4+
////function f/*1*/oo() {
5+
////}
6+
////f/*2*/oo/*3*/(/*4*/);
7+
/////** This is comment for function signature*/
8+
////function fo/*5*/oWithParameters(/** this is comment about a*/a: string,
9+
//// /** this is comment for b*/
10+
//// b: number) {
11+
//// var /*6*/d = /*7*/a;
12+
////}
13+
////fooWithParam/*8*/eters/*9*/(/*10*/"a",/*11*/10);
14+
15+
// ambient declaration
16+
/////**
17+
////* Does something
18+
////* @param a a string
19+
////*/
20+
////declare function fn(a: string);
21+
////fn(/*12*/"hello");
22+
23+
goTo.marker('1');
24+
verify.quickInfoIs("function foo(): void", "This comment should appear for foo");
25+
26+
goTo.marker('2');
27+
verify.quickInfoIs("function foo(): void", "This comment should appear for foo");
28+
29+
goTo.marker('3');
30+
verify.completionListContains('foo', 'function foo(): void', 'This comment should appear for foo');
31+
32+
goTo.marker('4');
33+
verify.currentSignatureHelpDocCommentIs("This comment should appear for foo");
34+
35+
goTo.marker('5');
36+
verify.quickInfoIs("function fooWithParameters(a: string, b: number): void", "This is comment for function signature");
37+
38+
goTo.marker('6');
39+
verify.quickInfoIs('(local var) d: string', '');
40+
41+
goTo.marker('7');
42+
verify.completionListContains('a', '(parameter) a: string', 'this is comment about a');
43+
verify.completionListContains('b', '(parameter) b: number', 'this is comment for b');
44+
45+
goTo.marker('8');
46+
verify.quickInfoIs("function fooWithParameters(a: string, b: number): void", "This is comment for function signature");
47+
48+
goTo.marker('9');
49+
verify.completionListContains('fooWithParameters', 'function fooWithParameters(a: string, b: number): void', 'This is comment for function signature');
50+
51+
goTo.marker('10');
52+
verify.currentSignatureHelpDocCommentIs("This is comment for function signature");
53+
verify.currentParameterHelpArgumentDocCommentIs("this is comment about a");
54+
55+
goTo.marker('11');
56+
verify.currentSignatureHelpDocCommentIs("This is comment for function signature");
57+
verify.currentParameterHelpArgumentDocCommentIs("this is comment for b");
58+
59+
goTo.marker('12');
60+
verify.currentSignatureHelpDocCommentIs("Does something");
61+
verify.currentParameterHelpArgumentDocCommentIs("a string");
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/// <reference path='fourslash.ts' />
2+
// TODO: Salsa test! With types!
3+
// TODO: Renumber!!!!
4+
// TODO:Remove some duplicate tests
5+
6+
// test arrow doc comments
7+
/////** lamdaFoo var comment*/
8+
////var lamb/*1*/daFoo = /** this is lambda comment*/ (/**param a*/a: number, /**param b*/b: number) => /*2*/a + b;
9+
////var lambddaN/*3*/oVarComment = /** this is lambda multiplication*/ (/**param a*/a: number, /**param b*/b: number) => a * b;
10+
/////*4*/lambdaFoo(/*5*/10, /*6*/20);
11+
12+
// test nested arrow doc comments
13+
////function /*7*/anotherFunc(a: number) {
14+
//// /** documentation
15+
//// @param b {string} inner parameter */
16+
//// var /*8*/lambdaVar = /** inner docs */(/*9*/b: string) => {
17+
//// var /*10*/localVar = "Hello ";
18+
//// return /*11*/localVar + /*12*/b;
19+
//// }
20+
//// return lamb/*13*/daVar("World") + a;
21+
////}
22+
23+
// test function expression doc comments
24+
/////**
25+
//// * On variable
26+
//// * @param s the first parameter!
27+
//// * @returns the parameter's length
28+
//// */
29+
////var assi/*14*/gned = /**
30+
//// * Summary on expression
31+
//// * @param s param on expression
32+
//// * @returns return on expression
33+
//// */function(/** On parameter */s: string) {
34+
//// return /*15*/s.length;
35+
////}
36+
////assig/*16*/ned/*17*/(/*18*/"hey");
37+
38+
39+
40+
goTo.marker('1');
41+
verify.quickInfoIs("var lambdaFoo: (a: number, b: number) => number", "lamdaFoo var comment\nthis is lambda comment");
42+
43+
goTo.marker('2');
44+
verify.completionListContains('a', '(parameter) a: number', 'param a');
45+
verify.completionListContains('b', '(parameter) b: number', 'param b');
46+
47+
goTo.marker('3');
48+
// pick up doccomments from the lambda itself
49+
verify.quickInfoIs("var lambddaNoVarComment: (a: number, b: number) => number", "this is lambda multiplication");
50+
51+
goTo.marker('4');
52+
verify.completionListContains('lambdaFoo', 'var lambdaFoo: (a: number, b: number) => number', 'lamdaFoo var comment\nthis is lambda comment');
53+
verify.completionListContains('lambddaNoVarComment', 'var lambddaNoVarComment: (a: number, b: number) => number', 'this is lambda multiplication');
54+
55+
goTo.marker('5');
56+
verify.currentParameterHelpArgumentDocCommentIs("param a");
57+
58+
goTo.marker('6');
59+
verify.currentParameterHelpArgumentDocCommentIs("param b");
60+
61+
62+
63+
64+
goTo.marker('7');
65+
// no documentation from nested lambda
66+
verify.quickInfoIs('function anotherFunc(a: number): string', '');
67+
goTo.marker('8');
68+
verify.quickInfoIs('(local var) lambdaVar: (b: string) => string', 'documentation\ninner docs ');
69+
goTo.marker('9');
70+
verify.quickInfoIs('(parameter) b: string', '{string} inner parameter ');
71+
goTo.marker('10');
72+
verify.quickInfoIs('(local var) localVar: string', '');
73+
goTo.marker('11');
74+
verify.quickInfoIs('(local var) localVar: string', '');
75+
goTo.marker('12');
76+
verify.quickInfoIs('(parameter) b: string', '{string} inner parameter ');
77+
goTo.marker('13');
78+
verify.quickInfoIs('(local var) lambdaVar: (b: string) => string', 'documentation\ninner docs ');
79+
80+
goTo.marker('14');
81+
verify.quickInfoIs("var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression");
82+
goTo.marker('15');
83+
verify.completionListContains('s', '(parameter) s: string', "the first parameter!\nparam on expression\nOn parameter ");
84+
goTo.marker('16');
85+
verify.quickInfoIs("var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression");
86+
goTo.marker('17');
87+
verify.completionListContains("assigned", "var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression");
88+
goTo.marker('18');
89+
verify.currentSignatureHelpDocCommentIs("On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression");
90+
verify.currentParameterHelpArgumentDocCommentIs("the first parameter!\nparam on expression\nOn parameter ");
91+

0 commit comments

Comments
 (0)