From 756fdb7d00f14bd475fda1425607c3b2052323d9 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 17 May 2020 00:40:55 -0400 Subject: [PATCH] Tests are once again passing. --- src/bin.rs | 22 ++++++++++++++++------ src/renderer/errors.rs | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) 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),