@@ -5,27 +5,32 @@ import { annotationDeprecated } from "../../src/transformation/utils/diagnostics
55import { couldNotResolveRequire } from "../../src/transpilation/diagnostics" ;
66import * as util from "../util" ;
77
8- const targetSpecs : Array < [ string , tstl . LuaTarget | undefined , string ] > = [
9- [ "" , undefined , "./transformation" ] ,
10- [ "Luau " , tstl . LuaTarget . Luau , "./transformation/luau" ] ,
11- ] ;
8+ const fixturesPath = path . join ( __dirname , "./transformation" ) ;
9+ const fixtures = fs
10+ . readdirSync ( fixturesPath )
11+ . filter ( f => path . extname ( f ) === ".ts" )
12+ . sort ( )
13+ . map ( f => [ path . parse ( f ) . name , fs . readFileSync ( path . join ( fixturesPath , f ) , "utf8" ) ] ) ;
1214
13- for ( const [ name , luaTarget , targetDir ] of targetSpecs ) {
14- const fixturesPath = path . join ( __dirname , targetDir ) ;
15- const fixtures = fs
16- . readdirSync ( fixturesPath )
17- . filter ( f => path . extname ( f ) === ".ts" )
18- . sort ( )
19- . map ( f => [ path . parse ( f ) . name , fs . readFileSync ( path . join ( fixturesPath , f ) , "utf8" ) ] ) ;
15+ test . each ( fixtures ) ( "Transformation (%s)" , ( _name , content ) => {
16+ util . testModule ( content )
17+ . setOptions ( { luaLibImport : tstl . LuaLibImportKind . Require } )
18+ . ignoreDiagnostics ( [ annotationDeprecated . code , couldNotResolveRequire . code ] )
19+ . disableSemanticCheck ( )
20+ . expectLuaToMatchSnapshot ( ) ;
21+ } ) ;
2022
21- test . each ( fixtures ) ( `${ name } Transformation (%s)` , ( _name , content ) => {
22- util . testModule ( content )
23- . setOptions ( {
24- luaLibImport : tstl . LuaLibImportKind . Require ,
25- luaTarget,
26- } )
27- . ignoreDiagnostics ( [ annotationDeprecated . code , couldNotResolveRequire . code ] )
28- . disableSemanticCheck ( )
29- . expectLuaToMatchSnapshot ( ) ;
30- } ) ;
31- }
23+ const luauFixturesPath = path . join ( fixturesPath , "luau" ) ;
24+ const luauFixtures = fs
25+ . readdirSync ( luauFixturesPath )
26+ . filter ( f => path . extname ( f ) === ".ts" )
27+ . sort ( )
28+ . map ( f => [ path . parse ( f ) . name , fs . readFileSync ( path . join ( luauFixturesPath , f ) , "utf8" ) ] ) ;
29+
30+ test . each ( luauFixtures ) ( "Luau-specific Transformation (%s)" , ( _name , content ) => {
31+ util . testModule ( content )
32+ . setOptions ( { luaLibImport : tstl . LuaLibImportKind . Require , luaTarget : tstl . LuaTarget . Luau } )
33+ . ignoreDiagnostics ( [ annotationDeprecated . code , couldNotResolveRequire . code ] )
34+ . disableSemanticCheck ( )
35+ . expectLuaToMatchSnapshot ( ) ;
36+ } ) ;
0 commit comments