-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for (ignored) comment lines in source documents
- Loading branch information
Showing
3 changed files
with
65 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
extern crate fastobo_syntax; | ||
use fastobo_syntax::OboParser; | ||
use fastobo_syntax::Rule; | ||
|
||
macro_rules! test_parse { | ||
($rule:ident, $input:literal) => ({ | ||
match OboParser::parse(Rule::$rule, $input) { | ||
Ok(mut pairs) => assert_eq!(pairs.next().unwrap().as_str(), $input), | ||
Err(e) => panic!("could not parse {:?}:\n{}", $input, e), | ||
} | ||
}) | ||
} | ||
|
||
#[test] | ||
fn term_frame() { | ||
test_parse!(EntityFrame, "[Term]\nid: TST:001\n"); | ||
test_parse!(EntityFrame, "! irrelevant\n[Term]\nid: TST:001\n"); | ||
test_parse!(EntityFrame, "[Term]\n! irrelevant\nid: TST:001\n"); | ||
test_parse!(EntityFrame, "[Term]\nid: TST:001\n! irrelevant\n"); | ||
} | ||
|
||
#[test] | ||
fn header_frame() { | ||
test_parse!(HeaderFrame, "format-version: 1,4\n! this is a comment\n"); | ||
test_parse!(HeaderFrame, "! this is a comment\nformat-version: 1,4\n"); | ||
test_parse!(OboDoc, "format-version: 1,4\n! this is a comment\n"); | ||
test_parse!(OboDoc, "! this is a comment\nformat-version: 1,4\n"); | ||
} | ||
|
||
#[test] | ||
fn typedef_frame() { | ||
test_parse!(EntityFrame, "[Typedef]\nid: TST:001\n"); | ||
test_parse!(EntityFrame, "! irrelevant\n[Typedef]\nid: TST:001\n"); | ||
test_parse!(EntityFrame, "[Typedef]\n! irrelevant\nid: TST:001\n"); | ||
test_parse!(EntityFrame, "[Typedef]\nid: TST:001\n! irrelevant\n"); | ||
} | ||
|
||
#[test] | ||
fn instance_frame() { | ||
test_parse!(EntityFrame, "[Instance]\nid: TST:001\n"); | ||
test_parse!(EntityFrame, "! irrelevant\n[Term]\nid: TST:001\n"); | ||
test_parse!(EntityFrame, "[Instance]\n! irrelevant\nid: TST:001\n"); | ||
test_parse!(EntityFrame, "[Instance]\nid: TST:001\n! irrelevant\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters