Skip to content

Commit

Permalink
Add a test for sequence expressions in match argument and body
Browse files Browse the repository at this point in the history
Summary: Add a test for sequence expressions in match argument and body, making sure that the sequence expressions are always wrapped in parens when printed.

Reviewed By: SamChou19815

Differential Revision: D67489432

fbshipit-source-id: 99c17d408da510a00ca986557f99d8673170a0a2
  • Loading branch information
gkz authored and facebook-github-bot committed Dec 20, 2024
1 parent 874b0c0 commit 667676a
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ describe('Match expression', () => {
`);
});

test('sequence expressions: always with parens', async () => {
expect(
format(`
const e = match (x, y) {
1: (x, y),
2 if (x, y): 0,
};
`),
).toMatchInlineSnapshot(`
"const e = match ((x, y)) {
1: (x, y),
2 if (x, y): 0,
};
"
`);
});

test('patterns: core', async () => {
expect(
format(`
Expand Down

0 comments on commit 667676a

Please sign in to comment.