//! Regression pin for primitive Eq/Ord mono-symbol body hashes. //! //! Locks the six primitive mono symbols (`eq__Int`, `eq__Bool`, `eq__Str`, //! `compare__Int`, `compare__Bool`, `compare__Str`) to their pre-iter-23.4 //! body hashes. The unified mono pass MUST produce bit-identical bodies. use ailang_core::ast::Def; use ailang_core::hash::def_hash; use ailang_core::workspace::load_workspace; use std::path::PathBuf; fn fixture_path() -> PathBuf { let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR")); d.pop(); d.pop(); d.join("examples").join("mono_hash_pin_smoke.ail.json") } #[test] fn primitive_eq_ord_mono_symbol_hashes_stay_bit_identical() { let ws = load_workspace(&fixture_path()).expect("workspace loads"); let diags = ailang_check::check_workspace(&ws); assert!(diags.is_empty(), "typecheck diagnostics: {diags:?}"); let post_mono = ailang_check::monomorphise_workspace(&ws).expect("mono green"); // Mono symbols for class methods are appended to the instance's // `defining_module` — i.e. the prelude module, since all six // primitive Eq/Ord instances live there. let prelude_mod = post_mono .modules .get("prelude") .expect("prelude module present"); let pins: &[(&str, &str)] = &[ ("eq__Int", "81d59ac38ab3663d"), ("eq__Bool", "11da98a358b5979b"), ("eq__Str", "277516bb7f195b2a"), ("compare__Int", "d5d3f66b86c7e758"), ("compare__Bool", "676e3ea0298a8795"), ("compare__Str", "a532710899cf14fe"), ]; for (sym, pin) in pins { let def = prelude_mod .defs .iter() .find(|d| matches!(d, Def::Fn(f) if f.name == *sym)) .unwrap_or_else(|| panic!("mono symbol {sym} not found in prelude module")); let h = def_hash(def); assert_eq!(&h, pin, "{sym} body hash drifted"); } }