diff --git a/src/error.rs b/src/error.rs index de399b2..7efdcc4 100644 --- a/src/error.rs +++ b/src/error.rs @@ -229,7 +229,7 @@ impl Error { } } - pub fn is_type_check_error(&self, other: &Error) -> bool { + pub fn is_error(&self, other: &Error) -> bool { match self { Error::AtSourcePosition { error, .. } => error.as_ref() == other, _ => self == other, diff --git a/tests/interpret.rs b/tests/interpret.rs index 0784f03..a7db5db 100644 --- a/tests/interpret.rs +++ b/tests/interpret.rs @@ -40,7 +40,7 @@ mod assignment { ", ); - assert!(result.unwrap_err().is_type_check_error(&Error::TypeCheck { + assert!(result.unwrap_err().is_error(&Error::TypeCheck { expected: Type::String, actual: Type::Integer })) @@ -172,7 +172,7 @@ mod value { fn map_type_errors() { assert!(interpret("{ foo = 'bar' }") .unwrap_err() - .is_type_check_error(&Error::TypeCheck { + .is_error(&Error::TypeCheck { expected: Type::Boolean, actual: Type::String })) @@ -435,7 +435,7 @@ mod type_definition { fn simple_type_check() { let result = interpret("x = 1"); - assert!(result.unwrap_err().is_type_check_error(&Error::TypeCheck { + assert!(result.unwrap_err().is_error(&Error::TypeCheck { expected: Type::Boolean, actual: Type::Integer })); @@ -468,7 +468,7 @@ mod type_definition { ", ); - assert!(result.unwrap_err().is_type_check_error(&Error::TypeCheck { + assert!(result.unwrap_err().is_error(&Error::TypeCheck { expected: Type::Function { parameter_types: vec![], return_type: Box::new(Type::Boolean),