Skip to content

Commit 1ecb896

Browse files
Merge pull request #3292 from Microsoft/jsDocTests1
Add a couple of tests for jsdoccomments.
2 parents 3f87259 + 302a0da commit 1ecb896

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

src/harness/fourslash.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,8 +798,17 @@ module FourSlash {
798798
return "\nActual " + name + ":\n\t" + actualValue + "\nExpected value:\n\t" + expectedValue;
799799
}
800800

801+
public getSyntacticDiagnostics(expected: string) {
802+
var diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
803+
this.testDiagnostics(expected, diagnostics);
804+
}
805+
801806
public getSemanticDiagnostics(expected: string) {
802807
var diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName);
808+
this.testDiagnostics(expected, diagnostics);
809+
}
810+
811+
private testDiagnostics(expected: string, diagnostics: ts.Diagnostic[]) {
803812
var realized = ts.realizeDiagnostics(diagnostics, "\r\n");
804813
var actual = JSON.stringify(realized, null, " ");
805814
assert.equal(actual, expected);

tests/cases/fourslash/fourslash.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,10 @@ module FourSlashInterface {
448448
FourSlash.currentTestState.verifyQuickInfoDisplayParts(kind, kindModifiers, textSpan, displayParts, documentation);
449449
}
450450

451+
public getSyntacticDiagnostics(expected: string) {
452+
FourSlash.currentTestState.getSyntacticDiagnostics(expected);
453+
}
454+
451455
public getSemanticDiagnostics(expected: string) {
452456
FourSlash.currentTestState.getSemanticDiagnostics(expected);
453457
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowNonTsExtensions: true
4+
// @Filename: a.js
5+
//// function foo(...a) {}
6+
7+
verify.getSemanticDiagnostics(`[]`);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowNonTsExtensions: true
4+
// @Filename: a.js
5+
//// /**
6+
//// * @type {number}
7+
//// * @type {string}
8+
//// */
9+
//// var v;
10+
11+
verify.getSyntacticDiagnostics(`[
12+
{
13+
"message": "\'type\' tag already specified.",
14+
"start": 26,
15+
"length": 4,
16+
"category": "error",
17+
"code": 1219
18+
}
19+
]`);

0 commit comments

Comments
 (0)