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>
This commit is contained in:
30
src/tests/mir_pure_e2e_vm.rs
Normal file
30
src/tests/mir_pure_e2e_vm.rs
Normal file
@ -0,0 +1,30 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::parser::NyashParser;
|
||||
use crate::backend::VM;
|
||||
|
||||
#[test]
|
||||
fn vm_exec_new_string_length_under_pure_mode() {
|
||||
// Enable Core-13 pure mode
|
||||
std::env::set_var("NYASH_MIR_CORE13_PURE", "1");
|
||||
|
||||
// Nyash code: return (new StringBox("Hello")).length()
|
||||
let code = r#"
|
||||
return (new StringBox("Hello")).length()
|
||||
"#;
|
||||
|
||||
// Parse -> MIR -> VM execute
|
||||
let ast = NyashParser::parse_from_string(code).expect("parse");
|
||||
let mut compiler = crate::mir::MirCompiler::new();
|
||||
let result = compiler.compile(ast).expect("compile");
|
||||
|
||||
let mut vm = VM::new();
|
||||
let out = vm.execute_module(&result.module).expect("vm exec");
|
||||
// Expect 5 as string (to_string_box) for convenience
|
||||
assert_eq!(out.to_string_box().value, "5");
|
||||
|
||||
// Cleanup
|
||||
std::env::remove_var("NYASH_MIR_CORE13_PURE");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user