Skip to content

Commit 2462427

Browse files
committed
fix: failing radon error tests
1 parent d03ce84 commit 2462427

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

rad/src/error.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,9 @@ impl RadError {
564564
};
565565
Some(serialize_args((message,))?)
566566
}
567+
RadError::BufferIsNotValue { description } => {
568+
Some(serialize_args((description,))?)
569+
}
567570
_ => None,
568571
};
569572

@@ -770,6 +773,9 @@ mod tests {
770773
inner: None,
771774
message: Some("Only the message field is serialized".to_string()),
772775
},
776+
RadonErrors::BufferIsNotValue => RadError::BufferIsNotValue {
777+
description: "Buffer is no value".to_string(),
778+
},
773779
// If this panics after adding a new `RadonTypes`, add a new example above
774780
_ => panic!("No example for {:?}", radon_errors),
775781
}

rad/src/operators/array.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,30 +123,19 @@ pub fn join(input: &RadonArray, args: &[Value]) -> Result<RadonTypes, RadError>
123123
} else {
124124
String::from("")
125125
};
126-
match input.value().first() {
126+
match input.value().first() {
127127
Some(RadonTypes::String(_)) => {
128-
let string_list: Vec<String> = input.value().into_iter().map(|item|
129-
RadonString::try_from(item).unwrap_or_default().value()
130-
).collect();
131-
Ok(RadonTypes::from(RadonString::from(string_list.join(separator.as_str()))))
132-
}
133-
Some(first_item) => {
134-
Err(RadError::UnsupportedOperator {
135-
input_type: first_item.radon_type_name().to_string(),
136-
operator: "ArrayJoin".to_string(),
137-
args: Some(args.to_vec())
138-
})
139-
}
140-
_ => {
141-
Err(RadError::EmptyArray)
142-
}
128+
let string_list: Vec<String> = input
143129
.value()
144130
.into_iter()
145131
.map(|item| RadonString::try_from(item).unwrap_or_default().value())
146132
.collect();
147133
Ok(RadonTypes::from(RadonString::from(
148134
string_list.join(separator.as_str()),
149135
)))
136+
}
137+
Some(first_item) => Err(RadError::UnsupportedOperator {
138+
input_type: first_item.radon_type_name().to_string(),
150139
operator: "ArrayJoin".to_string(),
151140
args: Some(args.to_vec()),
152141
}),

0 commit comments

Comments
 (0)