about summary refs log tree commit diff
path: root/crates/test_utils
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2019-02-08 14:49:43 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2019-02-08 14:49:43 +0300
commit12e3b4c70b5ef23b2fdfc197296d483680e125f9 (patch)
tree71baa0e0a62f9f6b61450501c5f821f67badf9e4 /crates/test_utils
parent5cb1d41a30d25cbe136402644bf5434dd667f1e5 (diff)
downloadrust-12e3b4c70b5ef23b2fdfc197296d483680e125f9.tar.gz
rust-12e3b4c70b5ef23b2fdfc197296d483680e125f9.zip
reformat the world
Diffstat (limited to 'crates/test_utils')
-rw-r--r--crates/test_utils/src/lib.rs37
-rw-r--r--crates/test_utils/src/marks.rs5
2 files changed, 12 insertions, 30 deletions
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs
index 35a679aea5a..09fc2e65970 100644
--- a/crates/test_utils/src/lib.rs
+++ b/crates/test_utils/src/lib.rs
@@ -85,9 +85,7 @@ pub fn extract_ranges(mut text: &str, tag: &str) -> (Vec<TextRange>, String) {
                     stack.push(from);
                 } else if text.starts_with(&close) {
                     text = &text[close.len()..];
-                    let from = stack
-                        .pop()
-                        .unwrap_or_else(|| panic!("unmatched </{}>", tag));
+                    let from = stack.pop().unwrap_or_else(|| panic!("unmatched </{}>", tag));
                     let to = TextUnit::of_str(&res);
                     ranges.push(TextRange::from_to(from, to));
                 }
@@ -131,10 +129,7 @@ pub fn parse_fixture(fixture: &str) -> Vec<FixtureEntry> {
     macro_rules! flush {
         () => {
             if let Some(meta) = meta {
-                res.push(FixtureEntry {
-                    meta: meta.to_string(),
-                    text: buf.clone(),
-                });
+                res.push(FixtureEntry { meta: meta.to_string(), text: buf.clone() });
                 buf.clear();
             }
         };
@@ -226,15 +221,13 @@ pub fn find_mismatch<'a>(expected: &'a Value, actual: &'a Value) -> Option<(&'a
             let mut l = l.iter().collect::<Vec<_>>();
             let mut r = r.iter().collect::<Vec<_>>();
 
-            l.retain(
-                |l| match r.iter().position(|r| find_mismatch(l, r).is_none()) {
-                    Some(i) => {
-                        r.remove(i);
-                        false
-                    }
-                    None => true,
-                },
-            );
+            l.retain(|l| match r.iter().position(|r| find_mismatch(l, r).is_none()) {
+                Some(i) => {
+                    r.remove(i);
+                    false
+                }
+                None => true,
+            });
 
             if !l.is_empty() {
                 assert!(!r.is_empty());
@@ -250,10 +243,7 @@ pub fn find_mismatch<'a>(expected: &'a Value, actual: &'a Value) -> Option<(&'a
                 return Some((expected, actual));
             }
 
-            l.values()
-                .zip(r.values())
-                .filter_map(|(l, r)| find_mismatch(l, r))
-                .nth(0)
+            l.values().zip(r.values()).filter_map(|(l, r)| find_mismatch(l, r)).nth(0)
         }
         (&Null, &Null) => None,
         // magic string literal "{...}" acts as wildcard for any sub-JSON
@@ -312,12 +302,7 @@ fn test_from_dir(dir: &Path) -> Vec<PathBuf> {
 
 pub fn project_dir() -> PathBuf {
     let dir = env!("CARGO_MANIFEST_DIR");
-    PathBuf::from(dir)
-        .parent()
-        .unwrap()
-        .parent()
-        .unwrap()
-        .to_owned()
+    PathBuf::from(dir).parent().unwrap().parent().unwrap().to_owned()
 }
 
 /// Read file and normalize newlines.
diff --git a/crates/test_utils/src/marks.rs b/crates/test_utils/src/marks.rs
index ee47b521981..d2a84643c8a 100644
--- a/crates/test_utils/src/marks.rs
+++ b/crates/test_utils/src/marks.rs
@@ -64,10 +64,7 @@ pub struct MarkChecker {
 impl MarkChecker {
     pub fn new(mark: &'static AtomicUsize) -> MarkChecker {
         let value_on_entry = mark.load(Ordering::SeqCst);
-        MarkChecker {
-            mark,
-            value_on_entry,
-        }
+        MarkChecker { mark, value_on_entry }
     }
 }