aboutsummaryrefslogtreecommitdiffstats
path: root/testing/tests/ws.rs
diff options
context:
space:
mode:
Diffstat (limited to 'testing/tests/ws.rs')
-rw-r--r--testing/tests/ws.rs214
1 files changed, 214 insertions, 0 deletions
diff --git a/testing/tests/ws.rs b/testing/tests/ws.rs
new file mode 100644
index 0000000..3f62da5
--- /dev/null
+++ b/testing/tests/ws.rs
@@ -0,0 +1,214 @@
+// This file is auto generated by gen_ws_tests.py
+
+use askama::Template;
+
+macro_rules! test_template {
+ ($source:literal, $rendered:expr) => {{
+ #[derive(Template)]
+ #[template(source = $source, ext = "txt")]
+ struct CondWS;
+
+ assert_eq!(CondWS.render().unwrap(), $rendered);
+ }};
+}
+
+#[rustfmt::skip]
+#[test]
+fn test_cond_ws() {
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{% endif %}\n\n\n3\r\n\r\n\r\n", "\n1\r\n\n\n2\r\n\r\n\n\n\n3");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{% endif -%}\n\n\n3\r\n\r\n\r\n", "\n1\r\n\n\n2\r\n\r\n3");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{%- endif %}\n\n\n3\r\n\r\n\r\n", "\n1\r\n\n\n2\n\n\n3");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{%- endif -%}\n\n\n3\r\n\r\n\r\n", "\n1\r\n\n\n23");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{% endif %}\n\n\n3\r\n\r\n\r\n", "\n1\r\n2\r\n\r\n\n\n\n3");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{% endif -%}\n\n\n3\r\n\r\n\r\n", "\n1\r\n2\r\n\r\n3");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{%- endif %}\n\n\n3\r\n\r\n\r\n", "\n1\r\n2\n\n\n3");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{%- endif -%}\n\n\n3\r\n\r\n\r\n", "\n1\r\n23");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{% endif %}\n\n\n3\r\n\r\n\r\n", "\n1\n\n2\r\n\r\n\n\n\n3");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{% endif -%}\n\n\n3\r\n\r\n\r\n", "\n1\n\n2\r\n\r\n3");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{%- endif %}\n\n\n3\r\n\r\n\r\n", "\n1\n\n2\n\n\n3");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{%- endif -%}\n\n\n3\r\n\r\n\r\n", "\n1\n\n23");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{% endif %}\n\n\n3\r\n\r\n\r\n", "\n12\r\n\r\n\n\n\n3");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{% endif -%}\n\n\n3\r\n\r\n\r\n", "\n12\r\n\r\n3");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{%- endif %}\n\n\n3\r\n\r\n\r\n", "\n12\n\n\n3");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{%- endif -%}\n\n\n3\r\n\r\n\r\n", "\n123");
+
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\r\n\r\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\n\n\n\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\r\n\r\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n34");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\r\n\r\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\n\n\n\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\r\n\r\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n34");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\n\n\n\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n24");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\n\n\n\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\n\n\n\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n24");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n34");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\n\n\n\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n24");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n2\n\n\n\n4");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\n\n\n\n4");
+ test_template!("\n1\r\n{% if true %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n24");
+ test_template!("\n1\r\n{% if false %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n34");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\r\n\r\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\n\n\n\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\r\n\r\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n34");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\r\n\r\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\n\n\n\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\r\n\r\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n34");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\n\n\n\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n24");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\n\n\n\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n3\n\n\n\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n24");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n\n\n\n34");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\n\n\n\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n24");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n2\n\n\n\n4");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n3\n\n\n\n4");
+ test_template!("\n1\r\n{% if true -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n24");
+ test_template!("\n1\r\n{% if false -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\r\n34");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\r\n\r\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\r\n\r\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n34");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\r\n\r\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\r\n\r\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n134");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n24");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n24");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n34");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n24");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n2\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n24");
+ test_template!("\n1\r\n{%- if false %}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n134");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\r\n\r\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\r\n\r\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{% else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n34");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\r\n\r\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\r\n\r\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{% else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n134");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n124");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n3\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n124");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{%- else %}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n1\n\n\n34");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\r\n\r\n\r\n\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n124");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{% endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\r\n\r\n\r\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n12\n\n\n\n4");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif %}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n13\n\n\n\n4");
+ test_template!("\n1\r\n{%- if true -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n124");
+ test_template!("\n1\r\n{%- if false -%}\n\n2\r\n\r\n{%- else -%}\n\n\n3\r\n\r\n\r\n{%- endif -%}\n\n\n\n4\r\n\r\n\r\n\r\n", "\n134");
+}
+
+#[rustfmt::skip]
+macro_rules! test_match {
+ ($source:literal, $some_rendered:expr, $none_rendered:expr) => {{
+ #[derive(Template)]
+ #[template(source = $source, ext = "txt")]
+ struct MatchWS {
+ item: Option<&'static str>,
+ }
+
+ assert_eq!(MatchWS { item: Some("foo") }.render().unwrap(), $some_rendered);
+ assert_eq!(MatchWS { item: None }.render().unwrap(), $none_rendered);
+ }};
+}
+
+#[rustfmt::skip]
+#[test]
+fn test_match_ws() {
+ test_match!("before {% match item %}{% when Some with (item) %} foo {% when None %} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) %} foo {% when None %} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) %} foo {% when None -%} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) %} foo {% when None -%} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) %} foo {%- when None %} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) %} foo {%- when None %} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) %} foo {%- when None -%} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) %} foo {%- when None -%} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) -%} foo {% when None %} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) -%} foo {% when None %} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) -%} foo {% when None -%} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) -%} foo {% when None -%} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) -%} foo {%- when None %} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) -%} foo {%- when None %} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) -%} foo {%- when None -%} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{% when Some with (item) -%} foo {%- when None -%} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) %} foo {% when None %} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) %} foo {% when None %} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) %} foo {% when None -%} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) %} foo {% when None -%} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) %} foo {%- when None %} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) %} foo {%- when None %} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) %} foo {%- when None -%} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) %} foo {%- when None -%} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) -%} foo {% when None %} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) -%} foo {% when None %} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) -%} foo {% when None -%} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) -%} foo {% when None -%} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) -%} foo {%- when None %} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) -%} foo {%- when None %} bar {%- endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) -%} foo {%- when None -%} bar {% endmatch %} after", "before foo after", "before bar after");
+ test_match!("before {% match item %}{%- when Some with (item) -%} foo {%- when None -%} bar {%- endmatch %} after", "before foo after", "before bar after");
+}