Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest rickynils/master #1

Open
wants to merge 38 commits into
base: cross-native
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
da12696
Bump sbt from 0.13.13 to 0.13.15
zaneli May 5, 2017
57b6fb4
Collect frequency stats of Gen.pick
ashawley May 10, 2017
2ee295d
Fix distribution of Gen.pick
ashawley May 10, 2017
3fe20bf
Add Arbitrary[UUID]
nigredo-tori Jun 14, 2017
bf8f340
upgrade to newer Scala.js version
SethTisue Jun 20, 2017
c2dbe4c
Add failing Serializable tests
travisbrown-stripe Jul 12, 2017
9aa8d60
Add other Serializable tests for good measure
travisbrown-stripe Jul 13, 2017
8dfa1aa
Instantiate FunctionN values instead of using literals
travisbrown-stripe Jul 13, 2017
bfcd403
Run codegen
travisbrown-stripe Jul 13, 2017
aab353f
Merge pull request #341 from SethTisue/scala-js-upgrade-master
rickynils Jul 13, 2017
3f7ef62
Merge pull request #336 from nigredo-tori/arbitrary-uuid
rickynils Jul 13, 2017
db2a1fc
Merge pull request #333 from ashawley/gen-pick-defect
rickynils Jul 13, 2017
35d5948
Merge pull request #343 from travisbrown/fix/342
rickynils Jul 13, 2017
1fad5c4
Merge pull request #331 from zaneli/update-sbt
rickynils Jul 13, 2017
0d2b792
delete unused private method
xuwei-k Jul 23, 2017
8465d71
Merge pull request #346 from xuwei-k/delete-secure
rickynils Jul 24, 2017
8ae3697
upgrade scalajs to 0.6.18
kailuowang Jul 28, 2017
2f2552e
Update plugin.sbt
kailuowang Aug 7, 2017
772ee61
Add Scala 2.13.0-M2 suppport
limansky Aug 10, 2017
ddf65bd
Update Travis build configuration as well
limansky Aug 10, 2017
99309ff
Merge pull request #348 from kailuowang/patch-1
rickynils Aug 16, 2017
961f782
Merge pull request #353 from limansky/scala_2_13
rickynils Aug 16, 2017
3268050
Added support to build on scala.js 1.0.0-M1
cquiroz Jul 14, 2017
c59ae70
Merge pull request #345 from cquiroz/scala.js-0.6.18-1.0.0-M1
rickynils Aug 24, 2017
8115a68
Added columnWidth parameter to ConsoleReporter to support adjustable-…
Aug 26, 2017
c062f37
Added Intellij .idea folder to .gitignore
joroKr21 Sep 21, 2017
102654b
Dropped Ordering bound on the values in cogenMap
joroKr21 Sep 21, 2017
5336cf0
Add Gen.product and Gen.tailRecM
oscar-stripe Oct 3, 2017
b817db8
improve tests and fix implementations
oscar-stripe Oct 3, 2017
1b14c68
remove product implementation
oscar-stripe Oct 4, 2017
4cf7f8f
Merge pull request #359 from johnynek/oscar/tailrecm
non Oct 4, 2017
bc672d9
Merge pull request #357 from joroKr21/cogen-map
non Oct 4, 2017
1faea6c
Fixes the type parameter in a call to arbitrary in a property
mdimjasevic Oct 20, 2017
b21040c
Add Gen.filterNot() method
evis Oct 26, 2017
0d2e076
Merge pull request #354 from sean-ogle/console_reporter_adjustable_co…
rickynils Dec 4, 2017
6441f45
Merge pull request #364 from mdimjasevic/master
rickynils Dec 4, 2017
720b9b3
Merge pull request #367 from evis/gen_filternot
rickynils Dec 4, 2017
6e2a474
Cross compile to Scala Native
Duhemm May 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ target

/examples/simple-sbt/project/
/examples/simple-sbt/target/

# Intellij
.idea
15 changes: 13 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: scala
dist: trusty
script: ./tools/travis-script.sh
after_success: ./tools/travis-deploy.sh
branches:
Expand All @@ -14,8 +15,9 @@ notifications:

scala:
- 2.10.6
- 2.11.8
- 2.12.0
- 2.11.11
- 2.12.3
- 2.13.0-M2
jdk:
- oraclejdk8
env:
Expand All @@ -27,4 +29,13 @@ env:
- PLATFORM=jvm SBT_PARALLEL=true WORKERS=4 DEPLOY=false
- PLATFORM=jvm SBT_PARALLEL=false WORKERS=4 DEPLOY=false
- PLATFORM=js SBT_PARALLEL=true WORKERS=1 DEPLOY=true
- PLATFORM=js SBT_PARALLEL=true WORKERS=1 DEPLOY=true SCALAJS_VERSION=1.0.0-M1
sudo: false

matrix:
include:
- scala: 2.11.11
before_script:
- curl https://raw.githubusercontent.com/scala-native/scala-native/21539aa97947f767afcd85b5c2fb3c0262b2d301/bin/travis_setup.sh | bash -x
sudo: required
env: PLATFORM=native SBT_PARALLEL=true WORKERS=1 DEPLOY=true
21 changes: 16 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ lazy val isRelease = false
lazy val travisCommit = Option(System.getenv().get("TRAVIS_COMMIT"))

lazy val scalaVersionSettings = Seq(
scalaVersion := "2.12.1",
crossScalaVersions := Seq("2.10.6", "2.11.8", scalaVersion.value)
scalaVersion := "2.12.3",
crossScalaVersions := Seq("2.10.6", "2.11.11", "2.13.0-M2", scalaVersion.value)
)

lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq(
Expand Down Expand Up @@ -56,7 +56,6 @@ lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq(
"-feature",
"-unchecked",
"-Xfatal-warnings",
"-Xlint",
"-Xfuture",
"-Yno-adapted-args",
"-Ywarn-dead-code",
Expand All @@ -65,8 +64,9 @@ lazy val sharedSettings = MimaSettings.settings ++ scalaVersionSettings ++ Seq(
"-Ywarn-nullary-unit",
"-Ywarn-numeric-widen") ++ {
scalaBinaryVersion.value match {
case "2.10" => Nil
case _ => Seq("-Ywarn-infer-any", "-Ywarn-unused-import")
case "2.10" => Seq("-Xlint")
case "2.11" => Seq("-Xlint", "-Ywarn-infer-any", "-Ywarn-unused-import")
case _ => Seq("-Xlint:-unused", "-Ywarn-infer-any", "-Ywarn-unused:imports,-patvars,-implicits,-locals,-privates,-params")
}
},

Expand Down Expand Up @@ -129,3 +129,14 @@ lazy val jvm = project.in(file("jvm"))
.settings(
libraryDependencies += "org.scala-sbt" % "test-interface" % "1.0"
)

lazy val native = project.in(file("native"))
.settings(sharedSettings: _*)
.settings(
doc in Compile := (doc in Compile in jvm).value,
scalaVersion := "2.11.11",
libraryDependencies ++= Seq(
"org.scala-native" %% "test-interface_native0.3" % "0.3.1"
)
)
.enablePlugins(ScalaNativePlugin)
8 changes: 3 additions & 5 deletions js/src/main/scala/org/scalacheck/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ private[scalacheck] object Platform {
def loadModule(name: String, loader: ClassLoader): AnyRef =
org.scalajs.testinterface.TestUtils.loadModule(name, loader)

def newInstance(name: String, loader: ClassLoader)(args: Seq[AnyRef]): AnyRef =
org.scalajs.testinterface.TestUtils.newInstance(name, loader)(args)
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef =
org.scalajs.testinterface.TestUtils.newInstance(name, loader, paramTypes)(args)

type JSExportDescendentObjects = scala.scalajs.js.annotation.JSExportDescendentObjects

type JSExportDescendentClasses = scala.scalajs.js.annotation.JSExportDescendentClasses
type EnableReflectiveInstantiation = scala.scalajs.reflect.annotation.EnableReflectiveInstantiation
}
12 changes: 2 additions & 10 deletions jvm/src/main/scala/org/scalacheck/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,12 @@ private[scalacheck] object Platform {
}
}

def newInstance(name: String, loader: ClassLoader)(args: Seq[AnyRef]): AnyRef =
def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef =
if(!args.isEmpty) ???
else Class.forName(name, true, loader).newInstance.asInstanceOf[AnyRef]

def loadModule(name: String, loader: ClassLoader): AnyRef =
Class.forName(name + "$", true, loader).getField("MODULE$").get(null)

class JSExportDescendentObjects(ignoreInvalidDescendants: Boolean)
extends scala.annotation.Annotation {
def this() = this(false)
}

class JSExportDescendentClasses(ignoreInvalidDescendants: Boolean)
extends scala.annotation.Annotation {
def this() = this(false)
}
class EnableReflectiveInstantiation extends scala.annotation.Annotation
}
42 changes: 40 additions & 2 deletions jvm/src/test/scala/org/scalacheck/GenSpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ object GenSpecification extends Properties("Gen") {
}
}

property("distributed pick") = {
val lst = (0 to 7).toIterable
val n = 2
forAll(pick(n, lst)) { xs: Seq[Int] =>
xs.map { x: Int =>
Prop.collect(x) {
xs.size == n
}
} reduce (_ && _)
}
}

property("numChar") = forAll(numChar)(_.isDigit)

property("calendar") = forAll(calendar) { cal =>
Expand Down Expand Up @@ -313,11 +325,37 @@ object GenSpecification extends Properties("Gen") {

property("some") = forAll { n: Int =>
forAll(some(n)) {
case Some(m) if m == n => true
case Some(m) => m == n
case _ => false
}
}

property("tailRecM") = forAll { (init: Int, seeds: List[Seed]) =>
val g: ((Int, Int)) => Gen[Either[(Int, Int), Int]] =
{
case (c, x) if c <= 0 =>
Gen.const(Right(x))
case (c, x) =>
val g = Gen.choose(Int.MinValue, x)
g.map { i => Left(((c - 1), i)) }
}

val g1 = Gen.tailRecM((10, init))(g)
def g2(x: (Int, Int)): Gen[Int] = g(x).flatMap {
case Left(y) => g2(y)
case Right(x) => Gen.const(x)
}

val finalG2 = g2((10, init))


val params = Gen.Parameters.default

seeds.forall { seed =>
g1.pureApply(params, seed) == finalG2.pureApply(params, seed)
}
}

property("uuid version 4") = forAll(uuid) { _.version == 4 }

property("uuid unique") = forAll(uuid, uuid) {
Expand Down Expand Up @@ -472,7 +510,7 @@ object GenSpecification extends Properties("Gen") {
}

property("arbitrary[Boolean] is deterministic") =
testDeterministicGen(arbitrary[Long])
testDeterministicGen(arbitrary[Boolean])

property("arbitrary[Long] is deterministic") =
testDeterministicGen(arbitrary[Long])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,24 @@ object SerializabilitySpecification extends Properties("Serializability") {
serializableArbitrary[Int]("Int")
serializableArbitrary[Double]("Double")
serializableArbitrary[Boolean]("Boolean")
serializableArbitrary[Int => Int]("Int => Int")

serializableGen("identifier", Gen.identifier)
serializableGen("oneOf", Gen.oneOf(true, false))
serializableGen("choose", Gen.choose(1, 10))
serializableGen("function1", Gen.function1[Int, Int](Gen.choose(1, 10)))

serializableCogen[String]("String")
serializableCogen[Int]("Int")
serializableCogen[Double]("Double")
serializableCogen[Boolean]("Boolean")
serializableCogen[Int => Int]("Int => Int")

serializableShrink[String]("String")
serializableShrink[Int]("Int")
serializableShrink[Double]("Double")
serializableShrink[Boolean]("Boolean")
serializableShrink[Int => Int]("Int => Int")

property("Seed serializability") = {
assert(serializable(rng.Seed(1L)))
Expand Down
36 changes: 36 additions & 0 deletions native/src/main/scala/org/scalacheck/Platform.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*-------------------------------------------------------------------------*\
** ScalaCheck **
** Copyright (c) 2007-2017 Rickard Nilsson. All rights reserved. **
** http://www.scalacheck.org **
** **
** This software is released under the terms of the Revised BSD License. **
** There is NO WARRANTY. See the file LICENSE for the full text. **
\*------------------------------------------------------------------------ */

package org.scalacheck

import Test._

import scala.scalanative.testinterface.PreloadedClassLoader

private[scalacheck] object Platform {

def runWorkers(
params: Parameters,
workerFun: Int => Result,
stop: () => Unit
): Result = {
workerFun(0)
}

def loadModule(name: String, loader: ClassLoader): AnyRef =
loader.asInstanceOf[PreloadedClassLoader].loadPreloaded(name)

def newInstance(name: String, loader: ClassLoader, paramTypes: Seq[Class[_]])(args: Seq[AnyRef]): AnyRef =
org.scalajs.testinterface.TestUtils.newInstance(name, loader, paramTypes)(args)

// We don't need those annotation in Native, and they have been deprecated.
// We use `String` instead of the definition in Native because `-Xfatal-warnings`
// is set.
type EnableReflectiveInstantiation = String
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.13
sbt.version=0.13.15
7 changes: 6 additions & 1 deletion project/plugin.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.14")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.13")
val scalaJSVersion =
Option(System.getenv("SCALAJS_VERSION")).getOrElse("0.6.19")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)

addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.3")

scalacOptions += "-deprecation"
4 changes: 4 additions & 0 deletions src/main/scala/org/scalacheck/Arbitrary.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ private[scalacheck] sealed trait ArbitraryLowPriority {
implicit lazy val arbError: Arbitrary[Error] =
Arbitrary(const(new Error))

/** Arbitrary instance of UUID */
implicit lazy val arbUuid: Arbitrary[java.util.UUID] =
Arbitrary(Gen.uuid)

/** Arbitrary BigInt */
implicit lazy val arbBigInt: Arbitrary[BigInt] = {
val long: Gen[Long] =
Expand Down
Loading