summaryrefslogtreecommitdiffstats
path: root/vendor/handlebars/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/handlebars/tests
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/handlebars/tests')
-rw-r--r--vendor/handlebars/tests/escape.rs25
-rw-r--r--vendor/handlebars/tests/helper_macro.rs20
2 files changed, 45 insertions, 0 deletions
diff --git a/vendor/handlebars/tests/escape.rs b/vendor/handlebars/tests/escape.rs
index 4a737f5ce..2b9512290 100644
--- a/vendor/handlebars/tests/escape.rs
+++ b/vendor/handlebars/tests/escape.rs
@@ -27,19 +27,44 @@ fn test_string_no_escape_422() {
handlebars_helper!(replace: |input: str, from: str, to: str| {
input.replace(from, to)
});
+ handlebars_helper!(echo: |input: str| {
+ input
+ });
hbs.register_helper("replace", Box::new(replace));
+ hbs.register_helper("echo", Box::new(echo));
assert_eq!(
r#"some\ path"#,
hbs.render_template(r#"{{replace "some/path" "/" "\\ " }}"#, &())
.unwrap()
);
+ assert_eq!(
+ r#"some\ path"#,
+ hbs.render_template(r#"{{replace 'some/path' '/' '\\ ' }}"#, &())
+ .unwrap()
+ );
assert_eq!(
r#"some\path"#,
hbs.render_template(r#"{{replace "some/path" "/" "\\" }}"#, &())
.unwrap()
);
+ assert_eq!(
+ r#"some\path"#,
+ hbs.render_template(r#"{{replace 'some/path' '/' '\\' }}"#, &())
+ .unwrap()
+ );
+
+ assert_eq!(
+ r#"double-quoted \ &#x27;with&#x27; &quot;nesting&quot;"#,
+ hbs.render_template(r#"{{echo "double-quoted \\ 'with' \"nesting\""}}"#, &())
+ .unwrap()
+ );
+ assert_eq!(
+ r#"single-quoted \ &#x27;with&#x27; &quot;nesting&quot;"#,
+ hbs.render_template(r#"{{echo 'single-quoted \\ \'with\' "nesting"'}}"#, &())
+ .unwrap()
+ );
}
#[test]
diff --git a/vendor/handlebars/tests/helper_macro.rs b/vendor/handlebars/tests/helper_macro.rs
index cc5ed914b..f40ab778a 100644
--- a/vendor/handlebars/tests/helper_macro.rs
+++ b/vendor/handlebars/tests/helper_macro.rs
@@ -86,4 +86,24 @@ fn test_macro_helper() {
.unwrap(),
"2015-02-18"
);
+
+ assert_eq!(
+ hbs.render_template("{{eq image.link null}}", &json!({"image": {"link": null}}))
+ .unwrap(),
+ "true"
+ );
+
+ assert_eq!(
+ hbs.render_template(
+ "{{eq image.link null}}",
+ &json!({"image": {"link": "https://url"}})
+ )
+ .unwrap(),
+ "false"
+ );
+
+ assert_eq!(
+ hbs.render_template("{{tag 'html'}}", &()).unwrap(),
+ "&lt;html&gt;"
+ );
}