@@ -5,45 +5,36 @@ import * as util from "../../util";
55// fails with "'end' expected near 'local'"). Lua 5.2+ relaxed this restriction.
66// TSTL should strip dead code after break on all targets to avoid these errors.
77
8- function expectNoDeadCode ( ...deadCodeStrings : string [ ] ) : util . TapCallback {
9- return builder => {
10- const lua = builder . getMainLuaCodeChunk ( ) ;
11- for ( const deadCode of deadCodeStrings ) {
12- expect ( lua ) . not . toContain ( deadCode ) ;
13- }
14- } ;
15- }
16-
178util . testEachVersion (
189 "for dead code after break" ,
1910 ( ) => util . testFunction `
2011 for (let i = 0; i < 10; i++) { break; const b = 8; }
2112 ` ,
22- util . expectAllVersions ( expectNoDeadCode ( "local b = 8" ) )
13+ util . expectEachVersionExceptJit ( builder => builder . expectNoExecutionError ( ) )
2314) ;
2415
2516util . testEachVersion (
2617 "for..in dead code after break" ,
2718 ( ) => util . testFunction `
2819 for (let a in {"a": 5, "b": 8}) { break; const b = 8; }
2920 ` ,
30- util . expectAllVersions ( expectNoDeadCode ( "local b = 8" ) )
21+ util . expectEachVersionExceptJit ( builder => builder . expectNoExecutionError ( ) )
3122) ;
3223
3324util . testEachVersion (
3425 "for..of dead code after break" ,
3526 ( ) => util . testFunction `
3627 for (let a of [1,2,4]) { break; const b = 8; }
3728 ` ,
38- util . expectAllVersions ( expectNoDeadCode ( "local b = 8" ) )
29+ util . expectEachVersionExceptJit ( builder => builder . expectNoExecutionError ( ) )
3930) ;
4031
4132util . testEachVersion (
4233 "while dead code after break" ,
4334 ( ) => util . testFunction `
4435 while (true) { break; const b = 8; }
4536 ` ,
46- util . expectAllVersions ( expectNoDeadCode ( "local b = 8" ) )
37+ util . expectEachVersionExceptJit ( builder => builder . expectNoExecutionError ( ) )
4738) ;
4839
4940util . testEachVersion (
@@ -58,13 +49,13 @@ util.testEachVersion(
5849 let def = 6;
5950 }
6051 ` ,
61- util . expectAllVersions ( expectNoDeadCode ( "abc = 4" , "def = 6" ) )
52+ util . expectEachVersionExceptJit ( builder => builder . expectNoExecutionError ( ) )
6253) ;
6354
6455util . testEachVersion (
6556 "do-while dead code after break" ,
6657 ( ) => util . testFunction `
6758 do { break; const b = 8; } while (true);
6859 ` ,
69- util . expectAllVersions ( expectNoDeadCode ( "local b = 8" ) )
60+ util . expectEachVersionExceptJit ( builder => builder . expectNoExecutionError ( ) )
7061) ;
0 commit comments