test: clean red signal for env-construction pin (inline module_types)
This commit is contained in:
@@ -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<String, indexmap::IndexMap<String, ailang_core::ast::TypeDef>> = BTreeMap::new();
|
||||
for (mname, m) in &ws.modules {
|
||||
let mut tys: indexmap::IndexMap<String, ailang_core::ast::TypeDef> = 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() {
|
||||
|
||||
Reference in New Issue
Block a user