From 4f482c05b2eaebb194a518ce288d35a21f4d18a9 Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Thu, 22 Jun 2023 14:22:18 -0500 Subject: [PATCH] Update tests --- crates/compiler/test_derive/src/util.rs | 28 +++++++++++++++++------- crates/reporting/tests/helpers/mod.rs | 21 +++++++++--------- crates/reporting/tests/test_reporting.rs | 4 ++-- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/crates/compiler/test_derive/src/util.rs b/crates/compiler/test_derive/src/util.rs index f3977cc3f43..463f1cd9990 100644 --- a/crates/compiler/test_derive/src/util.rs +++ b/crates/compiler/test_derive/src/util.rs @@ -3,7 +3,10 @@ use std::path::PathBuf; use bumpalo::Bump; use roc_packaging::cache::RocCacheDir; -use roc_solve::FunctionKind; +use roc_solve::{ + module::{SolveConfig, SolveOutput}, + FunctionKind, +}; use ven_pretty::DocAllocator; use roc_can::{ @@ -419,18 +422,27 @@ fn check_derived_typechecks_and_golden( roc_debug_flags::ROC_PRINT_UNIFICATIONS_DERIVED, std::env::set_var(roc_debug_flags::ROC_PRINT_UNIFICATIONS, "1") ); - let (mut solved_subs, _, problems, _) = roc_solve::module::run_solve( - test_module, + + let solve_config = SolveConfig { + home: test_module, + constraints: &constraints, + root_constraint: constr, types, - &constraints, - constr, + pending_derives: Default::default(), + exposed_by_module: &exposed_for_module.exposed_by_module, + derived_module: Default::default(), + }; + + let SolveOutput { + subs: mut solved_subs, + errors: problems, + .. + } = roc_solve::module::run_solve( + solve_config, RigidVariables::default(), test_subs, Default::default(), abilities_store, - Default::default(), - &exposed_for_module.exposed_by_module, - Default::default(), ); dbg_do!( roc_debug_flags::ROC_PRINT_UNIFICATIONS_DERIVED, diff --git a/crates/reporting/tests/helpers/mod.rs b/crates/reporting/tests/helpers/mod.rs index 187102105ea..a8bea3eeacb 100644 --- a/crates/reporting/tests/helpers/mod.rs +++ b/crates/reporting/tests/helpers/mod.rs @@ -15,7 +15,8 @@ use roc_module::symbol::{IdentIds, Interns, ModuleId, ModuleIds}; use roc_parse::parser::{SourceError, SyntaxError}; use roc_problem::can::Problem; use roc_region::all::Loc; -use roc_solve::solve::{self, Aliases}; +use roc_solve::module::SolveConfig; +use roc_solve::{solve, Aliases}; use roc_solve_problem::TypeError; use roc_types::subs::{Content, Subs, VarStore, Variable}; use roc_types::types::Types; @@ -33,26 +34,24 @@ pub fn infer_expr( problems: &mut Vec, types: Types, constraints: &Constraints, - constraint: &Constraint, + constraint: Constraint, pending_derives: PendingDerives, aliases: &mut Aliases, abilities_store: &mut AbilitiesStore, derived_module: SharedDerivedModule, expr_var: Variable, ) -> (Content, Subs) { - let (solved, _) = solve::run( - ModuleId::ATTR, + let config = SolveConfig { types, constraints, - problems, - subs, - aliases, - constraint, + root_constraint: constraint, + home: ModuleId::ATTR, pending_derives, - abilities_store, - &Default::default(), + exposed_by_module: &Default::default(), derived_module, - ); + }; + + let (solved, _) = solve::run(config, problems, subs, aliases, abilities_store); let content = *solved.inner().get_content_without_compacting(expr_var); diff --git a/crates/reporting/tests/test_reporting.rs b/crates/reporting/tests/test_reporting.rs index 482555598d1..823bebed027 100644 --- a/crates/reporting/tests/test_reporting.rs +++ b/crates/reporting/tests/test_reporting.rs @@ -260,7 +260,7 @@ mod test_reporting { subs.rigid_var(var.value, "*".into()); } - let mut solve_aliases = roc_solve::solve::Aliases::default(); + let mut solve_aliases = roc_solve::Aliases::default(); for (name, alias) in output.aliases { solve_aliases.insert(&mut types, name, alias); @@ -273,7 +273,7 @@ mod test_reporting { &mut unify_problems, types, &constraints, - &constraint, + constraint, // Use `new_report_problem_as` in order to get proper derives. // TODO: remove the non-new reporting test infra. PendingDerives::default(),