diff --git a/shared/scalafmt.test.scala b/shared/scalafmt.test.scala index 9acc0b3..1d4c930 100644 --- a/shared/scalafmt.test.scala +++ b/shared/scalafmt.test.scala @@ -59,9 +59,18 @@ given Featureful[Indents] = Featureful.derive[Indents]( ) ) -given Featureful[ScalafmtRunner] = Featureful.derived +case class DialectOptions(dialectName: String) -type ScalafmtConfigSubset = (Docstrings, Comments, Indents, BinPack, OptIn) +given Featureful[DialectOptions] = Featureful.derive( + FieldConfig( + Map( + "dialectName" -> Feature.StringCategory(List("scala213", "scala3")) + ) + ) +) + +type ScalafmtConfigSubset = + (Docstrings, Comments, Indents, BinPack, OptIn, DialectOptions) class ScalafmtTest extends FunSuite: test("scalafmt"): @@ -74,6 +83,10 @@ class ScalafmtTest extends FunSuite: import com.github.vickumar1981.stringdistance.StringDistance.* import com.github.vickumar1981.stringdistance.impl.ConstantGap + val dialect = cfg._6.dialectName match + case "scala213" => scala.meta.dialects.Scala213 + case "scala3" => scala.meta.dialects.Scala3 + cache.computeIfAbsent( cfg, { _ => @@ -86,7 +99,7 @@ class ScalafmtTest extends FunSuite: indent = cfg._3, binPack = cfg._4, optIn = cfg._5 - ) + ).withDialect(dialect) ) .toEither .fold( @@ -111,7 +124,7 @@ class ScalafmtTest extends FunSuite: val trainingConfig = TrainingConfig( populationSize = 100, mutationRate = NormalisedFloat(0.8f), - steps = 5, + steps = 100, random = scala.util.Random(80085L), selection = Selection.Top(0.8) )