From 8021156156f43c2ca936a638cd4e3ed7dda87a80 Mon Sep 17 00:00:00 2001 From: Laurent Carlier Date: Tue, 24 Dec 2024 16:21:32 +0100 Subject: [PATCH] tests: add sj.get_modules() lua example --- tests/lua_examples/lua_module.asm | 52 +++++++++++++++++++++++++ tests/lua_examples/lua_module.lst | 63 +++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 tests/lua_examples/lua_module.asm create mode 100644 tests/lua_examples/lua_module.lst diff --git a/tests/lua_examples/lua_module.asm b/tests/lua_examples/lua_module.asm new file mode 100644 index 00000000..85cf7bd9 --- /dev/null +++ b/tests/lua_examples/lua_module.asm @@ -0,0 +1,52 @@ + LUA + -- outside of a module -- + my_var = sj.get_modules() + -- sj.get_modules() returns "" -- + sj.insert_label(my_var.."label", 0xA0A0) + ENDLUA + + ASSERT label = 0xA0A0 + + MODULE plop + + LUA + -- entering module plop -- + my_var = sj.get_modules() + -- sj.get_modules() returns "plop" + sj.insert_label(my_var..".label", 0xB0B0) + ENDLUA + + ASSERT plop.label = 0xB0B0 + + MODULE plip + + LUA + -- entering module plip -- + my_var = sj.get_modules() + -- sj.get_modules() returns "plop.plip" -- + sj.insert_label(my_var..".label", 0xC0C0) + ENDLUA + + ASSERT plop.plip.label = 0xC0C0 + + ENDMODULE + + LUA + -- returning in module plop -- + my_var = sj.get_modules() + -- sj.get_modules() returns "plop" -- + sj.insert_label(my_var..".label", 0xD0D0) + ENDLUA + + ASSERT plip.label = 0xD0D0 + + ENDMODULE + + LUA + -- outside of a module -- + my_var = sj.get_modules() + sj.insert_label(my_var.."label", 0xE0E0) + -- sj.get_modules() returns "" + ENDLUA + + ASSERT label = 0xE0E0 diff --git a/tests/lua_examples/lua_module.lst b/tests/lua_examples/lua_module.lst new file mode 100644 index 00000000..b1c31aec --- /dev/null +++ b/tests/lua_examples/lua_module.lst @@ -0,0 +1,63 @@ +# file opened: lua_module.asm + 1 0000 LUA + 2 0000 ~ -- outside of a module -- + 3 0000 ~ my_var = sj.get_modules() + 4 0000 ~ -- sj.get_modules() returns "" -- + 5 0000 ~ sj.insert_label(my_var.."label", 0xA0A0) + 6 0000 ENDLUA + 7 0000 + 8 0000 ASSERT label = 0xA0A0 + 9 0000 +10 0000 MODULE plop +11 0000 +12 0000 LUA +13 0000 ~ -- entering module plop -- +14 0000 ~ my_var = sj.get_modules() +15 0000 ~ -- sj.get_modules() returns "plop" +16 0000 ~ sj.insert_label(my_var..".label", 0xB0B0) +17 0000 ENDLUA +18 0000 +19 0000 ASSERT plop.label = 0xB0B0 +20 0000 +21 0000 MODULE plip +22 0000 +23 0000 LUA +24 0000 ~ -- entering module plip -- +25 0000 ~ my_var = sj.get_modules() +26 0000 ~ -- sj.get_modules() returns "plop.plip" -- +27 0000 ~ sj.insert_label(my_var..".label", 0xC0C0) +28 0000 ENDLUA +29 0000 +30 0000 ASSERT plop.plip.label = 0xC0C0 +31 0000 +32 0000 ENDMODULE +33 0000 +34 0000 LUA +35 0000 ~ -- returning in module plop -- +36 0000 ~ my_var = sj.get_modules() +37 0000 ~ -- sj.get_modules() returns "plop" -- +38 0000 ~ sj.insert_label(my_var..".label", 0xD0D0) +39 0000 ENDLUA +40 0000 +lua_module.asm(41): error: [ASSERT] Assertion failed: plip.label = 0xD0D0 +41 0000 ASSERT plip.label = 0xD0D0 +42 0000 +43 0000 ENDMODULE +44 0000 +45 0000 LUA +46 0000 ~ -- outside of a module -- +47 0000 ~ my_var = sj.get_modules() +48 0000 ~ sj.insert_label(my_var.."label", 0xE0E0) +49 0000 ~ -- sj.get_modules() returns "" +50 0000 ENDLUA +51 0000 +lua_module.asm(52): error: [ASSERT] Assertion failed: label = 0xE0E0 +52 0000 ASSERT label = 0xE0E0 +53 0000 +# file closed: lua_module.asm + +Value Label +------ - ----------------------------------------------------------- +0xA0A0 label +0xB0B0 X plop.label +0xC0C0 plop.plip.label