A test for type annotation
This commit is contained in:
parent
f48adbd9bf
commit
c20f93e18c
@ -900,6 +900,7 @@ mod parse_tests {
|
||||
use super::{AST, Expression, Statement, Operation, TypeBody, Variant, parse, tokenize};
|
||||
use super::Statement::*;
|
||||
use super::Declaration::*;
|
||||
use super::TypeAnno;
|
||||
use super::ExpressionType::*;
|
||||
|
||||
macro_rules! rc {
|
||||
@ -951,18 +952,12 @@ mod parse_tests {
|
||||
parse_test!("1 && 2", AST(vec![exprstatement!(binexp!("&&", IntLiteral(1), IntLiteral(2)))]));
|
||||
|
||||
parse_test!("1 + 2 * 3 + 4", AST(vec![exprstatement!(
|
||||
binexp!("+",
|
||||
binexp!("+", IntLiteral(1),
|
||||
binexp!("*", IntLiteral(2), IntLiteral(3))
|
||||
),
|
||||
IntLiteral(4)
|
||||
)
|
||||
)]));
|
||||
binexp!("+",
|
||||
binexp!("+", IntLiteral(1), binexp!("*", IntLiteral(2), IntLiteral(3))),
|
||||
IntLiteral(4)))]));
|
||||
|
||||
parse_test!("(1 + 2) * 3", AST(vec!
|
||||
[
|
||||
exprstatement!(binexp!("*", binexp!("+", IntLiteral(1), IntLiteral(2)), IntLiteral(3)))
|
||||
]));
|
||||
[exprstatement!(binexp!("*", binexp!("+", IntLiteral(1), IntLiteral(2)), IntLiteral(3)))]));
|
||||
|
||||
parse_test!(".1 + .2", AST(vec![exprstatement!(binexp!("+", FloatLiteral(0.1), FloatLiteral(0.2)))]));
|
||||
}
|
||||
@ -1047,4 +1042,13 @@ mod parse_tests {
|
||||
Some(vec![exprstatement!(Variable(rc!(c)))])))])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parsing_type_annotations() {
|
||||
parse_test!("const a = b : Int", AST(vec![
|
||||
Declaration(Binding { name: rc!(a), constant: true, expr:
|
||||
Expression(var!("b"), Some(TypeAnno(rc!(Int)))) })]));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user