|
1 | 1 | /// <reference path="..\harness.ts" />
|
2 | 2 |
|
3 | 3 | namespace ts {
|
4 |
| - function diagnosticToString(diagnostic: Diagnostic) { |
5 |
| - let output = ""; |
6 |
| - |
7 |
| - if (diagnostic.file) { |
8 |
| - const loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start); |
9 |
| - |
10 |
| - output += `${diagnostic.file.fileName}(${loc.line + 1},${loc.character + 1}): `; |
11 |
| - } |
12 |
| - |
13 |
| - const category = DiagnosticCategory[diagnostic.category].toLowerCase(); |
14 |
| - output += `${category} TS${diagnostic.code}: ${flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine)}${sys.newLine}`; |
15 |
| - |
16 |
| - return output; |
17 |
| - } |
18 |
| - |
19 | 4 | interface File {
|
20 | 5 | name: string;
|
21 | 6 | content?: string;
|
@@ -322,9 +307,9 @@ namespace ts {
|
322 | 307 |
|
323 | 308 | assert.equal(program.getSourceFiles().length, expectedFilesCount);
|
324 | 309 | const syntacticDiagnostics = program.getSyntacticDiagnostics();
|
325 |
| - assert.equal(syntacticDiagnostics.length, 0, `expect no syntactic diagnostics, got: ${JSON.stringify(syntacticDiagnostics.map(diagnosticToString))}`); |
| 310 | + assert.equal(syntacticDiagnostics.length, 0, `expect no syntactic diagnostics, got: ${JSON.stringify(Harness.Compiler.minimalDiagnosticsToString(syntacticDiagnostics))}`); |
326 | 311 | const semanticDiagnostics = program.getSemanticDiagnostics();
|
327 |
| - assert.equal(semanticDiagnostics.length, 0, `expect no semantic diagnostics, got: ${JSON.stringify(semanticDiagnostics.map(diagnosticToString))}`); |
| 312 | + assert.equal(semanticDiagnostics.length, 0, `expect no semantic diagnostics, got: ${JSON.stringify(Harness.Compiler.minimalDiagnosticsToString(semanticDiagnostics))}`); |
328 | 313 |
|
329 | 314 | // try to get file using a relative name
|
330 | 315 | for (const relativeFileName of relativeNamesToCheck) {
|
@@ -403,7 +388,7 @@ export = C;
|
403 | 388 | };
|
404 | 389 | const program = createProgram(rootFiles, options, host);
|
405 | 390 | const diagnostics = sortAndDeduplicateDiagnostics(program.getSemanticDiagnostics().concat(program.getOptionsDiagnostics()));
|
406 |
| - assert.equal(diagnostics.length, diagnosticCodes.length, `Incorrect number of expected diagnostics, expected ${diagnosticCodes.length}, got '${map(diagnostics, diagnosticToString).join("\r\n")}'`); |
| 391 | + assert.equal(diagnostics.length, diagnosticCodes.length, `Incorrect number of expected diagnostics, expected ${diagnosticCodes.length}, got '${Harness.Compiler.minimalDiagnosticsToString(diagnostics)}'`); |
407 | 392 | for (let i = 0; i < diagnosticCodes.length; i++) {
|
408 | 393 | assert.equal(diagnostics[i].code, diagnosticCodes[i], `Expected diagnostic code ${diagnosticCodes[i]}, got '${diagnostics[i].code}': '${diagnostics[i].messageText}'`);
|
409 | 394 | }
|
|
0 commit comments