Tests for type annotations
This commit is contained in:
parent
98169bd352
commit
9214f36c04
@ -960,11 +960,15 @@ mod parse_tests {
|
|||||||
($var:expr) => { Variable(Rc::new($var.to_string())) }
|
($var:expr) => { Variable(Rc::new($var.to_string())) }
|
||||||
}
|
}
|
||||||
macro_rules! exprstatement {
|
macro_rules! exprstatement {
|
||||||
($expr_type:expr) => { Statement::ExpressionStatement(Expression($expr_type, None)) }
|
($expr_type:expr) => { Statement::ExpressionStatement(Expression($expr_type, None)) };
|
||||||
|
($expr_type:expr, $type_anno:expr) => { Statement::ExpressionStatement(Expression($expr_type, Some($type_anno))) };
|
||||||
}
|
}
|
||||||
macro_rules! ex {
|
macro_rules! ex {
|
||||||
($expr_type:expr) => { Expression($expr_type, None) }
|
($expr_type:expr) => { Expression($expr_type, None) }
|
||||||
}
|
}
|
||||||
|
macro_rules! ty {
|
||||||
|
($name:expr) => { TypeAnno::Singleton { name: Rc::new($name.to_string()), params: vec![] } };
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parsing_number_literals_and_binexps() {
|
fn parsing_number_literals_and_binexps() {
|
||||||
@ -1088,6 +1092,18 @@ mod parse_tests {
|
|||||||
params: vec![],
|
params: vec![],
|
||||||
})) })]));
|
})) })]));
|
||||||
|
|
||||||
|
parse_test!("a : Int", AST(vec![
|
||||||
|
exprstatement!(var!("a"), ty!("Int"))
|
||||||
|
]));
|
||||||
|
|
||||||
|
parse_test!("a : Option<Int>", AST(vec![
|
||||||
|
exprstatement!(var!("a"), TypeAnno::Singleton { name: rc!(Option), params: vec![ty!("Int")] })
|
||||||
|
]));
|
||||||
|
|
||||||
|
parse_test!("a : KoreanBBQSpecifier<Kimchi, Option<Bulgogi> >", AST(vec![
|
||||||
|
exprstatement!(var!("a"), TypeAnno::Singleton { name: rc!(KoreanBBQSpecifier), params: vec![
|
||||||
|
ty!("Kimchi"), TypeAnno::Singleton { name: rc!(Option), params: vec![ty!("Bulgogi")] }
|
||||||
|
] })
|
||||||
|
]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user