test
This commit is contained in:
parent
be501f540e
commit
9ed860383e
@ -3,10 +3,24 @@ mod sexp;
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parsing() {
|
fn basic_parsing() {
|
||||||
let (parsed, rest) = literal("a").parse("a yolo").unwrap();
|
let (parsed, rest) = literal("a").parse("a yolo").unwrap();
|
||||||
assert_eq!(parsed, "a");
|
assert_eq!(parsed, "a");
|
||||||
assert_eq!(rest, " yolo");
|
assert_eq!(rest, " yolo");
|
||||||
|
|
||||||
|
fn bare_function_parser(input: &str) -> ParseResult<&str, i32, String> {
|
||||||
|
match input.chars().next() {
|
||||||
|
Some('0') => Ok((0, &input[1..])),
|
||||||
|
Some('1') => Ok((1, &input[1..])),
|
||||||
|
_ => Err(("lol a parse error".to_string(), input)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_eq!(bare_function_parser.parse("0foo"), Ok((0, "foo")));
|
||||||
|
assert_eq!(
|
||||||
|
bare_function_parser.parse("xfoo"),
|
||||||
|
Err(("lol a parse error".to_string(), "xfoo"))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user