minor: more focusted tests

This commit is contained in:
Aleksey Kladov 2021-09-25 14:02:33 +03:00
parent a6f17f7436
commit 1567bbb73e
7 changed files with 107 additions and 156 deletions

View file

@ -115,6 +115,10 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi, prefer_expr: bool) {
// }
match with_semi {
StmtWithSemi::No => (),
StmtWithSemi::Optional => {
p.eat(T![;]);
}
StmtWithSemi::Yes => {
if blocklike.is_block() {
p.eat(T![;]);
@ -122,48 +126,35 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi, prefer_expr: bool) {
p.expect(T![;]);
}
}
StmtWithSemi::No => {}
StmtWithSemi::Optional => {
if p.at(T![;]) {
p.eat(T![;]);
}
}
}
m.complete(p, EXPR_STMT);
}
// test let_stmt
// fn foo() {
// let a;
// let b: i32;
// let c = 92;
// let d: i32 = 92;
// let e: !;
// let _: ! = {};
// let f = #[attr]||{};
// }
// fn f() { let x: i32 = 92; }
fn let_stmt(p: &mut Parser, m: Marker, with_semi: StmtWithSemi) {
assert!(p.at(T![let]));
p.bump(T![let]);
patterns::pattern(p);
if p.at(T![:]) {
// test let_stmt_ascription
// fn f() { let x: i32; }
types::ascription(p);
}
if p.eat(T![=]) {
// test let_stmt_init
// fn f() { let x = 92; }
expressions::expr_with_attrs(p);
}
match with_semi {
StmtWithSemi::No => (),
StmtWithSemi::Optional => {
p.eat(T![;]);
}
StmtWithSemi::Yes => {
p.expect(T![;]);
}
StmtWithSemi::No => {}
StmtWithSemi::Optional => {
if p.at(T![;]) {
p.eat(T![;]);
}
}
}
m.complete(p, LET_STMT);
}