aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar René Kijewski <kijewski@library.vetmed.fu-berlin.de>2021-07-30 17:36:29 +0200
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2021-07-30 21:57:00 +0200
commit6d1cf5e43dbf5d26506585db1f801064051f49a4 (patch)
treebde45915de8dd5b08ade77205a12b6dd9388dce6
parent4123ec37a2a58248433b03765ebfb2d55155a2ae (diff)
downloadaskama-6d1cf5e43dbf5d26506585db1f801064051f49a4.tar.gz
askama-6d1cf5e43dbf5d26506585db1f801064051f49a4.tar.bz2
askama-6d1cf5e43dbf5d26506585db1f801064051f49a4.zip
Issue #379 was fixed
This PR adds the tests by @msrd0 <git@msrd0.de> that failed before. The error was fixed somewhen between f23162a and now, so these tests serve to prevent regressions in the future. I simplified the tests very slightly to omit whitespaces in the output.
-rw-r--r--testing/templates/macro-import-str-cmp-macro.html13
-rw-r--r--testing/templates/macro-import-str-cmp.html15
-rw-r--r--testing/tests/macro.rs10
3 files changed, 38 insertions, 0 deletions
diff --git a/testing/templates/macro-import-str-cmp-macro.html b/testing/templates/macro-import-str-cmp-macro.html
new file mode 100644
index 0000000..a951f93
--- /dev/null
+++ b/testing/templates/macro-import-str-cmp-macro.html
@@ -0,0 +1,13 @@
+{% macro strcmp0(s, other) -%}
+ {%- if s == "foo" -%}
+ foo
+ {%- else if s == other -%}
+ other
+ {%- else -%}
+ neither
+ {%- endif -%}
+{% endmacro %}
+
+{% macro strcmp(s) %}
+ {%- call strcmp0(s, "bar") -%}
+{% endmacro %}
diff --git a/testing/templates/macro-import-str-cmp.html b/testing/templates/macro-import-str-cmp.html
new file mode 100644
index 0000000..648a0cf
--- /dev/null
+++ b/testing/templates/macro-import-str-cmp.html
@@ -0,0 +1,15 @@
+{%- import "macro-import-str-cmp-macro.html" as macros -%}
+
+A
+
+{%- call macros::strcmp("foo") -%}
+
+B
+
+{%- call macros::strcmp("bar") -%}
+
+C
+
+{%- call macros::strcmp("cat") -%}
+
+D
diff --git a/testing/tests/macro.rs b/testing/tests/macro.rs
index 7f7e4dc..e449dd5 100644
--- a/testing/tests/macro.rs
+++ b/testing/tests/macro.rs
@@ -63,3 +63,13 @@ fn test_nested_macro_with_args() {
let t = NestedMacroArgsTemplate {};
assert_eq!(t.render().unwrap(), "first second");
}
+
+#[derive(Template)]
+#[template(path = "macro-import-str-cmp.html")]
+struct StrCmpTemplate;
+
+#[test]
+fn str_cmp() {
+ let t = StrCmpTemplate;
+ assert_eq!(t.render().unwrap(), "AfooBotherCneitherD");
+}