Tests are once again passing.

This commit is contained in:
Tom Alexander 2020-05-17 00:40:55 -04:00
parent 830bb06a92
commit 756fdb7d00
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 17 additions and 6 deletions

View File

@ -208,8 +208,16 @@ impl CompareContextElement for serde_json::Value {
( (
serde_json::Value::Array(self_array), serde_json::Value::Array(self_array),
serde_json::Value::Array(other_array), serde_json::Value::Array(other_array),
) => convert_vec_to_context_element(self_array) ) => {
.partial_cmp(&convert_vec_to_context_element(other_array)), return self
.render(&Vec::new())
.unwrap_or("".to_owned())
.partial_cmp(
&other_json_value
.render(&Vec::new())
.unwrap_or("".to_owned()),
)
}
_ => None, _ => None,
}; };
} }
@ -371,10 +379,12 @@ mod tests {
use super::*; use super::*;
#[test] #[test]
fn test_type_coercion_object_int() { fn test_nested_array_render() {
let x: serde_json::Value = let x: serde_json::Value =
serde_json::from_str(r#"{"name": "cat"}"#).expect("Failed to parse json"); serde_json::from_str(r#"[3,5,[7,9]]"#).expect("Failed to parse json");
let y: u64 = 7; assert_eq!(
// assert_eq!(x.partial_compare(&y), Some(Ordering::Greater)); x.render(&Vec::new()),
Ok::<_, RenderError>("3,5,7,9".to_owned())
);
} }
} }

View File

@ -4,6 +4,7 @@ use std::fmt;
/// Fatal errors while rendering. /// Fatal errors while rendering.
/// ///
/// A RenderError will halt rendering. /// A RenderError will halt rendering.
#[derive(PartialEq)]
pub enum RenderError { pub enum RenderError {
Generic(String), Generic(String),
TemplateNotFound(String), TemplateNotFound(String),