Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ayazhafiz committed Jun 22, 2023
1 parent 2e84d5c commit 4f482c0
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
28 changes: 20 additions & 8 deletions crates/compiler/test_derive/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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,
Expand Down
21 changes: 10 additions & 11 deletions crates/reporting/tests/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,26 +34,24 @@ pub fn infer_expr(
problems: &mut Vec<TypeError>,
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);

Expand Down
4 changes: 2 additions & 2 deletions crates/reporting/tests/test_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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(),
Expand Down

0 comments on commit 4f482c0

Please sign in to comment.