diff --git a/src/bin.rs b/src/bin.rs index 29e72b2..7e0f6ff 100644 --- a/src/bin.rs +++ b/src/bin.rs @@ -208,8 +208,16 @@ impl CompareContextElement for serde_json::Value { ( serde_json::Value::Array(self_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, }; } @@ -371,10 +379,12 @@ mod tests { use super::*; #[test] - fn test_type_coercion_object_int() { + fn test_nested_array_render() { let x: serde_json::Value = - serde_json::from_str(r#"{"name": "cat"}"#).expect("Failed to parse json"); - let y: u64 = 7; - // assert_eq!(x.partial_compare(&y), Some(Ordering::Greater)); + serde_json::from_str(r#"[3,5,[7,9]]"#).expect("Failed to parse json"); + assert_eq!( + x.render(&Vec::new()), + Ok::<_, RenderError>("3,5,7,9".to_owned()) + ); } } diff --git a/src/renderer/errors.rs b/src/renderer/errors.rs index 7dac064..a72ef61 100644 --- a/src/renderer/errors.rs +++ b/src/renderer/errors.rs @@ -4,6 +4,7 @@ use std::fmt; /// Fatal errors while rendering. /// /// A RenderError will halt rendering. +#[derive(PartialEq)] pub enum RenderError { Generic(String), TemplateNotFound(String),