Add and pass test
This commit is contained in:
parent
fdf6983ab2
commit
65d2fd3270
@ -107,10 +107,10 @@ pub fn parser<'src>() -> DustParser<'src> {
|
||||
infix(left(1), just(Token::Operator("<=")), |left, right| {
|
||||
Expression::Logic(Box::new(Logic::LessOrEqual(left, right)))
|
||||
}),
|
||||
infix(right(1), just(Token::Operator("&&")), |left, right| {
|
||||
infix(left(1), just(Token::Operator("&&")), |left, right| {
|
||||
Expression::Logic(Box::new(Logic::And(left, right)))
|
||||
}),
|
||||
infix(right(1), just(Token::Operator("||")), |left, right| {
|
||||
infix(left(1), just(Token::Operator("||")), |left, right| {
|
||||
Expression::Logic(Box::new(Logic::Or(left, right)))
|
||||
}),
|
||||
))
|
||||
|
@ -1,6 +1,32 @@
|
||||
use dust_lang::*;
|
||||
use dust_lang::{
|
||||
abstract_tree::Type,
|
||||
error::{Error, TypeCheckError, ValidationError},
|
||||
*,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn set_and_get_variable() {
|
||||
assert_eq!(interpret("foobar = true; foobar"), Ok(Value::boolean(true)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_variable_with_type() {
|
||||
assert_eq!(
|
||||
interpret("foobar: bool = true; foobar"),
|
||||
Ok(Value::boolean(true))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_variable_with_type_error() {
|
||||
assert_eq!(
|
||||
interpret("foobar: str = true"),
|
||||
Err(vec![Error::Validation {
|
||||
error: ValidationError::TypeCheck(TypeCheckError {
|
||||
actual: Type::Boolean,
|
||||
expected: Type::String
|
||||
}),
|
||||
span: (0..18).into()
|
||||
}])
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user