diff options
author | Matthew Taylor <wrapperup4@gmail.com> | 2023-07-24 05:39:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-24 11:39:14 +0200 |
commit | ac8de6260e34c7dc7f7f2228e832d1860a31707d (patch) | |
tree | dbdceecef23a2db606c6d5df33deefb783798686 /askama_derive/src/parser/tests.rs | |
parent | 31e9ed52bebb6d026dc3a8ae29c28af4beb7122e (diff) | |
download | askama-ac8de6260e34c7dc7f7f2228e832d1860a31707d.tar.gz askama-ac8de6260e34c7dc7f7f2228e832d1860a31707d.tar.bz2 askama-ac8de6260e34c7dc7f7f2228e832d1860a31707d.zip |
Fix Rust macro invocations not accepting a path (#837)
Diffstat (limited to 'askama_derive/src/parser/tests.rs')
-rw-r--r-- | askama_derive/src/parser/tests.rs | 45 |
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: "{=", |