Skip to content

Commit 1803d73

Browse files
committed
added initial set of unit tests for separate compilation mode
1 parent 49b3f85 commit 1803d73

35 files changed

+275
-1
lines changed

src/harness/harness.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,10 @@ module Harness {
10621062
options.preserveConstEnums = setting.value === 'true';
10631063
break;
10641064

1065+
case 'separatecompilation':
1066+
options.separateCompilation = setting.value === 'true';
1067+
break;
1068+
10651069
case 'suppressimplicitanyindexerrors':
10661070
options.suppressImplicitAnyIndexErrors = setting.value === 'true';
10671071
break;
@@ -1461,7 +1465,12 @@ module Harness {
14611465
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
14621466

14631467
// List of allowed metadata names
1464-
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal"];
1468+
var fileMetadataNames = ["filename", "comments", "declaration", "module",
1469+
"nolib", "sourcemap", "target", "out", "outdir", "noemitonerror",
1470+
"noimplicitany", "noresolve", "newline", "newlines", "emitbom",
1471+
"errortruncation", "usecasesensitivefilenames", "preserveconstenums",
1472+
"includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal",
1473+
"separatecompilation"];
14651474

14661475
function extractCompilerSettings(content: string): CompilerSetting[] {
14671476

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
tests/cases/compiler/separateCompilationAmbientConstEnum.ts(3,20): error TS1209: Ambient const enums are not allowed when the '--separateCompilation' flag is provided.
2+
3+
4+
==== tests/cases/compiler/separateCompilationAmbientConstEnum.ts (1 errors) ====
5+
6+
7+
declare const enum E { X = 1}
8+
~
9+
!!! error TS1209: Ambient const enums are not allowed when the '--separateCompilation' flag is provided.
10+
export var y;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//// [separateCompilationAmbientConstEnum.ts]
2+
3+
4+
declare const enum E { X = 1}
5+
export var y;
6+
7+
//// [separateCompilationAmbientConstEnum.js]
8+
export var y;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error TS5044: Option 'declaration' cannot be specified with option 'separateCompilation'.
2+
3+
4+
!!! error TS5044: Option 'declaration' cannot be specified with option 'separateCompilation'.
5+
==== tests/cases/compiler/separateCompilationDeclaration.ts (0 errors) ====
6+
7+
export var x;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//// [separateCompilationDeclaration.ts]
2+
3+
export var x;
4+
5+
//// [separateCompilationDeclaration.js]
6+
export var x;
7+
8+
9+
//// [separateCompilationDeclaration.d.ts]
10+
export declare var x: any;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//// [separateCompilationES6.ts]
2+
export var x;
3+
4+
//// [separateCompilationES6.js]
5+
export var x;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
=== tests/cases/compiler/separateCompilationES6.ts ===
2+
export var x;
3+
>x : any
4+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error TS5045: Option 'noEmitOnError' cannot be specified with option 'separateCompilation'.
2+
3+
4+
!!! error TS5045: Option 'noEmitOnError' cannot be specified with option 'separateCompilation'.
5+
==== tests/cases/compiler/separateCompilationNoEmitOnError.ts (0 errors) ====
6+
7+
export var x;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tests/cases/compiler/separateCompilationNoExternalModule.ts(2,1): error TS1208: Cannot compile non-external modules when the '--separateCompilation' flag is provided.
2+
3+
4+
==== tests/cases/compiler/separateCompilationNoExternalModule.ts (1 errors) ====
5+
6+
var x;
7+
~~~
8+
!!! error TS1208: Cannot compile non-external modules when the '--separateCompilation' flag is provided.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//// [separateCompilationNoExternalModule.ts]
2+
3+
var x;
4+
5+
//// [separateCompilationNoExternalModule.js]
6+
var x;

0 commit comments

Comments
 (0)