From f582ab4eaa553ea5b73f560d86dd78d91522d8c1 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 19 Jun 2018 02:22:19 -0700 Subject: [PATCH] Test for new style parsing --- schala-lang/src/parsing.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/schala-lang/src/parsing.rs b/schala-lang/src/parsing.rs index aadc90a..7358ab5 100644 --- a/schala-lang/src/parsing.rs +++ b/schala-lang/src/parsing.rs @@ -894,7 +894,9 @@ pub fn parse(input: Vec) -> (Result, Vec) { #[cfg(test)] mod parse_tests { use ::std::rc::Rc; - use super::{AST, Expression, Statement, PrefixOp, BinOp, TypeBody, Variant, Enumerator, ForBody, parse, tokenize}; + use super::{parse, tokenize}; + use builtin::{PrefixOp, BinOp}; + use ast::{AST, Expression, Statement, IfExpressionBody, Discriminator, TypeBody, Variant, Enumerator, ForBody}; use super::Statement::*; use super::Declaration::*; use super::Signature; @@ -1123,6 +1125,22 @@ fn a(x) { #[test] fn parsing_block_expressions() { + parse_test! { + "if a() then { b(); c() }", AST(vec![exprstatement!( + IfExpression { + discriminator: bx! { + Discriminator::Simple(ex!(Call { f: bx!(ex!(val!("a"))), arguments: vec![]})) + }, + body: bx! { + IfExpressionBody::SimpleConditional( + vec![exprstatement!(Call { f: bx!(ex!(val!("b"))), arguments: vec![]}), exprstatement!(Call { f: bx!(ex!(val!("c"))), arguments: vec![] })], + None + ) + } + } + )]) + }; + /* parse_test!("if a() then { b(); c() }", AST(vec![exprstatement!( IfExpression(bx!(ex!(Call { f: bx!(ex!(val!("a"))), arguments: vec![]})),