aboutsummaryrefslogtreecommitdiffstats
path: root/testing
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--testing/tests/matches.rs25
-rw-r--r--testing/tests/ui/match_with_extra.rs20
-rw-r--r--testing/tests/ui/match_with_extra.stderr8
3 files changed, 53 insertions, 0 deletions
diff --git a/testing/tests/matches.rs b/testing/tests/matches.rs
index 206cd1d..35c1204 100644
--- a/testing/tests/matches.rs
+++ b/testing/tests/matches.rs
@@ -172,3 +172,28 @@ fn test_match_option_result_option() {
};
assert_eq!(s.render().unwrap(), "num=4711");
}
+
+#[derive(Template)]
+#[template(
+ ext = "txt",
+ source = r#"
+{%- match good -%}
+ {#- when good, then good -#}
+ {%- when true -%}
+ good
+ {%- when _ -%}
+ bad
+{%- endmatch -%}"#
+)]
+struct MatchWithComment {
+ good: bool,
+}
+
+#[test]
+fn test_match_with_comment() {
+ let s = MatchWithComment { good: true };
+ assert_eq!(s.render().unwrap(), "good");
+
+ let s = MatchWithComment { good: false };
+ assert_eq!(s.render().unwrap(), "bad");
+}
diff --git a/testing/tests/ui/match_with_extra.rs b/testing/tests/ui/match_with_extra.rs
new file mode 100644
index 0000000..528441e
--- /dev/null
+++ b/testing/tests/ui/match_with_extra.rs
@@ -0,0 +1,20 @@
+use askama::Template;
+
+#[derive(Template)]
+#[template(
+ ext = "txt",
+ source = r#"
+{%- match good -%}
+ // Help, I forgot how to write comments!
+ {%- when true %}
+ good
+ {%- when _ -%}
+ bad
+{%- endmatch -%}"#
+)]
+struct MatchWithExtra {
+ good: bool,
+}
+
+fn main() {
+}
diff --git a/testing/tests/ui/match_with_extra.stderr b/testing/tests/ui/match_with_extra.stderr
new file mode 100644
index 0000000..8f515bd
--- /dev/null
+++ b/testing/tests/ui/match_with_extra.stderr
@@ -0,0 +1,8 @@
+error: problems parsing template source at row 3, column 4 near:
+ "// Help, I forgot how to write comments!"...
+ --> tests/ui/match_with_extra.rs:3:10
+ |
+3 | #[derive(Template)]
+ | ^^^^^^^^
+ |
+ = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info)