Add a check to the equality helper to mark identical paths as equal.
This commit is contained in:
parent
d751df6fd5
commit
41e4874d75
@ -38,7 +38,7 @@ while read -r test_group; do
|
|||||||
else
|
else
|
||||||
echo "$test_group_name::$test_case_name FAILED"
|
echo "$test_group_name::$test_case_name FAILED"
|
||||||
if [ $show_diff -eq 1 ]; then
|
if [ $show_diff -eq 1 ]; then
|
||||||
diff --label "dustjs-linked" --label "duster" <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust' | sort) node "$DIR/dustjs_shim.js" < "$test_case" 2>/dev/null ) <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust' | sort) "$DIR/../target/debug/duster-cli" < "$test_case" 2>/dev/null )
|
diff --label "dustjs-linkedin" --label "duster" <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust' | sort) node "$DIR/dustjs_shim.js" < "$test_case" 2>/dev/null ) <(xargs -a <(find "$test_group" -maxdepth 1 -mindepth 1 -type f -name 'main.dust'; find "$test_group" -maxdepth 1 -mindepth 1 -type f -name '*.dust' ! -name 'main.dust' | sort) "$DIR/../target/debug/duster-cli" < "$test_case" 2>/dev/null )
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -230,6 +230,20 @@ impl<'a> DustRenderer<'a> {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|pair: &KVPair<'a>| (pair.key, &pair.value))
|
.map(|pair: &KVPair<'a>| (pair.key, &pair.value))
|
||||||
.collect();
|
.collect();
|
||||||
|
// Special case: when comparing two RVPaths, if the
|
||||||
|
// path is equal then dust assumes the values are
|
||||||
|
// equal (otherwise, non-scalar values are
|
||||||
|
// automatically not equal)
|
||||||
|
if Self::are_paths_identical(¶m_map) {
|
||||||
|
return match ¶meterized_block.contents {
|
||||||
|
None => Ok("".to_owned()),
|
||||||
|
Some(body) => {
|
||||||
|
let rendered_content = self.render_body(body, breadcrumbs, blocks)?;
|
||||||
|
Ok(rendered_content)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let left_side: Result<&dyn ContextElement, WalkError> = match param_map.get("key") {
|
let left_side: Result<&dyn ContextElement, WalkError> = match param_map.get("key") {
|
||||||
None => return Ok("".to_owned()),
|
None => return Ok("".to_owned()),
|
||||||
Some(rval) => match rval {
|
Some(rval) => match rval {
|
||||||
@ -324,6 +338,19 @@ impl<'a> DustRenderer<'a> {
|
|||||||
Ok(walk_target) => walk_target.get_loop_elements(),
|
Ok(walk_target) => walk_target.get_loop_elements(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn are_paths_identical<'b>(param_map: &HashMap<&str, &RValue<'b>>) -> bool {
|
||||||
|
match (param_map.get("key"), param_map.get("value")) {
|
||||||
|
(None, _) => false,
|
||||||
|
(_, None) => false,
|
||||||
|
(Some(key_rval), Some(value_rval)) => match (key_rval, value_rval) {
|
||||||
|
(RValue::RVPath(key_path), RValue::RVPath(value_path)) => {
|
||||||
|
key_path.keys == value_path.keys
|
||||||
|
}
|
||||||
|
_ => false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user