chore: format

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

View File

@ -5193,49 +5193,51 @@ mod tests {
#[test] #[test]
fn short_while() { fn short_while() {
assert_ast("<?php while (true): $a; endwhile;", &[ assert_ast(
Statement::While { "<?php while (true): $a; endwhile;",
&[Statement::While {
condition: Expression::Bool { value: true }, condition: Expression::Bool { value: true },
body: vec![ body: vec![expr!(Expression::Variable { name: "a".into() })],
expr!(Expression::Variable { name: "a".into() }) }],
] );
}
]);
} }
#[test] #[test]
fn short_for() { fn short_for() {
assert_ast("<?php for ($a; $b; $c): $d; endfor;", &[ assert_ast(
Statement::For { "<?php for ($a; $b; $c): $d; endfor;",
&[Statement::For {
init: Some(Expression::Variable { name: "a".into() }), init: Some(Expression::Variable { name: "a".into() }),
condition: Some(Expression::Variable { name: "b".into() }), condition: Some(Expression::Variable { name: "b".into() }),
r#loop: Some(Expression::Variable { name: "c".into() }), r#loop: Some(Expression::Variable { name: "c".into() }),
then: vec![ then: vec![expr!(Expression::Variable { name: "d".into() })],
expr!(Expression::Variable { name: "d".into() }) }],
] );
}
]);
} }
#[test] #[test]
fn shorthand_switch() { fn shorthand_switch() {
assert_ast("<?php switch ($a): endswitch;", &[ assert_ast(
Statement::Switch { condition: Expression::Variable { name: "a".into() }, cases: vec![] } "<?php switch ($a): endswitch;",
]); &[Statement::Switch {
condition: Expression::Variable { name: "a".into() },
cases: vec![],
}],
);
} }
#[test] #[test]
fn shorthand_declare() { fn shorthand_declare() {
assert_ast("<?php declare(a=b): $a; enddeclare;", &[ assert_ast(
Statement::Declare { declares: vec![ "<?php declare(a=b): $a; enddeclare;",
DeclareItem { &[Statement::Declare {
declares: vec![DeclareItem {
key: "a".into(), key: "a".into(),
value: Expression::Identifier { name: "b".into() }, value: Expression::Identifier { name: "b".into() },
} }],
], body: vec![ body: vec![expr!(Expression::Variable { name: "a".into() })],
expr!(Expression::Variable { name: "a".into() }) }],
] } );
]);
} }
fn assert_ast(source: &str, expected: &[Statement]) { fn assert_ast(source: &str, expected: &[Statement]) {