aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared
diff options
context:
space:
mode:
authorLibravatar vallentin <mail@vallentin.dev>2020-12-18 12:59:31 +0100
committerLibravatar Christian Vallentin <vallentinsource@gmail.com>2020-12-18 15:05:26 +0100
commitb7483faa3e956a8f2955a2542536c8b676d74ec1 (patch)
tree30a19495bbe3d482385ed6799efddc7eba826d16 /askama_shared
parent677c03b133515e0c252c75513e550c2c7836e90c (diff)
downloadaskama-b7483faa3e956a8f2955a2542536c8b676d74ec1.tar.gz
askama-b7483faa3e956a8f2955a2542536c8b676d74ec1.tar.bz2
askama-b7483faa3e956a8f2955a2542536c8b676d74ec1.zip
Added comment parser tests
Diffstat (limited to 'askama_shared')
-rw-r--r--askama_shared/src/parser.rs17
1 files changed, 17 insertions, 0 deletions
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<nom::error::Error<&'a [u8]>>>;