diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-12-08 11:15:04 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-12-08 11:36:18 +0100 |
| commit | 64f938b449b7ff5e53b6a06ed943bf9dedc1014b (patch) | |
| tree | c8237458ea10c21e9b3ce9fc2c02bdd7df9a1fca /tests/parse.rs | |
| parent | f364395e1d774456500ea61bb7b931f48a62ddfa (diff) | |
Improve testers ♻
Diffstat (limited to 'tests/parse.rs')
| -rw-r--r-- | tests/parse.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/parse.rs b/tests/parse.rs index a56059d7..953cc959 100644 --- a/tests/parse.rs +++ b/tests/parse.rs @@ -1,10 +1,10 @@ use typstc::syntax::*; - use Token::{ Space as S, Newline as N, LeftBracket as LB, RightBracket as RB, Text as T, * }; +/// Parses the test syntax. macro_rules! tokens { ($($src:expr =>($line:expr)=> $tokens:expr)*) => ({ #[allow(unused_mut)] @@ -15,18 +15,25 @@ macro_rules! tokens { } fn main() { - let tests = include!("cache/parsing.rs"); - + let tests = include!("cache/parse"); let mut errors = false; + + let len = tests.len(); + println!(); + println!("Running {} test{}", len, if len > 1 { "s" } else { "" }); + + // Go through all test files. for (file, cases) in tests.into_iter() { print!("Testing: {}. ", file); let mut okay = 0; let mut failed = 0; + // Go through all tests in a test file. for (line, src, expected) in cases.into_iter() { let found: Vec<_> = tokenize(src).map(Spanned::value).collect(); + // Check whether the tokenization works correctly. if found == expected { okay += 1; } else { @@ -44,6 +51,7 @@ fn main() { } } + // Print a small summary. print!("{} okay, {} failed.", okay, failed); if failed == 0 { print!(" ✔") |
