Skip to content

Commit

Permalink
Merge pull request rust-lang#62 from chrissimpkins/remove-duplicated-…
Browse files Browse the repository at this point in the history
…start-check

Refactor Toolchain testing, eliminate duplicated start date checks
  • Loading branch information
pnkfelix committed Mar 11, 2020
2 parents 25e566a + c950c79 commit 1b1c144
Show file tree
Hide file tree
Showing 3 changed files with 703 additions and 606 deletions.
26 changes: 8 additions & 18 deletions src/least_satisfying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,13 @@ where
let mut cache = BTreeMap::new();
let mut predicate = |idx: usize| *cache.entry(idx).or_insert_with(|| predicate(&slice[idx]));
let mut unknown_ranges: Vec<(usize, usize)> = Vec::new();
let mut rm_no = 0; // presume that the slice starts with a no
// presume that the slice starts with a no
// this should be tested before call
let mut rm_no = 0;

eprintln!("verifying the start of the range does not reproduce the regression");
match predicate(rm_no) {
Satisfies::No => {
eprintln!("confirmed the start of the range does not reproduce the regression")
}
_ => panic!("the start of the range to test must not reproduce the regression"),
}

let mut lm_yes = slice.len() - 1; // presume that the slice ends with a yes

eprintln!("verifying the end of the range reproduces the regression");
match predicate(lm_yes) {
Satisfies::Yes => eprintln!("confirmed the end of the range reproduces the regression"),
_ => panic!("the end of the range to test must reproduce the regression"),
}
// presume that the slice ends with a yes
// this should be tested before the call
let mut lm_yes = slice.len() - 1;

let mut next = (rm_no + lm_yes) / 2;

Expand Down Expand Up @@ -111,7 +101,7 @@ mod tests {
#[test]
fn least_satisfying_1() {
assert_eq!(
least_satisfying(&[No, Unknown, Unknown, No, Yes], |i| *i),
least_satisfying(&[No, Unknown, Unknown, No, Yes],|i| *i),
4
);
}
Expand Down Expand Up @@ -155,7 +145,7 @@ mod tests {
#[test]
fn least_satisfying_8() {
assert_eq!(
least_satisfying(&[No, Unknown, No, No, Unknown, Yes, Yes], |i| *i),
least_satisfying(&[No, Unknown, No, No, Unknown, Yes, Yes],|i| *i),
5
);
}
Expand Down
Loading

0 comments on commit 1b1c144

Please sign in to comment.