From 695526e64f2dc07b4153f90e0169f4fca4fc8ac1 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:36:37 -0800 Subject: [PATCH] Test AvoidInfix with match as lhs --- .../test/resources/scala3/OptionalBraces.stat | 47 +++++++++++++++++++ .../resources/scala3/OptionalBraces_fold.stat | 46 ++++++++++++++++++ .../resources/scala3/OptionalBraces_keep.stat | 46 ++++++++++++++++++ .../scala3/OptionalBraces_unfold.stat | 46 ++++++++++++++++++ .../test/scala/org/scalafmt/FormatTests.scala | 2 +- 5 files changed, 186 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 0d96fbca5..39cbea6c9 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat @@ -7564,3 +7564,50 @@ object Build: } }.evaluated ) +<<< AvoidInfix with match +rewrite.rules = [AvoidInfix] +=== +object a { + a b c match + case _ => +} +>>> +object a { + a.b(c) match + case _ => +} +<<< AvoidInfix with match within applyinfix +rewrite.rules = [AvoidInfix] +=== +object a { + a b c match { + case _ => + } d e +} +>>> +test does not parse +[dialect scala3] `;` expected but `.` found + a .b( c) match { + case _ => + } .d( e) + ^ +} +====== full result: ====== +object a { + a .b( c) match { + case _ => + } .d( e) +} +<<< AvoidInfix with match, with dot +rewrite.rules = [AvoidInfix] +=== +object a { + (a.b(c)).match + case _ => +} +>>> +object a { + (a.b(c)) + .match + case _ => +} 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 595f389c1..a08ab241b 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat @@ -7275,3 +7275,49 @@ object Build: config: GenerationConfig => config.remove[SiteRoot] } }.evaluated) +<<< AvoidInfix with match +rewrite.rules = [AvoidInfix] +=== +object a { + a b c match + case _ => +} +>>> +object a { + a.b(c) match + case _ => +} +<<< AvoidInfix with match within applyinfix +rewrite.rules = [AvoidInfix] +=== +object a { + a b c match { + case _ => + } d e +} +>>> +test does not parse +[dialect scala3] `;` expected but `.` found + a .b( c) match { + case _ => + } .d( e) + ^ +} +====== full result: ====== +object a { + a .b( c) match { + case _ => + } .d( e) +} +<<< AvoidInfix with match, with dot +rewrite.rules = [AvoidInfix] +=== +object a { + (a.b(c)).match + case _ => +} +>>> +object a { + (a.b(c)).match + case _ => +} 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 de21c14bf..2515ab331 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat @@ -7592,3 +7592,49 @@ object Build: } }.evaluated ) +<<< AvoidInfix with match +rewrite.rules = [AvoidInfix] +=== +object a { + a b c match + case _ => +} +>>> +object a { + a.b(c) match + case _ => +} +<<< AvoidInfix with match within applyinfix +rewrite.rules = [AvoidInfix] +=== +object a { + a b c match { + case _ => + } d e +} +>>> +test does not parse +[dialect scala3] `;` expected but `.` found + a .b( c) match { + case _ => + } .d( e) + ^ +} +====== full result: ====== +object a { + a .b( c) match { + case _ => + } .d( e) +} +<<< AvoidInfix with match, with dot +rewrite.rules = [AvoidInfix] +=== +object a { + (a.b(c)).match + case _ => +} +>>> +object a { + (a.b(c)).match + case _ => +} 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 c84a38f02..45dc8b704 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat @@ -7879,3 +7879,49 @@ object Build: } .evaluated ) +<<< AvoidInfix with match +rewrite.rules = [AvoidInfix] +=== +object a { + a b c match + case _ => +} +>>> +object a { + a.b(c) match + case _ => +} +<<< AvoidInfix with match within applyinfix +rewrite.rules = [AvoidInfix] +=== +object a { + a b c match { + case _ => + } d e +} +>>> +test does not parse +[dialect scala3] `;` expected but `.` found + a .b( c) match { + case _ => + } .d( e) + ^ +} +====== full result: ====== +object a { + a .b( c) match { + case _ => + } .d( e) +} +<<< AvoidInfix with match, with dot +rewrite.rules = [AvoidInfix] +=== +object a { + (a.b(c)).match + case _ => +} +>>> +object a { + (a.b(c)).match + case _ => +} 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 779ec0e9d..2f14c53cc 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, 1082944, "total explored") + assertEquals(explored, 1083242, "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 :'(