Skip to content

Commit

Permalink
Avoid blessing duplicated Expects
Browse files Browse the repository at this point in the history
  • Loading branch information
ecstatic-morse committed Dec 22, 2021
1 parent 83ed8bb commit c9a75c0
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ fn solve_goal(program_text: &str, goals: Vec<(&str, SolverChoice, TestGoal)>, co
db.program_ir().unwrap()
};

for (goal_text, solver_choice, expected) in goals {
let mut last_expected_pos = None;

for (goal_text, solver_choice, mut expected) in goals {
match (&solver_choice, &expected) {
(SolverChoice::Recursive { .. }, TestGoal::All(_))
| (SolverChoice::Recursive { .. }, TestGoal::First(_)) => {
Expand All @@ -264,6 +266,15 @@ fn solve_goal(program_text: &str, goals: Vec<(&str, SolverChoice, TestGoal)>, co
db.set_solver_choice(solver_choice);
}

if let TestGoal::Aggregated(expected) = &mut expected {
if let Some(last_expected_pos) = last_expected_pos {
if last_expected_pos == ExpectPos::of(expected) {
expected.bless(false)
}
}
last_expected_pos = Some(ExpectPos::of(expected));
}

chalk_integration::tls::set_current_program(&program, || {
println!("----------------------------------------------------------------------");
println!("goal {}", goal_text);
Expand Down Expand Up @@ -332,6 +343,23 @@ fn solve_goal(program_text: &str, goals: Vec<(&str, SolverChoice, TestGoal)>, co
})
}

#[derive(Clone, Copy, PartialEq, Eq)]
struct ExpectPos {
file: &'static str,
line: u32,
column: u32,
}

impl ExpectPos {
fn of(e: &Expect) -> Self {
Self {
file: e.position.file,
line: e.position.line,
column: e.position.column
}
}
}

mod arrays;
mod auto_traits;
mod closures;
Expand Down

0 comments on commit c9a75c0

Please sign in to comment.