chore: format

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

View File

@ -195,7 +195,7 @@ impl Parser {
}
TokenKind::Do => {
self.next();
self.lbrace()?;
let body = self.block(&TokenKind::RightBrace)?;
self.rbrace()?;
@ -208,7 +208,7 @@ impl Parser {
self.semi()?;
Statement::DoWhile { condition, body }
},
}
TokenKind::While => {
self.next();
self.lparen()?;
@ -3063,23 +3063,29 @@ mod tests {
#[test]
fn do_while() {
assert_ast("<?php do { } while ($a);", &[
Statement::DoWhile { condition: Expression::Variable { name: "a".into() }, body: vec![] }
]);
assert_ast(
"<?php do { } while ($a);",
&[Statement::DoWhile {
condition: Expression::Variable { name: "a".into() },
body: vec![],
}],
);
assert_ast("<?php
assert_ast(
"<?php
do {
echo 'Hi!';
} while (true);
", &[
Statement::DoWhile {
",
&[Statement::DoWhile {
condition: Expression::Bool { value: true },
body: vec![
Statement::Echo { values: vec![
Expression::ConstantString { value: "Hi!".into() }
]}
]
}])
body: vec![Statement::Echo {
values: vec![Expression::ConstantString {
value: "Hi!".into(),
}],
}],
}],
)
}
fn assert_ast(source: &str, expected: &[Statement]) {