From 86262d6722c678e0b2e0b126f144a7ddcc635122 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Tue, 19 Nov 2024 22:44:54 -0800 Subject: [PATCH] Test match with/without dot and trailing comment --- .../test/resources/scala3/OptionalBraces.stat | 20 +++++++++++++++++ .../resources/scala3/OptionalBraces_fold.stat | 20 +++++++++++++++++ .../resources/scala3/OptionalBraces_keep.stat | 20 +++++++++++++++++ .../scala3/OptionalBraces_unfold.stat | 22 +++++++++++++++++++ .../test/scala/org/scalafmt/FormatTests.scala | 2 +- 5 files changed, 83 insertions(+), 1 deletion(-) diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat index 7e3a4ba871..117c6d8c8d 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat @@ -7603,3 +7603,23 @@ object a { .match case _ => } +<<< match with dot, trailing case comment +object a: + b.c.match + case d if e => f + // comment +>>> +object a: + b.c.match + case d if e => f + // comment +<<< match without dot, trailing case comment +object a: + b.c match + case d if e => f + // comment +>>> +object a: + b.c match + case d if e => f + // comment diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat index 5d45dec21e..ed8f22d5a1 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat @@ -7311,3 +7311,23 @@ object a { (a.b(c)).match case _ => } +<<< match with dot, trailing case comment +object a: + b.c.match + case d if e => f + // comment +>>> +object a: + b.c.match + case d if e => f + // comment +<<< match without dot, trailing case comment +object a: + b.c match + case d if e => f + // comment +>>> +object a: + b.c match + case d if e => f + // comment diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat index d675ccc27c..7c8601f8d4 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat @@ -7630,3 +7630,23 @@ object a { (a.b(c)).match case _ => } +<<< match with dot, trailing case comment +object a: + b.c.match + case d if e => f + // comment +>>> +object a: + b.c.match + case d if e => f + // comment +<<< match without dot, trailing case comment +object a: + b.c match + case d if e => f + // comment +>>> +object a: + b.c match + case d if e => f + // comment diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat index 4458bed87c..be0e01ef0a 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat @@ -7919,3 +7919,25 @@ object a { (a.b(c)).match case _ => } +<<< match with dot, trailing case comment +object a: + b.c.match + case d if e => f + // comment +>>> +Idempotency violated +=> Diff (- obtained, + expected) + f +- // comment ++ // comment +<<< match without dot, trailing case comment +object a: + b.c match + case d if e => f + // comment +>>> +object a: + b.c match + case d if e => + f + // comment diff --git a/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala b/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala index 77937b4ad7..fe052f8673 100644 --- a/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala +++ b/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala @@ -144,7 +144,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions { val explored = Debug.explored.get() logger.debug(s"Total explored: $explored") if (!onlyUnit && !onlyManual) - assertEquals(explored, 1083470, "total explored") + assertEquals(explored, 1083760, "total explored") val results = debugResults.result() // TODO(olafur) don't block printing out test results. // I don't want to deal with scalaz's Tasks :'(