aboutsummaryrefslogtreecommitdiffstats
path: root/askama_derive/src/parser/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'askama_derive/src/parser/tests.rs')
-rw-r--r--askama_derive/src/parser/tests.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/askama_derive/src/parser/tests.rs b/askama_derive/src/parser/tests.rs
index 91bb09b..801e787 100644
--- a/askama_derive/src/parser/tests.rs
+++ b/askama_derive/src/parser/tests.rs
@@ -222,6 +222,51 @@ fn test_parse_root_path() {
}
#[test]
+fn test_rust_macro() {
+ let syntax = Syntax::default();
+ assert_eq!(
+ super::parse("{{ vec!(1, 2, 3) }}", &syntax).unwrap(),
+ vec![Node::Expr(
+ Ws(None, None),
+ Expr::RustMacro(vec!["vec"], "1, 2, 3",),
+ )],
+ );
+ assert_eq!(
+ super::parse("{{ alloc::vec!(1, 2, 3) }}", &syntax).unwrap(),
+ vec![Node::Expr(
+ Ws(None, None),
+ Expr::RustMacro(vec!["alloc", "vec"], "1, 2, 3",),
+ )],
+ );
+ assert_eq!(
+ super::parse("{{a!()}}", &syntax).unwrap(),
+ [Node::Expr(Ws(None, None), Expr::RustMacro(vec!["a"], ""))],
+ );
+ assert_eq!(
+ super::parse("{{a !()}}", &syntax).unwrap(),
+ [Node::Expr(Ws(None, None), Expr::RustMacro(vec!["a"], ""))],
+ );
+ assert_eq!(
+ super::parse("{{a! ()}}", &syntax).unwrap(),
+ [Node::Expr(Ws(None, None), Expr::RustMacro(vec!["a"], ""))],
+ );
+ assert_eq!(
+ super::parse("{{a ! ()}}", &syntax).unwrap(),
+ [Node::Expr(Ws(None, None), Expr::RustMacro(vec!["a"], ""))],
+ );
+ assert_eq!(
+ super::parse("{{A!()}}", &syntax).unwrap(),
+ [Node::Expr(Ws(None, None), Expr::RustMacro(vec!["A"], ""),)],
+ );
+ assert_eq!(
+ &*super::parse("{{a.b.c!( hello )}}", &syntax)
+ .unwrap_err()
+ .msg,
+ "problems parsing template source at row 1, column 7 near:\n\"!( hello )}}\"",
+ );
+}
+
+#[test]
fn change_delimiters_parse_filter() {
let syntax = Syntax {
expr_start: "{=",