From 696561003d9caaf5d1fd537d6a0f4f88fccca8ce Mon Sep 17 00:00:00 2001 From: PizzasBear <43722034+PizzasBear@users.noreply.github.com> Date: Wed, 22 Nov 2023 17:09:33 +0200 Subject: Add better support for rust-like number literals (#908) Signed-off-by: max --- testing/tests/simple.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'testing/tests') diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index 627a8a3..f0f0a26 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -461,3 +461,26 @@ fn test_define_string_var() { let template = DefineStringVar; assert_eq!(template.render().unwrap(), ""); } + +#[derive(askama::Template)] +#[template(source = "{% let x = 4.5 %}{{ x }}", ext = "html")] +struct SimpleFloat; + +#[test] +fn test_simple_float() { + let template = SimpleFloat; + assert_eq!(template.render().unwrap(), "4.5"); +} + +#[derive(askama::Template)] +#[template(path = "num-literals.html")] +struct NumLiterals; + +#[test] +fn test_num_literals() { + let template = NumLiterals; + assert_eq!( + template.render().unwrap(), + "[90, -90, 90, 2, 56, 240, 10.5, 10.5, 100000000000, 105000000000]", + ); +} -- cgit