Files
hakorune/src/tests/mir_pure_locals_normalized.rs
moe-charm b8bdb867d8 Merge selfhosting-dev into main (Core-13 pure CI/tests + LLVM bridge) (#126)
* WIP: sync before merging origin/main

* fix: unify using/module + build CLI; add missing helper in runner; build passes; core smokes green; jit any.len string now returns 3

* Apply local changes after merging main; keep docs/phase-15 removed per main; add phase-15.1 docs and tests

* Remove legacy docs/phase-15/README.md to align with main

* integration: add Core-13 pure CI, tests, and minimal LLVM execute bridge (no docs) (#125)

Co-authored-by: Tomoaki <tomoaki@example.com>

---------

Co-authored-by: Selfhosting Dev <selfhost@example.invalid>
Co-authored-by: Tomoaki <tomoaki@example.com>
2025-09-07 07:36:15 +09:00

32 lines
1.0 KiB
Rust

#[cfg(test)]
mod tests {
use crate::parser::NyashParser;
use crate::mir::MirPrinter;
#[test]
fn locals_rewritten_to_env_local_calls_in_pure_mode() {
// Enable Core-13 pure mode
std::env::set_var("NYASH_MIR_CORE13_PURE", "1");
// Use locals and arithmetic so Load/Store would appear without normalization
let code = r#"
local x
x = 10
x = x + 32
return x
"#;
let ast = NyashParser::parse_from_string(code).expect("parse");
let mut compiler = crate::mir::MirCompiler::new();
let result = compiler.compile(ast).expect("compile");
let dump = MirPrinter::new().print_module(&result.module);
// Expect env.local.get/set present (pure-mode normalization)
assert!(dump.contains("extern_call env.local.get"), "expected env.local.get in MIR. dump=\n{}", dump);
assert!(dump.contains("extern_call env.local.set"), "expected env.local.set in MIR. dump=\n{}", dump);
std::env::remove_var("NYASH_MIR_CORE13_PURE");
}
}