diff --git a/conditional.schala b/conditional.schala index 88ffbdf..ccd7cfa 100644 --- a/conditional.schala +++ b/conditional.schala @@ -1,2 +1,2 @@ -if true then 20 else 40 end +if 34 then 20 else 40 end diff --git a/src/parser.rs b/src/parser.rs index b2fd9b3..3ed5d20 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -452,4 +452,21 @@ mod tests { &[ExprNode(BinExp(ref mul, box BinExp(ref plus, box Variable(ref a), box Variable(ref b)), box Variable(ref c)))], plus == "+" && mul == "*" && a == "a" && b == "b" && c == "c"); } + + #[test] + fn conditional_parse_test() { + use tokenizer; + use super::ASTNode::*; + use super::Expression::*; + + let t1 = "if null then 20 else 40 end"; + let tokens = tokenizer::tokenize(t1).unwrap(); + match parse(&tokens, &[]).unwrap()[..] { + [ExprNode(Conditional(box Null, box ref a, Some(box ref b)))] => { + // TODO make this test better + + } + _ => panic!("Bad conditional test"), + } + } }