parser: add basic short if test case

This commit is contained in:
Ryan Chandler 2022-09-16 23:34:38 +01:00
parent c2486d39db
commit d19f7d5827
No known key found for this signature in database
GPG Key ID: F113BCADDB3B0CCA

View File

@ -4745,6 +4745,23 @@ mod tests {
); );
} }
#[test]
fn short_if() {
assert_ast("<?php
if ($a):
$a;
endif;", &[
Statement::If {
condition: Expression::Variable { name: "a".into() },
then: vec![
expr!(Expression::Variable { name: "a".into() })
],
else_ifs: vec![],
r#else: None,
}
])
}
fn assert_ast(source: &str, expected: &[Statement]) { fn assert_ast(source: &str, expected: &[Statement]) {
let mut lexer = Lexer::new(None); let mut lexer = Lexer::new(None);
let tokens = lexer.tokenize(source).unwrap(); let tokens = lexer.tokenize(source).unwrap();