mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
Add mono checker to tests
This commit is contained in:
parent
6e72307736
commit
7b21936d4f
3 changed files with 100 additions and 36 deletions
|
@ -13,11 +13,13 @@ extern crate indoc;
|
|||
#[allow(dead_code)]
|
||||
const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024;
|
||||
|
||||
use bumpalo::Bump;
|
||||
use roc_collections::all::MutMap;
|
||||
use roc_load::ExecutionMode;
|
||||
use roc_load::LoadConfig;
|
||||
use roc_load::LoadMonomorphizedError;
|
||||
use roc_load::Threading;
|
||||
use roc_module::symbol::Interns;
|
||||
use roc_module::symbol::Symbol;
|
||||
use roc_mono::ir::Proc;
|
||||
use roc_mono::ir::ProcLayout;
|
||||
|
@ -75,7 +77,6 @@ fn promote_expr_to_module(src: &str) -> String {
|
|||
}
|
||||
|
||||
fn compiles_to_ir(test_name: &str, src: &str) {
|
||||
use bumpalo::Bump;
|
||||
use roc_packaging::cache::RocCacheDir;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
@ -129,6 +130,7 @@ fn compiles_to_ir(test_name: &str, src: &str) {
|
|||
procedures,
|
||||
exposed_to_host,
|
||||
layout_interner,
|
||||
interns,
|
||||
..
|
||||
} = loaded;
|
||||
|
||||
|
@ -145,9 +147,26 @@ fn compiles_to_ir(test_name: &str, src: &str) {
|
|||
|
||||
let main_fn_symbol = exposed_to_host.values.keys().copied().next().unwrap();
|
||||
|
||||
check_procedures(&arena, &interns, &layout_interner, &procedures);
|
||||
|
||||
verify_procedures(test_name, layout_interner, procedures, main_fn_symbol);
|
||||
}
|
||||
|
||||
fn check_procedures<'a>(
|
||||
arena: &'a Bump,
|
||||
interns: &Interns,
|
||||
interner: &STLayoutInterner<'a>,
|
||||
procedures: &MutMap<(Symbol, ProcLayout<'a>), Proc<'a>>,
|
||||
) {
|
||||
use roc_mono::debug::{check_procs, format_problems};
|
||||
let problems = check_procs(arena, interner, procedures);
|
||||
if problems.is_empty() {
|
||||
return;
|
||||
}
|
||||
let formatted = format_problems(interns, interner, problems);
|
||||
panic!("IR problems found:\n{formatted}");
|
||||
}
|
||||
|
||||
fn verify_procedures<'a>(
|
||||
test_name: &str,
|
||||
interner: STLayoutInterner<'a>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue