Files
hakorune/src/tests/plugin_hygiene.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

35 lines
1.3 KiB
Rust

#[test]
fn plugin_invoke_hygiene_prefers_hostcall_for_mapped() {
use crate::jit::policy::invoke::{decide_box_method, InvokeDecision};
use crate::jit::r#extern::collections as c;
// Ensure plugin builtins are not forced
std::env::remove_var("NYASH_USE_PLUGIN_BUILTINS");
// For ArrayBox.get, policy should map to hostcall symbol, not plugin invoke
let decision = decide_box_method("ArrayBox", "get", 2, true);
match decision {
InvokeDecision::HostCall { symbol, reason, .. } => {
assert_eq!(symbol, c::SYM_ARRAY_GET_H);
assert_eq!(reason, "mapped_symbol");
}
other => panic!("expected HostCall(mapped_symbol), got: {:?}", other),
}
}
#[test]
fn plugin_invoke_hygiene_string_len_is_hostcall() {
use crate::jit::policy::invoke::{decide_box_method, InvokeDecision};
use crate::jit::r#extern::collections as c;
std::env::remove_var("NYASH_USE_PLUGIN_BUILTINS");
let decision = decide_box_method("StringBox", "len", 1, true);
match decision {
InvokeDecision::HostCall { symbol, reason, .. } => {
assert_eq!(symbol, c::SYM_STRING_LEN_H);
assert_eq!(reason, "mapped_symbol");
}
other => panic!("expected HostCall(mapped_symbol) for String.len, got: {:?}", other),
}
}