mirror of
https://github.com/danog/parser.git
synced 2024-11-27 04:14:55 +01:00
chore: format
This commit is contained in:
parent
22de6202e1
commit
62eb62e2fe
@ -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]) {
|
||||
|
Loading…
Reference in New Issue
Block a user