From 42a7ed7673a2a25263880fc18d44e65d2267e635 Mon Sep 17 00:00:00 2001 From: Brummel Date: Sun, 10 May 2026 02:06:46 +0200 Subject: [PATCH] test: clean red signal for env-construction pin (inline module_types) --- .../tests/env_construction_pin.rs | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/crates/ailang-check/tests/env_construction_pin.rs b/crates/ailang-check/tests/env_construction_pin.rs index de3f9b2..1ef019b 100644 --- a/crates/ailang-check/tests/env_construction_pin.rs +++ b/crates/ailang-check/tests/env_construction_pin.rs @@ -9,7 +9,7 @@ //! `Def::Instance`, one user ADT, and one cross-module import (the //! same shape that `test_mono_imports_*` use). -use ailang_check::{build_check_env, build_module_globals, build_module_types, Env}; +use ailang_check::{build_check_env, build_module_globals, Env}; use ailang_core::ast::Def; use ailang_core::load_workspace; use std::collections::BTreeMap; @@ -17,12 +17,16 @@ use std::path::Path; fn examples_dir() -> std::path::PathBuf { let manifest = env!("CARGO_MANIFEST_DIR"); - Path::new(manifest).parent().unwrap().parent().unwrap().join("examples") + Path::new(manifest) + .parent().expect("CARGO_MANIFEST_DIR has a parent (crates/ailang-check)") + .parent().expect("CARGO_MANIFEST_DIR has a grandparent (crates/)") + .join("examples") } /// In-test reproduction of the pre-refactor `check_in_workspace` -/// workspace-flat seeding (lib.rs as of commit a9c685d). Kept as a -/// frozen reference: any future divergence between this body and +/// workspace-flat seeding (the inline seeding that lived in +/// `check_in_workspace` before this milestone). Kept as a frozen +/// reference: any future divergence between this body and /// `build_check_env` makes the assertion below fail. fn build_env_inline_pre_refactor(ws: &ailang_core::workspace::Workspace) -> Env { let mut env = Env::default(); @@ -50,8 +54,20 @@ fn build_env_inline_pre_refactor(ws: &ailang_core::workspace::Workspace) -> Env .map(|(k, v)| (k.clone(), v.fns.clone())) .collect(); - // env.module_types — workspace-wide. - env.module_types = build_module_types(ws); + // env.module_types — workspace-wide ADT index, inlined here as + // a frozen reproduction (test does not share helper code with + // production). + let mut module_types: BTreeMap> = BTreeMap::new(); + for (mname, m) in &ws.modules { + let mut tys: indexmap::IndexMap = indexmap::IndexMap::new(); + for d in &m.defs { + if let Def::Type(td) = d { + tys.insert(td.name.clone(), td.clone()); + } + } + module_types.insert(mname.clone(), tys); + } + env.module_types = module_types; // env.module_imports — per-module alias map. for m in ws.modules.values() {