Skip to content

Commit

Permalink
fix: failing radon error tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guidiaz committed Jan 12, 2024
1 parent d03ce84 commit 2462427
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
6 changes: 6 additions & 0 deletions rad/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,9 @@ impl RadError {
};
Some(serialize_args((message,))?)
}
RadError::BufferIsNotValue { description } => {
Some(serialize_args((description,))?)
}
_ => None,
};

Expand Down Expand Up @@ -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),
}
Expand Down
21 changes: 5 additions & 16 deletions rad/src/operators/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,30 +123,19 @@ pub fn join(input: &RadonArray, args: &[Value]) -> Result<RadonTypes, RadError>
} else {
String::from("")
};
match input.value().first() {
match input.value().first() {
Some(RadonTypes::String(_)) => {
let string_list: Vec<String> = 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<String> = 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()),
}),
Expand Down

0 comments on commit 2462427

Please sign in to comment.