aboutsummaryrefslogtreecommitdiff
path: root/crates/test_utils
diff options
context:
space:
mode:
Diffstat (limited to 'crates/test_utils')
-rw-r--r--crates/test_utils/src/lib.rs22
1 files changed, 13 insertions, 9 deletions
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs
index ea99ac062..816d01f09 100644
--- a/crates/test_utils/src/lib.rs
+++ b/crates/test_utils/src/lib.rs
@@ -134,21 +134,25 @@ pub fn parse_fixture(fixture: &str) -> Vec<FixtureEntry> {
134 } 134 }
135 }; 135 };
136 }; 136 };
137
137 let margin = fixture 138 let margin = fixture
138 .lines() 139 .lines()
139 .filter(|it| it.trim_start().starts_with("//-")) 140 .filter(|it| it.trim_start().starts_with("//-"))
140 .map(|it| it.len() - it.trim_start().len()) 141 .map(|it| it.len() - it.trim_start().len())
141 .next() 142 .next()
142 .expect("empty fixture"); 143 .expect("empty fixture");
143 let lines = fixture.lines().filter_map(|line| { 144
144 if line.len() >= margin { 145 let lines = fixture
145 assert!(line[..margin].trim().is_empty()); 146 .split('\n') // don't use `.lines` to not drop `\r\n`
146 Some(&line[margin..]) 147 .filter_map(|line| {
147 } else { 148 if line.len() >= margin {
148 assert!(line.trim().is_empty()); 149 assert!(line[..margin].trim().is_empty());
149 None 150 Some(&line[margin..])
150 } 151 } else {
151 }); 152 assert!(line.trim().is_empty());
153 None
154 }
155 });
152 156
153 for line in lines { 157 for line in lines {
154 if line.starts_with("//-") { 158 if line.starts_with("//-") {