From 61b473aacbfc652bb2be8275d02e19e14c109f4e Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Fri, 5 Jun 2026 17:37:05 +0800 Subject: [PATCH] Add test for #4032 (#19296) --- .../__snapshots__/format.test.js.snap | 114 ++++++++++++++++++ .../format/js/comments/return-statement-2.js | 24 ++++ 2 files changed, 138 insertions(+) diff --git a/tests/format/js/comments/__snapshots__/format.test.js.snap b/tests/format/js/comments/__snapshots__/format.test.js.snap index 2eaf4615c..fdac21fab 100644 --- a/tests/format/js/comments/__snapshots__/format.test.js.snap +++ b/tests/format/js/comments/__snapshots__/format.test.js.snap @@ -6202,6 +6202,30 @@ function foo() { ); } +// #4032 +function transitionedFromBleepToBloop() { + return !!( + // Start with a bloop. + thing != null && (thing.foo && thing.foo.bar === 'bloop') && + // End up with a bleep. + (thing.foo && thing.foo.bar === 'bleep') + ); + + return Boolean( + // Start with a bloop. + thing != null && (thing.foo && thing.foo.bar === 'bloop') && + // End up with a bleep. + (thing.foo && thing.foo.bar === 'bleep') + ); + + return foo( + // Start with a bloop. + thing != null && (thing.foo && thing.foo.bar === 'bloop') && + // End up with a bleep. + (thing.foo && thing.foo.bar === 'bleep') + ); +} + =====================================output===================================== function foo() { return ( @@ -6242,6 +6266,39 @@ function foo() { ) } +// #4032 +function transitionedFromBleepToBloop() { + return !!( + // Start with a bloop. + thing != null && + thing.foo && + thing.foo.bar === "bloop" && + // End up with a bleep. + thing.foo && + thing.foo.bar === "bleep" + ) + + return Boolean( + // Start with a bloop. + thing != null && + thing.foo && + thing.foo.bar === "bloop" && + // End up with a bleep. + thing.foo && + thing.foo.bar === "bleep", + ) + + return foo( + // Start with a bloop. + thing != null && + thing.foo && + thing.foo.bar === "bloop" && + // End up with a bleep. + thing.foo && + thing.foo.bar === "bleep", + ) +} + ================================================================================ `; @@ -6288,6 +6345,30 @@ function foo() { ); } +// #4032 +function transitionedFromBleepToBloop() { + return !!( + // Start with a bloop. + thing != null && (thing.foo && thing.foo.bar === 'bloop') && + // End up with a bleep. + (thing.foo && thing.foo.bar === 'bleep') + ); + + return Boolean( + // Start with a bloop. + thing != null && (thing.foo && thing.foo.bar === 'bloop') && + // End up with a bleep. + (thing.foo && thing.foo.bar === 'bleep') + ); + + return foo( + // Start with a bloop. + thing != null && (thing.foo && thing.foo.bar === 'bloop') && + // End up with a bleep. + (thing.foo && thing.foo.bar === 'bleep') + ); +} + =====================================output===================================== function foo() { return ( @@ -6328,6 +6409,39 @@ function foo() { ); } +// #4032 +function transitionedFromBleepToBloop() { + return !!( + // Start with a bloop. + thing != null && + thing.foo && + thing.foo.bar === "bloop" && + // End up with a bleep. + thing.foo && + thing.foo.bar === "bleep" + ); + + return Boolean( + // Start with a bloop. + thing != null && + thing.foo && + thing.foo.bar === "bloop" && + // End up with a bleep. + thing.foo && + thing.foo.bar === "bleep", + ); + + return foo( + // Start with a bloop. + thing != null && + thing.foo && + thing.foo.bar === "bloop" && + // End up with a bleep. + thing.foo && + thing.foo.bar === "bleep", + ); +} + ================================================================================ `; diff --git a/tests/format/js/comments/return-statement-2.js b/tests/format/js/comments/return-statement-2.js index 179d42486..1d2f15ecb 100644 --- a/tests/format/js/comments/return-statement-2.js +++ b/tests/format/js/comments/return-statement-2.js @@ -35,3 +35,27 @@ function foo() { a = b ); } + +// #4032 +function transitionedFromBleepToBloop() { + return !!( + // Start with a bloop. + thing != null && (thing.foo && thing.foo.bar === 'bloop') && + // End up with a bleep. + (thing.foo && thing.foo.bar === 'bleep') + ); + + return Boolean( + // Start with a bloop. + thing != null && (thing.foo && thing.foo.bar === 'bloop') && + // End up with a bleep. + (thing.foo && thing.foo.bar === 'bleep') + ); + + return foo( + // Start with a bloop. + thing != null && (thing.foo && thing.foo.bar === 'bloop') && + // End up with a bleep. + (thing.foo && thing.foo.bar === 'bleep') + ); +}