@@ -477,10 +477,8 @@ public void luaHeavyBootstrapStateIsSeededFromMain() throws IOException {
477477 String beforeMain = compiled .substring (0 , mainPos );
478478 assertFalse (beforeMain .contains ("__wurst_objectIndexMap = ({" ));
479479 assertFalse (beforeMain .contains ("__wurst_string_index_map = ({" ));
480- assertFalse (beforeMain .contains ("Wurst experimental Lua assertion guards" ));
481480 assertTrue (mainSection .contains ("__wurst_objectIndexMap = ({" ));
482481 assertTrue (mainSection .contains ("__wurst_string_index_map = ({" ));
483- assertTrue (mainSection .contains ("Wurst experimental Lua assertion guards" ));
484482 }
485483
486484 @ Test
@@ -531,7 +529,6 @@ public void luaDeferredBootstrapRunsBeforeInitGlobalsInMain() throws IOException
531529 assertOccursBefore (mainSection , "C.__wurst_supertypes =" , "initGlobals()" );
532530 assertOccursBefore (mainSection , "C.__typeId__ =" , "initGlobals()" );
533531 assertOccursBefore (mainSection , "C.C_f =" , "initGlobals()" );
534- assertOccursBefore (mainSection , "Wurst experimental Lua assertion guards" , "initGlobals()" );
535532 }
536533
537534 @ Test
@@ -1198,15 +1195,19 @@ public void reflectionNativeStubsAreGuardedByExistingDefinitions() throws IOExce
11981195 }
11991196
12001197 @ Test
1201- public void stdLibInitUsesTriggerEvaluateGuardInMain () throws IOException {
1198+ public void stdLibInitUsesXpcallInsteadOfTriggerEvaluateInMain () throws IOException {
12021199 test ().testLua (true ).withStdLib ().lines (
12031200 "package Test" ,
12041201 "init" ,
12051202 " skip"
12061203 );
1207- String compiled = Files .toString (new File ("test-output/lua/LuaTranslationTests_stdLibInitUsesTriggerEvaluateGuardInMain.lua" ), Charsets .UTF_8 );
1208- assertTrue (compiled .contains ("if not(TriggerEvaluate(" ));
1209- assertTrue (compiled .contains ("TriggerClearConditions" ));
1204+ String compiled = Files .toString (new File ("test-output/lua/LuaTranslationTests_stdLibInitUsesXpcallInsteadOfTriggerEvaluateInMain.lua" ), Charsets .UTF_8 );
1205+ // Package inits use direct xpcall — no WC3 trigger handle overhead
1206+ assertTrue (compiled .contains ("xpcall(init_" ));
1207+ assertTrue (compiled .contains ("__wurst_init_ok" ));
1208+ // TriggerEvaluate pattern must NOT appear for init functions
1209+ assertFalse (compiled .contains ("if not(TriggerEvaluate(" ));
1210+ assertFalse (compiled .contains ("TriggerClearConditions" ));
12101211 }
12111212
12121213 @ Test
@@ -1261,22 +1262,23 @@ public void hashtableHandleExtensionsUseWurstLuaHelpers() throws IOException {
12611262 String compiled = Files .toString (new File ("test-output/lua/LuaTranslationTests_hashtableHandleExtensionsUseWurstLuaHelpers.lua" ), Charsets .UTF_8 );
12621263 assertDoesNotContainRegex (compiled , "\\ bHaveSavedHandle\\ (" );
12631264 assertContainsRegex (compiled , "\\ b__wurst_HaveSavedHandle\\ (" );
1264- assertTrue (compiled .contains ("Wurst experimental Lua assertion guards" ));
12651265 }
12661266
12671267 @ Test
1268- public void hashtableNativeOverrideGuardsAreRuntimeSafe () throws IOException {
1268+ public void hashtableNativesAreReplacedByWurstHelpers () throws IOException {
12691269 test ().testLua (true ).withStdLib ().lines (
12701270 "package Test" ,
12711271 "init" ,
12721272 " let h = InitHashtable()" ,
12731273 " h.saveInt(1, 2, 7)"
12741274 );
1275- String compiled = Files .toString (new File ("test-output/lua/LuaTranslationTests_hashtableNativeOverrideGuardsAreRuntimeSafe.lua" ), Charsets .UTF_8 );
1276- assertTrue (compiled .contains ("Wurst experimental Lua assertion guards" ));
1277- assertContainsRegex (compiled , "\\ blocal\\ s+__wurst_guard_ok\\ s*=\\ s*pcall\\ s*\\ (\\ s*function\\ s*\\ (" );
1278- assertContainsRegex (compiled , "\\ bInitHashtable\\ s*=\\ s*function\\ s*\\ (" );
1279- assertContainsRegex (compiled , "\\ bSaveInteger\\ s*=\\ s*function\\ s*\\ (" );
1275+ String compiled = Files .toString (new File ("test-output/lua/LuaTranslationTests_hashtableNativesAreReplacedByWurstHelpers.lua" ), Charsets .UTF_8 );
1276+ // Runtime guard overrides are removed; compile-time checks are authoritative.
1277+ assertFalse (compiled .contains ("Wurst experimental Lua assertion guards" ));
1278+ assertFalse (compiled .contains ("__wurst_guard_ok" ));
1279+ // __wurst_ helper definitions must still be present.
1280+ assertContainsRegex (compiled , "\\ bfunction\\ s+__wurst_InitHashtable\\ s*\\ (" );
1281+ assertContainsRegex (compiled , "\\ bfunction\\ s+__wurst_SaveInteger\\ s*\\ (" );
12801282 }
12811283
12821284 @ Test
0 commit comments