Skip to content

Commit a87293b

Browse files
committed
ssr: Test cases for let statement trailing semi insertion/omission
1 parent 77aa03c commit a87293b

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

crates/ssr/src/tests.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,11 @@ fn ssr_block_expr_match() {
198198

199199
#[test]
200200
fn ssr_let_stmt_replace() {
201-
// FIXME: See remark above about trailing semicolons
202-
// assert_ssr_transform(
203-
// "let $a = $b ==>> let $a = 11",
204-
// "fn main() { let x = 10; x }",
205-
// expect![["fn main() { let x = 11; x }"]],
206-
// );
201+
assert_ssr_transform(
202+
"let $a = $b ==>> let $a = 11",
203+
"fn main() { let x = 10; x }",
204+
expect![["fn main() { let x = 11; x }"]],
205+
);
207206

208207
// Pattern without trailing semicolon
209208
// FIXME: This should fail, the expected value must be `let x = 11;;`
@@ -219,6 +218,30 @@ fn ssr_let_stmt_replace() {
219218
"fn main() { let x = 10; x }",
220219
expect![["fn main() { let x = 11; x }"]],
221220
);
221+
222+
// Trailing semicolon should be dropped from the new expression
223+
assert_ssr_transform(
224+
"let $a = $b; ==>> let $a = 11",
225+
"fn main() { let x = 10; x }",
226+
expect![["fn main() { let x = 11 x }"]],
227+
);
228+
}
229+
230+
#[test]
231+
fn ssr_let_stmt_replace_expr() {
232+
// Trailing semicolon should be dropped from the new expression
233+
assert_ssr_transform(
234+
"let $a = $b; ==>> $b",
235+
"fn main() { let x = 10; }",
236+
expect![["fn main() { 10 }"]],
237+
);
238+
239+
// Trailing semicolon should _not_ be dropped from the new expression
240+
assert_ssr_transform(
241+
"let $a = $b ==>> $b",
242+
"fn main() { let x = 10; }",
243+
expect![["fn main() { 10; }"]],
244+
);
222245
}
223246

224247
#[test]

0 commit comments

Comments
 (0)