From 2462427431a8ee62b4c5e18e8ca6a5cbe2fad957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20D=C3=ADaz?= Date: Fri, 12 Jan 2024 14:26:02 +0100 Subject: [PATCH] fix: failing radon error tests --- rad/src/error.rs | 6 ++++++ rad/src/operators/array.rs | 21 +++++---------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/rad/src/error.rs b/rad/src/error.rs index 3eeb11c3f..4b2e8344f 100644 --- a/rad/src/error.rs +++ b/rad/src/error.rs @@ -564,6 +564,9 @@ impl RadError { }; Some(serialize_args((message,))?) } + RadError::BufferIsNotValue { description } => { + Some(serialize_args((description,))?) + } _ => None, }; @@ -770,6 +773,9 @@ mod tests { inner: None, message: Some("Only the message field is serialized".to_string()), }, + RadonErrors::BufferIsNotValue => RadError::BufferIsNotValue { + description: "Buffer is no value".to_string(), + }, // If this panics after adding a new `RadonTypes`, add a new example above _ => panic!("No example for {:?}", radon_errors), } diff --git a/rad/src/operators/array.rs b/rad/src/operators/array.rs index 468e0bf07..1f3c809cd 100644 --- a/rad/src/operators/array.rs +++ b/rad/src/operators/array.rs @@ -123,23 +123,9 @@ pub fn join(input: &RadonArray, args: &[Value]) -> Result } else { String::from("") }; - match input.value().first() { + match input.value().first() { Some(RadonTypes::String(_)) => { - let string_list: Vec = input.value().into_iter().map(|item| - RadonString::try_from(item).unwrap_or_default().value() - ).collect(); - Ok(RadonTypes::from(RadonString::from(string_list.join(separator.as_str())))) - } - Some(first_item) => { - Err(RadError::UnsupportedOperator { - input_type: first_item.radon_type_name().to_string(), - operator: "ArrayJoin".to_string(), - args: Some(args.to_vec()) - }) - } - _ => { - Err(RadError::EmptyArray) - } + let string_list: Vec = input .value() .into_iter() .map(|item| RadonString::try_from(item).unwrap_or_default().value()) @@ -147,6 +133,9 @@ pub fn join(input: &RadonArray, args: &[Value]) -> Result Ok(RadonTypes::from(RadonString::from( string_list.join(separator.as_str()), ))) + } + Some(first_item) => Err(RadError::UnsupportedOperator { + input_type: first_item.radon_type_name().to_string(), operator: "ArrayJoin".to_string(), args: Some(args.to_vec()), }),