@@ -11,123 +11,121 @@ function outFileOptionsWithEntry(luaEntry: string): CompilerOptions {
1111 return { outFile : "main.lua" , noHoisting : true , module : ts . ModuleKind . AMD , luaEntry } ;
1212}
1313
14- describe ( "outFile" , ( ) => {
15- test ( "import module -> main" , ( ) => {
16- util . testBundle `
17- import { value } from "./module";
18- ${ exportResultSource }
19- `
20- . addExtraFile ( "module.ts" , exportValueSource )
21- . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
22- . expectToEqual ( { result : true } ) ;
23- } ) ;
14+ test ( "import module -> main" , ( ) => {
15+ util . testBundle `
16+ import { value } from "./module";
17+ ${ exportResultSource }
18+ `
19+ . addExtraFile ( "module.ts" , exportValueSource )
20+ . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
21+ . expectToEqual ( { result : true } ) ;
22+ } ) ;
2423
25- test ( "import chain export -> reexport -> main" , ( ) => {
26- util . testBundle `
27- import { value } from "./reexport";
28- ${ exportResultSource }
29- `
30- . addExtraFile ( "reexport.ts" , reexportValueSource )
31- . addExtraFile ( "export.ts" , exportValueSource )
32- . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
33- . expectToEqual ( { result : true } ) ;
34- } ) ;
24+ test ( "import chain export -> reexport -> main" , ( ) => {
25+ util . testBundle `
26+ import { value } from "./reexport";
27+ ${ exportResultSource }
28+ `
29+ . addExtraFile ( "reexport.ts" , reexportValueSource )
30+ . addExtraFile ( "export.ts" , exportValueSource )
31+ . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
32+ . expectToEqual ( { result : true } ) ;
33+ } ) ;
3534
36- test ( "diamond imports/exports -> reexport1 & reexport2 -> main" , ( ) => {
37- util . testBundle `
38- import { value as a } from "./reexport1";
39- import { value as b } from "./reexport2";
40- if (a !== true || b !== true) {
41- throw "Failed to import a or b";
42- }
43- `
44- . addExtraFile ( "reexport1.ts" , reexportValueSource )
45- . addExtraFile ( "reexport2.ts" , reexportValueSource )
46- . addExtraFile ( "export.ts" , exportValueSource )
47- . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
48- . expectNoExecutionError ( ) ;
49- } ) ;
35+ test ( "diamond imports/exports -> reexport1 & reexport2 -> main" , ( ) => {
36+ util . testBundle `
37+ import { value as a } from "./reexport1";
38+ import { value as b } from "./reexport2";
39+ if (a !== true || b !== true) {
40+ throw "Failed to import a or b";
41+ }
42+ `
43+ . addExtraFile ( "reexport1.ts" , reexportValueSource )
44+ . addExtraFile ( "reexport2.ts" , reexportValueSource )
45+ . addExtraFile ( "export.ts" , exportValueSource )
46+ . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
47+ . expectNoExecutionError ( ) ;
48+ } ) ;
5049
51- test ( "module in directory" , ( ) => {
52- util . testBundle `
53- import { value } from "./module/module";
54- ${ exportValueSource }
55- `
56- . addExtraFile ( "module/module.ts" , exportValueSource )
57- . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
58- . expectNoExecutionError ( ) ;
59- } ) ;
50+ test ( "module in directory" , ( ) => {
51+ util . testBundle `
52+ import { value } from "./module/module";
53+ ${ exportValueSource }
54+ `
55+ . addExtraFile ( "module/module.ts" , exportValueSource )
56+ . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
57+ . expectNoExecutionError ( ) ;
58+ } ) ;
6059
61- test ( "modules aren't ordered by name" , ( ) => {
62- util . testBundle `
63- import { value } from "./a";
64- ${ exportResultSource }
65- `
66- . addExtraFile ( "a.ts" , exportValueSource )
67- . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
68- . expectToEqual ( { result : true } ) ;
69- } ) ;
60+ test ( "modules aren't ordered by name" , ( ) => {
61+ util . testBundle `
62+ import { value } from "./a";
63+ ${ exportResultSource }
64+ `
65+ . addExtraFile ( "a.ts" , exportValueSource )
66+ . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
67+ . expectToEqual ( { result : true } ) ;
68+ } ) ;
7069
71- test ( "entry point in directory" , ( ) => {
72- util . testBundle ``
73- . addExtraFile (
74- "main/main.ts" ,
75- `
76- import { value } from "../module";
77- ${ exportResultSource }
78- `
79- )
80- . addExtraFile ( "module.ts" , exportValueSource )
81- . setOptions ( outFileOptionsWithEntry ( "main/main.ts" ) )
82- . expectToEqual ( { result : true } ) ;
83- } ) ;
70+ test ( "entry point in directory" , ( ) => {
71+ util . testBundle ``
72+ . addExtraFile (
73+ "main/main.ts" ,
74+ `
75+ import { value } from "../module";
76+ ${ exportResultSource }
77+ `
78+ )
79+ . addExtraFile ( "module.ts" , exportValueSource )
80+ . setOptions ( outFileOptionsWithEntry ( "main/main.ts" ) )
81+ . expectToEqual ( { result : true } ) ;
82+ } ) ;
8483
85- test ( "LuaLibs" , ( ) => {
86- util . testBundle `
87- import { array } from "./module";
88- if (array[2] !== 3) {
89- throw "Array's third item is not three";
90- }
91- `
92- . addExtraFile (
93- "module.ts" ,
94- `
95- export const array = [1, 2];
96- array.push(3);
97- `
98- )
99- . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
100- . expectNoExecutionError ( ) ;
101- } ) ;
84+ test ( "LuaLibs" , ( ) => {
85+ util . testBundle `
86+ import { array } from "./module";
87+ if (array[2] !== 3) {
88+ throw "Array's third item is not three";
89+ }
90+ `
91+ . addExtraFile (
92+ "module.ts" ,
93+ `
94+ export const array = [1, 2];
95+ array.push(3);
96+ `
97+ )
98+ . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
99+ . expectNoExecutionError ( ) ;
100+ } ) ;
102101
103- test ( "cyclic imports" , ( ) => {
104- util . testBundle `
105- export const a = true;
106- import { value } from "./b";
107- ${ exportResultSource }
108- `
109- . addExtraFile (
110- "b.ts" ,
111- `
112- import { a } from "./main";
113- export const value = a;
114- `
115- )
116- . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
117- . expectToEqual ( { a : true , result : true } ) ;
118- } ) ;
102+ test ( "cyclic imports" , ( ) => {
103+ util . testBundle `
104+ export const a = true;
105+ import { value } from "./b";
106+ ${ exportResultSource }
107+ `
108+ . addExtraFile (
109+ "b.ts" ,
110+ `
111+ import { a } from "./main";
112+ export const value = a;
113+ `
114+ )
115+ . setOptions ( outFileOptionsWithEntry ( "main.ts" ) )
116+ . expectToEqual ( { a : true , result : true } ) ;
117+ } ) ;
119118
120- test ( "luaEntry doesn't exist" , ( ) => {
121- util . testBundle ``
122- . setOptions ( outFileOptionsWithEntry ( "entry.ts" ) )
123- . expectToHaveDiagnosticOfError ( TSTLErrors . LuaEntryNotFound ( "entry.ts" ) ) ;
124- } ) ;
119+ test ( "luaEntry doesn't exist" , ( ) => {
120+ util . testBundle ``
121+ . setOptions ( outFileOptionsWithEntry ( "entry.ts" ) )
122+ . expectToHaveDiagnosticOfError ( TSTLErrors . LuaEntryNotFound ( "entry.ts" ) ) ;
123+ } ) ;
125124
126- test ( "luaEntry resolved from path specified in tsconfig" , ( ) => {
127- util . testBundle ``
128- . addExtraFile ( "src/main.ts" , "" )
129- . addExtraFile ( "src/module.ts" , "" )
130- . setOptions ( { rootDir : "src" , ...outFileOptionsWithEntry ( "src/main.ts" ) } )
131- . expectToHaveNoDiagnostics ( ) ;
132- } ) ;
125+ test ( "luaEntry resolved from path specified in tsconfig" , ( ) => {
126+ util . testBundle ``
127+ . addExtraFile ( "src/main.ts" , "" )
128+ . addExtraFile ( "src/module.ts" , "" )
129+ . setOptions ( { rootDir : "src" , ...outFileOptionsWithEntry ( "src/main.ts" ) } )
130+ . expectToHaveNoDiagnostics ( ) ;
133131} ) ;
0 commit comments