Add and update jsdoc annotation refactoring tests

This commit is contained in:
Nathan Shively-Sanders 2017-10-11 13:34:16 -07:00
parent 4930cad653
commit 1a1c1f9e93
14 changed files with 47 additions and 258 deletions

View file

@ -12,4 +12,4 @@ verify.fileAfterApplyingRefactorAtMarker('1',
* @param {?} x
* @returns {number}
*/
var f = (x): number => x`, 'Annotate with return type from JSDoc', 'annotate');
var f = (x: any): number => x`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -12,4 +12,4 @@ verify.fileAfterApplyingRefactorAtMarker('2',
* @param {?} x
* @returns {number}
*/
var f = (x: any) => x`, 'Annotate with type from JSDoc', 'annotate');
var f = (x: any): number => x`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -18,4 +18,4 @@ verify.fileAfterApplyingRefactorAtMarker('1',
*/
m(x): any[] {
}
}`, 'Annotate with return type from JSDoc', 'annotate');
}`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -8,4 +8,4 @@ verify.fileAfterApplyingRefactorAtMarker('1',
`class C {
/** @return {number} */
get c(): number { return 12; }
}`, 'Annotate with return type from JSDoc', 'annotate');
}`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -8,4 +8,4 @@ verify.fileAfterApplyingRefactorAtMarker('1',
`/** @return {number} */
function f(): number {
return 12;
}`, 'Annotate with return type from JSDoc', 'annotate');
}`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -13,134 +13,6 @@
//// */
////function f(/*1*/x, /*2*/y, /*3*/z, /*4*/alpha, /*5*/beta, /*6*/gamma, /*7*/delta, /*8*/epsilon, /*9*/zeta) {
////}
verify.applicableRefactorAvailableAtMarker('1');
verify.fileAfterApplyingRefactorAtMarker('1',
`/**
* @param {Boolean} x
* @param {String} y
* @param {Number} z
* @param {Object} alpha
* @param {date} beta
* @param {promise} gamma
* @param {array} delta
* @param {Array<number>} epsilon
* @param {promise<String>} zeta
*/
function f(x: boolean, y, z, alpha, beta, gamma, delta, epsilon, zeta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('2');
verify.fileAfterApplyingRefactorAtMarker('2',
`/**
* @param {Boolean} x
* @param {String} y
* @param {Number} z
* @param {Object} alpha
* @param {date} beta
* @param {promise} gamma
* @param {array} delta
* @param {Array<number>} epsilon
* @param {promise<String>} zeta
*/
function f(x: boolean, y: string, z, alpha, beta, gamma, delta, epsilon, zeta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('3');
verify.fileAfterApplyingRefactorAtMarker('3',
`/**
* @param {Boolean} x
* @param {String} y
* @param {Number} z
* @param {Object} alpha
* @param {date} beta
* @param {promise} gamma
* @param {array} delta
* @param {Array<number>} epsilon
* @param {promise<String>} zeta
*/
function f(x: boolean, y: string, z: number, alpha, beta, gamma, delta, epsilon, zeta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('4');
verify.fileAfterApplyingRefactorAtMarker('4',
`/**
* @param {Boolean} x
* @param {String} y
* @param {Number} z
* @param {Object} alpha
* @param {date} beta
* @param {promise} gamma
* @param {array} delta
* @param {Array<number>} epsilon
* @param {promise<String>} zeta
*/
function f(x: boolean, y: string, z: number, alpha: object, beta, gamma, delta, epsilon, zeta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('5');
verify.fileAfterApplyingRefactorAtMarker('5',
`/**
* @param {Boolean} x
* @param {String} y
* @param {Number} z
* @param {Object} alpha
* @param {date} beta
* @param {promise} gamma
* @param {array} delta
* @param {Array<number>} epsilon
* @param {promise<String>} zeta
*/
function f(x: boolean, y: string, z: number, alpha: object, beta: Date, gamma, delta, epsilon, zeta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('6');
verify.fileAfterApplyingRefactorAtMarker('6',
`/**
* @param {Boolean} x
* @param {String} y
* @param {Number} z
* @param {Object} alpha
* @param {date} beta
* @param {promise} gamma
* @param {array} delta
* @param {Array<number>} epsilon
* @param {promise<String>} zeta
*/
function f(x: boolean, y: string, z: number, alpha: object, beta: Date, gamma: Promise<any>, delta, epsilon, zeta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('7');
verify.fileAfterApplyingRefactorAtMarker('7',
`/**
* @param {Boolean} x
* @param {String} y
* @param {Number} z
* @param {Object} alpha
* @param {date} beta
* @param {promise} gamma
* @param {array} delta
* @param {Array<number>} epsilon
* @param {promise<String>} zeta
*/
function f(x: boolean, y: string, z: number, alpha: object, beta: Date, gamma: Promise<any>, delta: Array<any>, epsilon, zeta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('8');
verify.fileAfterApplyingRefactorAtMarker('8',
`/**
* @param {Boolean} x
* @param {String} y
* @param {Number} z
* @param {Object} alpha
* @param {date} beta
* @param {promise} gamma
* @param {array} delta
* @param {Array<number>} epsilon
* @param {promise<String>} zeta
*/
function f(x: boolean, y: string, z: number, alpha: object, beta: Date, gamma: Promise<any>, delta: Array<any>, epsilon: Array<number>, zeta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('9');
verify.fileAfterApplyingRefactorAtMarker('9',
`/**
@ -155,4 +27,4 @@ verify.fileAfterApplyingRefactorAtMarker('9',
* @param {promise<String>} zeta
*/
function f(x: boolean, y: string, z: number, alpha: object, beta: Date, gamma: Promise<any>, delta: Array<any>, epsilon: Array<number>, zeta: Promise<string>) {
}`, 'Annotate with type from JSDoc', 'annotate');
}`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -1,9 +1,9 @@
/// <reference path='fourslash.ts' />
// @strict: true
/////** @type {function(*, ...number, ...boolean): void} */
////var /*1*/x;
////var /*1*/x = (x, ys, ...zs) => { };
verify.applicableRefactorAvailableAtMarker('1');
verify.fileAfterApplyingRefactorAtMarker('1',
`/** @type {function(*, ...number, ...boolean): void} */
var x: (arg0: any, arg1: number[], ...rest: boolean[]) => void;`, 'Annotate with type from JSDoc', 'annotate');
var x: (arg0: any, arg1: number[], ...rest: boolean[]) => void = (x, ys, ...zs) => { };`, 'Annotate with type from JSDoc', 'annotate');

View file

@ -0,0 +1,18 @@
/// <reference path='fourslash.ts' />
////class C {
//// /**
//// * @param {number} x - the first parameter
//// */
//// constructor(/*1*/x) {
//// }
////}
verify.applicableRefactorAvailableAtMarker('1');
verify.fileAfterApplyingRefactorAtMarker('1',
`class C {
/**
* @param {number} x - the first parameter
*/
constructor(x: number) {
}
}`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -0,0 +1,11 @@
/// <reference path='fourslash.ts' />
////class C {
//// /** @param {number} value */
//// set c(/*1*/value) { return 12 }
////}
verify.applicableRefactorAvailableAtMarker('1');
verify.fileAfterApplyingRefactorAtMarker('1',
`class C {
/** @param {number} value */
set c(value: number) { return 12; }
}`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -9,37 +9,10 @@
////function f(/*1*/x, /*2*/y, /*3*/z: string, /*4*/alpha, /*5*/beta) {
////}
verify.applicableRefactorAvailableAtMarker('1');
verify.fileAfterApplyingRefactorAtMarker('1',
`/**
* @param {number} x - the first parameter
* @param {{ a: string, b: Date }} y - the most complex parameter
* @param z - the best parameter
* @param alpha - the other best parameter
* @param {*} beta - I have no idea how this got here
*/
function f(x: number, y, z: string, alpha, beta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('2');
verify.fileAfterApplyingRefactorAtMarker('2',
`/**
* @param {number} x - the first parameter
* @param {{ a: string, b: Date }} y - the most complex parameter
* @param z - the best parameter
* @param alpha - the other best parameter
* @param {*} beta - I have no idea how this got here
*/
function f(x: number, y: {
a: string;
b: Date;
}, z: string, alpha, beta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.not.applicableRefactorAvailableAtMarker('3');
verify.not.applicableRefactorAvailableAtMarker('4');
verify.applicableRefactorAvailableAtMarker('5');
verify.fileAfterApplyingRefactorAtMarker('5',
verify.applicableRefactorAvailableAtMarker('1');
verify.fileAfterApplyingRefactorAtMarker('1',
`/**
* @param {number} x - the first parameter
* @param {{ a: string, b: Date }} y - the most complex parameter
@ -51,4 +24,5 @@ function f(x: number, y: {
a: string;
b: Date;
}, z: string, alpha, beta: any) {
}`, 'Annotate with type from JSDoc', 'annotate');
}`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -12,94 +12,8 @@
////function f(/*1*/x, /*2*/y, /*3*/z, /*4*/alpha, /*5*/beta, /*6*/gamma, /*7*/delta) {
////}
verify.applicableRefactorAvailableAtMarker('1');
verify.fileAfterApplyingRefactorAtMarker('1',
`/**
* @param {*} x
* @param {?} y
* @param {number=} z
* @param {...number} alpha
* @param {function(this:{ a: string}, string, number): boolean} beta
* @param {number?} gamma
* @param {number!} delta
*/
function f(x: any, y, z, alpha, beta, gamma, delta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('2');
verify.fileAfterApplyingRefactorAtMarker('2',
`/**
* @param {*} x
* @param {?} y
* @param {number=} z
* @param {...number} alpha
* @param {function(this:{ a: string}, string, number): boolean} beta
* @param {number?} gamma
* @param {number!} delta
*/
function f(x: any, y: any, z, alpha, beta, gamma, delta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('3');
verify.fileAfterApplyingRefactorAtMarker('3',
`/**
* @param {*} x
* @param {?} y
* @param {number=} z
* @param {...number} alpha
* @param {function(this:{ a: string}, string, number): boolean} beta
* @param {number?} gamma
* @param {number!} delta
*/
function f(x: any, y: any, z: number | undefined, alpha, beta, gamma, delta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('4');
verify.fileAfterApplyingRefactorAtMarker('4',
`/**
* @param {*} x
* @param {?} y
* @param {number=} z
* @param {...number} alpha
* @param {function(this:{ a: string}, string, number): boolean} beta
* @param {number?} gamma
* @param {number!} delta
*/
function f(x: any, y: any, z: number | undefined, alpha: number[], beta, gamma, delta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('5');
verify.fileAfterApplyingRefactorAtMarker('5',
`/**
* @param {*} x
* @param {?} y
* @param {number=} z
* @param {...number} alpha
* @param {function(this:{ a: string}, string, number): boolean} beta
* @param {number?} gamma
* @param {number!} delta
*/
function f(x: any, y: any, z: number | undefined, alpha: number[], beta: (this: {
a: string;
}, arg1: string, arg2: number) => boolean, gamma, delta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('6');
verify.fileAfterApplyingRefactorAtMarker('6',
`/**
* @param {*} x
* @param {?} y
* @param {number=} z
* @param {...number} alpha
* @param {function(this:{ a: string}, string, number): boolean} beta
* @param {number?} gamma
* @param {number!} delta
*/
function f(x: any, y: any, z: number | undefined, alpha: number[], beta: (this: {
a: string;
}, arg1: string, arg2: number) => boolean, gamma: number | null, delta) {
}`, 'Annotate with type from JSDoc', 'annotate');
verify.applicableRefactorAvailableAtMarker('7');
verify.fileAfterApplyingRefactorAtMarker('7',
`/**
* @param {*} x
* @param {?} y
@ -112,4 +26,4 @@ verify.fileAfterApplyingRefactorAtMarker('7',
function f(x: any, y: any, z: number | undefined, alpha: number[], beta: (this: {
a: string;
}, arg1: string, arg2: number) => boolean, gamma: number | null, delta: number) {
}`, 'Annotate with type from JSDoc', 'annotate');
}`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -13,5 +13,5 @@ verify.fileAfterApplyingRefactorAtMarker('1',
* @param {number} x
* @returns {number}
*/
function f(x): number {
}`, 'Annotate with return type from JSDoc', 'annotate');
function f(x: number): number {
}`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -13,5 +13,5 @@ verify.fileAfterApplyingRefactorAtMarker('1',
* @param {number} x
* @returns {number}
*/
var f = function(x): number {
}`, 'Annotate with return type from JSDoc', 'annotate');
var f = function(x: number): number {
}`, 'Annotate with types from JSDoc', 'annotate');

View file

@ -12,4 +12,4 @@ verify.fileAfterApplyingRefactorAtMarker('1',
* @param {?} x
* @returns {number}
*/
var f = (x: any) => x`, 'Annotate with type from JSDoc', 'annotate');
var f = (x: any): number => x`, 'Annotate with types from JSDoc', 'annotate');