aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-10-31 20:41:43 +0000
committerAleksey Kladov <[email protected]>2018-10-31 20:41:43 +0000
commit6be50f7d5de3737464853a589673375fc0cafa97 (patch)
tree2c6da7f3a1234c3f2fd3f330d2c9445953979598 /crates/test_utils/src
parent857c1650efdb51650458f9ec1119adaa49b34371 (diff)
Reformat all
Diffstat (limited to 'crates/test_utils/src')
-rw-r--r--crates/test_utils/src/lib.rs31
1 files changed, 17 insertions, 14 deletions
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs
index 8980f077f..d9fbb9b5b 100644
--- a/crates/test_utils/src/lib.rs
+++ b/crates/test_utils/src/lib.rs
@@ -89,7 +89,6 @@ pub fn add_cursor(text: &str, offset: TextUnit) -> String {
89 res 89 res
90} 90}
91 91
92
93#[derive(Debug)] 92#[derive(Debug)]
94pub struct FixtureEntry { 93pub struct FixtureEntry {
95 pub meta: String, 94 pub meta: String,
@@ -112,25 +111,29 @@ pub fn parse_fixture(fixture: &str) -> Vec<FixtureEntry> {
112 macro_rules! flush { 111 macro_rules! flush {
113 () => { 112 () => {
114 if let Some(meta) = meta { 113 if let Some(meta) = meta {
115 res.push(FixtureEntry { meta: meta.to_string(), text: buf.clone() }); 114 res.push(FixtureEntry {
115 meta: meta.to_string(),
116 text: buf.clone(),
117 });
116 buf.clear(); 118 buf.clear();
117 } 119 }
118 }; 120 };
119 }; 121 };
120 let margin = fixture.lines() 122 let margin = fixture
123 .lines()
121 .filter(|it| it.trim_start().starts_with("//-")) 124 .filter(|it| it.trim_start().starts_with("//-"))
122 .map(|it| it.len() - it.trim_start().len()) 125 .map(|it| it.len() - it.trim_start().len())
123 .next().expect("empty fixture"); 126 .next()
124 let lines = fixture.lines() 127 .expect("empty fixture");
125 .filter_map(|line| { 128 let lines = fixture.lines().filter_map(|line| {
126 if line.len() >= margin { 129 if line.len() >= margin {
127 assert!(line[..margin].trim().is_empty()); 130 assert!(line[..margin].trim().is_empty());
128 Some(&line[margin..]) 131 Some(&line[margin..])
129 } else { 132 } else {
130 assert!(line.trim().is_empty()); 133 assert!(line.trim().is_empty());
131 None 134 None
132 } 135 }
133 }); 136 });
134 137
135 for line in lines { 138 for line in lines {
136 if line.starts_with("//-") { 139 if line.starts_with("//-") {