diff --git a/.gitignore b/.gitignore index e7d1ab3..403ed45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -test*.py +/test*.py __pycache__*/ build/ dist/ diff --git a/tests/test_cf.py b/tests/test_cf.py new file mode 100644 index 0000000..19b12b2 --- /dev/null +++ b/tests/test_cf.py @@ -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"