mirror of
https://github.com/danog/parser.git
synced 2024-11-30 04:29:13 +01:00
parser: add basic short if test case
This commit is contained in:
parent
c2486d39db
commit
d19f7d5827
@ -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]) {
|
||||
let mut lexer = Lexer::new(None);
|
||||
let tokens = lexer.tokenize(source).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user