- Fix condition_fn resolution: Value call path + dev safety + stub injection - VM bridge: handle Method::birth via BoxCall; ArrayBox push/get/length/set direct bridge - Receiver safety: pin receiver in method_call_handlers to avoid undefined use across blocks - Local vars: materialize on declaration (use init ValueId; void for uninit) - Prefer legacy BoxCall for Array/Map/String/user boxes in emit_box_or_plugin_call (stability-first) - Test runner: update LLVM hint to llvmlite harness (remove LLVM_SYS_180_PREFIX guidance) - Docs/roadmap: update CURRENT_TASK with unified default-ON + guards Note: NYASH_DEV_BIRTH_INJECT_BUILTINS=1 can re-enable builtin birth() injection during migration.
28 lines
937 B
Rust
28 lines
937 B
Rust
#![cfg(feature = "interpreter-legacy")]
|
|
|
|
use crate::parser::NyashParser;
|
|
use crate::interpreter::NyashInterpreter;
|
|
|
|
#[test]
|
|
fn vm_exec_bitwise_and_shift() {
|
|
let code = r#"
|
|
return (5 & 3) + (5 | 2) + (5 ^ 1) + (1 << 5) + (32 >> 3)
|
|
"#;
|
|
let ast = NyashParser::parse_from_string(code).expect("parse ok");
|
|
let mut interp = NyashInterpreter::new();
|
|
let out = interp.execute(ast).expect("exec ok");
|
|
assert_eq!(out.to_string_box().value, "48");
|
|
}
|
|
|
|
#[test]
|
|
fn vm_exec_shift_masking() {
|
|
// 1 << 100 should mask to 1 << (100 & 63) = 1 << 36
|
|
let code = r#" return 1 << 100 "#;
|
|
let ast = NyashParser::parse_from_string(code).expect("parse ok");
|
|
let mut interp = NyashInterpreter::new();
|
|
let out = interp.execute(ast).expect("exec ok");
|
|
// compute expected as i64
|
|
let expected = (1_i64 as i64).wrapping_shl((100_u32) & 63);
|
|
assert_eq!(out.to_string_box().value, expected.to_string());
|
|
}
|