Add more jsdoc tests

This commit is contained in:
Nathan Shively-Sanders 2016-09-01 09:25:49 -07:00
parent 65d1079f8f
commit b14d7c7ebb
11 changed files with 155 additions and 1 deletions

View File

@ -0,0 +1,9 @@
// @allowJs: true
// @filename: returns.js
// @out: dummy.js
/**
* @returns {string} This comment is not currently exposed
*/
function f() {
return "";
}

View File

@ -0,0 +1,15 @@
///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////**
//// * Do some foo things
//// * @template T A Foolish template
//// * @param {T} x a parameter
//// */
////function foo(x) {
////}
////
////fo/**/o()
goTo.marker();
verify.quickInfoIs("function foo<T>(x: T): void", "Do some foo things");

View File

@ -0,0 +1,9 @@
///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////**
//// * @type {{ [name: string]: string; }} variables
//// */
////const vari/**/ables = {};
goTo.marker();
verify.quickInfoIs("const variables: {\n [name: string]: string;\n}");

View File

@ -0,0 +1,13 @@
///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////**
//// * @param {{ stringProp: string,
//// * numProp: number }} o
//// */
////function f1(o) {
//// o/**/;
////}
goTo.marker();
verify.quickInfoIs("(parameter) o: any");

View File

@ -9,4 +9,4 @@
//// f6('', /**/false)
goTo.marker();
verify.currentSignatureHelpIs('f6(p0: string, p1?: boolean): number')
verify.currentSignatureHelpIs('f6(arg0: string, arg1?: boolean): number')

View File

@ -0,0 +1,18 @@
///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////**
//// * Filters a path based on a regexp or glob pattern.
//// * @param {String} basePath The base path where the search will be performed.
//// * @param {String} pattern A string defining a regexp of a glob pattern.
//// * @param {String} type The search pattern type, can be a regexp or a glob.
//// * @param {Object} options A object containing options to the search.
//// * @return {Array} A list containing the filtered paths.
//// */
////function pathFilter(basePath, pattern, type, options){
//////...
////}
////pathFilter(/**/'foo', 'bar', 'baz', {});
goTo.marker();
verify.currentSignatureHelpDocCommentIs("Filters a path based on a regexp or glob pattern.");

View File

@ -0,0 +1,19 @@
///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////**
//// * @param {string} p1 - A string param
//// * @param {string?} p2 - An optional param
//// * @param {string} [p3] - Another optional param
//// * @param {string} [p4="test"] - An optional param with a default value
//// */
////function f1(p1, p2, p3, p4){}
////f1(/*1*/'foo', /*2*/'bar', /*3*/'baz', /*4*/'qux');
goTo.marker('1');
verify.currentParameterHelpArgumentDocCommentIs("- A string param");
goTo.marker('2');
verify.currentParameterHelpArgumentDocCommentIs("- An optional param ");
goTo.marker('3');
verify.currentParameterHelpArgumentDocCommentIs("- Another optional param");
goTo.marker('4');
verify.currentParameterHelpArgumentDocCommentIs("- An optional param with a default value");

View File

@ -0,0 +1,16 @@
///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////**
//// * @param {string} p0
//// * @param {string} [p1]
//// */
////function Test(p0, p1) {
//// this.P0 = p0;
//// this.P1 = p1;
////}
////
////
////var /**/test = new Test("");
goTo.marker();
verify.quickInfoIs('var test: {\n P0: string;\n P1: string;\n}');

View File

@ -0,0 +1,16 @@
///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////**
//// * Represents a person
//// * @constructor
//// * @param {string} name The name of the person
//// * @param {number} age The age of the person
//// */
////function Person(name, age) {
//// this.name = name;
//// this.age = age;
////}
////var p = new Pers/**/on();
goTo.marker();
verify.quickInfoIs("function Person(name: string, age: number): void", "Represents a person");

View File

@ -0,0 +1,22 @@
///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: Foo.js
/////** first line of the comment
////
////third line */
////function foo() {}
////foo/**/();
goTo.marker();
verify.verifyQuickInfoDisplayParts('function',
'',
{ start: 63, length: 3 },
[{"text": "function", "kind": "keyword"},
{"text": " ", "kind": "space"},
{"text": "foo", "kind": "functionName"},
{"text": "(", "kind": "punctuation"},
{"text": ")", "kind": "punctuation"},
{"text": ":", "kind": "punctuation"},
{"text": " ", "kind": "space"},
{"text": "void", "kind": "keyword"}
],
[{"text": "first line of the comment\n\nthird line ", "kind": "text"}]);

View File

@ -0,0 +1,17 @@
///<reference path="fourslash.ts" />
// @allowJs: true
// @Filename: dummy.js
/////**
//// * Find an item
//// * @template T
//// * @param {T[]} l
//// * @param {T} x
//// * @returns {?T} The names of the found item(s).
//// */
////function find(l, x) {
////}
////find(''/**/);
goTo.marker();
verify.currentSignatureHelpIs("find<T>(l: T[], x: T): T")
// There currently isn't a way to display the return tag comment