Files
hakorune/tests/mir_instruction_set_sync.rs
Moe Charm bf4b87526e phase(9.78h): stabilize MIR/VM pipeline
- Add MIR26 doc≡code sync test (tests/mir_instruction_set_sync.rs)
- Quiet snapshots; filter plugin/net logs; golden all green
- Delegate VM phi selection to LoopExecutor (borrow-safe)
- ResultBox migration: remove legacy box_trait::ResultBox paths
- VM BoxRef arithmetic fallbacks via toString().parse::<i64>()
- Bridge BoxCall(InstanceBox) to Class.method/arity in VM
- Fix Effects purity (READ -> readonly, not pure)
- Mark Catch as CONTROL to prevent DCE; Try/Catch test green
- Add env-gated debug logs (effects, verifier, mir-printer, trycatch, ref, bin)
- Update CURRENT_TASK with progress and next steps
2025-08-26 05:49:23 +09:00

47 lines
1.8 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use std::fs;
use std::path::Path;
use nyash_rust::mir::instruction_introspection;
// Compare the source-of-truth doc and implementation core instruction names.
#[test]
fn mir_instruction_set_doc_sync() {
// 1) Read the canonical list from docs
let doc_path = Path::new("docs/reference/mir/INSTRUCTION_SET.md");
let content = fs::read_to_string(doc_path)
.expect("Failed to read docs/reference/mir/INSTRUCTION_SET.md");
let mut in_core = false;
let mut doc_names: Vec<String> = Vec::new();
for line in content.lines() {
let line = line.trim();
if line.starts_with("## Core Instructions") {
in_core = true;
continue;
}
if in_core && line.starts_with("## ") { // stop at next section (e.g., Meta)
break;
}
if in_core {
if let Some(rest) = line.strip_prefix("- ") {
// Each bullet is a name, possibly with annotations like ... → strip anything after a space/paren
let name = rest.split(|c: char| c.is_whitespace() || c == '' || c == '(')
.next().unwrap_or("").trim();
if !name.is_empty() {
doc_names.push(name.to_string());
}
}
}
}
assert_eq!(doc_names.len(), 26, "Doc must list exactly 26 core instructions");
// 2) Implementation list
let impl_names = instruction_introspection::core_instruction_names();
// Compare as sets (order-agnostic)
let doc_set: std::collections::BTreeSet<_> = doc_names.iter().map(|s| s.as_str()).collect();
let impl_set: std::collections::BTreeSet<_> = impl_names.iter().copied().collect();
assert_eq!(doc_set, impl_set, "MIR core instruction names must match docs exactly");
}