2024-02-13 15:49:49 +00:00
|
|
|
use dust_lang::{error::ValidationError, *};
|
2024-02-13 15:26:26 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn string_as_list() {
|
|
|
|
assert_eq!(
|
|
|
|
interpret("'foobar' as [str]"),
|
|
|
|
Ok(Value::List(List::with_items(vec![
|
|
|
|
Value::String("f".to_string()),
|
|
|
|
Value::String("o".to_string()),
|
|
|
|
Value::String("o".to_string()),
|
|
|
|
Value::String("b".to_string()),
|
|
|
|
Value::String("a".to_string()),
|
|
|
|
Value::String("r".to_string()),
|
|
|
|
])))
|
|
|
|
)
|
|
|
|
}
|
2024-02-13 15:49:49 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn string_as_list_conversion_error() {
|
|
|
|
assert_eq!(
|
|
|
|
interpret("'foobar' as [float]"),
|
|
|
|
Err(Error::Validation(ValidationError::ConversionImpossible {
|
|
|
|
initial_type: Type::String,
|
|
|
|
target_type: Type::List(Box::new(Type::Float))
|
|
|
|
}))
|
|
|
|
)
|
|
|
|
}
|