use super::*;
#[test]
fn parse_if_else_expression() {
with_first_return_value("return if true then 1 else 2", |expression| {
assert!(matches!(expression.kind(), ExpressionKind::If { .. }));
});
with_first_return_value(
"return if true then 1 elseif true then 2 else 3",
|elseif| {
let ExpressionKind::If {
else_expression, ..
} = elseif.kind()
else {
panic!("expected if expression");
};
assert!(matches!(else_expression.kind(), ExpressionKind::If { .. }));
},
);
with_first_return_value(
"return if true then 1 else if true then 2 else 3",
|else_if| {
let ExpressionKind::If {
else_expression, ..
} = else_if.kind()
else {
panic!("expected if expression");
};
assert!(matches!(else_expression.kind(), ExpressionKind::If { .. }));
},
);
with_first_return_value(
"return if if true then false else true then 1 else 2",
|nested_condition| {
let ExpressionKind::If { condition, .. } = nested_condition.kind() else {
panic!("expected if expression");
};
assert!(matches!(condition.kind(), ExpressionKind::If { .. }));
},
);
}