1+ import * as path from "path" ;
12import * as ts from "typescript" ;
23import { couldNotResolveRequire , emitPathCollision } from "../../../src/transpilation/diagnostics" ;
34import * as util from "../../util" ;
@@ -170,8 +171,7 @@ test.each([
170171// Can't test this via execution because the test harness uses package.preload
171172// instead of real filesystem resolution, so require() always finds the module
172173// regardless of output path. We check the output path directly instead.
173- // TODO: test via actual Lua execution once the harness supports filesystem resolution.
174- test ( "dots in directory names emit to nested directories" , ( ) => {
174+ test ( "dots in directory names are replaced with underscores in output" , ( ) => {
175175 const { transpiledFiles } = util . testModule `
176176 import { answer } from "./Foo.Bar";
177177 export const result = answer;
@@ -180,21 +180,20 @@ test("dots in directory names emit to nested directories", () => {
180180 . setOptions ( { rootDir : "." } )
181181 . getLuaResult ( ) ;
182182
183- // Foo.Bar/index.ts should emit to Foo/Bar/index.lua, not Foo.Bar/index.lua
184183 const dottedFile = transpiledFiles . find ( f => f . lua ?. includes ( "answer = 42" ) ) ;
185184 expect ( dottedFile ) . toBeDefined ( ) ;
186- expect ( dottedFile ! . outPath ) . toContain ( "Foo/Bar/ index.lua") ;
185+ expect ( dottedFile ! . outPath ) . toContain ( path . join ( "Foo_Bar" , " index.lua") ) ;
187186 expect ( dottedFile ! . outPath ) . not . toContain ( "Foo.Bar" ) ;
188187} ) ;
189188
190189test ( "dots in paths that collide with existing paths produce a diagnostic" , ( ) => {
191190 util . testModule `
192191 import { a } from "./Foo.Bar";
193- import { b } from "./Foo/Bar ";
192+ import { b } from "./Foo_Bar ";
194193 export const result = a + b;
195194 `
196195 . addExtraFile ( "Foo.Bar/index.ts" , "export const a = 1;" )
197- . addExtraFile ( "Foo/Bar /index.ts" , "export const b = 2;" )
196+ . addExtraFile ( "Foo_Bar /index.ts" , "export const b = 2;" )
198197 . setOptions ( { rootDir : "." } )
199198 . expectToHaveDiagnostics ( [ emitPathCollision . code ] ) ;
200199} ) ;
0 commit comments