Skip to content

Commit d066a4d

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

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

rad/src/error.rs

+4
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ impl RadError {
564564
};
565565
Some(serialize_args((message,))?)
566566
}
567+
RadError::BufferIsNotValue { description } => Some(serialize_args((description,))?),
567568
_ => None,
568569
};
569570

@@ -770,6 +771,9 @@ mod tests {
770771
inner: None,
771772
message: Some("Only the message field is serialized".to_string()),
772773
},
774+
RadonErrors::BufferIsNotValue => RadError::BufferIsNotValue {
775+
description: "Buffer is no value".to_string(),
776+
},
773777
// If this panics after adding a new `RadonTypes`, add a new example above
774778
_ => panic!("No example for {:?}", radon_errors),
775779
}

rad/src/operators/array.rs

+5-16
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)