Add tests and update baselines

This commit is contained in:
Kanchalai Tanglertsampan 2017-05-23 16:11:23 -07:00
parent 72e6678804
commit bd422e3a52
11 changed files with 1485 additions and 0 deletions

View file

@ -0,0 +1,584 @@
[
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 26
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 26,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "S",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 55
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 55,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "N",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 85
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 85,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "B",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "boolean",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 112
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 112,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "V",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 144
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 144,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "U",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "undefined",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 171
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 171,
"length": 2
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Nl",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "null",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 200
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 200,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "A",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
},
{
"text": "[",
"kind": "punctuation"
},
{
"text": "]",
"kind": "punctuation"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 230
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 230,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "P",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Promise",
"kind": "interfaceName"
},
{
"text": "<",
"kind": "punctuation"
},
{
"text": "any",
"kind": "keyword"
},
{
"text": ">",
"kind": "punctuation"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 259
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 259,
"length": 3
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Obj",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 292
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 292,
"length": 4
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Func",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Function",
"kind": "localName"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 319
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 319,
"length": 7
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "AnyType",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 349
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 349,
"length": 5
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "QType",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag1.js",
"position": 389
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 389,
"length": 4
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "SOrN",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "|",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
}
]

View file

@ -0,0 +1,598 @@
[
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 26
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 26,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "s",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 55
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 55,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "n",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 85
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 85,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "b",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "boolean",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 112
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 112,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "v",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 144
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 144,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "u",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "undefined",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 171
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 171,
"length": 2
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "nl",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "null",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 200
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 200,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "a",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
},
{
"text": "[",
"kind": "punctuation"
},
{
"text": "]",
"kind": "punctuation"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 230
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 230,
"length": 1
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "p",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "Promise",
"kind": "interfaceName"
},
{
"text": "<",
"kind": "punctuation"
},
{
"text": "any",
"kind": "keyword"
},
{
"text": ">",
"kind": "punctuation"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 260
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 260,
"length": 8
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "nullable",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 298
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 298,
"length": 4
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "func",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=>",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 349
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 349,
"length": 5
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "func1",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": "arg0",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=>",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/jsDocTypeTag2.js",
"position": 391
},
"quickInfo": {
"kind": "var",
"kindModifiers": "",
"textSpan": {
"start": 391,
"length": 4
},
"displayParts": [
{
"text": "var",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "sOrn",
"kind": "localName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "|",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
}
],
"documentation": [],
"tags": []
}
}
]

View file

@ -0,0 +1,37 @@
//// [0.js]
// @ts-check
/** @type {*} */
var anyT = 2;
/** @type {?} */
var anyT1 = 2;
anyT1 = "hi";
/** @type {Function} */
const x = (a) => a + 1;
x(1);
/** @type {function (number)} */
const x1 = (a) => a + 1;
x1(0);
/** @type {function (number): number} */
const x2 = (a) => a + 1;
x2(0);
//// [0.js]
// @ts-check
/** @type {*} */
var anyT = 2;
/** @type {?} */
var anyT1 = 2;
anyT1 = "hi";
/** @type {Function} */
var x = function (a) { return a + 1; };
x(1);
/** @type {function (number)} */
var x1 = function (a) { return a + 1; };
x1(0);
/** @type {function (number): number} */
var x2 = function (a) { return a + 1; };
x2(0);

View file

@ -0,0 +1,40 @@
=== tests/cases/conformance/salsa/0.js ===
// @ts-check
/** @type {*} */
var anyT = 2;
>anyT : Symbol(anyT, Decl(0.js, 2, 3))
/** @type {?} */
var anyT1 = 2;
>anyT1 : Symbol(anyT1, Decl(0.js, 5, 3))
anyT1 = "hi";
>anyT1 : Symbol(anyT1, Decl(0.js, 5, 3))
/** @type {Function} */
const x = (a) => a + 1;
>x : Symbol(x, Decl(0.js, 9, 5))
>a : Symbol(a, Decl(0.js, 9, 11))
>a : Symbol(a, Decl(0.js, 9, 11))
x(1);
>x : Symbol(x, Decl(0.js, 9, 5))
/** @type {function (number)} */
const x1 = (a) => a + 1;
>x1 : Symbol(x1, Decl(0.js, 13, 5))
>a : Symbol(a, Decl(0.js, 13, 12))
>a : Symbol(a, Decl(0.js, 13, 12))
x1(0);
>x1 : Symbol(x1, Decl(0.js, 13, 5))
/** @type {function (number): number} */
const x2 = (a) => a + 1;
>x2 : Symbol(x2, Decl(0.js, 17, 5))
>a : Symbol(a, Decl(0.js, 17, 12))
>a : Symbol(a, Decl(0.js, 17, 12))
x2(0);
>x2 : Symbol(x2, Decl(0.js, 17, 5))

View file

@ -0,0 +1,59 @@
=== tests/cases/conformance/salsa/0.js ===
// @ts-check
/** @type {*} */
var anyT = 2;
>anyT : any
>2 : 2
/** @type {?} */
var anyT1 = 2;
>anyT1 : any
>2 : 2
anyT1 = "hi";
>anyT1 = "hi" : "hi"
>anyT1 : any
>"hi" : "hi"
/** @type {Function} */
const x = (a) => a + 1;
>x : Function
>(a) => a + 1 : (a: any) => any
>a : any
>a + 1 : any
>a : any
>1 : 1
x(1);
>x(1) : any
>x : Function
>1 : 1
/** @type {function (number)} */
const x1 = (a) => a + 1;
>x1 : (arg0: number) => any
>(a) => a + 1 : (a: any) => any
>a : any
>a + 1 : any
>a : any
>1 : 1
x1(0);
>x1(0) : any
>x1 : (arg0: number) => any
>0 : 0
/** @type {function (number): number} */
const x2 = (a) => a + 1;
>x2 : (arg0: number) => number
>(a) => a + 1 : (a: any) => any
>a : any
>a + 1 : any
>a : any
>1 : 1
x2(0);
>x2(0) : number
>x2 : (arg0: number) => number
>0 : 0

View file

@ -0,0 +1,21 @@
tests/cases/conformance/salsa/0.js(5,4): error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'.
tests/cases/conformance/salsa/0.js(12,1): error TS2322: Type 'number' is not assignable to type 'string'.
==== tests/cases/conformance/salsa/0.js (2 errors) ====
// @ts-check
/** @type {function (number)} */
const x1 = (a) => a + 1;
x1("string");
~~~~~~~~
!!! error TS2345: Argument of type '"string"' is not assignable to parameter of type 'number'.
/** @type {function (number): number} */
const x2 = (a) => a + 1;
/** @type {string} */
var a;
a = x2(0);
~
!!! error TS2322: Type 'number' is not assignable to type 'string'.

View file

@ -0,0 +1,24 @@
//// [0.js]
// @ts-check
/** @type {function (number)} */
const x1 = (a) => a + 1;
x1("string");
/** @type {function (number): number} */
const x2 = (a) => a + 1;
/** @type {string} */
var a;
a = x2(0);
//// [0.js]
// @ts-check
/** @type {function (number)} */
var x1 = function (a) { return a + 1; };
x1("string");
/** @type {function (number): number} */
var x2 = function (a) { return a + 1; };
/** @type {string} */
var a;
a = x2(0);

View file

@ -0,0 +1,23 @@
// @allowJS: true
// @suppressOutputPathCheck: true
// @filename: 0.js
// @ts-check
/** @type {*} */
var anyT = 2;
/** @type {?} */
var anyT1 = 2;
anyT1 = "hi";
/** @type {Function} */
const x = (a) => a + 1;
x(1);
/** @type {function (number)} */
const x1 = (a) => a + 1;
x1(0);
/** @type {function (number): number} */
const x2 = (a) => a + 1;
x2(0);

View file

@ -0,0 +1,16 @@
// @allowJS: true
// @suppressOutputPathCheck: true
// @filename: 0.js
// @ts-check
/** @type {function (number)} */
const x1 = (a) => a + 1;
x1("string");
/** @type {function (number): number} */
const x2 = (a) => a + 1;
/** @type {string} */
var a;
a = x2(0);

View file

@ -0,0 +1,43 @@
/// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: jsDocTypeTag1.js
//// /** @type {String} */
//// var /*1*/S;
//// /** @type {Number} */
//// var /*2*/N;
//// /** @type {Boolean} */
//// var /*3*/B;
//// /** @type {Void} */
//// var /*4*/V;
//// /** @type {Undefined} */
//// var /*5*/U;
//// /** @type {Null} */
//// var /*6*/Nl;
//// /** @type {Array} */
//// var /*7*/A;
//// /** @type {Promise} */
//// var /*8*/P;
//// /** @type {Object} */
//// var /*9*/Obj;
//// /** @type {Function} */
//// var /*10*/Func;
//// /** @type {*} */
//// var /*11*/AnyType;
//// /** @type {?} */
//// var /*12*/QType;
//// /** @type {String|Number} */
//// var /*13*/SOrN;
verify.baselineQuickInfo();

View file

@ -0,0 +1,40 @@
/// <reference path="fourslash.ts" />
// @allowJs: true
// @Filename: jsDocTypeTag2.js
//// /** @type {string} */
//// var /*1*/s;
//// /** @type {number} */
//// var /*2*/n;
//// /** @type {boolean} */
//// var /*3*/b;
//// /** @type {void} */
//// var /*4*/v;
//// /** @type {undefined} */
//// var /*5*/u;
//// /** @type {null} */
//// var /*6*/nl;
//// /** @type {array} */
//// var /*7*/a;
//// /** @type {promise} */
//// var /*8*/p;
//// /** @type {?number} */
//// var /*9*/nullable;
//// /** @type {function} */
//// var /*10*/func;
//// /** @type {function (number): number} */
//// var /*11*/func1;
//// /** @type {string | number} */
//// var /*12*/sOrn;
verify.baselineQuickInfo();