Skip to content

Commit

Permalink
Add basic control flow test
Browse files Browse the repository at this point in the history
  • Loading branch information
N3rdL0rd committed Nov 29, 2024
1 parent 91c30b5 commit 120b1c9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
test*.py
/test*.py
__pycache__*/
build/
dist/
Expand Down
21 changes: 21 additions & 0 deletions tests/test_cf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from crashlink import *

from typing import Tuple

def load_test(path) -> Tuple[Bytecode, Function]:
code = Bytecode.from_path(path)
assert code is not None
func = None
for f in code.functions:
if "main" in fmt.disasm.full_func_name(code, f):
func = f
break
assert func is not None
return code, func

def test_switch():
code, func = load_test("tests/haxe/Switch.hl")
cfg = fmt.decomp.CFGraph(func)
cfg.build()
assert cfg.nodes[0].ops[-1].op == "Switch"
assert cfg.nodes[-1].ops[-1].op == "Ret"

0 comments on commit 120b1c9

Please sign in to comment.