@@ -262,4 +262,66 @@ public void luaFramehandleFromIndexDoesNotUseFogstateHashtablePath() throws IOEx
262262 assertFalse (unitFromIndexSavesFog .matcher (compiled ).find ());
263263 }
264264
265+ @ Test
266+ public void luaTypeCastingCompatWrappersUseLuaHelpers () throws IOException {
267+ test ().testLua (true ).withStdLib ().lines (
268+ "package Test" ,
269+ "import TypeCasting" ,
270+ "init" ,
271+ " let u = unitFromIndex(1)" ,
272+ " let ui = unitToIndex(u)" ,
273+ " let w = widgetFromIndex(2)" ,
274+ " let wi = widgetToIndex(w)" ,
275+ " let fh = framehandleFromIndex(3)" ,
276+ " let fhi = framehandleToIndex(fh)" ,
277+ " let k = oskeytypeFromIndex(4)" ,
278+ " let ki = oskeytypeToIndex(k)" ,
279+ " let s = stringFromIndex(stringToIndex(\" abc\" ))" ,
280+ " if ui + wi + fhi + ki >= 0 and s.length() >= 0" ,
281+ " skip"
282+ );
283+ String compiled = Files .toString (new File ("test-output/lua/LuaTypecastingTests_luaTypeCastingCompatWrappersUseLuaHelpers.lua" ), Charsets .UTF_8 );
284+
285+ assertTrue (Pattern .compile (
286+ "function\\ s+unitFromIndex\\ ([^)]*\\ )[\\ s\\ S]*?return\\ s+__wurst_objectFromIndex\\ (" ,
287+ Pattern .MULTILINE
288+ ).matcher (compiled ).find ());
289+ assertTrue (Pattern .compile (
290+ "function\\ s+unitToIndex\\ ([^)]*\\ )[\\ s\\ S]*?return\\ s+__wurst_objectToIndex\\ (" ,
291+ Pattern .MULTILINE
292+ ).matcher (compiled ).find ());
293+ assertTrue (Pattern .compile (
294+ "function\\ s+widgetFromIndex\\ ([^)]*\\ )[\\ s\\ S]*?return\\ s+__wurst_objectFromIndex\\ (" ,
295+ Pattern .MULTILINE
296+ ).matcher (compiled ).find ());
297+ assertTrue (Pattern .compile (
298+ "function\\ s+widgetToIndex\\ ([^)]*\\ )[\\ s\\ S]*?return\\ s+__wurst_objectToIndex\\ (" ,
299+ Pattern .MULTILINE
300+ ).matcher (compiled ).find ());
301+ assertTrue (Pattern .compile (
302+ "function\\ s+framehandleFromIndex\\ ([^)]*\\ )[\\ s\\ S]*?return\\ s+__wurst_objectFromIndex\\ (" ,
303+ Pattern .MULTILINE
304+ ).matcher (compiled ).find ());
305+ assertTrue (Pattern .compile (
306+ "function\\ s+framehandleToIndex\\ ([^)]*\\ )[\\ s\\ S]*?return\\ s+__wurst_objectToIndex\\ (" ,
307+ Pattern .MULTILINE
308+ ).matcher (compiled ).find ());
309+ assertTrue (Pattern .compile (
310+ "function\\ s+oskeytypeFromIndex\\ ([^)]*\\ )[\\ s\\ S]*?return\\ s+__wurst_objectFromIndex\\ (" ,
311+ Pattern .MULTILINE
312+ ).matcher (compiled ).find ());
313+ assertTrue (Pattern .compile (
314+ "function\\ s+oskeytypeToIndex\\ ([^)]*\\ )[\\ s\\ S]*?return\\ s+__wurst_objectToIndex\\ (" ,
315+ Pattern .MULTILINE
316+ ).matcher (compiled ).find ());
317+ assertTrue (Pattern .compile (
318+ "function\\ s+stringToIndex\\ ([^)]*\\ )[\\ s\\ S]*?return\\ s+__wurst_stringToIndex\\ (" ,
319+ Pattern .MULTILINE
320+ ).matcher (compiled ).find ());
321+ assertTrue (Pattern .compile (
322+ "function\\ s+stringFromIndex\\ ([^)]*\\ )[\\ s\\ S]*?return\\ s+__wurst_stringFromIndex\\ (" ,
323+ Pattern .MULTILINE
324+ ).matcher (compiled ).find ());
325+ }
326+
265327}
0 commit comments