Skip to content

Commit

Permalink
Merge 8ad1ab1 into 7743802
Browse files Browse the repository at this point in the history
  • Loading branch information
alexflav23 committed Aug 6, 2017
2 parents 7743802 + 8ad1ab1 commit 04b10be
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion project/Publishing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object Publishing {
}

val versionSettings = Seq(
version := "0.36.0",
version := "0.37.0",
credentials ++= defaultCredentials
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ trait Generators extends GenerationDomain {
*/
def gen[T : Sample]: T = implicitly[Sample[T]].sample

def genOpt[T : Sample]: Option[T] = Some(implicitly[Sample[T]].sample)
def genOpt[T : Sample]: Option[T] = {
val bool = Random.nextBoolean()

if (bool) {
Some(implicitly[Sample[T]].sample)
} else {
None
}
}

/**
* Generates a list of elements based on an input collection type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ trait Sample[T] {

object Sample {

def derive[T : Sample, T1](fn: T => T1): Sample[T1] = new Sample[T1] {
override def sample: T1 = fn(gen[T])
}

def arbitrary[T : Sample]: Arbitrary[T] = Arbitrary(generator[T])

def generator[T : Sample]: Gen[T] = Gen.delay(gen[T])
Expand Down Expand Up @@ -60,10 +64,6 @@ object Sample {

object Samples extends Generators {

def derive[T : Sample, T1](fn: T => T1): Sample[T1] = new Sample[T1] {
override def sample: T1 = fn(gen[T])
}

private[this] val byteLimit = 127
private[this] val shortLimit = 256
private[this] val inetBlock = 4
Expand Down

0 comments on commit 04b10be

Please sign in to comment.