From 667676a63f3d64a672ef31325b65ca7445bb95e1 Mon Sep 17 00:00:00 2001 From: George Zahariev Date: Fri, 20 Dec 2024 07:43:30 -0800 Subject: [PATCH] Add a test for sequence expressions in match argument and body 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 --- .../__tests__/match-test.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/hermes-parser/js/prettier-plugin-hermes-parser/__tests__/match-test.js b/tools/hermes-parser/js/prettier-plugin-hermes-parser/__tests__/match-test.js index a086e861565..2cbe3f81395 100644 --- a/tools/hermes-parser/js/prettier-plugin-hermes-parser/__tests__/match-test.js +++ b/tools/hermes-parser/js/prettier-plugin-hermes-parser/__tests__/match-test.js @@ -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(`