diff --git a/.travis.yml b/.travis.yml index 37717cdf..e954bfae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,14 +8,13 @@ scala: - 2.11.12 - 2.12.12 - 2.13.3 + - 3.0.0-M1 env: - SCALAJS_VERSION= ADOPTOPENJDK=8 - - SCALAJS_VERSION=0.6.33 ADOPTOPENJDK=8 - - SCALAJS_VERSION=1.3.0 ADOPTOPENJDK=8 + - SCALAJS_VERSION=1.3.1 ADOPTOPENJDK=8 - SCALAJS_VERSION= ADOPTOPENJDK=11 - - SCALAJS_VERSION=0.6.33 ADOPTOPENJDK=11 - - SCALAJS_VERSION=1.3.0 ADOPTOPENJDK=11 + - SCALAJS_VERSION=1.3.1 ADOPTOPENJDK=11 matrix: diff --git a/build.sbt b/build.sbt index 9248fdc5..04adfa5f 100644 --- a/build.sbt +++ b/build.sbt @@ -31,6 +31,8 @@ lazy val root = project compat212JS, compat213JVM, compat213JS, + compat30JVM, + compat30JS, `scalafix-data211`, `scalafix-data212`, `scalafix-data213`, @@ -51,6 +53,7 @@ lazy val junit = libraryDependencies += "com.novocode" % "junit-interface" % "0. lazy val scala211 = "2.11.12" lazy val scala212 = "2.12.12" lazy val scala213 = "2.13.3" +lazy val scala30 = "3.0.0-M1" lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform)( "compat", @@ -62,7 +65,7 @@ lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform scalacOptions ++= Seq("-feature", "-language:higherKinds", "-language:implicitConversions"), Compile / unmanagedSourceDirectories += { val sharedSourceDir = (ThisBuild / baseDirectory).value / "compat/src/main" - if (scalaVersion.value.startsWith("2.13.")) sharedSourceDir / "scala-2.13" + if (scalaVersion.value.startsWith("2.13.") || isDotty.value) sharedSourceDir / "scala-2.13" else sharedSourceDir / "scala-2.11_2.12" }, ) @@ -79,13 +82,16 @@ lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform }, ) .jsSettings( - scalacOptions += { - val x = (LocalRootProject / baseDirectory).value.toURI.toString - val y = "https://raw.githubusercontent.com/scala/scala-collection-compat/" + sys.process - .Process("git rev-parse HEAD") - .lineStream_! - .head - s"-P:scalajs:mapSourceURI:$x->$y/" + scalacOptions ++= { + if (isDotty.value) Seq() // Scala.js does not support -P with Scala 3: lampepfl/dotty#9783 + else { + val x = (LocalRootProject / baseDirectory).value.toURI.toString + val y = "https://raw.githubusercontent.com/scala/scala-collection-compat/" + sys.process + .Process("git rev-parse HEAD") + .lineStream_! + .head + Seq(s"-P:scalajs:mapSourceURI:$x->$y/") + } }, Test / fork := false // Scala.js cannot run forked tests ) @@ -102,6 +108,7 @@ lazy val compat = MultiScalaCrossProject(JSPlatform, JVMPlatform, NativePlatform val compat211 = compat(scala211) val compat212 = compat(scala212) val compat213 = compat(scala213) +val compat30 = compat(scala30) lazy val compat211JVM = compat211.jvm lazy val compat211JS = compat211.js @@ -110,6 +117,8 @@ lazy val compat212JVM = compat212.jvm lazy val compat212JS = compat212.js lazy val compat213JVM = compat213.jvm lazy val compat213JS = compat213.js +lazy val compat30JVM = compat30.jvm +lazy val compat30JS = compat30.js lazy val `binary-compat-old` = project .in(file("binary-compat/old")) diff --git a/compat/src/test/scala/test/scala/collection/ArraySeqTest.scala b/compat/src/test/scala/test/scala/collection/ArraySeqTest.scala index 12eae4ce..f2d8204a 100644 --- a/compat/src/test/scala/test/scala/collection/ArraySeqTest.scala +++ b/compat/src/test/scala/test/scala/collection/ArraySeqTest.scala @@ -14,6 +14,7 @@ package test.scala.collection import org.junit.{Assert, Test} +import scala.reflect.ClassTag import scala.collection.compat.immutable.ArraySeq // The unmodified ArraySeqTest from collection-strawman @@ -53,22 +54,22 @@ class ArraySeqTest { def unit1(): Unit = {} def unit2(): Unit = {} - Assert.assertEquals(unit1, unit2) + Assert.assertEquals(unit1(), unit2()) // unitArray is actually an instance of Immutable[BoxedUnit], the check to which is actually checked slice // implementation of ofRef - val unitArray: ArraySeq[Unit] = Array(unit1, unit2, unit1, unit2) - check(unitArray, Array(unit1, unit1), Array(unit1, unit1)) + val unitArray: ArraySeq[Unit] = Array(unit1(), unit2(), unit1(), unit2()) + check(unitArray, Array(unit1(), unit1()), Array(unit1(), unit1())) } private def check[T](array: ArraySeq[T], expectedSliceResult1: ArraySeq[T], - expectedSliceResult2: ArraySeq[T]) { + expectedSliceResult2: ArraySeq[T])(implicit elemTag: ClassTag[T]): Unit = { Assert.assertEquals(array, array.slice(-1, 4)) Assert.assertEquals(array, array.slice(0, 5)) Assert.assertEquals(array, array.slice(-1, 5)) Assert.assertEquals(expectedSliceResult1, array.slice(0, 2)) Assert.assertEquals(expectedSliceResult2, array.slice(1, 3)) - Assert.assertEquals(ArraySeq.empty[Nothing], array.slice(1, 1)) - Assert.assertEquals(ArraySeq.empty[Nothing], array.slice(2, 1)) + Assert.assertEquals(ArraySeq[T](), array.slice(1, 1)) + Assert.assertEquals(ArraySeq[T](), array.slice(2, 1)) } } diff --git a/compat/src/test/scala/test/scala/collection/LazyListLazinessTest.scala b/compat/src/test/scala/test/scala/collection/LazyListLazinessTest.scala index f9886b54..08cdaaf2 100644 --- a/compat/src/test/scala/test/scala/collection/LazyListLazinessTest.scala +++ b/compat/src/test/scala/test/scala/collection/LazyListLazinessTest.scala @@ -825,7 +825,6 @@ class LazyListLazinessTest { } @Test - @Ignore // TODO: enable after we drop Scala.js 0.6.x support def `#::_properlyLazy`(): Unit = { // genericCons_properlyLazy(_ #:: _) genericCons_properlyLazy((hd, tl) => tl.#::(hd)) diff --git a/compat/src/test/scala/test/scala/collection/LazyListTest.scala b/compat/src/test/scala/test/scala/collection/LazyListTest.scala index d5b56178..3126b55b 100644 --- a/compat/src/test/scala/test/scala/collection/LazyListTest.scala +++ b/compat/src/test/scala/test/scala/collection/LazyListTest.scala @@ -37,7 +37,7 @@ class LazyListTest { assertEquals(5, wf.map(identity).length) // success instead of NPE } - @Test(timeout = 10000) // scala/bug#6881 + @Test(timeout = 10000L) // scala/bug#6881 def test_reference_equality: Unit = { // Make sure we're tested with reference equality val s = LazyList.from(0) @@ -192,7 +192,7 @@ class LazyListTest { val cycle1: LazyList[Int] = 1 #:: 2 #:: cycle1 val cycle2: LazyList[Int] = 1 #:: 2 #:: 3 #:: cycle2 - @Test(timeout = 10000) + @Test(timeout = 10000L) def testSameElements(): Unit = { assert(LazyList().sameElements(LazyList())) assert(!LazyList().sameElements(LazyList(1))) diff --git a/project/MultiScalaProject.scala b/project/MultiScalaProject.scala index 0961aade..ff52206c 100644 --- a/project/MultiScalaProject.scala +++ b/project/MultiScalaProject.scala @@ -44,6 +44,7 @@ trait MultiScala { val sourceDir = (ThisBuild / baseDirectory).value / base / "src" / "main" CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, n)) if n >= 12 => List(sourceDir / "scala-2.12+") + case Some((3, _)) => List(sourceDir / "scala-2.13") case _ => Nil } }, diff --git a/project/plugins.sbt b/project/plugins.sbt index dddaab79..4deb4126 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,10 @@ val crossVer = "1.0.0" val scalaJSVersion = - Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("0.6.33") + Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("1.3.1") val scalaNativeVersion = Option(System.getenv("SCALANATIVE_VERSION")).filter(_.nonEmpty).getOrElse("0.3.9") +addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.6") addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion) addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % crossVer) addSbtPlugin("org.scala-native" % "sbt-scala-native" % scalaNativeVersion)