diff options
author | vallentin <mail@vallentin.dev> | 2021-02-22 02:56:37 +0100 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2021-02-22 13:05:44 +0100 |
commit | 7609f00c4b70fa78d2d3e532e786989e719abc18 (patch) | |
tree | 340402e1ca6cf87c2d36f06aae93249d4f4d4b4b /testing/tests | |
parent | e021e027ba1f1f5220a4b4a4140277f82152777a (diff) | |
download | askama-7609f00c4b70fa78d2d3e532e786989e719abc18.tar.gz askama-7609f00c4b70fa78d2d3e532e786989e719abc18.tar.bz2 askama-7609f00c4b70fa78d2d3e532e786989e719abc18.zip |
Added range test case
Diffstat (limited to 'testing/tests')
-rw-r--r-- | testing/tests/loops.rs | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/testing/tests/loops.rs b/testing/tests/loops.rs index 809f75e..b324ae3 100644 --- a/testing/tests/loops.rs +++ b/testing/tests/loops.rs @@ -70,11 +70,11 @@ fn test_for_range() { #[derive(Template)] #[template(source = "{% for i in [1, 2, 3] %}{{ i }}{% endfor %}", ext = "txt")] -struct ForArrayTemplate {} +struct ForArrayTemplate; #[test] fn test_for_array() { - let t = ForArrayTemplate {}; + let t = ForArrayTemplate; assert_eq!(t.render().unwrap(), "123"); } @@ -83,11 +83,11 @@ fn test_for_array() { source = "{% for i in [1, 2, 3].iter() %}{{ i }}{% endfor %}", ext = "txt" )] -struct ForMethodCallTemplate {} +struct ForMethodCallTemplate; #[test] fn test_for_method_call() { - let t = ForMethodCallTemplate {}; + let t = ForMethodCallTemplate; assert_eq!(t.render().unwrap(), "123"); } @@ -108,10 +108,26 @@ fn test_for_path_call() { source = "{% for i in [1, 2, 3, 4, 5][3..] %}{{ i }}{% endfor %}", ext = "txt" )] -struct ForIndexTemplate {} +struct ForIndexTemplate; #[test] fn test_for_index() { - let t = ForIndexTemplate {}; + let t = ForIndexTemplate; assert_eq!(t.render().unwrap(), "45"); } + +#[derive(Template)] +#[template( + source = "{% for (i, j) in (0..10).zip(10..20).zip(30..40) %}{{ i.0 }} {{ i.1 }} {{ j }} {% endfor %}", + ext = "txt" +)] +struct ForZipRangesTemplate; + +#[test] +fn test_for_zip_ranges() { + let t = ForZipRangesTemplate; + assert_eq!( + t.render().unwrap(), + "0 10 30 1 11 31 2 12 32 3 13 33 4 14 34 5 15 35 6 16 36 7 17 37 8 18 38 9 19 39 " + ); +} |