From b7483faa3e956a8f2955a2542536c8b676d74ec1 Mon Sep 17 00:00:00 2001 From: vallentin Date: Fri, 18 Dec 2020 12:59:31 +0100 Subject: Added comment parser tests --- askama_shared/src/parser.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'askama_shared/src/parser.rs') diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs index ba5ea0c..275c92b 100644 --- a/askama_shared/src/parser.rs +++ b/askama_shared/src/parser.rs @@ -1329,6 +1329,23 @@ mod tests { )], ); } + + #[test] + fn test_parse_comments() { + let s = &Syntax::default(); + assert_eq!( + super::parse("{#- foo\n bar -#}", s).unwrap(), + vec![Node::Comment(WS(true, true))], + ); + assert_eq!( + super::parse("{#- foo\n {#- bar\n -#} baz -#}", s).unwrap(), + vec![Node::Comment(WS(true, true))], + ); + assert_eq!( + super::parse("{# foo {# bar #} {# {# baz #} qux #} #}", s).unwrap(), + vec![Node::Comment(WS(false, false))], + ); + } } type ParserError<'a, T> = Result<(&'a [u8], T), nom::Err>>; -- cgit