-
Notifications
You must be signed in to change notification settings - Fork 544
Expand file tree
/
Copy pathrun_tests.rs
More file actions
47 lines (41 loc) · 1.6 KB
/
Copy pathrun_tests.rs
File metadata and controls
47 lines (41 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use harper_core::linting::{LintGroup, Linter};
use harper_core::spell::FstDictionary;
use harper_core::{Dialect, Document};
use harper_tex::TeX;
/// Creates a unit test checking that the linting of a document in
/// `tests_sources` produces the expected number of lints.
macro_rules! create_test {
($filename:ident.$ext:ident, $correct_expected:expr) => {
paste::paste! {
#[test]
fn [<lints_ $filename _correctly>](){
let source = include_str!(
concat!(
"./test_sources/",
concat!(stringify!($filename), ".", stringify!($ext))
)
);
let dict = FstDictionary::curated();
let document = Document::new(&source, &TeX::default(), &dict);
let mut linter = LintGroup::new_curated(dict, Dialect::American);
let lints = linter.lint(&document);
dbg!(&lints);
assert_eq!(lints.len(), $correct_expected);
// Make sure that all generated tokens span real characters
for token in document.tokens(){
assert!(token.span.try_get_content(document.get_source()).is_some());
}
}
}
};
}
create_test!(clean.tex, 0);
create_test!(simple.tex, 1);
create_test!(heading.tex, 1);
create_test!(title.tex, 1);
create_test!(city.tex, 0);
create_test!(many_tags.tex, 6);
create_test!(many_more_tags.tex, 11);
create_test!(em_dash.tex, 0);
create_test!(issue_2835.tex, 3);
create_test!(issue_3791.tex, 2);