Change parser tests dir to inline/ok and inline/err

This commit is contained in:
DJMcNab 2018-12-20 15:09:22 +00:00
parent e2a7e94518
commit 63ca8bc91a
3 changed files with 57 additions and 34 deletions

View file

@ -21,6 +21,7 @@ const TOOLCHAIN: &str = "1.31.0";
pub struct Test {
pub name: String,
pub text: String,
pub ok: bool,
}
pub fn collect_tests(s: &str) -> Vec<(usize, Test)> {
@ -38,11 +39,16 @@ pub fn collect_tests(s: &str) -> Vec<(usize, Test)> {
}
let mut block = block.map(|(idx, line)| (idx, &line[prefix.len()..]));
let mut ok = true;
let (start_line, name) = loop {
match block.next() {
Some((idx, line)) if line.starts_with("test ") => {
break (idx, line["test ".len()..].to_string());
}
Some((idx, line)) if line.starts_with("test_fail ") => {
ok = false;
break (idx, line["test_fail ".len()..].to_string());
}
Some(_) => (),
None => continue 'outer,
}
@ -52,7 +58,7 @@ pub fn collect_tests(s: &str) -> Vec<(usize, Test)> {
"\n",
);
assert!(!text.trim().is_empty() && text.ends_with('\n'));
res.push((start_line, Test { name, text }))
res.push((start_line, Test { name, text, ok }))
}
res
}