From c20f93e18ca91753c3b71bee43b6ac9b3e11dac7 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 28 Sep 2017 00:45:36 -0700 Subject: [PATCH] A test for type annotation --- src/schala_lang/parsing.rs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/schala_lang/parsing.rs b/src/schala_lang/parsing.rs index d5fe0bc..425d166 100644 --- a/src/schala_lang/parsing.rs +++ b/src/schala_lang/parsing.rs @@ -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)))) })])); + + + } }