From 1119be008a540e0759b6de95f4a1720855a809d4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 21 Apr 2022 18:06:15 +0200 Subject: Add tests for Whitespace::Minize parsing --- askama_shared/src/parser.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs index 3725681..624fbc6 100644 --- a/askama_shared/src/parser.rs +++ b/askama_shared/src/parser.rs @@ -1725,6 +1725,35 @@ mod tests { Some(Whitespace::Preserve) ))], ); + assert_eq!( + super::parse("{#~ #}", s).unwrap(), + vec![Node::Comment(Ws(Some(Whitespace::Minimize), None))], + ); + assert_eq!( + super::parse("{# ~#}", s).unwrap(), + vec![Node::Comment(Ws(None, Some(Whitespace::Minimize)))], + ); + assert_eq!( + super::parse("{#~~#}", s).unwrap(), + vec![Node::Comment(Ws( + Some(Whitespace::Minimize), + Some(Whitespace::Minimize) + ))], + ); + assert_eq!( + super::parse("{#~ foo\n bar ~#}", s).unwrap(), + vec![Node::Comment(Ws( + Some(Whitespace::Minimize), + Some(Whitespace::Minimize) + ))], + ); + assert_eq!( + super::parse("{#~ foo\n {#~ bar\n ~#} baz -~#}", s).unwrap(), + vec![Node::Comment(Ws( + Some(Whitespace::Minimize), + Some(Whitespace::Minimize) + ))], + ); assert_eq!( super::parse("{# foo {# bar #} {# {# baz #} qux #} #}", s).unwrap(), -- cgit