parser: add test with body for do/while

This commit is contained in:
Ryan Chandler 2022-09-12 12:09:20 +01:00
parent a897328b69
commit 22de6202e1
No known key found for this signature in database
GPG Key ID: F113BCADDB3B0CCA

View File

@ -3066,6 +3066,20 @@ mod tests {
assert_ast("<?php do { } while ($a);", &[
Statement::DoWhile { condition: Expression::Variable { name: "a".into() }, body: vec![] }
]);
assert_ast("<?php
do {
echo 'Hi!';
} while (true);
", &[
Statement::DoWhile {
condition: Expression::Bool { value: true },
body: vec![
Statement::Echo { values: vec![
Expression::ConstantString { value: "Hi!".into() }
]}
]
}])
}
fn assert_ast(source: &str, expected: &[Statement]) {