Merge pull request #732 from utkarshkukreti/update-diff-to-0.1.8
Update diff to 0.1.8
This commit is contained in:
commit
0698f0255a
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -2,7 +2,7 @@
|
||||
name = "rustfmt"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"diff 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"diff 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -30,7 +30,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "diff"
|
||||
version = "0.1.7"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -20,7 +20,7 @@ unicode-segmentation = "0.1.2"
|
||||
regex = "0.1.41"
|
||||
term = "0.2.11"
|
||||
strings = "0.0.1"
|
||||
diff = "0.1.7"
|
||||
diff = "0.1.8"
|
||||
syntex_syntax = "0.23.0"
|
||||
log = "0.3.2"
|
||||
env_logger = "0.3.1"
|
||||
|
@ -2,12 +2,14 @@ use std::collections::VecDeque;
|
||||
use diff;
|
||||
use term;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum DiffLine {
|
||||
Context(String),
|
||||
Expected(String),
|
||||
Resulting(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct Mismatch {
|
||||
pub line_number: u32,
|
||||
pub lines: Vec<DiffLine>,
|
||||
|
@ -273,3 +273,17 @@ fn get_target(file_name: &str, target: Option<&str>, write_mode: WriteMode) -> S
|
||||
file_name.to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rustfmt_diff_make_diff_tests() {
|
||||
let diff = make_diff("a\nb\nc\nd", "a\ne\nc\nd", 3);
|
||||
assert_eq!(diff,
|
||||
vec![Mismatch {
|
||||
line_number: 1,
|
||||
lines: vec![DiffLine::Context("a".into()),
|
||||
DiffLine::Resulting("b".into()),
|
||||
DiffLine::Expected("e".into()),
|
||||
DiffLine::Context("c".into()),
|
||||
DiffLine::Context("d".into())],
|
||||
}]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user