Pass tests
This commit is contained in:
parent
62185ff087
commit
05c9e70d49
@ -50,7 +50,17 @@ impl AbstractTree for ValueNode {
|
||||
Ok(r#type)
|
||||
}
|
||||
|
||||
fn validate(&self, _context: &Context) -> Result<(), ValidationError> {
|
||||
fn validate(&self, context: &Context) -> Result<(), ValidationError> {
|
||||
if let ValueNode::Map(map_assignments) = self {
|
||||
for (_identifier, r#type, expression) in map_assignments {
|
||||
if let Some(expected_type) = r#type {
|
||||
let actual_type = expression.expected_type(context)?;
|
||||
|
||||
expected_type.check(&actual_type)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ fn map_types() {
|
||||
map.insert(Identifier::new("foo"), Value::string("bar".to_string()));
|
||||
|
||||
assert_eq!(
|
||||
interpret("{ x <int> = 1, foo <str> = 'bar' }"),
|
||||
interpret("{ x : int = 1, foo : str = 'bar' }"),
|
||||
Ok(Some(Value::map(map)))
|
||||
);
|
||||
}
|
||||
@ -134,13 +134,13 @@ fn map_types() {
|
||||
#[test]
|
||||
fn map_type_errors() {
|
||||
assert_eq!(
|
||||
interpret("{ foo <bool> = 'bar' }"),
|
||||
interpret("{ foo : bool = 'bar' }"),
|
||||
Err(vec![Error::Validation {
|
||||
error: ValidationError::TypeCheck(TypeCheckError {
|
||||
actual: Type::String,
|
||||
expected: Type::Boolean
|
||||
}),
|
||||
span: (0..0).into()
|
||||
span: (0..22).into()
|
||||
}])
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user