From 9832f62f48b0d6da4af72efc6ba10160b37e0442 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 8 Jun 2016 10:56:52 -0700 Subject: [PATCH] Split commentsFunction test into expr/decl And renumber. --- tests/cases/fourslash/commentsFunction.ts | 157 ------------------ .../fourslash/commentsFunctionDeclaration.ts | 61 +++++++ .../fourslash/commentsFunctionExpression.ts | 91 ++++++++++ 3 files changed, 152 insertions(+), 157 deletions(-) delete mode 100644 tests/cases/fourslash/commentsFunction.ts create mode 100644 tests/cases/fourslash/commentsFunctionDeclaration.ts create mode 100644 tests/cases/fourslash/commentsFunctionExpression.ts diff --git a/tests/cases/fourslash/commentsFunction.ts b/tests/cases/fourslash/commentsFunction.ts deleted file mode 100644 index 2dff7c357a6..00000000000 --- a/tests/cases/fourslash/commentsFunction.ts +++ /dev/null @@ -1,157 +0,0 @@ -/// - -/////** This comment should appear for foo*/ -////function f/*6*/oo() { -////} -////f/*7*/oo/*4*/(/*1*/); -/////** This is comment for function signature*/ -////function fo/*8*/oWithParameters(/** this is comment about a*/a: string, -//// /** this is comment for b*/ -//// b: number) { -//// var /*20*/d = /*10*/a; -////} -////fooWithParam/*9*/eters/*5*/(/*2*/"a",/*3*/10); -/////** lamdaFoo var comment*/ -////var lamb/*11*/daFoo = /** this is lambda comment*/ (/**param a*/a: number, /**param b*/b: number) => /*18*/a + b; -////var lambddaN/*12*/oVarComment = /** this is lambda multiplication*/ (/**param a*/a: number, /**param b*/b: number) => a * b; -/////*13*/lambdaFoo(/*14*/10, /*15*/20); -////lambddaNoVarComment(/*16*/10, /*17*/20); -/////** -////* Does something -////* @param a a string -////*/ -////declare function fn(a: string); -////fn(/*19*/"hello"); -////var lambdaA/*20a*/notherFunc = (/*21*/a: number) => { -//// var bb/*22*/bb = 10; -//// return /*24*/a + b/*23*/bbb; -////} -////function /*25*/anotherFunc(/*26*/a: number) { -//// var /*27a*/lambdaVar = (/*27*/b: string) => { -//// var /*28*/localVar = "Hello "; -//// return /*29*/localVar + /*30*/b; -//// } -//// return lamb/*31*/daVar("World") + /*32*/a; -////} -/////** -//// * On variable -//// * @param s the first parameter! -//// * @returns the parameter's length -//// */ -////var assi/*33*/gned = /** -//// * Summary on expression -//// * @param s param on expression -//// * @returns return on expression -//// */function(/** On parameter */s: string) { -//// return s.length; -////} -////assig/*34*/ned/*35*/(/*36*/"hey"); - - -goTo.marker('1'); -verify.currentSignatureHelpDocCommentIs("This comment should appear for foo"); - -goTo.marker('2'); -verify.currentSignatureHelpDocCommentIs("This is comment for function signature"); -verify.currentParameterHelpArgumentDocCommentIs("this is comment about a"); - -goTo.marker('3'); -verify.currentSignatureHelpDocCommentIs("This is comment for function signature"); -verify.currentParameterHelpArgumentDocCommentIs("this is comment for b"); - -goTo.marker('4'); -verify.completionListContains('foo', 'function foo(): void', 'This comment should appear for foo'); - -goTo.marker('5'); -verify.completionListContains('fooWithParameters', 'function fooWithParameters(a: string, b: number): void', 'This is comment for function signature'); - -goTo.marker('6'); -verify.quickInfoIs("function foo(): void", "This comment should appear for foo"); - -goTo.marker('7'); -verify.quickInfoIs("function foo(): void", "This comment should appear for foo"); - -goTo.marker('8'); -verify.quickInfoIs("function fooWithParameters(a: string, b: number): void", "This is comment for function signature"); - -goTo.marker('9'); -verify.quickInfoIs("function fooWithParameters(a: string, b: number): void", "This is comment for function signature"); - -goTo.marker('10'); -verify.completionListContains('a', '(parameter) a: string', 'this is comment about a'); -verify.completionListContains('b', '(parameter) b: number', 'this is comment for b'); - -goTo.marker('11'); -verify.quickInfoIs("var lambdaFoo: (a: number, b: number) => number", "lamdaFoo var comment\nthis is lambda comment"); - -goTo.marker('12'); -// pick up doccomments from the lambda itself -verify.quickInfoIs("var lambddaNoVarComment: (a: number, b: number) => number", "this is lambda multiplication"); - -goTo.marker('13'); -verify.completionListContains('lambdaFoo', 'var lambdaFoo: (a: number, b: number) => number', 'lamdaFoo var comment\nthis is lambda comment'); -verify.completionListContains('lambddaNoVarComment', 'var lambddaNoVarComment: (a: number, b: number) => number', 'this is lambda multiplication'); - -goTo.marker('14'); -verify.currentParameterHelpArgumentDocCommentIs("param a"); - -goTo.marker('15'); -verify.currentParameterHelpArgumentDocCommentIs("param b"); - -goTo.marker('16'); -verify.currentParameterHelpArgumentDocCommentIs("param a"); - -goTo.marker('17'); -verify.currentParameterHelpArgumentDocCommentIs("param b"); - -goTo.marker('18'); -verify.completionListContains('a', '(parameter) a: number', 'param a'); -verify.completionListContains('b', '(parameter) b: number', 'param b'); - -goTo.marker('19'); -verify.currentSignatureHelpDocCommentIs("Does something"); -verify.currentParameterHelpArgumentDocCommentIs("a string"); - -goTo.marker('20'); -verify.quickInfoIs('(local var) d: string', ''); - -goTo.marker('20a'); -verify.quickInfoIs('var lambdaAnotherFunc: (a: number) => number', ''); -goTo.marker('21'); -verify.quickInfoIs('(parameter) a: number', ''); -goTo.marker('22'); -verify.quickInfoIs('(local var) bbbb: number', ''); -goTo.marker('23'); -verify.quickInfoIs('(local var) bbbb: number', ''); -goTo.marker('24'); -verify.quickInfoIs('(parameter) a: number', ''); - -goTo.marker('25'); -verify.quickInfoIs('function anotherFunc(a: number): string', ''); -goTo.marker('26'); -verify.quickInfoIs('(parameter) a: number', ''); -goTo.marker('27a'); -verify.quickInfoIs('(local var) lambdaVar: (b: string) => string', ''); -goTo.marker('27'); -verify.quickInfoIs('(parameter) b: string', ''); -goTo.marker('28'); -verify.quickInfoIs('(local var) localVar: string', ''); -goTo.marker('29'); -verify.quickInfoIs('(local var) localVar: string', ''); -goTo.marker('30'); -verify.quickInfoIs('(parameter) b: string', ''); -goTo.marker('31'); -verify.quickInfoIs('(local var) lambdaVar: (b: string) => string', ''); -goTo.marker('32'); -verify.quickInfoIs('(parameter) a: number', ''); - -goTo.marker('33'); -verify.quickInfoIs("var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); -goTo.marker('34'); -verify.quickInfoIs("var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); -goTo.marker('35'); -verify.completionListContains("assigned", "var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); -goTo.marker('36'); -verify.currentSignatureHelpDocCommentIs("On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); -verify.currentParameterHelpArgumentDocCommentIs("the first parameter!\nparam on expression\nOn parameter "); - diff --git a/tests/cases/fourslash/commentsFunctionDeclaration.ts b/tests/cases/fourslash/commentsFunctionDeclaration.ts new file mode 100644 index 00000000000..892cbf90760 --- /dev/null +++ b/tests/cases/fourslash/commentsFunctionDeclaration.ts @@ -0,0 +1,61 @@ +/// + +/////** This comment should appear for foo*/ +////function f/*1*/oo() { +////} +////f/*2*/oo/*3*/(/*4*/); +/////** This is comment for function signature*/ +////function fo/*5*/oWithParameters(/** this is comment about a*/a: string, +//// /** this is comment for b*/ +//// b: number) { +//// var /*6*/d = /*7*/a; +////} +////fooWithParam/*8*/eters/*9*/(/*10*/"a",/*11*/10); + +// ambient declaration +/////** +////* Does something +////* @param a a string +////*/ +////declare function fn(a: string); +////fn(/*12*/"hello"); + +goTo.marker('1'); +verify.quickInfoIs("function foo(): void", "This comment should appear for foo"); + +goTo.marker('2'); +verify.quickInfoIs("function foo(): void", "This comment should appear for foo"); + +goTo.marker('3'); +verify.completionListContains('foo', 'function foo(): void', 'This comment should appear for foo'); + +goTo.marker('4'); +verify.currentSignatureHelpDocCommentIs("This comment should appear for foo"); + +goTo.marker('5'); +verify.quickInfoIs("function fooWithParameters(a: string, b: number): void", "This is comment for function signature"); + +goTo.marker('6'); +verify.quickInfoIs('(local var) d: string', ''); + +goTo.marker('7'); +verify.completionListContains('a', '(parameter) a: string', 'this is comment about a'); +verify.completionListContains('b', '(parameter) b: number', 'this is comment for b'); + +goTo.marker('8'); +verify.quickInfoIs("function fooWithParameters(a: string, b: number): void", "This is comment for function signature"); + +goTo.marker('9'); +verify.completionListContains('fooWithParameters', 'function fooWithParameters(a: string, b: number): void', 'This is comment for function signature'); + +goTo.marker('10'); +verify.currentSignatureHelpDocCommentIs("This is comment for function signature"); +verify.currentParameterHelpArgumentDocCommentIs("this is comment about a"); + +goTo.marker('11'); +verify.currentSignatureHelpDocCommentIs("This is comment for function signature"); +verify.currentParameterHelpArgumentDocCommentIs("this is comment for b"); + +goTo.marker('12'); +verify.currentSignatureHelpDocCommentIs("Does something"); +verify.currentParameterHelpArgumentDocCommentIs("a string"); diff --git a/tests/cases/fourslash/commentsFunctionExpression.ts b/tests/cases/fourslash/commentsFunctionExpression.ts new file mode 100644 index 00000000000..ace3b07d455 --- /dev/null +++ b/tests/cases/fourslash/commentsFunctionExpression.ts @@ -0,0 +1,91 @@ +/// +// TODO: Salsa test! With types! +// TODO: Renumber!!!! +// TODO:Remove some duplicate tests + +// test arrow doc comments +/////** lamdaFoo var comment*/ +////var lamb/*1*/daFoo = /** this is lambda comment*/ (/**param a*/a: number, /**param b*/b: number) => /*2*/a + b; +////var lambddaN/*3*/oVarComment = /** this is lambda multiplication*/ (/**param a*/a: number, /**param b*/b: number) => a * b; +/////*4*/lambdaFoo(/*5*/10, /*6*/20); + +// test nested arrow doc comments +////function /*7*/anotherFunc(a: number) { +//// /** documentation +//// @param b {string} inner parameter */ +//// var /*8*/lambdaVar = /** inner docs */(/*9*/b: string) => { +//// var /*10*/localVar = "Hello "; +//// return /*11*/localVar + /*12*/b; +//// } +//// return lamb/*13*/daVar("World") + a; +////} + +// test function expression doc comments +/////** +//// * On variable +//// * @param s the first parameter! +//// * @returns the parameter's length +//// */ +////var assi/*14*/gned = /** +//// * Summary on expression +//// * @param s param on expression +//// * @returns return on expression +//// */function(/** On parameter */s: string) { +//// return /*15*/s.length; +////} +////assig/*16*/ned/*17*/(/*18*/"hey"); + + + +goTo.marker('1'); +verify.quickInfoIs("var lambdaFoo: (a: number, b: number) => number", "lamdaFoo var comment\nthis is lambda comment"); + +goTo.marker('2'); +verify.completionListContains('a', '(parameter) a: number', 'param a'); +verify.completionListContains('b', '(parameter) b: number', 'param b'); + +goTo.marker('3'); +// pick up doccomments from the lambda itself +verify.quickInfoIs("var lambddaNoVarComment: (a: number, b: number) => number", "this is lambda multiplication"); + +goTo.marker('4'); +verify.completionListContains('lambdaFoo', 'var lambdaFoo: (a: number, b: number) => number', 'lamdaFoo var comment\nthis is lambda comment'); +verify.completionListContains('lambddaNoVarComment', 'var lambddaNoVarComment: (a: number, b: number) => number', 'this is lambda multiplication'); + +goTo.marker('5'); +verify.currentParameterHelpArgumentDocCommentIs("param a"); + +goTo.marker('6'); +verify.currentParameterHelpArgumentDocCommentIs("param b"); + + + + +goTo.marker('7'); +// no documentation from nested lambda +verify.quickInfoIs('function anotherFunc(a: number): string', ''); +goTo.marker('8'); +verify.quickInfoIs('(local var) lambdaVar: (b: string) => string', 'documentation\ninner docs '); +goTo.marker('9'); +verify.quickInfoIs('(parameter) b: string', '{string} inner parameter '); +goTo.marker('10'); +verify.quickInfoIs('(local var) localVar: string', ''); +goTo.marker('11'); +verify.quickInfoIs('(local var) localVar: string', ''); +goTo.marker('12'); +verify.quickInfoIs('(parameter) b: string', '{string} inner parameter '); +goTo.marker('13'); +verify.quickInfoIs('(local var) lambdaVar: (b: string) => string', 'documentation\ninner docs '); + +goTo.marker('14'); +verify.quickInfoIs("var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); +goTo.marker('15'); +verify.completionListContains('s', '(parameter) s: string', "the first parameter!\nparam on expression\nOn parameter "); +goTo.marker('16'); +verify.quickInfoIs("var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); +goTo.marker('17'); +verify.completionListContains("assigned", "var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); +goTo.marker('18'); +verify.currentSignatureHelpDocCommentIs("On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); +verify.currentParameterHelpArgumentDocCommentIs("the first parameter!\nparam on expression\nOn parameter "); +