Skip to content

Commit

Permalink
Add a simple parsing test for YAML
Browse files Browse the repository at this point in the history
A related test for highlighting YAML currently fails with the
fancy-regex changes, so this simpler test may make it easier to track
down the problem.
  • Loading branch information
robinst committed Jul 27, 2017
1 parent 4ea3415 commit 0448adf
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/parsing/parser.rs
Expand Up @@ -471,6 +471,26 @@ mod tests {
assert_eq!(&ops2[0..test_ops2.len()], &test_ops2[..]);
}

#[test]
fn can_parse_yaml() {
let ps = SyntaxSet::load_from_folder("testdata/Packages").unwrap();
let mut state = {
let syntax = ps.find_syntax_by_name("YAML").unwrap();
ParseState::new(syntax)
};

assert_eq!(ops("key: value\n", &mut state), vec![
(0, Push(Scope::new("source.yaml").unwrap())),
(0, Push(Scope::new("string.unquoted.plain.out.yaml").unwrap())),
(0, Push(Scope::new("entity.name.tag.yaml").unwrap())),
(3, Pop(2)),
(3, Push(Scope::new("punctuation.separator.key-value.mapping.yaml").unwrap())),
(4, Pop(1)),
(5, Push(Scope::new("string.unquoted.plain.out.yaml").unwrap())),
(10, Pop(1)),
]);
}

#[test]
fn can_parse_includes() {
let ps = SyntaxSet::load_from_folder("testdata/Packages").unwrap();
Expand Down

0 comments on commit 0448adf

Please sign in to comment.