From b90dc8cd2dcd259a4d0d8798d276bf28fc90931c Mon Sep 17 00:00:00 2001 From: vallentin Date: Wed, 6 Jan 2021 22:26:09 +0100 Subject: Improved comment parsing test --- askama_shared/src/parser.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/askama_shared/src/parser.rs b/askama_shared/src/parser.rs index 0b42b13..2b8e8f0 100644 --- a/askama_shared/src/parser.rs +++ b/askama_shared/src/parser.rs @@ -1415,6 +1415,24 @@ mod tests { #[test] fn test_parse_comments() { let s = &Syntax::default(); + + assert_eq!( + super::parse("{##}", s).unwrap(), + vec![Node::Comment(WS(false, false))], + ); + assert_eq!( + super::parse("{#- #}", s).unwrap(), + vec![Node::Comment(WS(true, false))], + ); + assert_eq!( + super::parse("{# -#}", s).unwrap(), + vec![Node::Comment(WS(false, true))], + ); + assert_eq!( + super::parse("{#--#}", s).unwrap(), + vec![Node::Comment(WS(true, true))], + ); + assert_eq!( super::parse("{#- foo\n bar -#}", s).unwrap(), vec![Node::Comment(WS(true, true))], -- cgit