Add a test case for type casting to the equality helper tests.

Tom Alexander 4 years ago
parent 4731ddaa6b
commit 5dff03bb37
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

@ -30,4 +30,11 @@ Do objects with different paths referencing the same variable match?{~n}
Floating point equality{~n}
{@eq key=int value=7.0}int is equal to 7.0{:else}int is not equal to 7.0{/eq}
{@eq key=int value=7.0}int is equal to 7.0{~n}{:else}int is not equal to 7.0{~n}{/eq}
Type cast{~n}
{@eq key=int value="7"}int is equal to "7"{~n}{:else}int is not equal to "7"{~n}{/eq}
{@eq key=int value="7" type="number"}int is equal to "7"::number{~n}{:else}int is not equal to "7"::number{~n}{/eq}
{@eq key=beta value=21 type="string"}beta is equal to 21::string{~n}{:else}beta is not equal to 21::string{~n}{/eq}
{@eq key=beta value="21" type="string"}beta is equal to "21"::string{~n}{:else}beta is not equal to "21"::string{~n}{/eq}

@ -1012,6 +1012,7 @@ impl<'a> DustRenderer<'a> {
let left_side = self.tap(breadcrumbs, &param_map, "key");
let right_side = self.tap(breadcrumbs, &param_map, "value");
let type_cast = self.tap(breadcrumbs, &param_map, "type");
let left_side_ce = left_side.as_ref().map(|maybe_ice| {
@ -1023,6 +1024,15 @@ impl<'a> DustRenderer<'a> {
.map(|ice| ice.get_context_element_reference())
let type_rendered = match type_cast.as_ref().map(|maybe_ice| {
.map(|ice| ice.get_context_element_reference())
.map(|ce| ce.render(&Vec::new()))
}) {
Some(Ok(Ok(val))) => Some(val),
_ => None,
if left_side_ce.is_none() {
// If key did not exist at all, return None
return None;