switch assert_log to a better debug library

This commit is contained in:
Niko Matsakis 2018-10-22 09:12:15 -04:00
parent 1ab8d1a64e
commit ce24850c3d
2 changed files with 6 additions and 10 deletions

View file

@ -18,5 +18,5 @@ log = "0.4.5"
smallvec = "0.6.5"
[dev-dependencies]
difference = "2.0"
diff = "0.1.0"
env_logger = "0.5.13"

View file

@ -19,8 +19,6 @@ pub(crate) struct TestContextImpl {
impl TestContextImpl {
pub(crate) fn assert_log(&self, expected_log: &[&str]) {
use difference::{Changeset, Difference};
let expected_text = &format!("{:#?}", expected_log);
let actual_text = &format!("{:#?}", self.log().take());
@ -28,13 +26,11 @@ impl TestContextImpl {
return;
}
let Changeset { diffs, .. } = Changeset::new(expected_text, actual_text, "\n");
for i in 0..diffs.len() {
match &diffs[i] {
Difference::Same(x) => println!(" {}", x),
Difference::Add(x) => println!("+{}", x),
Difference::Rem(x) => println!("-{}", x),
for diff in diff::lines(expected_text, actual_text) {
match diff {
diff::Result::Left(l) => println!("-{}", l),
diff::Result::Both(l, _) => println!(" {}", l),
diff::Result::Right(r) => println!("+{}", r),
}
}