update the tests

This commit is contained in:
Folkert 2022-01-26 15:59:21 +01:00
parent c663a35e16
commit b9c318e9fb
13 changed files with 29 additions and 18 deletions

4
Cargo.lock generated
View file

@ -3690,6 +3690,7 @@ dependencies = [
"roc_problem", "roc_problem",
"roc_region", "roc_region",
"roc_solve", "roc_solve",
"roc_target",
"roc_test_utils", "roc_test_utils",
"roc_types", "roc_types",
"ven_pretty", "ven_pretty",
@ -3712,6 +3713,7 @@ dependencies = [
"roc_problem", "roc_problem",
"roc_region", "roc_region",
"roc_solve", "roc_solve",
"roc_target",
"roc_types", "roc_types",
"roc_unify", "roc_unify",
"tempfile", "tempfile",
@ -4280,6 +4282,7 @@ dependencies = [
"roc_reporting", "roc_reporting",
"roc_solve", "roc_solve",
"roc_std", "roc_std",
"roc_target",
"roc_types", "roc_types",
"roc_unify", "roc_unify",
"target-lexicon", "target-lexicon",
@ -4301,6 +4304,7 @@ dependencies = [
"roc_load", "roc_load",
"roc_module", "roc_module",
"roc_mono", "roc_mono",
"roc_target",
"test_mono_macros", "test_mono_macros",
] ]

View file

@ -28,6 +28,8 @@ mod test_load {
use roc_types::subs::Subs; use roc_types::subs::Subs;
use std::collections::HashMap; use std::collections::HashMap;
const TARGET_INFO: roc_target::TargetInfo = roc_target::TargetInfo::default_x86_64();
// HELPERS // HELPERS
fn multiple_modules(files: Vec<(&str, &str)>) -> Result<LoadedModule, String> { fn multiple_modules(files: Vec<(&str, &str)>) -> Result<LoadedModule, String> {
@ -110,7 +112,7 @@ mod test_load {
arena.alloc(stdlib), arena.alloc(stdlib),
dir.path(), dir.path(),
exposed_types, exposed_types,
8, TARGET_INFO,
builtin_defs_map, builtin_defs_map,
) )
}; };
@ -134,7 +136,7 @@ mod test_load {
arena.alloc(roc_builtins::std::standard_stdlib()), arena.alloc(roc_builtins::std::standard_stdlib()),
src_dir.as_path(), src_dir.as_path(),
subs_by_module, subs_by_module,
8, TARGET_INFO,
builtin_defs_map, builtin_defs_map,
); );
let mut loaded_module = match loaded { let mut loaded_module = match loaded {
@ -305,7 +307,7 @@ mod test_load {
arena.alloc(roc_builtins::std::standard_stdlib()), arena.alloc(roc_builtins::std::standard_stdlib()),
src_dir.as_path(), src_dir.as_path(),
subs_by_module, subs_by_module,
8, TARGET_INFO,
builtin_defs_map, builtin_defs_map,
); );

View file

@ -21,6 +21,7 @@ roc_builtins = { path = "../builtins" }
roc_problem = { path = "../problem" } roc_problem = { path = "../problem" }
roc_parse = { path = "../parse" } roc_parse = { path = "../parse" }
roc_solve = { path = "../solve" } roc_solve = { path = "../solve" }
roc_target = { path = "../target" }
pretty_assertions = "1.0.0" pretty_assertions = "1.0.0"
indoc = "1.0.3" indoc = "1.0.3"
tempfile = "3.2.0" tempfile = "3.2.0"

View file

@ -63,7 +63,7 @@ mod solve_expr {
&stdlib, &stdlib,
dir.path(), dir.path(),
exposed_types, exposed_types,
8, roc_target::TargetInfo::default_x86_64(),
builtin_defs_map, builtin_defs_map,
); );

View file

@ -31,6 +31,7 @@ roc_load = { path = "../load" }
roc_can = { path = "../can" } roc_can = { path = "../can" }
roc_parse = { path = "../parse" } roc_parse = { path = "../parse" }
roc_build = { path = "../build" } roc_build = { path = "../build" }
roc_target = { path = "../target" }
roc_std = { path = "../../roc_std" } roc_std = { path = "../../roc_std" }
bumpalo = { version = "3.8.0", features = ["collections"] } bumpalo = { version = "3.8.0", features = ["collections"] }
either = "1.6.1" either = "1.6.1"

View file

@ -23,9 +23,9 @@ fn width_and_alignment_u8_u8() {
let layout = Layout::Union(UnionLayout::NonRecursive(&tt)); let layout = Layout::Union(UnionLayout::NonRecursive(&tt));
let ptr_width = 8; let target_info = roc_target::TargetInfo::default_x86_64();
assert_eq!(layout.alignment_bytes(ptr_width), 1); assert_eq!(layout.alignment_bytes(target_info), 1);
assert_eq!(layout.stack_size(ptr_width), 2); assert_eq!(layout.stack_size(target_info), 2);
} }
#[test] #[test]

View file

@ -57,7 +57,7 @@ pub fn helper(
&stdlib, &stdlib,
src_dir, src_dir,
exposed_types, exposed_types,
8, roc_target::TargetInfo::default_x86_64(),
builtin_defs_map, builtin_defs_map,
); );

View file

@ -42,6 +42,8 @@ fn create_llvm_module<'a>(
) -> (&'static str, String, &'a Module<'a>) { ) -> (&'static str, String, &'a Module<'a>) {
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
let target_info = roc_target::TargetInfo::from(target);
let filename = PathBuf::from("Test.roc"); let filename = PathBuf::from("Test.roc");
let src_dir = Path::new("fake/test/path"); let src_dir = Path::new("fake/test/path");
@ -56,8 +58,6 @@ fn create_llvm_module<'a>(
module_src = &temp; module_src = &temp;
} }
let ptr_bytes = target.pointer_width().unwrap().bytes() as u32;
let exposed_types = MutMap::default(); let exposed_types = MutMap::default();
let loaded = roc_load::file::load_and_monomorphize_from_str( let loaded = roc_load::file::load_and_monomorphize_from_str(
arena, arena,
@ -66,7 +66,7 @@ fn create_llvm_module<'a>(
stdlib, stdlib,
src_dir, src_dir,
exposed_types, exposed_types,
ptr_bytes, target_info,
test_builtin_defs, test_builtin_defs,
); );
@ -213,7 +213,7 @@ fn create_llvm_module<'a>(
context, context,
interns, interns,
module, module,
target_info: ptr_bytes, target_info,
is_gen_test, is_gen_test,
// important! we don't want any procedures to get the C calling convention // important! we don't want any procedures to get the C calling convention
exposed_to_host: MutSet::default(), exposed_to_host: MutSet::default(),

View file

@ -94,7 +94,6 @@ fn compile_roc_to_wasm_bytes<'a, T: Wasm32TestResult>(
} }
let exposed_types = MutMap::default(); let exposed_types = MutMap::default();
let ptr_bytes = 4;
let loaded = roc_load::file::load_and_monomorphize_from_str( let loaded = roc_load::file::load_and_monomorphize_from_str(
arena, arena,
filename, filename,
@ -102,7 +101,7 @@ fn compile_roc_to_wasm_bytes<'a, T: Wasm32TestResult>(
stdlib, stdlib,
src_dir, src_dir,
exposed_types, exposed_types,
ptr_bytes, roc_target::TargetInfo::default_wasm32(),
builtin_defs_map, builtin_defs_map,
); );

View file

@ -16,6 +16,7 @@ roc_builtins = { path = "../builtins" }
roc_load = { path = "../load" } roc_load = { path = "../load" }
roc_can = { path = "../can" } roc_can = { path = "../can" }
roc_mono = { path = "../mono" } roc_mono = { path = "../mono" }
roc_target = { path = "../target" }
test_mono_macros = { path = "../test_mono_macros" } test_mono_macros = { path = "../test_mono_macros" }
pretty_assertions = "1.0.0" pretty_assertions = "1.0.0"
bumpalo = { version = "3.8.0", features = ["collections"] } bumpalo = { version = "3.8.0", features = ["collections"] }

View file

@ -25,6 +25,8 @@ use roc_mono::ir::Proc;
use roc_mono::ir::ProcLayout; use roc_mono::ir::ProcLayout;
const TARGET_INFO: roc_target::TargetInfo = roc_target::TargetInfo::default_x86_64();
/// Without this, some tests pass in `cargo test --release` but fail without /// Without this, some tests pass in `cargo test --release` but fail without
/// the --release flag because they run out of stack space. This increases /// the --release flag because they run out of stack space. This increases
/// stack size for debug builds only, while leaving the stack space at the default /// stack size for debug builds only, while leaving the stack space at the default
@ -104,7 +106,7 @@ fn compiles_to_ir(test_name: &str, src: &str) {
&stdlib, &stdlib,
src_dir, src_dir,
exposed_types, exposed_types,
8, TARGET_INFO,
builtin_defs_map, builtin_defs_map,
); );

View file

@ -24,6 +24,7 @@ roc_constrain = { path = "../compiler/constrain" }
roc_builtins = { path = "../compiler/builtins" } roc_builtins = { path = "../compiler/builtins" }
roc_problem = { path = "../compiler/problem" } roc_problem = { path = "../compiler/problem" }
roc_parse = { path = "../compiler/parse" } roc_parse = { path = "../compiler/parse" }
roc_target = { path = "../compiler/target" }
roc_test_utils = { path = "../test_utils" } roc_test_utils = { path = "../test_utils" }
pretty_assertions = "1.0.0" pretty_assertions = "1.0.0"
indoc = "1.0.3" indoc = "1.0.3"

View file

@ -96,8 +96,8 @@ mod test_reporting {
let mut update_mode_ids = UpdateModeIds::new(); let mut update_mode_ids = UpdateModeIds::new();
// Populate Procs and Subs, and get the low-level Expr from the canonical Expr // Populate Procs and Subs, and get the low-level Expr from the canonical Expr
let ptr_bytes = 8; let target_info = roc_target::TargetInfo::default_x86_64();
let mut layout_cache = LayoutCache::new(ptr_bytes); let mut layout_cache = LayoutCache::new(target_info);
let mut mono_env = roc_mono::ir::Env { let mut mono_env = roc_mono::ir::Env {
arena: &arena, arena: &arena,
subs: &mut subs, subs: &mut subs,
@ -105,7 +105,7 @@ mod test_reporting {
home, home,
ident_ids: &mut ident_ids, ident_ids: &mut ident_ids,
update_mode_ids: &mut update_mode_ids, update_mode_ids: &mut update_mode_ids,
target_info: ptr_bytes, target_info,
// call_specialization_counter=0 is reserved // call_specialization_counter=0 is reserved
call_specialization_counter: 1, call_specialization_counter: 1,
}; };