From a280f8a814cd46927ff4b792b63e4653538d4cf0 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Tue, 22 Jun 2021 22:36:31 +0100 Subject: [PATCH 01/23] Disable SJS 0.6, SN 0.4.0-M2 and update readme (#53) --- .github/workflows/release.yml | 2 -- README.md | 13 ++++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 05027a6..f6a2461 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,6 +27,4 @@ jobs: sudo apt-get update sudo apt install clang libunwind-dev libgc-dev libre2-dev sbt -v ci-release - env SCALAJS_VERSION="0.6.33" CI_RELEASE="clean;expectyJS2_11/publishSigned;expectyJS2_12/publishSigned;expectyJS/publishSigned" sbt -v ci-release - env SCALANATIVE_VERSION="0.4.0-M2" CI_RELEASE="clean;expectyNative2_11/publishSigned" sbt -v ci-release shell: bash diff --git a/README.md b/README.md index 1fb7041..f7b5449 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,21 @@ Expecty is licensed under the Apache 2 license. ## Setup +[![expecty Scala version support](https://index.scala-lang.org/eed3si9n/expecty/expecty/latest-by-scala-version.svg?color=orange)](https://index.scala-lang.org/eed3si9n/expecty/expecty) + ```scala -libraryDependencies += "com.eed3si9n.expecty" %% "expecty" % "0.15.1" % Test +libraryDependencies += "com.eed3si9n.expecty" %% "expecty" % "" % Test ``` +| Scala Version | JVM | JS (1.x) | Native (0.4.x) | +| ------------- | :-: | :------: | :------------: | +| 3.0.0 | ✅ | ✅ | n/a | +| 2.13.x | ✅ | ✅ | ✅ | +| 2.12.x | ✅ | ✅ | ✅ | +| 2.11.x | ✅ | ✅ | ✅ | + + + ## Code Examples ```scala From 54728d4a461e730d615ed33fa41f478d1f9fefcc Mon Sep 17 00:00:00 2001 From: Olivier Melois Date: Mon, 30 Aug 2021 15:39:18 +0200 Subject: [PATCH 02/23] Fix relativisation edge-case (Windows) There seem to be a pretty weird edge case where paths cannot be relativised because the compiled file is on another disk (for instance C:/) than the CWD (D:/). See https://github.com/VirtuslabRnD/scala-cli/pull/105/checks?check_run_id=3441114875 Checking that the roots match seem to do the trick --- src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala | 2 +- src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala b/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala index acf304c..3450f32 100644 --- a/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala +++ b/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala @@ -209,7 +209,7 @@ Instrumented AST: ${showRaw(instrumented)}") val p = context.enclosingPosition.source.path val abstractFile = context.enclosingPosition.source.file - val rp = if (!abstractFile.isVirtual) { + val rp = if (!abstractFile.isVirtual && pwd.getRoot() == abstractFile.file.toPath.getRoot()) { pwd.relativize(abstractFile.file.toPath()).toString() } else p diff --git a/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala b/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala index 6135dc2..7ed8c18 100644 --- a/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala +++ b/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala @@ -69,7 +69,7 @@ class RecorderMacro(using qctx0: Quotes) { val line = Expr(pos.endLine) val path = pos.sourceFile.jpath - if (path != null){ + if (path != null && path.getRoot() == pwd.getRoot()){ val file = path.toFile val pathExpr = Expr(path.toString) @@ -130,7 +130,7 @@ class RecorderMacro(using qctx0: Quotes) { } } - private[this] def isImplicitParameter(t: Term): Boolean = + private[this] def isImplicitParameter(t: Term): Boolean = t.symbol.flags.is(Flags.Given) || t.symbol.flags.is(Flags.Implicit) private[this] def recordSubValues(runtime: Term, expr: Term): Term = { @@ -152,10 +152,10 @@ class RecorderMacro(using qctx0: Quotes) { } case a @ Apply(x, ys) => try { - + if(ys.nonEmpty && ys.forall(isImplicitParameter)) Apply(recordSubValues(runtime, x), ys) - else + else Apply(recordSubValues(runtime, x), ys.map(recordAllValues(runtime, _))) } catch { case e: AssertionError => expr From ace4008c6433c48bd7acd2e710faaec8df676712 Mon Sep 17 00:00:00 2001 From: Olivier Melois Date: Tue, 31 Aug 2021 11:00:32 +0200 Subject: [PATCH 03/23] Adding comments regarding root checks --- src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala | 2 ++ src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala b/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala index 3450f32..19e61d8 100644 --- a/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala +++ b/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala @@ -209,6 +209,8 @@ Instrumented AST: ${showRaw(instrumented)}") val p = context.enclosingPosition.source.path val abstractFile = context.enclosingPosition.source.file + // Comparing roots to avoid the windows-specific edge case of relativisation crashing + // because the CWD and the source file are in two different drives (C:/ and D:/ for instance). val rp = if (!abstractFile.isVirtual && pwd.getRoot() == abstractFile.file.toPath.getRoot()) { pwd.relativize(abstractFile.file.toPath()).toString() } else p diff --git a/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala b/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala index 7ed8c18..37bc8c7 100644 --- a/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala +++ b/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala @@ -69,6 +69,8 @@ class RecorderMacro(using qctx0: Quotes) { val line = Expr(pos.endLine) val path = pos.sourceFile.jpath + // Comparing roots to avoid the windows-specific edge case of relativisation crashing + // because the CWD and the source file are in two different drives (C:/ and D:/ for instance). if (path != null && path.getRoot() == pwd.getRoot()){ val file = path.toFile From f1d8927e60b8e1ad570f6844c3ef83b4353aa509 Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Tue, 31 Aug 2021 10:21:28 +0100 Subject: [PATCH 04/23] publish on pushes to develop branch (#57) --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f6a2461..f2b9085 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,7 +1,7 @@ name: Release on: push: - branches: [master, main] + branches: [develop] tags: ["*"] jobs: publish: From 0af90390eb8d5b7dae31682c0b14efe019b689bc Mon Sep 17 00:00:00 2001 From: Anton Sviridov Date: Tue, 31 Aug 2021 10:25:10 +0100 Subject: [PATCH 05/23] Minimal reproduction and fix (#55) --- project/build.properties | 2 +- src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala | 7 ++++++- src/test/scala-3/ExpectyScala3Test.scala | 4 ++++ src/test/scala-3/Fixtures.scala | 7 +++++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/test/scala-3/Fixtures.scala diff --git a/project/build.properties b/project/build.properties index 19479ba..10fd9ee 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.2 +sbt.version=1.5.5 diff --git a/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala b/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala index 37bc8c7..2f55924 100644 --- a/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala +++ b/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala @@ -29,6 +29,7 @@ class RecorderMacro(using qctx0: Quotes) { listener: Expr[RecorderListener[A, R]])(using qctx0: Quotes): Expr[R] = { val termArgs: Seq[Term] = recordings.map(_.asTerm.underlyingArgument) + '{ val recorderRuntime: RecorderRuntime[A, R] = new RecorderRuntime($listener) recorderRuntime.recordMessage($message) @@ -164,7 +165,10 @@ class RecorderMacro(using qctx0: Quotes) { } // case TypeApply(x, ys) => recordValue(TypeApply.copy(expr)(recordSubValues(x), ys), expr) case TypeApply(x, ys) => TypeApply.copy(expr)(recordSubValues(runtime, x), ys) - case Select(x, y) => Select.copy(expr)(recordAllValues(runtime, x), y) + case Select(x, y) => + if(!x.symbol.flags.is(Flags.Package)) + Select.copy(expr)(recordAllValues(runtime, x), y) + else expr case Typed(x, tpe) => Typed.copy(expr)(recordSubValues(runtime, x), tpe) case Repeated(xs, y) => Repeated.copy(expr)(xs.map(recordAllValues(runtime, _)), y) case _ => expr @@ -200,6 +204,7 @@ class RecorderMacro(using qctx0: Quotes) { case sym if sym.isValDef => skipIdent(sym) case _ => true }) + expr match { case Select(_, _) if skipSelect(expr.symbol) => expr case TypeApply(_, _) => expr diff --git a/src/test/scala-3/ExpectyScala3Test.scala b/src/test/scala-3/ExpectyScala3Test.scala index 5af8d38..afff82f 100644 --- a/src/test/scala-3/ExpectyScala3Test.scala +++ b/src/test/scala-3/ExpectyScala3Test.scala @@ -64,5 +64,9 @@ object ExpectyScala3Test extends verify.BasicTestSuite { assert1(z.hello(50)(using ti2) == 50 -> 50) assert1(z.hello(128) == 25 -> 128) } + + test("Capturing package names correctly") { + assert1(cats.data.Chain(1, 2, 3).size == 3) + } } diff --git a/src/test/scala-3/Fixtures.scala b/src/test/scala-3/Fixtures.scala new file mode 100644 index 0000000..4f6bef5 --- /dev/null +++ b/src/test/scala-3/Fixtures.scala @@ -0,0 +1,7 @@ +package cats { + package data { + object Chain { + def apply[A](a: A*) : List[A] = List(a*) + } + } +} \ No newline at end of file From 399e82aa99d1af4c0efb009bedc38f4f130a86a5 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Mon, 14 Mar 2022 10:01:38 -0500 Subject: [PATCH 06/23] bump Scala versions (2.12.15, 2.13.8, 3.0.2) and Scala.js and the Scala version bumps require also bumping: * Scala.js (1.9.0; was 1.5.0) * Scala Native (1.4.4; was 1.4.0) --- build.sbt | 6 +++--- project/plugins.sbt | 6 ++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index 0708e62..af3fef4 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ val scala211 = "2.11.12" -val scala212 = "2.12.13" -val scala213 = "2.13.5" -val scala3 = "3.0.0" +val scala212 = "2.12.15" +val scala213 = "2.13.8" +val scala3 = "3.0.2" ThisBuild / scalaVersion := scala213 Global / semanticdbEnabled := true Global / semanticdbVersion := "4.4.17" diff --git a/project/plugins.sbt b/project/plugins.sbt index 87ce2cd..46539a8 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,7 @@ val scalaJSVersion = - Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.5.0") - -// 0.4.0-M2's BigDecimal doesn't work https://github.com/scala-native/scala-native/issues/1770 + Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.9.0") val scalaNativeVersion = - Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.4.0") + Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.4.4") addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.5") addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.6.0") From ca99c93b251ba8e3a6b6951eb002cdbef9d5ec7a Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Mon, 14 Mar 2022 10:01:46 -0500 Subject: [PATCH 07/23] sbt 1.6.2 (was 1.5.5) --- build.sbt | 2 +- project/build.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index af3fef4..c92f76a 100644 --- a/build.sbt +++ b/build.sbt @@ -39,7 +39,7 @@ lazy val expecty = (projectMatrix in file(".")) settings = Seq( libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test, Test / unmanagedSourceDirectories ++= { - Seq((baseDirectory in LocalRootProject).value / "jvm" / "src" / "test" / "scala") + Seq((LocalRootProject / baseDirectory).value / "jvm" / "src" / "test" / "scala") }, ) ) diff --git a/project/build.properties b/project/build.properties index 10fd9ee..c8fcab5 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.5.5 +sbt.version=1.6.2 From 510bf61468dcfaf662b50aa0e35896ca75db21d9 Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Mon, 14 Mar 2022 10:01:54 -0500 Subject: [PATCH 08/23] semanticdb 4.5.0 (was 4.4.17) --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index c92f76a..19de8e2 100644 --- a/build.sbt +++ b/build.sbt @@ -4,7 +4,7 @@ val scala213 = "2.13.8" val scala3 = "3.0.2" ThisBuild / scalaVersion := scala213 Global / semanticdbEnabled := true -Global / semanticdbVersion := "4.4.17" +Global / semanticdbVersion := "4.5.0" lazy val verify = "com.eed3si9n.verify" %% "verify" % "1.0.0" From 9f9679f9f942f237411e7e8bb9d400cd4733cc1f Mon Sep 17 00:00:00 2001 From: Seth Tisue Date: Mon, 14 Mar 2022 10:08:15 -0500 Subject: [PATCH 09/23] readme tweaks --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f7b5449..7c17802 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ libraryDependencies += "com.eed3si9n.expecty" %% "expecty" % " import com.eed3si9n.expecty.Expecty.assert From 237bab727d11123563e7be683e6adbfe00a1b577 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 14 Mar 2022 20:15:08 +0100 Subject: [PATCH 10/23] Update sbt-projectmatrix to 0.9.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 87ce2cd..55e35ac 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -6,7 +6,7 @@ val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.4.0") addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.5") -addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.6.0") +addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion) addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0") From 389ed2805b1121b9092b07a485d8272a886327c7 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 14 Mar 2022 20:15:22 +0100 Subject: [PATCH 11/23] Update sbt-ci-release to 1.5.7 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 87ce2cd..e84d265 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,7 +5,7 @@ val scalaJSVersion = val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.4.0") -addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.5") +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.6.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion) From fbcc28d0cb0308df85697a198bf8f91b50c71d9c Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 14 Mar 2022 20:15:29 +0100 Subject: [PATCH 12/23] Update junit-interface to 0.13.3 --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 0708e62..ddc5507 100644 --- a/build.sbt +++ b/build.sbt @@ -37,7 +37,7 @@ lazy val expecty = (projectMatrix in file(".")) .jvmPlatform( scalaVersions = Seq(scala213, scala212, scala211, scala3), settings = Seq( - libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test, + libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.3" % Test, Test / unmanagedSourceDirectories ++= { Seq((baseDirectory in LocalRootProject).value / "jvm" / "src" / "test" / "scala") }, From d552b9ddbaf95b8a65aff3d0f024a87ef44d1dc7 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Mon, 14 Mar 2022 20:16:52 +0100 Subject: [PATCH 13/23] Update sbt-scalafmt to 2.4.6 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 87ce2cd..6b69d37 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -9,4 +9,4 @@ addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.5") addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.6.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion) -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") From 515956a8144d33266df4d4033cae432f4f29bda0 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sun, 20 Mar 2022 04:20:17 +0100 Subject: [PATCH 14/23] Update sbt-ci-release to 1.5.10 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index b1781a0..90da05f 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -3,7 +3,7 @@ val scalaJSVersion = val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.4.4") -addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7") +addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.0") addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion) From 165d1781c6f16d69837c5891aa75a096db31ef5e Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Tue, 5 Apr 2022 02:23:23 +0200 Subject: [PATCH 15/23] Update sbt-scalajs, scalajs-compiler, ... to 1.10.0 --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index 90da05f..d26786b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ val scalaJSVersion = - Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.9.0") + Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.10.0") val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.4.4") From aef1f64d4cca43dd6fcb54156fcb307984e1ee50 Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Wed, 6 Jul 2022 17:09:38 +0200 Subject: [PATCH 16/23] Update sbt-scalajs, scalajs-compiler, ... to 1.10.1 (#84) --- project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/plugins.sbt b/project/plugins.sbt index d26786b..c055e92 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,5 @@ val scalaJSVersion = - Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.10.0") + Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.10.1") val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.4.4") From f18a2b06ba8b7c270eb0522de95dd585e97707ab Mon Sep 17 00:00:00 2001 From: Scala Steward <43047562+scala-steward@users.noreply.github.com> Date: Tue, 12 Jul 2022 01:17:45 +0200 Subject: [PATCH 17/23] Update sbt to 1.7.0 (#89) --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index c8fcab5..5b12c1d 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.6.2 +sbt.version=1.7.0 From c7592c2317a4cfa4be90fa63606a406ed43ec5af Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Wed, 13 Jul 2022 17:32:59 +0000 Subject: [PATCH 18/23] Update sbt to 1.7.1 --- project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/build.properties b/project/build.properties index 5b12c1d..22af262 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.7.0 +sbt.version=1.7.1 From 64632b048cca53c02cdb3a7993e5a07cf9f98121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Wed, 14 Sep 2022 05:24:37 +0200 Subject: [PATCH 19/23] Enable support for the Scala3/Native combo This bumps Scala 3 to 3.2, but fixes emitted version to 3.1. --- .gitignore | 2 ++ build.sbt | 13 +++++++++---- project/plugins.sbt | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index dee0fae..41fbe51 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ bin/ *.ipr *.iws .bsp/ +.metals +.vscode diff --git a/build.sbt b/build.sbt index 2cc269e..225e630 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,8 @@ val scala211 = "2.11.12" val scala212 = "2.12.15" val scala213 = "2.13.8" -val scala3 = "3.0.2" +val scala3 = "3.1.2" +val scalaFull = Seq(scala213, scala212, scala211, scala3) ThisBuild / scalaVersion := scala213 Global / semanticdbEnabled := true Global / semanticdbVersion := "4.5.0" @@ -27,6 +28,10 @@ lazy val expecty = (projectMatrix in file(".")) .settings( name := "Expecty", scalacOptions ++= Seq("-Yrangepos", "-feature", "-deprecation"), + scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match { + case Some((3, _)) => Seq("-scala-output-version", "3.1") + case _ => Nil + }), libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, _)) => Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value) case _ => Nil @@ -35,7 +40,7 @@ lazy val expecty = (projectMatrix in file(".")) testFrameworks += new TestFramework("verify.runner.Framework"), ) .jvmPlatform( - scalaVersions = Seq(scala213, scala212, scala211, scala3), + scalaVersions = scalaFull, settings = Seq( libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.3" % Test, Test / unmanagedSourceDirectories ++= { @@ -43,8 +48,8 @@ lazy val expecty = (projectMatrix in file(".")) }, ) ) - .jsPlatform(scalaVersions = Seq(scala213, scala212, scala211, scala3)) - .nativePlatform(scalaVersions = Seq(scala211, scala212, scala213)) + .jsPlatform(scalaVersions = scalaFull) + .nativePlatform(scalaVersions = scalaFull) lazy val expecty3 = expecty .jvm(scala3) diff --git a/project/plugins.sbt b/project/plugins.sbt index c055e92..90ecca4 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,7 +1,7 @@ val scalaJSVersion = Option(System.getenv("SCALAJS_VERSION")).getOrElse("1.10.1") val scalaNativeVersion = - Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.4.4") + Option(System.getenv("SCALANATIVE_VERSION")).getOrElse("0.4.7") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10") addSbtPlugin("com.eed3si9n" % "sbt-projectmatrix" % "0.9.0") From c578a68e444bed9b3f48b11c3711c3d54275a083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Wed, 14 Sep 2022 05:36:43 +0200 Subject: [PATCH 20/23] Bump and reconfigure scalafmt to work with Scala 3 --- .../test/scala/org/expecty/ExpectySpec.scala | 2 +- .../com/eed3si9n/expecty/RecorderMacro.scala | 4 +- .../eed3si9n/expecty/AssertEqualsMacro.scala | 28 ++-- .../com/eed3si9n/expecty/Recorder.scala | 24 ++-- .../com/eed3si9n/expecty/RecorderMacro.scala | 129 +++++++++--------- .../scala/com/eed3si9n/expecty/DiffUtil.scala | 14 +- src/test/scala-3/ExpectyScala3Test.scala | 17 +-- src/test/scala-3/Fixtures.scala | 4 +- 8 files changed, 110 insertions(+), 112 deletions(-) diff --git a/jvm/src/test/scala/org/expecty/ExpectySpec.scala b/jvm/src/test/scala/org/expecty/ExpectySpec.scala index 5ac9fd0..a389925 100644 --- a/jvm/src/test/scala/org/expecty/ExpectySpec.scala +++ b/jvm/src/test/scala/org/expecty/ExpectySpec.scala @@ -61,7 +61,7 @@ class ExpectySpec { ) } - //TODO: needs assertion + // TODO: needs assertion // @Test(expected = classOf[AssertionError]) // def lateFailingExpectation(): Unit = { // def expect = new Expecty(failEarly = false) diff --git a/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala b/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala index 19e61d8..d601eff 100644 --- a/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala +++ b/src/main/scala-2/com/eed3si9n/expecty/RecorderMacro.scala @@ -144,8 +144,8 @@ Instrumented AST: ${showRaw(instrumented)}") case Literal(_) => expr // don't record // don't record value of implicit "this" added by compiler; couldn't find a better way to detect implicit "this" than via point case Select(x @ This(_), y) if getPosition(expr).point == getPosition(x).point => expr - case x: Select if x.symbol.isModule => expr // don't try to record the value of packages - case Apply(_, _) if expr.symbol.isImplicit => recordSubValues(expr) + case x: Select if x.symbol.isModule => expr // don't try to record the value of packages + case Apply(_, _) if expr.symbol.isImplicit => recordSubValues(expr) case _ => val sub = recordSubValues(expr) val res = recordValue(sub, expr) diff --git a/src/main/scala-3/com/eed3si9n/expecty/AssertEqualsMacro.scala b/src/main/scala-3/com/eed3si9n/expecty/AssertEqualsMacro.scala index a15924f..e4803d9 100644 --- a/src/main/scala-3/com/eed3si9n/expecty/AssertEqualsMacro.scala +++ b/src/main/scala-3/com/eed3si9n/expecty/AssertEqualsMacro.scala @@ -1,23 +1,23 @@ /* -* Copyright 2021 the original author or authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright 2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.eed3si9n.expecty trait AssertEquals[R] { def stringAssertEqualsListener: RecorderListener[String, R] - inline def assertEquals(expected: String, found: String): R = + inline def assertEquals(expected: String, found: String): R = ${ StringRecorderMacro.apply('expected, 'found, 'stringAssertEqualsListener) } - inline def assertEquals(expected: String, found: String, message: => String): R = + inline def assertEquals(expected: String, found: String, message: => String): R = ${ StringRecorderMacro.apply('expected, 'found, 'message, 'stringAssertEqualsListener) } } diff --git a/src/main/scala-3/com/eed3si9n/expecty/Recorder.scala b/src/main/scala-3/com/eed3si9n/expecty/Recorder.scala index b51a752..c30c396 100644 --- a/src/main/scala-3/com/eed3si9n/expecty/Recorder.scala +++ b/src/main/scala-3/com/eed3si9n/expecty/Recorder.scala @@ -1,16 +1,16 @@ /* -* Copyright 2012 the original author or authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright 2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.eed3si9n.expecty import language.experimental.macros diff --git a/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala b/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala index 2f55924..0b7aacc 100644 --- a/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala +++ b/src/main/scala-3/com/eed3si9n/expecty/RecorderMacro.scala @@ -1,16 +1,16 @@ /* -* Copyright 2012 the original author or authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* http://www.apache.org/licenses/LICENSE-2.0 -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Copyright 2012 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.eed3si9n.expecty import scala.quoted._ @@ -23,13 +23,11 @@ class RecorderMacro(using qctx0: Quotes) { private[this] val runtimeSym: Symbol = TypeRepr.of[RecorderRuntime[_, _]].typeSymbol - def apply[A: Type, R: Type]( - recordings: Seq[Expr[A]], - message: Expr[String], - listener: Expr[RecorderListener[A, R]])(using qctx0: Quotes): Expr[R] = { + def apply[A: Type, R: Type](recordings: Seq[Expr[A]], message: Expr[String], listener: Expr[RecorderListener[A, R]])( + using qctx0: Quotes + ): Expr[R] = { val termArgs: Seq[Term] = recordings.map(_.asTerm.underlyingArgument) - '{ val recorderRuntime: RecorderRuntime[A, R] = new RecorderRuntime($listener) recorderRuntime.recordMessage($message) @@ -46,7 +44,8 @@ class RecorderMacro(using qctx0: Quotes) { expected: Expr[A], found: Expr[A], message: Expr[String], - listener: Expr[RecorderListener[A, R]]): Expr[R] = { + listener: Expr[RecorderListener[A, R]] + ): Expr[R] = { val expectedArg: Term = expected.asTerm.underlyingArgument val foundArg: Term = found.asTerm.underlyingArgument @@ -56,7 +55,7 @@ class RecorderMacro(using qctx0: Quotes) { ${ Block( recordExpressions('{ recorderRuntime }.asTerm, expectedArg) ::: - recordExpressions('{ recorderRuntime }.asTerm, foundArg), + recordExpressions('{ recorderRuntime }.asTerm, foundArg), '{ recorderRuntime.completeRecording() }.asTerm ).asExprOf[R] } @@ -66,22 +65,22 @@ class RecorderMacro(using qctx0: Quotes) { private[this] def getSourceLocation(expr: Tree) = { val pos = expr.pos - val pwd = java.nio.file.Paths.get("").toAbsolutePath + val pwd = java.nio.file.Paths.get("").toAbsolutePath val line = Expr(pos.endLine) val path = pos.sourceFile.jpath // Comparing roots to avoid the windows-specific edge case of relativisation crashing // because the CWD and the source file are in two different drives (C:/ and D:/ for instance). - if (path != null && path.getRoot() == pwd.getRoot()){ + if (path != null && path.getRoot() == pwd.getRoot()) { val file = path.toFile val pathExpr = Expr(path.toString) val relativePath = Expr(pwd.relativize(path).toString()) val fileName = Expr(file.getName) - '{Location(${pathExpr}, ${relativePath}, ${line})}.asTerm + '{ Location(${ pathExpr }, ${ relativePath }, ${ line }) }.asTerm } else { - '{Location("", "", ${line})}.asTerm + '{ Location("", "", ${ line }) }.asTerm } } @@ -100,8 +99,8 @@ class RecorderMacro(using qctx0: Quotes) { recordExpression(runtime, source, ast, recording, sourceLoc) ) } catch { - case e: Throwable => throw new RuntimeException( - "Expecty: Error rewriting expression.\nText: " + source + "\nAST : " + ast, e) + case e: Throwable => + throw new RuntimeException("Expecty: Error rewriting expression.\nText: " + source + "\nAST : " + ast, e) } } @@ -112,22 +111,24 @@ class RecorderMacro(using qctx0: Quotes) { val m = runtimeSym.memberMethod("recordExpression").head runtime.select(m) } - Apply(recordExpressionSel, + Apply( + recordExpressionSel, List( Literal(StringConstant(source)), Literal(StringConstant(ast)), instrumented, loc - )) + ) + ) } private[this] def recordAllValues(runtime: Term, expr: Term): Term = { expr match { - case New(_) => expr - case Literal(_) => expr + case New(_) => expr + case Literal(_) => expr case Typed(r @ Repeated(xs, y), tpe) => Typed.copy(r)(recordSubValues(runtime, r), tpe) // don't record value of implicit "this" added by compiler; couldn't find a better way to detect implicit "this" than via point - case Select(x@This(_), y) if expr.pos.start == x.pos.start => expr + case Select(x @ This(_), y) if expr.pos.start == x.pos.start => expr // case x: Select if x.symbol.isModule => expr // don't try to record the value of packages case _ => recordValue(runtime, recordSubValues(runtime, expr), expr) } @@ -156,7 +157,7 @@ class RecorderMacro(using qctx0: Quotes) { case a @ Apply(x, ys) => try { - if(ys.nonEmpty && ys.forall(isImplicitParameter)) + if (ys.nonEmpty && ys.forall(isImplicitParameter)) Apply(recordSubValues(runtime, x), ys) else Apply(recordSubValues(runtime, x), ys.map(recordAllValues(runtime, _))) @@ -165,17 +166,17 @@ class RecorderMacro(using qctx0: Quotes) { } // case TypeApply(x, ys) => recordValue(TypeApply.copy(expr)(recordSubValues(x), ys), expr) case TypeApply(x, ys) => TypeApply.copy(expr)(recordSubValues(runtime, x), ys) - case Select(x, y) => - if(!x.symbol.flags.is(Flags.Package)) + case Select(x, y) => + if (!x.symbol.flags.is(Flags.Package)) Select.copy(expr)(recordAllValues(runtime, x), y) else expr - case Typed(x, tpe) => Typed.copy(expr)(recordSubValues(runtime, x), tpe) - case Repeated(xs, y) => Repeated.copy(expr)(xs.map(recordAllValues(runtime, _)), y) - case _ => expr + case Typed(x, tpe) => Typed.copy(expr)(recordSubValues(runtime, x), tpe) + case Repeated(xs, y) => Repeated.copy(expr)(xs.map(recordAllValues(runtime, _)), y) + case _ => expr } } - private[this] def isImplicitMethod(t : Apply): Boolean = { + private[this] def isImplicitMethod(t: Apply): Boolean = { t.symbol.flags.is(Flags.Implicit) } @@ -191,10 +192,10 @@ class RecorderMacro(using qctx0: Quotes) { case sym if sym.isDefDef => sym.signature.paramSigs.nonEmpty case _ => sym.fullName match { - case "scala" | "java" => true + case "scala" | "java" => true case fullName if fullName.startsWith("scala.") => true case fullName if fullName.startsWith("java.") => true - case _ => false + case _ => false } } @@ -202,14 +203,14 @@ class RecorderMacro(using qctx0: Quotes) { (sym match { case sym if sym.isDefDef => skipIdent(sym) case sym if sym.isValDef => skipIdent(sym) - case _ => true + case _ => true }) - + expr match { case Select(_, _) if skipSelect(expr.symbol) => expr - case TypeApply(_, _) => expr - case Ident(_) if skipIdent(expr.symbol) => expr - case a @ Apply(_, _) if isImplicitMethod(a) => expr + case TypeApply(_, _) => expr + case Ident(_) if skipIdent(expr.symbol) => expr + case a @ Apply(_, _) if isImplicitMethod(a) => expr case _ => val tapply = recordValueSel.appliedToType(expr.tpe) Apply.copy(expr)( @@ -233,48 +234,46 @@ class RecorderMacro(using qctx0: Quotes) { getAnchor(ys.head) case Apply(x, ys) => getAnchor(x) + 0 case TypeApply(x, ys) => getAnchor(x) + 0 - case Select(x, y) => + case Select(x, y) => expr.pos.startColumn + math.max(0, expr.pos.sourceCode.get.indexOf(y)) - case _ => expr.pos.startColumn + case _ => expr.pos.startColumn } } object RecorderMacro { - def apply[A: Type, R: Type]( - recording: Expr[A], - listener: Expr[RecorderListener[A, R]])(using qctx: Quotes): Expr[R] = - new RecorderMacro().apply(Seq(recording), '{""}, listener) + def apply[A: Type, R: Type](recording: Expr[A], listener: Expr[RecorderListener[A, R]])(using qctx: Quotes): Expr[R] = + new RecorderMacro().apply(Seq(recording), '{ "" }, listener) /** captures a method invocation in the shape of assert(expr, message). */ - def apply[A: Type, R: Type]( - recording: Expr[A], - message: Expr[String], - listener: Expr[RecorderListener[A, R]])(using qctx: Quotes): Expr[R] = + def apply[A: Type, R: Type](recording: Expr[A], message: Expr[String], listener: Expr[RecorderListener[A, R]])(using + qctx: Quotes + ): Expr[R] = new RecorderMacro().apply(Seq(recording), message, listener) - def varargs[A: Type, R: Type]( - recordings: Expr[Seq[A]], - listener: Expr[RecorderListener[A, R]])(using qctx: Quotes): Expr[R] = { + def varargs[A: Type, R: Type](recordings: Expr[Seq[A]], listener: Expr[RecorderListener[A, R]])(using + qctx: Quotes + ): Expr[R] = { import qctx.reflect._ - //!\ only works because we're expecting the macro to expand `R*` + // !\ only works because we're expecting the macro to expand `R*` val Varargs(unTraversedRecordings) = recordings - new RecorderMacro().apply(unTraversedRecordings, '{""}, listener) + new RecorderMacro().apply(unTraversedRecordings, '{ "" }, listener) } } object StringRecorderMacro { + /** captures a method invocation in the shape of assertEquals(expected, found). */ - def apply[R: Type]( - expected: Expr[String], - found: Expr[String], - listener: Expr[RecorderListener[String, R]])(using qctx: Quotes): Expr[R] = - new RecorderMacro().apply2[String, R](expected, found, '{""}, listener) + def apply[R: Type](expected: Expr[String], found: Expr[String], listener: Expr[RecorderListener[String, R]])(using + qctx: Quotes + ): Expr[R] = + new RecorderMacro().apply2[String, R](expected, found, '{ "" }, listener) /** captures a method invocation in the shape of assertEquals(expected, found). */ def apply[R: Type]( expected: Expr[String], found: Expr[String], message: Expr[String], - listener: Expr[RecorderListener[String, R]])(using qctx: Quotes): Expr[R] = + listener: Expr[RecorderListener[String, R]] + )(using qctx: Quotes): Expr[R] = new RecorderMacro().apply2[String, R](expected, found, message, listener) } diff --git a/src/main/scala/com/eed3si9n/expecty/DiffUtil.scala b/src/main/scala/com/eed3si9n/expecty/DiffUtil.scala index 31c5386..dc60cd2 100644 --- a/src/main/scala/com/eed3si9n/expecty/DiffUtil.scala +++ b/src/main/scala/com/eed3si9n/expecty/DiffUtil.scala @@ -72,13 +72,15 @@ object DiffUtil { } /** - * Return a colored diff between the tokens of every line in `expected` and `actual`. Each line of - * output contains the expected value on the left and the actual value on the right. + * Return a colored diff between the tokens of every line in `expected` and `actual`. Each line of output contains the + * expected value on the left and the actual value on the right. * - * @param expected The expected lines - * @param actual The actual lines - * @return A string with one element of `expected` and `actual` on each lines, where - * differences are highlighted. + * @param expected + * The expected lines + * @param actual + * The actual lines + * @return + * A string with one element of `expected` and `actual` on each lines, where differences are highlighted. */ def mkColoredLineDiff(expected: Seq[String], actual: Seq[String]): String = { val diffs = diff --git a/src/test/scala-3/ExpectyScala3Test.scala b/src/test/scala-3/ExpectyScala3Test.scala index afff82f..e9a421a 100644 --- a/src/test/scala-3/ExpectyScala3Test.scala +++ b/src/test/scala-3/ExpectyScala3Test.scala @@ -22,25 +22,23 @@ object ExpectyScala3Test extends verify.BasicTestSuite { val name = "Hi from Expecty!" - trait Eq[T]: - def eq(x: T, y: T): Boolean + trait Eq[T]: + def eq(x: T, y: T): Boolean - object Eq: - given Eq[Int] with - def eq(x: Int, y: Int) = (x - y) == 0 + object Eq: + given Eq[Int] with + def eq(x: Int, y: Int) = (x - y) == 0 test("scala 3 extension (1)") { // Regression test for https://github.com/eed3si9n/expecty/issues/50 - extension [T](i: T)(using eq: Eq[T]) - def ===(other: T) = eq.eq(i, other) + extension [T](i: T)(using eq: Eq[T]) def ===(other: T) = eq.eq(i, other) assert1("abc".length() === 3) } test("scala 3 extension (2)") { // Regression test for https://github.com/eed3si9n/expecty/issues/50 - extension [T](i: T) - def ===(other: T)(using eq: Eq[T]) = eq.eq(i, other) + extension [T](i: T) def ===(other: T)(using eq: Eq[T]) = eq.eq(i, other) assert1("abc".length() === 3) } @@ -69,4 +67,3 @@ object ExpectyScala3Test extends verify.BasicTestSuite { assert1(cats.data.Chain(1, 2, 3).size == 3) } } - diff --git a/src/test/scala-3/Fixtures.scala b/src/test/scala-3/Fixtures.scala index 4f6bef5..b8328c4 100644 --- a/src/test/scala-3/Fixtures.scala +++ b/src/test/scala-3/Fixtures.scala @@ -1,7 +1,7 @@ package cats { package data { object Chain { - def apply[A](a: A*) : List[A] = List(a*) + def apply[A](a: A*): List[A] = List(a*) } } -} \ No newline at end of file +} From 98d53cb5e1a5e7423d0fa2421af5235b9de0dfef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Wed, 14 Sep 2022 05:39:42 +0200 Subject: [PATCH 21/23] Forgot .scalafmt.conf --- .scalafmt.conf | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index ecb5c8d..f4cabb1 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,5 @@ -version = "2.7.5" +version = "3.1.2" +runner.dialect = scala213 preset=default maxColumn = 120 project.git = true @@ -6,7 +7,7 @@ lineEndings = preserve # https://docs.scala-lang.org/style/scaladoc.html recommends the JavaDoc style. # scala/scala is written that way too https://github.com/scala/scala/blob/v2.12.2/src/library/scala/Predef.scala -docstrings = JavaDoc +docstrings.style = Asterisk # This also seems more idiomatic to include whitespace in import x.{ yyy } spaces.inImportCurlyBraces = true @@ -15,8 +16,15 @@ spaces.inImportCurlyBraces = true # https://docs.scala-lang.org/style/indentation.html#methods-with-numerous-arguments align.openParenCallSite = false align.openParenDefnSite = false +align.preset = more danglingParentheses.defnSite = true danglingParentheses.callSite = true trailingCommas = preserve + +fileOverride { + "glob:**/scala-3/**.scala" { + runner.dialect = scala3 + } +} From db804238a90d01826249861a2dd4bbd1402e39b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Wed, 14 Sep 2022 05:42:48 +0200 Subject: [PATCH 22/23] Remove align.preset --- .scalafmt.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index f4cabb1..908600f 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -16,7 +16,6 @@ spaces.inImportCurlyBraces = true # https://docs.scala-lang.org/style/indentation.html#methods-with-numerous-arguments align.openParenCallSite = false align.openParenDefnSite = false -align.preset = more danglingParentheses.defnSite = true danglingParentheses.callSite = true From e56a81cc2dfa645137560f040e3629902884eb1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Wed, 14 Sep 2022 11:18:51 +0200 Subject: [PATCH 23/23] Remove scala target --- build.sbt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build.sbt b/build.sbt index 225e630..3ddbe17 100644 --- a/build.sbt +++ b/build.sbt @@ -28,10 +28,6 @@ lazy val expecty = (projectMatrix in file(".")) .settings( name := "Expecty", scalacOptions ++= Seq("-Yrangepos", "-feature", "-deprecation"), - scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match { - case Some((3, _)) => Seq("-scala-output-version", "3.1") - case _ => Nil - }), libraryDependencies ++= (CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, _)) => Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value) case _ => Nil