Add more test cases

This commit is contained in:
Yui T 2014-10-08 18:15:07 -07:00
parent 40f6b6719f
commit 67eff65e03
7 changed files with 75 additions and 10 deletions

View File

@ -25,8 +25,15 @@ module ts {
return indentStrings[1].length;
}
function isDeclarationFile(sourceFile: SourceFile): boolean {
if (sourceFile.flags & NodeFlags.DeclarationFile) {
return true;
}
return false;
}
export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
if (!(sourceFile.flags & NodeFlags.DeclarationFile)) {
if (!isDeclarationFile(sourceFile)) {
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.filename, ".js")) {
return true;
}
@ -3242,14 +3249,15 @@ module ts {
if (compilerOptions.out) {
emitFile(compilerOptions.out);
}
} else {
}
else {
// targetSourceFile is specified (e.g calling emitter from language service or calling getSemanticDiagnostic from language service)
if (shouldEmitToOwnFile(targetSourceFile, compilerOptions)) {
// If shouldEmitToOwnFile return true or targetSourceFile is an external module file, then emit targetSourceFile in its own output file
var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, ".js");
emitFile(jsFilePath, targetSourceFile);
}
else if (compilerOptions.out) {
else if (!isDeclarationFile(targetSourceFile) && compilerOptions.out) {
// Otherwise, if --out is specified and targetSourceFile shouldn't be emitted to own file, then emit all, non-external-module file, into one single output file
emitFile(compilerOptions.out);
}

View File

@ -1,6 +1,6 @@
EmitOutputStatus : JSGeneratedWithSemanticErrors
EmitOutputStatus : Succeeded
EmitOutputStatus : JSGeneratedWithSemanticErrors
EmitOutputStatus : Succeeded
Filename : tests/cases/fourslash/inputFile2.js
var x1 = "hello world";
var Foo = (function () {

View File

@ -0,0 +1,15 @@
EmitOutputStatus : Succeeded
EmitOutputStatus : Succeeded
Filename : tests/cases/fourslash/inputFile2.js
var Foo = (function () {
function Foo() {
}
return Foo;
})();
exports.Foo = Foo;
EmitOutputStatus : Succeeded
Filename : tests/cases/fourslash/inputFile3.js
var x = "hello";

View File

@ -0,0 +1,7 @@
EmitOutputStatus : Succeeded
EmitOutputStatus : Succeeded
Filename : declSingle.js
var x = "hello";
var x1 = 1000;

View File

@ -4,11 +4,7 @@
// @Filename: decl.d.ts
// @emitThisFile: true
//// declare x: string;
//// declare class Bar {
//// x : string;
//// y : number
//// }
//// interface I { a: string; }
// @Filename: inputFile2.ts
// @emitThisFile: true

View File

@ -0,0 +1,18 @@
/// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputWithDeclarationFile2.baseline
// @Filename: decl.d.ts
// @emitThisFile: true
//// interface I { a: string; }
// @Filename: inputFile2.ts
// @emitThisFile: true
//// export class Foo { }
// @Filename: inputFile3.ts
// @emitThisFile: true
//// var x:string = "hello";
debugger;
verify.baselineGetEmitOutput();

View File

@ -0,0 +1,21 @@
/// <reference path="fourslash.ts" />
// @BaselineFile: getEmitOutputWithDeclarationFile3.baseline
// @out: declSingle.js
// @Filename: decl.d.ts
// @emitThisFile: true
//// interface I { a: string; }
// @Filename: inputFile2.ts
//// export class Foo { }
// @Filename: inputFile3.ts
// @emitThisFile: true
//// var x:string = "hello";
// @Filename: inputFile4.ts
//// var x1:number = 1000;
debugger;
verify.baselineGetEmitOutput();