Skip to content

Commit

Permalink
Add tests with break/paren/comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Sep 12, 2024
1 parent 151b018 commit c27b71e
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 0 deletions.
60 changes: 60 additions & 0 deletions scalafmt-tests/src/test/resources/default/Apply.stat
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,24 @@ SSLConfig(SSLLooseConfig(allowLegacyHelloMessages = None)/*comment 123 comment 2
)
) // comment 345 comment 456
}
<<< #1604 1: apply with then without assign, and attached comments, with breaks before paren/comment
{
val config = WSClientConfig(ssl =
SSLConfig(
SSLLooseConfig(allowLegacyHelloMessages =
None) /*comment 123 comment 234*/
)
) // comment 345 comment 456
}
>>>
{
val config = WSClientConfig(ssl =
SSLConfig(
SSLLooseConfig(allowLegacyHelloMessages =
None) /*comment 123 comment 234*/
)
) // comment 345 comment 456
}
<<< #1604 2: apply without then with assign, and attached comments
{
val config = WSClientConfig(
Expand All @@ -666,6 +684,24 @@ SSLConfig(loose = SSLLooseConfig(allowLegacyHelloMessages = None)/*comment 123 c
)
) // comment 345 comment 456
}
<<< #1604 2: apply without then with assign, and attached comments, with breaks before paren/comment
{
val config = WSClientConfig(
SSLConfig(loose =
SSLLooseConfig(allowLegacyHelloMessages =
None) /*comment 123 comment 234*/
)
) // comment 345 comment 456
}
>>>
{
val config = WSClientConfig(
SSLConfig(loose =
SSLLooseConfig(allowLegacyHelloMessages =
None) /*comment 123 comment 234*/
)
) // comment 345 comment 456
}
<<< #1604 3: apply with assign and attached comments
{
val config = WSClientConfig(ssl =
Expand All @@ -677,6 +713,18 @@ SSLConfig(loose = SSLLooseConfig(allowLegacyHelloMessages = None)/*comment 123 c
SSLLooseConfig(allowLegacyHelloMessages = None) /*comment 123 comment 234*/
)) // comment 345 comment 456
}
<<< #1604 3: apply with assign and attached comments, with breaks before paren/comment
{
val config = WSClientConfig(ssl = SSLConfig(loose =
SSLLooseConfig(allowLegacyHelloMessages = None) /*comment 123 comment 234*/
)) // comment 345 comment 456
}
>>>
{
val config = WSClientConfig(ssl = SSLConfig(loose =
SSLLooseConfig(allowLegacyHelloMessages = None) /*comment 123 comment 234*/
)) // comment 345 comment 456
}
<<< #1604 4: apply without assign and attached comments
{
val config = WSClientConfig(
Expand All @@ -688,6 +736,18 @@ SSLConfig(SSLLooseConfig(None)/*comment 123 comment 234*/)) //comment 345 commen
SSLConfig(SSLLooseConfig(None) /*comment 123 comment 234*/ )
) // comment 345 comment 456
}
<<< #1604 4: apply without assign and attached comments, with breaks before paren/comment
{
val config = WSClientConfig(
SSLConfig(SSLLooseConfig(None) /*comment 123 comment 234*/ )
) // comment 345 comment 456
}
>>>
{
val config = WSClientConfig(
SSLConfig(SSLLooseConfig(None) /*comment 123 comment 234*/ )
) // comment 345 comment 456
}
<<< comment in first arg, no newline
maxColumn = 28
===
Expand Down
38 changes: 38 additions & 0 deletions scalafmt-tests/src/test/resources/default/Idempotency.stat
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,44 @@ val bindingFuture = Http().bindAndHandleSync({
}
}
}
<<< akka 1, expanded
{
{
{
val bindingFuture = Http().bindAndHandleSync(
{ case HttpRequest(_, _, headers, _, _) ⇒
val upgrade = headers.collectFirst { case u: UpgradeToWebSocket ⇒
u
}.get
upgrade.handleMessages(
Flow.fromSinkAndSource(Sink.ignore,
Source.fromPublisher(source)),
None)
},
interface = "localhost",
port = 0)
}
}
}
>>>
{
{
{
val bindingFuture = Http().bindAndHandleSync(
{ case HttpRequest(_, _, headers, _, _) ⇒
val upgrade = headers.collectFirst { case u: UpgradeToWebSocket ⇒
u
}.get
upgrade.handleMessages(
Flow.fromSinkAndSource(Sink.ignore,
Source.fromPublisher(source)),
None)
},
interface = "localhost",
port = 0)
}
}
}
<<< raw-request idempotent
{{{{{{
RawRequestURI(new String(uriBytes, HttpCharsets.aaaaaaaaaa.nioCharset)) :: headers
Expand Down
50 changes: 50 additions & 0 deletions scalafmt-tests/src/test/resources/default/Select.stat
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,30 @@ private def extractRhino(e: js.Dynamic): js.Array[String] = {
) // Rhino has platform-dependent EOL's
.jsSplit("\n")
}
<<< rhino superfluous parenthesis, with breaks before paren/comment
private def extractRhino(e: js.Dynamic): js.Array[String] = {
(e.stack
.asInstanceOf[js.UndefOr[String]])
.getOrElse("")
.jsReplace("""^\s+at\s+""".re("gm"), "") // remove 'at' and indentation
.jsReplace("""^(.+?)(?: \((.+)\))?$""".re("gm"), "$2@$1")
.jsReplace("""\r\n?""".re("gm"),
"\n"
) // Rhino has platform-dependent EOL's
.jsSplit("\n")
}
>>>
private def extractRhino(e: js.Dynamic): js.Array[String] = {
(e.stack
.asInstanceOf[js.UndefOr[String]])
.getOrElse("")
.jsReplace("""^\s+at\s+""".re("gm"), "") // remove 'at' and indentation
.jsReplace("""^(.+?)(?: \((.+)\))?$""".re("gm"), "$2@$1")
.jsReplace("""\r\n?""".re("gm"),
"\n"
) // Rhino has platform-dependent EOL's
.jsSplit("\n")
}
<<< rhino superfluous parenthesis, align close
align.closeParenSite = true
===
Expand All @@ -129,6 +153,32 @@ private def extractRhino(e: js.Dynamic): js.Array[String] = {
) // Rhino has platform-dependent EOL's
.jsSplit("\n")
}
<<< rhino superfluous parenthesis, align close, with breaks before paren/comment
align.closeParenSite = true
===
private def extractRhino(e: js.Dynamic): js.Array[String] = {
(e.stack
.asInstanceOf[js.UndefOr[String]])
.getOrElse("")
.jsReplace("""^\s+at\s+""".re("gm"), "") // remove 'at' and indentation
.jsReplace("""^(.+?)(?: \((.+)\))?$""".re("gm"), "$2@$1")
.jsReplace("""\r\n?""".re("gm"),
"\n"
) // Rhino has platform-dependent EOL's
.jsSplit("\n")
}
>>>
private def extractRhino(e: js.Dynamic): js.Array[String] = {
(e.stack
.asInstanceOf[js.UndefOr[String]])
.getOrElse("")
.jsReplace("""^\s+at\s+""".re("gm"), "") // remove 'at' and indentation
.jsReplace("""^(.+?)(?: \((.+)\))?$""".re("gm"), "$2@$1")
.jsReplace("""\r\n?""".re("gm"),
"\n"
) // Rhino has platform-dependent EOL's
.jsSplit("\n")
}
<<< select is cheaper
new ReflectiveDynamicAccess(classLoader).createInstanceFor[ScalaFmtLike](
"org.scalafmt.ScalaFmt210", Seq.empty)
Expand Down
30 changes: 30 additions & 0 deletions scalafmt-tests/src/test/resources/optIn/SelectChains.stat
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,33 @@ val design: Design =
.bind[D3].toInstance(D3(3)) // Bind D3 to a concrete instance D3(3)
.bind[D3].toInstance(D3(3)).bind[D3].toInstance(D3(3)).bind[D3].toInstance(
D3(3)).bind[D3].toInstance(D3(3)).bind[D3].toInstance(D3(3))
<<< airframe, with breaks before paren/comment
val design: Design =
newDesign // Create an empty design
.bind[A].to[AImpl] // Bind a concrete class AImpl to A
.bind[B].toInstance(
new B(1)
) // Bind a concrete instance to B (This instance will be a singleton)
.bind[S].toSingleton // S will be a singleton within the session
.bind[ES].toEagerSingleton // ES will be initialized as a singleton at session start time
.bind[D1]
.toInstance(D1(1)) // Bind D1 to a concrete instance D1(1)
.bind[D2].toInstance(D2(2)) // Bind D2 to a concrete instance D2(2)
.bind[D3].toInstance(D3(3)) // Bind D3 to a concrete instance D3(3)
.bind[D3].toInstance(D3(3)).bind[D3].toInstance(D3(3)).bind[D3].toInstance(
D3(3)).bind[D3].toInstance(D3(3)).bind[D3].toInstance(D3(3))
>>>
val design: Design =
newDesign // Create an empty design
.bind[A].to[AImpl] // Bind a concrete class AImpl to A
.bind[B].toInstance(
new B(1)
) // Bind a concrete instance to B (This instance will be a singleton)
.bind[S].toSingleton // S will be a singleton within the session
.bind[ES].toEagerSingleton // ES will be initialized as a singleton at session start time
.bind[D1]
.toInstance(D1(1)) // Bind D1 to a concrete instance D1(1)
.bind[D2].toInstance(D2(2)) // Bind D2 to a concrete instance D2(2)
.bind[D3].toInstance(D3(3)) // Bind D3 to a concrete instance D3(3)
.bind[D3].toInstance(D3(3)).bind[D3].toInstance(D3(3)).bind[D3].toInstance(
D3(3)).bind[D3].toInstance(D3(3)).bind[D3].toInstance(D3(3))
20 changes: 20 additions & 0 deletions scalafmt-tests/src/test/resources/unit/Apply.stat
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ new DenseMatrix(
majorStride = from.majorStride,
isTranspose = !from.isTranspose)
>>>
new DenseMatrix(
data = from.data map {
_.conjugate
},
offset = from.offset,
cols = from.rows,
rows = from.cols,
majorStride = from.majorStride,
isTranspose = !from.isTranspose)
<<< Init, multiline map
new DenseMatrix(
data = from.data map {
_.conjugate
},
offset = from.offset,
cols = from.rows,
rows = from.cols,
majorStride = from.majorStride,
isTranspose = !from.isTranspose)
>>>
new DenseMatrix(
data = from.data map {
_.conjugate
Expand Down
18 changes: 18 additions & 0 deletions scalafmt-tests/src/test/resources/unit/Lambda.stat
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ Thing(implicit ctx => j => ???)
<<< long curried with ()
Thing(implicit ctx => j => k => aaaaaaaaaaaaa(bbbbbbbbbbbbbbbbbbb, cccccccccc, ddddddddddddddddddddj)) // coooooooooooooooomment
>>>
Thing(implicit ctx =>
j =>
k =>
aaaaaaaaaaaaa(
bbbbbbbbbbbbbbbbbbb,
cccccccccc,
ddddddddddddddddddddj
)) // coooooooooooooooomment
<<< long curried with (), with breaks before paren/comment
Thing(implicit ctx =>
j =>
k =>
aaaaaaaaaaaaa(
bbbbbbbbbbbbbbbbbbb,
cccccccccc,
ddddddddddddddddddddj
)) // coooooooooooooooomment
>>>
Thing(implicit ctx =>
j =>
k =>
Expand Down

0 comments on commit c27b71e

Please sign in to comment.