Add test for conditional parsing

This commit is contained in:
greg 2016-12-31 04:00:30 -08:00
parent 82c52ede48
commit f626ca1427
2 changed files with 18 additions and 1 deletions

View File

@ -1,2 +1,2 @@
if true then 20 else 40 end
if 34 then 20 else 40 end

View File

@ -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"),
}
}
}