From f8287e42ce3b4946114ab23736472620e1ff23f5 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 12 Sep 2017 00:48:37 -0700 Subject: [PATCH] Binary literal test case --- src/schala_lang/parsing.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/schala_lang/parsing.rs b/src/schala_lang/parsing.rs index 72a349e..2f36bb7 100644 --- a/src/schala_lang/parsing.rs +++ b/src/schala_lang/parsing.rs @@ -210,6 +210,7 @@ mod schala_tokenizer_tests { macro_rules! ident { ($ident:expr) => { Identifier(Rc::new($ident.to_string())) } } macro_rules! op { ($ident:expr) => { Operator(Rc::new($ident.to_string())) } } + #[test] fn tokens() { let a = tokenize("let a: A = c ++ d"); @@ -519,9 +520,14 @@ mod parse_tests { use super::Statement::*; use super::Expression::*; use super::ParseError; + + macro_rules! parse_test { + ($string:expr, $correct:expr) => { assert_eq!(parse(tokenize($string)).unwrap(), $correct) } + } + #[test] fn test_parsing() { - let a = "8.1"; - assert_eq!(parse(tokenize(a)).unwrap(), AST(vec![Expression(FloatLiteral(8.1))])); + parse_test!("8.1", AST(vec![Expression(FloatLiteral(8.1))])); + parse_test!("0b010", AST(vec![Expression(IntLiteral(2))])); } }