From e02df91a74e4e6622ea6fc336f488050db30315e Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Mon, 17 Feb 2020 08:51:18 -0800 Subject: [PATCH] Add failing "unable to format due to bug" tests See #448, #1462, #1485, #1559 and #1717. --- .../src/test/resources/default/Lambda.stat | 37 ++++++++++++++++++ .../newlines/afterCurlyLambdaNever.stat | 20 ++++++++++ ...SingleArgParenLambdaParamsF_danglingT.stat | 39 +++++++++++++++++++ .../VerticalMultilineDefnSite.stat | 15 +++++++ 4 files changed, 111 insertions(+) diff --git a/scalafmt-tests/src/test/resources/default/Lambda.stat b/scalafmt-tests/src/test/resources/default/Lambda.stat index e145abc393..7385f59398 100644 --- a/scalafmt-tests/src/test/resources/default/Lambda.stat +++ b/scalafmt-tests/src/test/resources/default/Lambda.stat @@ -386,3 +386,40 @@ testAsync("Resource.make is equivalent to a partially applied bracket") { implic } } } +<<< #448 +object Foo { + code.collect { + case d: Defn.Def if (d match { + case _ => false + + + }) && + d=> + } +} +>>> +Unable to format file due to bug in scalafmt +<<< #1485 +style = IntelliJ +maxColumn = 120 +=== +class A { + def foo: B = + a.b() { c => + val d = c.add( + D[E]( + 1, { + case conditionNameShouldLongEnough => + foo1(objectNameShouldLongEnough, objectNameShouldLongEnough) + 0 + case conditionNameShouldLongEnough => + foo1(objectNameShouldLongEnough, objectNameShouldLongEnough) + 1 + } + ) + ) + } + .f("f") +} +>>> +Unable to format file due to bug in scalafmt diff --git a/scalafmt-tests/src/test/resources/newlines/afterCurlyLambdaNever.stat b/scalafmt-tests/src/test/resources/newlines/afterCurlyLambdaNever.stat index 8602f2866f..9b4168ec5c 100644 --- a/scalafmt-tests/src/test/resources/newlines/afterCurlyLambdaNever.stat +++ b/scalafmt-tests/src/test/resources/newlines/afterCurlyLambdaNever.stat @@ -37,3 +37,23 @@ def f = { def f = { something.call { x => g(x) } } +<<< #1717 +maxColumn = 100 +=== +class Bar { + def foo(request: Request): RpcResult[Response] = { + repository + .flatMap { campaigns => + request match { + case Nil => connection.pure(Right(toResponse(campaigns, Map.empty))) + case _ => + getProfileEmails(request.securityContext, profileIds).to[ConnectionIO].map { + profileEmails => + Right(toResponse(campaigns, profileEmails)) + } + } + }.transact(managerTransactor) + } +} +>>> +Unable to format file due to bug in scalafmt diff --git a/scalafmt-tests/src/test/resources/newlines/beforeConfigSingleArgParenLambdaParamsF_danglingT.stat b/scalafmt-tests/src/test/resources/newlines/beforeConfigSingleArgParenLambdaParamsF_danglingT.stat index 4d1f58e37d..338ae1e2d3 100644 --- a/scalafmt-tests/src/test/resources/newlines/beforeConfigSingleArgParenLambdaParamsF_danglingT.stat +++ b/scalafmt-tests/src/test/resources/newlines/beforeConfigSingleArgParenLambdaParamsF_danglingT.stat @@ -702,3 +702,42 @@ object a { _ => e ) } +<<< #1599 1: original, with partial func +object A { + def foo() = { + x.map(_.y( + abcd, + { case ((abcdefghij, aswbasdfaw), asfda) => aswdf}, + { case (abcdefghij, sadfasdass) => (asdfa.sadvfs(abcdefghij).get, asdfasdfasfdasda.asdfas(asdfasdaas).get) }, + foo + )) + } +} +>>> +Unable to format file due to bug in scalafmt +<<< #1599 2: modified, with partial func inside block +object A { + def foo() = { + x.map(_.y( + abcd, + {{ case ((abcdefghij, aswbasdfaw), asfda) => aswdf}}, + {{ case (abcdefghij, sadfasdass) => (asdfa.sadvfs(abcdefghij).get, asdfasdfasfdasda.asdfas(asdfasdaas).get) }}, + foo + )) + } +} +>>> +Unable to format file due to bug in scalafmt +<<< #1599 3: modified, with lambda +object A { + def foo() = { + x.map(_.y( + abcd, + { case_abcdefghij_aswbasdfaw_asfda => aswdf}, + { case_abcdefghij_sadfasdass => (asdfa.sadvfs(abcdefghij).get, asdfasdfasfdasda.asdfas(asdfasdaas).get) }, + foo + )) + } +} +>>> +Unable to format file due to bug in scalafmt diff --git a/scalafmt-tests/src/test/resources/vertical-multiline/VerticalMultilineDefnSite.stat b/scalafmt-tests/src/test/resources/vertical-multiline/VerticalMultilineDefnSite.stat index 0ebcc2895d..facc2571d7 100644 --- a/scalafmt-tests/src/test/resources/vertical-multiline/VerticalMultilineDefnSite.stat +++ b/scalafmt-tests/src/test/resources/vertical-multiline/VerticalMultilineDefnSite.stat @@ -14,3 +14,18 @@ def format_![T <: Tree]( )(implicit ev: Parse[T], ev2: EC ): String +<<< #1462 +maxColumn = 91 +=== +object Test { + + def create( + somethingInfo: foo.T = Something("my-something", Some("test-something"), "something", Some(Format("something", "something")), + Some(something.Something("something", "something", "something", "something"))) + ): Unit = { + w(foo) + } + +} +>>> +Unable to format file due to bug in scalafmt