Skip to content

Commit

Permalink
TestStyles: add [un]foldWithRewritesAndOverflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 9, 2024
1 parent 04be0dd commit 1915a55
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ private[community] object TestStyles {
),
)

def withOverflow(types: Newlines.AvoidForSimpleOverflow*): ScalafmtConfig =
style.copy(newlines = style.newlines.copy(avoidForSimpleOverflow = types))

}

private val baseKeepStyle = baseClassicStyle.withSource(Newlines.keep)
private val baseFoldStyle = baseClassicStyle.withSource(Newlines.fold)
private val baseUnfoldStyle = baseClassicStyle.withSource(Newlines.unfold)

val classic = baseClassicStyle
val classicWithRewrites = baseClassicStyle.withRewrites()
Expand All @@ -55,7 +59,11 @@ private[community] object TestStyles {
val keepWithAlign = baseKeepStyle.withAlign(Align.most)
val keepWithScalaJS = baseKeepStyle.forScalaJs
val fold = baseFoldStyle
val unfold = baseClassicStyle.withSource(Newlines.unfold)
val foldWithRewritesAndOverflow = baseFoldStyle.withRewrites()
.withOverflow(Newlines.AvoidForSimpleOverflow.all.map(_.value): _*)
val unfold = baseUnfoldStyle
val unfoldWithRewritesAndOverflow = baseUnfoldStyle.withRewrites()
.withOverflow(Newlines.AvoidForSimpleOverflow.all.map(_.value): _*)

val stylesWithLabels = Seq[sourcecode.Text[ScalafmtConfig]](
classic,
Expand All @@ -66,7 +74,9 @@ private[community] object TestStyles {
keepWithAlign,
keepWithScalaJS,
fold,
foldWithRewritesAndOverflow,
unfold,
unfoldWithRewritesAndOverflow,
)
val styles: Map[String, ScalafmtConfig] =
SortedMap(stylesWithLabels.map(x => x.source -> x.value): _*)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.scalafmt.community.other

import org.scalafmt.community.common.CommunityRepoSuite
import org.scalafmt.community.common.TestStyles

import scala.meta._

Expand All @@ -9,7 +10,12 @@ abstract class CommunityScalaJsSuite(name: String)

class CommunityScalaJs1_17Suite extends CommunityScalaJsSuite("scala-js-1.17") {

override protected def builds =
Seq(getBuild("v1.17.0", dialects.Scala213, 787))
override protected def builds = Seq(getBuild(
"v1.17.0",
dialects.Scala213,
787,
styles = Seq(TestStyles.foldWithRewritesAndOverflow),
stylesIncluded = false,
))

}

0 comments on commit 1915a55

Please sign in to comment.