From b0b7b33f5b3d765f0712ede80f281f0c357927ae Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Thu, 29 Jul 2021 19:54:57 +0000 Subject: [PATCH 1/7] Support java.time arbitraries on Scala.js --- build.sbt | 13 +++++++++++-- .../org/scalacheck/time/JavaTimeArbitrary.scala | 4 ---- .../scala/org/scalacheck/time/JavaTimeChoose.scala | 4 ---- .../scala/org/scalacheck/time/JavaTimeCogen.scala | 4 ---- .../scala/org/scalacheck/time/JavaTimeShrink.scala | 4 ---- .../org/scalacheck/time/JavaTimeArbitrary.scala | 0 .../scala/org/scalacheck/time/JavaTimeChoose.scala | 0 .../scala/org/scalacheck/time/JavaTimeCogen.scala | 0 .../scala/org/scalacheck/time/JavaTimeShrink.scala | 0 9 files changed, 11 insertions(+), 18 deletions(-) delete mode 100644 js/src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala delete mode 100644 js/src/main/scala/org/scalacheck/time/JavaTimeChoose.scala delete mode 100644 js/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala delete mode 100644 js/src/main/scala/org/scalacheck/time/JavaTimeShrink.scala rename {jvm/src => jvm-js}/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala (100%) rename {jvm/src => jvm-js}/main/scala/org/scalacheck/time/JavaTimeChoose.scala (100%) rename {jvm/src => jvm-js}/main/scala/org/scalacheck/time/JavaTimeCogen.scala (100%) rename {jvm/src => jvm-js}/main/scala/org/scalacheck/time/JavaTimeShrink.scala (100%) diff --git a/build.sbt b/build.sbt index d9058354e..0057cc6d3 100644 --- a/build.sbt +++ b/build.sbt @@ -207,17 +207,26 @@ lazy val sharedSettings = MimaSettings.settings ++ Seq( ) ) +lazy val sharedJVMJSSettings = Seq( + Compile / unmanagedSourceDirectories += (LocalRootProject / baseDirectory).value / "jvm-js" / "main" / "scala", + Test / unmanagedSourceDirectories += (LocalRootProject / baseDirectory).value / "jvm-js" / "test" / "scala" +) + lazy val js = project.in(file("js")) .settings(sharedSettings: _*) + .settings(sharedJVMJSSettings: _*) .settings( Global / scalaJSStage := FastOptStage, - libraryDependencies += - ("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion).cross(CrossVersion.for3Use2_13) + libraryDependencies ++= Seq( + ("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion).cross(CrossVersion.for3Use2_13), + "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" + ) ) .enablePlugins(ScalaJSPlugin) lazy val jvm = project.in(file("jvm")) .settings(sharedSettings: _*) + .settings(sharedJVMJSSettings: _*) .settings( Test / fork := { // Serialization issue in 2.13 and later diff --git a/js/src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala b/js/src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala deleted file mode 100644 index 6743327e1..000000000 --- a/js/src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala +++ /dev/null @@ -1,4 +0,0 @@ -package org.scalacheck.time - -/** Stub trait since ScalaJs does not have native support for java.time types. */ -private[scalacheck] trait JavaTimeArbitrary diff --git a/js/src/main/scala/org/scalacheck/time/JavaTimeChoose.scala b/js/src/main/scala/org/scalacheck/time/JavaTimeChoose.scala deleted file mode 100644 index d27e278ba..000000000 --- a/js/src/main/scala/org/scalacheck/time/JavaTimeChoose.scala +++ /dev/null @@ -1,4 +0,0 @@ -package org.scalacheck.time - -/** Stub trait since ScalaJs does not have native support for java.time types. */ -private[scalacheck] trait JavaTimeChoose diff --git a/js/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala b/js/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala deleted file mode 100644 index 5d8cbfb9e..000000000 --- a/js/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala +++ /dev/null @@ -1,4 +0,0 @@ -package org.scalacheck.time - -/** Stub trait since ScalaJs does not have native support for java.time types. */ -private[scalacheck] trait JavaTimeCogen diff --git a/js/src/main/scala/org/scalacheck/time/JavaTimeShrink.scala b/js/src/main/scala/org/scalacheck/time/JavaTimeShrink.scala deleted file mode 100644 index ca02c4738..000000000 --- a/js/src/main/scala/org/scalacheck/time/JavaTimeShrink.scala +++ /dev/null @@ -1,4 +0,0 @@ -package org.scalacheck.time - -/** Stub trait since ScalaJs does not have native support for java.time types. */ -private[scalacheck] trait JavaTimeShrink diff --git a/jvm/src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala b/jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala similarity index 100% rename from jvm/src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala rename to jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala diff --git a/jvm/src/main/scala/org/scalacheck/time/JavaTimeChoose.scala b/jvm-js/main/scala/org/scalacheck/time/JavaTimeChoose.scala similarity index 100% rename from jvm/src/main/scala/org/scalacheck/time/JavaTimeChoose.scala rename to jvm-js/main/scala/org/scalacheck/time/JavaTimeChoose.scala diff --git a/jvm/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala b/jvm-js/main/scala/org/scalacheck/time/JavaTimeCogen.scala similarity index 100% rename from jvm/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala rename to jvm-js/main/scala/org/scalacheck/time/JavaTimeCogen.scala diff --git a/jvm/src/main/scala/org/scalacheck/time/JavaTimeShrink.scala b/jvm-js/main/scala/org/scalacheck/time/JavaTimeShrink.scala similarity index 100% rename from jvm/src/main/scala/org/scalacheck/time/JavaTimeShrink.scala rename to jvm-js/main/scala/org/scalacheck/time/JavaTimeShrink.scala From 7c39a7b17320de5a4e949d040c29ff6ce59af39e Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 13 Nov 2021 22:39:14 +0000 Subject: [PATCH 2/7] Remove scala-java-time dependency --- build.sbt | 1 - 1 file changed, 1 deletion(-) diff --git a/build.sbt b/build.sbt index 0057cc6d3..d6b37a2e0 100644 --- a/build.sbt +++ b/build.sbt @@ -219,7 +219,6 @@ lazy val js = project.in(file("js")) Global / scalaJSStage := FastOptStage, libraryDependencies ++= Seq( ("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion).cross(CrossVersion.for3Use2_13), - "io.github.cquiroz" %%% "scala-java-time" % "2.3.0" ) ) .enablePlugins(ScalaJSPlugin) From d2e30128cf1b3b04276a64831239b497627c0476 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 13 Nov 2021 22:40:40 +0000 Subject: [PATCH 3/7] Diff minimizing --- build.sbt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index d6b37a2e0..78ed65aa7 100644 --- a/build.sbt +++ b/build.sbt @@ -217,9 +217,8 @@ lazy val js = project.in(file("js")) .settings(sharedJVMJSSettings: _*) .settings( Global / scalaJSStage := FastOptStage, - libraryDependencies ++= Seq( - ("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion).cross(CrossVersion.for3Use2_13), - ) + libraryDependencies += + ("org.scala-js" %% "scalajs-test-interface" % scalaJSVersion).cross(CrossVersion.for3Use2_13) ) .enablePlugins(ScalaJSPlugin) From ca4e99f8b08e199711001d432363997eac4446c0 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 14 Nov 2021 10:43:01 +0000 Subject: [PATCH 4/7] Fix Scala.js linking errors --- .../scalacheck/time/JavaTimeArbitrary.scala | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala b/jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala index d8bb90437..1e87a0fe0 100644 --- a/jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala +++ b/jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala @@ -19,20 +19,17 @@ import java.time._ */ private[scalacheck] trait JavaTimeArbitrary { - // Duration + // // Duration - // Java duration values are conceptually infinite, thus they do not expose - // Duration.MAX/Duration.MIN values, but in practice they are finite, - // restricted by their underlying representation a long and an int. + // // Java duration values are conceptually infinite, thus they do not expose + // // Duration.MAX/Duration.MIN values, but in practice they are finite, + // // restricted by their underlying representation a long and an int. - private final lazy val minJavaDuration: Duration = - Duration.ofSeconds(Long.MinValue) - - private final lazy val maxJavaDuration: Duration = - Duration.ofSeconds(Long.MaxValue, 999999999L) - - implicit final lazy val arbJavaDuration: Arbitrary[Duration] = + implicit final lazy val arbJavaDuration: Arbitrary[Duration] = { + val minJavaDuration = Duration.ofSeconds(Long.MinValue) + val maxJavaDuration = Duration.ofSeconds(Long.MaxValue, 999999999L) Arbitrary(Gen.choose(minJavaDuration, maxJavaDuration)) + } // Instant From a13cab05ff07a1a338e057eca7b956b6a9ffa2d3 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sun, 14 Nov 2021 10:43:43 +0000 Subject: [PATCH 5/7] Fix comment --- .../scala/org/scalacheck/time/JavaTimeArbitrary.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala b/jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala index 1e87a0fe0..cd1e83139 100644 --- a/jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala +++ b/jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala @@ -19,11 +19,11 @@ import java.time._ */ private[scalacheck] trait JavaTimeArbitrary { - // // Duration + // Duration - // // Java duration values are conceptually infinite, thus they do not expose - // // Duration.MAX/Duration.MIN values, but in practice they are finite, - // // restricted by their underlying representation a long and an int. + // Java duration values are conceptually infinite, thus they do not expose + // Duration.MAX/Duration.MIN values, but in practice they are finite, + // restricted by their underlying representation a long and an int. implicit final lazy val arbJavaDuration: Arbitrary[Duration] = { val minJavaDuration = Duration.ofSeconds(Long.MinValue) From 5931cd3b3bbeb2d5d6c573b7b919f63db5eb8435 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 7 Dec 2021 17:22:48 +0000 Subject: [PATCH 6/7] java.time arbitraries for everyone --- build.sbt | 7 ------- .../main/scala/org/scalacheck/time/JavaTimeArbitrary.scala | 0 .../main/scala/org/scalacheck/time/JavaTimeChoose.scala | 0 .../main/scala/org/scalacheck/time/JavaTimeCogen.scala | 0 .../main/scala/org/scalacheck/time/JavaTimeShrink.scala | 0 5 files changed, 7 deletions(-) rename {jvm-js => src}/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala (100%) rename {jvm-js => src}/main/scala/org/scalacheck/time/JavaTimeChoose.scala (100%) rename {jvm-js => src}/main/scala/org/scalacheck/time/JavaTimeCogen.scala (100%) rename {jvm-js => src}/main/scala/org/scalacheck/time/JavaTimeShrink.scala (100%) diff --git a/build.sbt b/build.sbt index 78ed65aa7..d9058354e 100644 --- a/build.sbt +++ b/build.sbt @@ -207,14 +207,8 @@ lazy val sharedSettings = MimaSettings.settings ++ Seq( ) ) -lazy val sharedJVMJSSettings = Seq( - Compile / unmanagedSourceDirectories += (LocalRootProject / baseDirectory).value / "jvm-js" / "main" / "scala", - Test / unmanagedSourceDirectories += (LocalRootProject / baseDirectory).value / "jvm-js" / "test" / "scala" -) - lazy val js = project.in(file("js")) .settings(sharedSettings: _*) - .settings(sharedJVMJSSettings: _*) .settings( Global / scalaJSStage := FastOptStage, libraryDependencies += @@ -224,7 +218,6 @@ lazy val js = project.in(file("js")) lazy val jvm = project.in(file("jvm")) .settings(sharedSettings: _*) - .settings(sharedJVMJSSettings: _*) .settings( Test / fork := { // Serialization issue in 2.13 and later diff --git a/jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala b/src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala similarity index 100% rename from jvm-js/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala rename to src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala diff --git a/jvm-js/main/scala/org/scalacheck/time/JavaTimeChoose.scala b/src/main/scala/org/scalacheck/time/JavaTimeChoose.scala similarity index 100% rename from jvm-js/main/scala/org/scalacheck/time/JavaTimeChoose.scala rename to src/main/scala/org/scalacheck/time/JavaTimeChoose.scala diff --git a/jvm-js/main/scala/org/scalacheck/time/JavaTimeCogen.scala b/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala similarity index 100% rename from jvm-js/main/scala/org/scalacheck/time/JavaTimeCogen.scala rename to src/main/scala/org/scalacheck/time/JavaTimeCogen.scala diff --git a/jvm-js/main/scala/org/scalacheck/time/JavaTimeShrink.scala b/src/main/scala/org/scalacheck/time/JavaTimeShrink.scala similarity index 100% rename from jvm-js/main/scala/org/scalacheck/time/JavaTimeShrink.scala rename to src/main/scala/org/scalacheck/time/JavaTimeShrink.scala From ab6fdef1e5c28068787dee29ea095f81efbebf92 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Tue, 7 Dec 2021 17:26:17 +0000 Subject: [PATCH 7/7] Delete the native stubs --- .../main/scala/org/scalacheck/time/JavaTimeArbitrary.scala | 4 ---- .../src/main/scala/org/scalacheck/time/JavaTimeChoose.scala | 4 ---- native/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala | 4 ---- .../src/main/scala/org/scalacheck/time/JavaTimeShrink.scala | 4 ---- 4 files changed, 16 deletions(-) delete mode 100644 native/src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala delete mode 100644 native/src/main/scala/org/scalacheck/time/JavaTimeChoose.scala delete mode 100644 native/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala delete mode 100644 native/src/main/scala/org/scalacheck/time/JavaTimeShrink.scala diff --git a/native/src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala b/native/src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala deleted file mode 100644 index 3fc80f03b..000000000 --- a/native/src/main/scala/org/scalacheck/time/JavaTimeArbitrary.scala +++ /dev/null @@ -1,4 +0,0 @@ -package org.scalacheck.time - -/** Stub trait since Scala Native does not have native support for java.time types. */ -private[scalacheck] trait JavaTimeArbitrary diff --git a/native/src/main/scala/org/scalacheck/time/JavaTimeChoose.scala b/native/src/main/scala/org/scalacheck/time/JavaTimeChoose.scala deleted file mode 100644 index 0aa01c623..000000000 --- a/native/src/main/scala/org/scalacheck/time/JavaTimeChoose.scala +++ /dev/null @@ -1,4 +0,0 @@ -package org.scalacheck.time - -/** Stub trait since Scala Native does not have native support for java.time types. */ -private[scalacheck] trait JavaTimeChoose diff --git a/native/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala b/native/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala deleted file mode 100644 index ddeb71f29..000000000 --- a/native/src/main/scala/org/scalacheck/time/JavaTimeCogen.scala +++ /dev/null @@ -1,4 +0,0 @@ -package org.scalacheck.time - -/** Stub trait since Scala Native does not have native support for java.time types. */ -private[scalacheck] trait JavaTimeCogen diff --git a/native/src/main/scala/org/scalacheck/time/JavaTimeShrink.scala b/native/src/main/scala/org/scalacheck/time/JavaTimeShrink.scala deleted file mode 100644 index d28ca4323..000000000 --- a/native/src/main/scala/org/scalacheck/time/JavaTimeShrink.scala +++ /dev/null @@ -1,4 +0,0 @@ -package org.scalacheck.time - -/** Stub trait since Scala Native does not have native support for java.time types. */ -private[scalacheck] trait JavaTimeShrink