fourslash diagnostics tests: use objects instead of strings (#22193)

This commit is contained in:
Andy
2018-02-26 14:55:26 -08:00
committed by GitHub
parent d15b098e70
commit 0b1e21794d
29 changed files with 226 additions and 212 deletions

View File

@@ -1236,20 +1236,18 @@ Actual: ${stringify(fullActual)}`);
return this.languageService.findReferences(this.activeFile.fileName, this.currentCaretPosition);
}
public getSyntacticDiagnostics(expected: string) {
public getSyntacticDiagnostics(expected: ReadonlyArray<ts.RealizedDiagnostic>) {
const diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
this.testDiagnostics(expected, diagnostics);
}
public getSemanticDiagnostics(expected: string) {
public getSemanticDiagnostics(expected: ReadonlyArray<ts.RealizedDiagnostic>) {
const diagnostics = this.languageService.getSemanticDiagnostics(this.activeFile.fileName);
this.testDiagnostics(expected, diagnostics);
}
private testDiagnostics(expected: string, diagnostics: ReadonlyArray<ts.Diagnostic>) {
const realized = ts.realizeDiagnostics(diagnostics, "\r\n");
const actual = stringify(realized);
assert.equal(actual, expected);
private testDiagnostics(expected: ReadonlyArray<ts.RealizedDiagnostic>, diagnostics: ReadonlyArray<ts.Diagnostic>) {
assert.deepEqual(ts.realizeDiagnostics(diagnostics, ts.newLineCharacter), expected);
}
public verifyQuickInfoAt(markerName: string, expectedText: string, expectedDocumentation?: string) {
@@ -4321,11 +4319,11 @@ namespace FourSlashInterface {
this.state.verifyQuickInfoDisplayParts(kind, kindModifiers, textSpan, displayParts, documentation, tags);
}
public getSyntacticDiagnostics(expected: string) {
public getSyntacticDiagnostics(expected: ReadonlyArray<ts.RealizedDiagnostic>) {
this.state.getSyntacticDiagnostics(expected);
}
public getSemanticDiagnostics(expected: string) {
public getSemanticDiagnostics(expected: ReadonlyArray<ts.RealizedDiagnostic>) {
this.state.getSemanticDiagnostics(expected);
}

View File

@@ -581,7 +581,7 @@ namespace ts {
}
}
interface RealizedDiagnostic {
export interface RealizedDiagnostic {
message: string;
start: number;
length: number;