Skip to content

Commit

Permalink
tests: add sj.get_modules() lua example
Browse files Browse the repository at this point in the history
  • Loading branch information
lordheavy committed Dec 24, 2024
1 parent 3882524 commit 8021156
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/lua_examples/lua_module.asm
Original file line number Diff line number Diff line change
@@ -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
63 changes: 63 additions & 0 deletions tests/lua_examples/lua_module.lst
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8021156

Please sign in to comment.