lua-decompile 0.1.0

a lua bytecode decompiler library
Documentation
use std::process::Command;

use lua_decompile::Decompiler;

fn compile(name: &str) -> Vec<u8> {
    std::fs::create_dir_all("tests/cache").unwrap();
    let result = Command::new("sh")
        .arg("-c")
        .arg(format!(
            "(luac5.1 -o tests/cache/bytecode_{}.out tests/lua51/{}.lua)",
            name, name
        ))
        .output()
        .unwrap();

    assert!(result.status.success());
    std::fs::read(format!("tests/cache/bytecode_{name}.out")).unwrap()
}

#[test]
fn test_variables() {
    Decompiler::decompile(&compile("variables")).unwrap();
}

#[test]
fn test_numbers() {
    Decompiler::decompile(&compile("numbers")).unwrap();
}

#[test]
fn test_strings() {
    Decompiler::decompile(&compile("strings")).unwrap();
}

#[test]
fn test_conditionals() {
    Decompiler::decompile(&compile("conditionals")).unwrap();
}

#[test]
fn test_loops() {
    Decompiler::decompile(&compile("loops")).unwrap();
}

#[test]
fn test_inlining() {
    Decompiler::decompile(&compile("inlining")).unwrap();
}