|
| 1 | + |
1 | 2 | //
|
2 | 3 | // Copyright (c) Microsoft Corporation. All rights reserved.
|
3 | 4 | //
|
@@ -538,6 +539,8 @@ module Harness {
|
538 | 539 |
|
539 | 540 | export var defaultLibFileName = 'lib.d.ts';
|
540 | 541 | export var defaultLibSourceFile = ts.createSourceFile(defaultLibFileName, IO.readFile(libFolder + 'lib.core.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*version:*/ "0");
|
| 542 | + export var defaultES6LibSourceFile = ts.createSourceFile(defaultLibFileName, IO.readFile(libFolder + 'lib.core.es6.d.ts'), /*languageVersion*/ ts.ScriptTarget.Latest, /*version:*/ "0"); |
| 543 | + |
541 | 544 |
|
542 | 545 | // Cache these between executions so we don't have to re-parse them for every test
|
543 | 546 | export var fourslashFilename = 'fourslash.ts';
|
@@ -580,15 +583,14 @@ module Harness {
|
580 | 583 | return fourslashSourceFile;
|
581 | 584 | }
|
582 | 585 | else {
|
583 |
| - var lib = defaultLibFileName; |
584 | 586 | if (fn === defaultLibFileName) {
|
585 |
| - return defaultLibSourceFile; |
| 587 | + return languageVersion === ts.ScriptTarget.ES6 ? defaultES6LibSourceFile : defaultLibSourceFile; |
586 | 588 | }
|
587 | 589 | // Don't throw here -- the compiler might be looking for a test that actually doesn't exist as part of the TC
|
588 | 590 | return undefined;
|
589 | 591 | }
|
590 | 592 | },
|
591 |
| - getDefaultLibFilename: () => defaultLibFileName, |
| 593 | + getDefaultLibFilename: options => defaultLibFileName, |
592 | 594 | writeFile,
|
593 | 595 | getCanonicalFileName,
|
594 | 596 | useCaseSensitiveFileNames: () => useCaseSensitiveFileNames,
|
@@ -1016,27 +1018,38 @@ module Harness {
|
1016 | 1018 | sys.newLine + sys.newLine + outputLines.join('\r\n');
|
1017 | 1019 | }
|
1018 | 1020 |
|
1019 |
| - /* TODO: Delete? |
1020 |
| - export function makeDefaultCompilerSettings(options?: { useMinimalDefaultLib: boolean; noImplicitAny: boolean; }) { |
1021 |
| - var useMinimalDefaultLib = options ? options.useMinimalDefaultLib : true; |
1022 |
| - var noImplicitAny = options ? options.noImplicitAny : false; |
1023 |
| - var settings = new TypeScript.CompilationSettings(); |
1024 |
| - settings.codeGenTarget = TypeScript.LanguageVersion.EcmaScript5; |
1025 |
| - settings.moduleGenTarget = TypeScript.ModuleGenTarget.Synchronous; |
1026 |
| - settings.noLib = useMinimalDefaultLib; |
1027 |
| - settings.noResolve = false; |
1028 |
| - settings.noImplicitAny = noImplicitAny; |
1029 |
| - return settings; |
| 1021 | + export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[], clean?: (s: string) => string) { |
| 1022 | + // Collect, test, and sort the filenames |
| 1023 | + function cleanName(fn: string) { |
| 1024 | + var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/'); |
| 1025 | + return fn.substr(lastSlash + 1).toLowerCase(); |
| 1026 | + } |
| 1027 | + outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName))); |
| 1028 | + |
| 1029 | + // Emit them |
| 1030 | + var result = ''; |
| 1031 | + ts.forEach(outputFiles, outputFile => { |
| 1032 | + // Some extra spacing if this isn't the first file |
| 1033 | + if (result.length) result = result + '\r\n\r\n'; |
| 1034 | + |
| 1035 | + // Filename header + content |
| 1036 | + result = result + '/*====== ' + outputFile.fileName + ' ======*/\r\n'; |
| 1037 | + if (clean) { |
| 1038 | + result = result + clean(outputFile.code); |
| 1039 | + } else { |
| 1040 | + result = result + outputFile.code; |
| 1041 | + } |
| 1042 | + }); |
| 1043 | + return result; |
1030 | 1044 | }
|
1031 |
| - */ |
1032 | 1045 |
|
1033 | 1046 | /** The harness' compiler instance used when tests are actually run. Reseting or changing settings of this compiler instance must be done within a test case (i.e., describe/it) */
|
1034 | 1047 | var harnessCompiler: HarnessCompiler;
|
1035 | 1048 |
|
1036 | 1049 | /** Returns the singleton harness compiler instance for generating and running tests.
|
1037 | 1050 | If required a fresh compiler instance will be created, otherwise the existing singleton will be re-used.
|
1038 | 1051 | */
|
1039 |
| - export function getCompiler(opts?: { useExistingInstance: boolean; optionsForFreshInstance?: { useMinimalDefaultLib: boolean; noImplicitAny: boolean; } }) { |
| 1052 | + export function getCompiler() { |
1040 | 1053 | return harnessCompiler = harnessCompiler || new HarnessCompiler();
|
1041 | 1054 | }
|
1042 | 1055 |
|
|
0 commit comments