Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=2.4.2
version=2.6.0
style = defaultWithAlign
maxColumn = 100

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ the code. Pull requests are also welcome.

People are expected to follow the [Code of Conduct](CODE_OF_CONDUCT.md) when discussing _exercises-scalacheck_ on the Github page or other venues.

If you are being harassed, please contact one of [us](AUTHORS.md#maintainers) immediately so that we can support you. In case you cannot get in touch with us please write an email to [47 Degrees](mailto:scala-exercises@47deg.com).
If you are being harassed, please contact one of [us](AUTHORS.md#maintainers) immediately so that we can support you. In case you cannot get in touch with us please write an email to [47 Degrees Open Source](mailto:hello@47deg.com).

## How can I help?

Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright (C) 2016-2020 47 Degrees <https://47deg.com>
Copyright (C) 2016-2020 47 Degrees Open Source <https://www.47deg.com>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

exercises-scalacheck

Copyright (c) 2016-2020 47 Degrees. All rights reserved.
Copyright (c) 2016-2020 47 Degrees Open Source. All rights reserved.

Licensed under Apache-2.0. See [LICENSE](LICENSE.md) for terms.
34 changes: 25 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
import com.jsuereth.sbtpgp.PgpKeys.publishSigned

ThisBuild / organization := "org.scala-exercises"
ThisBuild / githubOrganization := "47degrees"
ThisBuild / scalaVersion := "2.13.2"

publish / skip := true

// This is required by the exercises compiler:
publishLocal := (publishLocal dependsOn compile).value
publishSigned := (publishSigned dependsOn compile).value

addCommandAlias("ci-test", "scalafmtCheckAll; scalafmtSbtCheck; test")
addCommandAlias("ci-docs", "github; project-docs/mdoc; headerCreateAll")
addCommandAlias("ci-docs", "github; documentation/mdoc; headerCreateAll")
addCommandAlias("ci-publish", "github; ci-release")

lazy val exercises = (project in file("."))
.settings(moduleName := "exercises-scalacheck")
.settings(exercisesSettings)
.settings(name := "exercises-scalacheck")
.settings(
libraryDependencies ++= Seq(
"org.scala-exercises" %% "exercise-compiler" % "0.6.1",
"org.scala-exercises" %% "definitions" % "0.6.1",
"joda-time" % "joda-time" % "2.10.6",
"com.47deg" %% "scalacheck-toolbox-datetime" % "0.3.5",
"com.chuusai" %% "shapeless" % "2.3.3",
"org.scalatest" %% "scalatest" % "3.1.2",
"org.scalacheck" %% "scalacheck" % "1.14.3",
"org.scalatestplus" %% "scalacheck-1-14" % "3.1.2.0",
"com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % "1.2.5"
)
)
.enablePlugins(ExerciseCompilerPlugin)

lazy val `project-docs` = (project in file(".docs"))
.aggregate(exercises)
.dependsOn(exercises)
.settings(moduleName := "exercises-project-docs")
.settings(mdocIn := file(".docs"))
lazy val documentation = project
.settings(mdocOut := file("."))
.settings(skip in publish := true)
.settings(publish / skip := true)
.enablePlugins(MdocPlugin)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 0 additions & 53 deletions project/ProjectPlugin.scala

This file was deleted.

2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.11
sbt.version=1.3.12
19 changes: 9 additions & 10 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
resolvers += Resolver.sonatypeRepo("snapshots")
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.6.0")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.1.5")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.4")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("com.alejandrohdezma" %% "sbt-github" % "0.8.0")
addSbtPlugin("com.alejandrohdezma" % "sbt-github-header" % "0.8.0")
addSbtPlugin("com.alejandrohdezma" % "sbt-github-mdoc" % "0.8.0")
addSbtPlugin("com.alejandrohdezma" % "sbt-mdoc-toc" % "0.2")
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.6.1")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.1.5")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
addSbtPlugin("com.alejandrohdezma" % "sbt-github" % "0.8.2")
addSbtPlugin("com.alejandrohdezma" % "sbt-github-header" % "0.8.2")
addSbtPlugin("com.alejandrohdezma" % "sbt-github-mdoc" % "0.8.2")
addSbtPlugin("com.alejandrohdezma" % "sbt-remove-test-from-pom" % "0.1.0")
14 changes: 9 additions & 5 deletions src/main/scala/scalachecklib/ArbitrarySection.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 47 Degrees <https://47deg.com>
* Copyright 2016-2020 47 Degrees Open Source <https://www.47deg.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,7 +19,8 @@ package scalachecklib
import org.scalatest.matchers.should.Matchers
import org.scalatestplus.scalacheck.Checkers

/** ==The `arbitrary` Generator==
/**
* ==The `arbitrary` Generator==
*
* There is a special generator, `org.scalacheck.Arbitrary.arbitrary`, which generates arbitrary values of any
* supported type.
Expand Down Expand Up @@ -48,7 +49,8 @@ object ArbitrarySection extends Checkers with Matchers with org.scalaexercises.d

import GeneratorsHelper._

/** Let's see an example where we're defining an `implicit` `arbitrary` instance for `Char`
/**
* Let's see an example where we're defining an `implicit` `arbitrary` instance for `Char`
*/
def implicitArbitraryChar(res0: Seq[Char]) = {

Expand All @@ -63,7 +65,8 @@ object ArbitrarySection extends Checkers with Matchers with org.scalaexercises.d
check(forAll { c: Char => validChars.contains(c) })
}

/** This becomes more useful when we're dealing with our own data types.
/**
* This becomes more useful when we're dealing with our own data types.
* We'll use the case class defined in the ''Generators Section'':
*
* {{{
Expand All @@ -89,7 +92,8 @@ object ArbitrarySection extends Checkers with Matchers with org.scalaexercises.d
check(forAll { foo: Foo => (foo.intValue < 0) == res0 && !foo.charValue.isDigit })
}

/** The `Arbitrary.arbitrary` method also returns a `Gen` object.
/**
* The `Arbitrary.arbitrary` method also returns a `Gen` object.
*/
def useArbitraryOnGen(res0: Int) = {

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/scalachecklib/GeneratorsHelper.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 47 Degrees <https://47deg.com>
* Copyright 2016-2020 47 Degrees Open Source <https://www.47deg.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
28 changes: 17 additions & 11 deletions src/main/scala/scalachecklib/GeneratorsSection.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2020 47 Degrees <https://47deg.com>
* Copyright 2016-2020 47 Degrees Open Source <https://www.47deg.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -19,14 +19,14 @@ package scalachecklib
import org.scalatest.matchers.should.Matchers
import org.scalatestplus.scalacheck.Checkers

/** Generators are responsible for generating test data in ScalaCheck, and are represented by the `org.scalacheck.Gen`
/**
* Generators are responsible for generating test data in ScalaCheck, and are represented by the `org.scalacheck.Gen`
* class. ou need to know how to use this class if you want ScalaCheck to generate data of types that are not supported
* by default, or if you want to use the `forAll` method mentioned above, to state properties about a specific subset of
* a type. In the `Gen` object, there are several methods for creating new and modifying existing generators.
* We will show how to use some of them in this section. For a more complete reference of what is available,
* please see the API scaladoc.
*
*
* A generator can be seen simply as a function that takes some generation parameters, and (maybe) returns a
* generated value. That is, the type `Gen[T]` may be thought of as a function of type `Gen.Params => Option[T]`.
* However, the `Gen` class contains additional methods to make it possible to map generators, use them in
Expand All @@ -42,7 +42,8 @@ object GeneratorsSection

import GeneratorsHelper._

/** Let's see how to create a new generator. The best way to do it is to use the generator combinators that exist
/**
* Let's see how to create a new generator. The best way to do it is to use the generator combinators that exist
* in the `org.scalacheck.Gen` module. These can be combined using a for-comprehension. Suppose you need a generator
* which generates a tuple that contains two random integer values, one of them being at least twice as big as the
* other. The following definition does this:
Expand All @@ -65,11 +66,11 @@ object GeneratorsSection

}

/** You can create generators that pick one value out of a selection of values.
/**
* You can create generators that pick one value out of a selection of values.
* The `oneOf` method creates a generator that randomly picks one of its parameters each time it generates a value.
* Notice that plain values are implicitly converted to generators (which always generate that value) if needed.
*
*
* The following generator generates a vowel:
*/
def genOf(res0: Seq[Char]) = {
Expand All @@ -86,7 +87,8 @@ object GeneratorsSection
}
}

/** The distribution is uniform, but if you want to control it you can use the frequency combinator:
/**
* The distribution is uniform, but if you want to control it you can use the frequency combinator:
*
* {{{
* val vowel = Gen.frequency(
Expand Down Expand Up @@ -132,7 +134,8 @@ object GeneratorsSection
}
}

/** ==Conditional Generators==
/**
* ==Conditional Generators==
*
* Conditional generators can be defined using `Gen.suchThat`.
*
Expand All @@ -153,7 +156,8 @@ object GeneratorsSection
}
}

/** ==Case class Generators==
/**
* ==Case class Generators==
*
* On the basis of the above we can create a generator for the following case class:
*
Expand All @@ -176,7 +180,8 @@ object GeneratorsSection
}
}

/** ==Sized Generators==
/**
* ==Sized Generators==
*
* When ScalaCheck uses a generator to generate a value, it feeds it with some parameters. One of the parameters
* the generator is given is a size value, which some generators use to generate their values.
Expand Down Expand Up @@ -212,7 +217,8 @@ object GeneratorsSection
}
}

/** ==Generating Containers==
/**
* ==Generating Containers==
*
* There is a special generator, `Gen.containerOf`, that generates containers such as lists and arrays.
* It takes another generator as argument which is responsible for generating the individual items.
Expand Down
Loading