Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend tests to cover the insensitive analysis #96

Merged
merged 3 commits into from
Dec 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@ use std::path::Path;

fn test_facts(all_facts: &AllFacts, algorithms: &[Algorithm]) {
let naive = Output::compute(all_facts, Algorithm::Naive, true);

// Check that the "naive errors" are a subset of the "insensitive
// ones".
let insensitive = Output::compute(all_facts, Algorithm::LocationInsensitive, false);
for (naive_point, naive_loans) in &naive.errors {
match insensitive.errors.get(&naive_point) {
Some(insensitive_loans) => {
for naive_loan in naive_loans {
if !insensitive_loans.contains(naive_loan) {
panic!(
"naive analysis had error for `{:?}` at `{:?}` \
but insensitive analysis did not \
(loans = {:#?})",
naive_point, naive_loan, insensitive_loans,
);
}
}
}

None => {
panic!(
"naive analysis had errors at `{:?}` but insensitive analysis did not \
(loans = {:#?})",
naive_point, naive_loans,
);
}
}
}

// The optimized checks should behave exactly the same as the naive check.
for &optimized_algorithm in algorithms {
println!("Algorithm {:?}", optimized_algorithm);
let opt = Output::compute(all_facts, optimized_algorithm, true);
Expand Down