From 3b8205af14f0de3f32f23e644f856a4b9a620793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Wed, 12 May 2021 14:43:31 +0200 Subject: [PATCH 1/4] Scala 3.0.0 --- .github/workflows/ci.yml | 13 ++++++++++++- build.sbt | 6 ++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be64ae4..6e79913 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,7 @@ jobs: - 3.0.0-RC1 - 3.0.0-RC2 - 3.0.0-RC3 + - 3.0.0 java: [graalvm-ce-java11@20.3.0] runs-on: ${{ matrix.os }} steps: @@ -88,7 +89,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - scala: [3.0.0-RC3] + scala: [3.0.0] java: [graalvm-ce-java11@20.3.0] runs-on: ${{ matrix.os }} steps: @@ -244,6 +245,16 @@ jobs: tar xf targets.tar rm targets.tar + - name: Download target directories (3.0.0) + uses: actions/download-artifact@v2 + with: + name: target-${{ matrix.os }}-3.0.0-${{ matrix.java }} + + - name: Inflate target directories (3.0.0) + run: | + tar xf targets.tar + rm targets.tar + - uses: olafurpg/setup-gpg@v3 - run: sbt ++${{ matrix.scala }} ci-release \ No newline at end of file diff --git a/build.sbt b/build.sbt index cb424ca..62c539e 100644 --- a/build.sbt +++ b/build.sbt @@ -27,7 +27,7 @@ val GraalVM11 = "graalvm-ce-java11@20.3.0" // for dottydoc ThisBuild / resolvers += Resolver.JCenterRepository -ThisBuild / scalaVersion := "3.0.0-RC3" +ThisBuild / scalaVersion := "3.0.0" ThisBuild / crossScalaVersions := Seq( "2.12.10", "2.12.11", @@ -43,7 +43,8 @@ ThisBuild / crossScalaVersions := Seq( "3.0.0-M3", "3.0.0-RC1", "3.0.0-RC2", - "3.0.0-RC3" + "3.0.0-RC3", + "3.0.0" ) ThisBuild / githubWorkflowJavaVersions := Seq(GraalVM11) @@ -76,6 +77,7 @@ def scalatestVersion(scalaVersion: String) = case "3.0.0-M3" => "3.2.3" case "3.0.0-RC1" => "3.2.5" case "3.0.0-RC2" => "3.2.7" + case "3.0.0" => "3.2.9" //wishful thinking case _ => "3.2.8" } From 2401de8f57e73670159ebf7aa5c9c8848de2c202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Thu, 13 May 2021 16:43:53 +0200 Subject: [PATCH 2/4] Special-case 3.0.0 final --- build.sbt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 62c539e..8c7208c 100644 --- a/build.sbt +++ b/build.sbt @@ -88,7 +88,8 @@ val plugin = project.settings( crossVersion := CrossVersion.full, libraryDependencies ++= Seq( scalaOrganization.value % ( - if (scalaVersion.value.startsWith("3")) + if (scalaVersion.value == "3.0.0") "scala3-compiler_3" + else if (scalaVersion.value.startsWith("3")) s"scala3-compiler_${scalaVersion.value}" else "scala-compiler" ) % scalaVersion.value From 49d7d36714ce28a8f38e0ce8643e523ed7ab6a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Thu, 13 May 2021 17:40:54 +0200 Subject: [PATCH 3/4] Migrate tests to munit --- build.sbt | 11 +--- tests/src/test/scala/Demo.scala | 92 +++++++++++++++++++-------------- 2 files changed, 53 insertions(+), 50 deletions(-) diff --git a/build.sbt b/build.sbt index 8c7208c..6392ddb 100644 --- a/build.sbt +++ b/build.sbt @@ -72,15 +72,6 @@ val commonSettings = Seq( scalacOptions -= "-Xfatal-warnings" ) -def scalatestVersion(scalaVersion: String) = - scalaVersion match { - case "3.0.0-M3" => "3.2.3" - case "3.0.0-RC1" => "3.2.5" - case "3.0.0-RC2" => "3.2.7" - case "3.0.0" => "3.2.9" //wishful thinking - case _ => "3.2.8" - } - val plugin = project.settings( name := "better-tostring", commonSettings, @@ -108,7 +99,7 @@ val tests = project.settings( ) //borrowed from bm4 }, libraryDependencies ++= Seq( - "org.scalatest" %% "scalatest" % scalatestVersion(scalaVersion.value) % Test + "org.scalameta" %% "munit" % "0.7.26" % Test ) ) diff --git a/tests/src/test/scala/Demo.scala b/tests/src/test/scala/Demo.scala index d712593..2cb84a0 100644 --- a/tests/src/test/scala/Demo.scala +++ b/tests/src/test/scala/Demo.scala @@ -1,68 +1,78 @@ -import org.scalatest.matchers.should.Matchers -import org.scalatest.wordspec.AnyWordSpec +import munit.FunSuite -class Tests extends AnyWordSpec with Matchers { +class Tests extends FunSuite { - "Simple case class" should { - "stringify nicely" in { + test("Simple case class stringifies nicely") { + assertEquals( SimpleCaseClass( "Joe", 23 - ).toString shouldBe "SimpleCaseClass(name = Joe, age = 23)" - - } + ).toString, + "SimpleCaseClass(name = Joe, age = 23)" + ) } - "Case class with multiple parameter lists" should { - "only have the first list included" in { + test("Case class with multiple parameter lists only has the first list included") { + assertEquals( MultiParameterList("foo", 20)( "s" - ).toString shouldBe "MultiParameterList(name = foo, age = 20)" - } + ).toString, + "MultiParameterList(name = foo, age = 20)" + ) } - "Case class with custom toString" should { - "use it" in { - CustomTostring("Joe").toString shouldBe "***" - } + test("Case class with custom toString should not be overridden") { + assertEquals( + CustomTostring("Joe").toString, + "***" + ) } - "Method with alternate constructors" should { - "stringify based on primary constructor" in { + test("Method with alternate constructors should stringify based on primary constructor") { + assertEquals( new HasOtherConstructors( 10 - ).toString shouldBe "HasOtherConstructors(s = 10 beers)" - } + ).toString, + "HasOtherConstructors(s = 10 beers)" + ) } - "Class nested in an object" should { - "include enclosing object's name" in { - ObjectNestedParent.ObjectNestedClass("Joe").toString shouldBe "ObjectNestedParent.ObjectNestedClass(name = Joe)" - } + test("Class nested in an object should include enclosing object's name") { + assertEquals( + ObjectNestedParent.ObjectNestedClass("Joe").toString, + "ObjectNestedParent.ObjectNestedClass(name = Joe)" + ) } - "Class nested in a package object" should { - "not include package's name" in { - pack.InPackageObject("Joe").toString shouldBe "InPackageObject(name = Joe)" - } + test("Class nested in a package object should not include package's name") { + assertEquals( + pack.InPackageObject("Joe").toString, + "InPackageObject(name = Joe)" + ) } - "Class nested in another class" should { - "stringify normally" in { - new NestedParent().NestedChild("a").toString shouldBe "NestedChild(a)" - } + test("Class nested in another class should stringify normally") { + assertEquals( + new NestedParent().NestedChild("a").toString, + "NestedChild(a)" + ) } - "Class nested in an object itself nested in a class" should { - "stringify normally" in { - new DeeplyNestedInClassGrandparent().DeeplyNestedInClassParent.DeeplyNestedInClassClass("a").toString shouldBe "DeeplyNestedInClassClass(a)" - } + test("Class nested in an object itself nested in a class should stringify normally") { + assertEquals( + new DeeplyNestedInClassGrandparent() + .DeeplyNestedInClassParent + .DeeplyNestedInClassClass("a") + .toString, + "DeeplyNestedInClassClass(a)" + ) } - "Method-local class" should { - "stringify normally" in { - MethodLocalWrapper.methodLocalClassStringify shouldBe "LocalClass(a)" - } + test("Method-local class should stringify normally") { + assertEquals( + MethodLocalWrapper.methodLocalClassStringify, + "LocalClass(a)" + ) } } @@ -86,9 +96,11 @@ object ObjectNestedParent { } final class DeeplyNestedInClassGrandparent { + object DeeplyNestedInClassParent { case class DeeplyNestedInClassClass(name: String) } + } object MethodLocalWrapper { From 3fcf20101c39f7ebb09e524ce7c7a8fb695b9e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owski?= Date: Thu, 13 May 2021 17:45:09 +0200 Subject: [PATCH 4/4] fine, we'll use different versions --- build.sbt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 6392ddb..da154fa 100644 --- a/build.sbt +++ b/build.sbt @@ -99,7 +99,12 @@ val tests = project.settings( ) //borrowed from bm4 }, libraryDependencies ++= Seq( - "org.scalameta" %% "munit" % "0.7.26" % Test + "org.scalameta" %% "munit" % (scalaVersion.value match { + case "3.0.0-M3" => "0.7.22" + case "3.0.0-RC1" => "0.7.23" + case "3.0.0-RC2" => "0.7.25" + case _ => "0.7.26" + }) % Test ) )