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

Expand All @@ -19,5 +20,4 @@ docstrings = JavaDoc
rewrite {
rules = [SortImports, RedundantBraces]
redundantBraces.maxLines = 1
}

}
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

38 changes: 13 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
import ProjectPlugin.autoImport._
addCommandAlias("ci-test", "scalafmtCheckAll; scalafmtSbtCheck; test")
addCommandAlias("ci-docs", "github; project-docs/mdoc; headerCreateAll")

val scalaExercisesV = "0.6.0-SNAPSHOT"

def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExercisesV

lazy val scalacheck = (project in file("."))
lazy val exercises = (project in file("."))
.settings(moduleName := "exercises-scalacheck")
.settings(exercisesSettings)
.enablePlugins(ExerciseCompilerPlugin)
.settings(
name := "exercises-scalacheck",
libraryDependencies ++= Seq(
dep("exercise-compiler"),
dep("definitions"),
%%("scalatest", V.scalatest),
%%("scalacheck", V.scalacheck),
%%("shapeless", V.shapeless),
"joda-time" % "joda-time" % V.jodaTime,
"com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % V.scalacheckShapeless,
"com.47deg" %% "scalacheck-toolbox-datetime" % V.scalacheckDatetime,
"org.scalatestplus" %% "scalatestplus-scalacheck" % V.scalatestplusScheck
)
)

// Distribution

pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
pgpSecretRing := file(s"$gpgFolder/secring.gpg")
lazy val `project-docs` = (project in file(".docs"))
.aggregate(exercises)
.dependsOn(exercises)
.settings(moduleName := "exercises-project-docs")
.settings(mdocIn := file(".docs"))
.settings(mdocOut := file("."))
.settings(skip in publish := true)
.enablePlugins(MdocPlugin)
62 changes: 29 additions & 33 deletions project/ProjectPlugin.scala
Original file line number Diff line number Diff line change
@@ -1,57 +1,53 @@
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
import de.heikoseeberger.sbtheader.License._
import sbt.Keys._
import sbt._
import sbtorgpolicies._
import sbtorgpolicies.model._
import sbtorgpolicies.OrgPoliciesPlugin.autoImport._
import com.alejandrohdezma.sbt.github.SbtGithubPlugin

object ProjectPlugin extends AutoPlugin {

override def trigger: PluginTrigger = allRequirements

override def requires: Plugins = plugins.JvmPlugin && OrgPoliciesPlugin
override def requires: Plugins = plugins.JvmPlugin && SbtGithubPlugin

object autoImport {

lazy val V = new {
val scala213: String = "2.13.1"
val jodaTime: String = "2.10.5"
val shapeless: String = "2.3.3"
val scalatest: String = "3.1.1"
val scalatestplusScheck: String = "3.1.0.0-RC2"
val scala: String = "2.13.2"
val scalaExercises: String = "0.6.0-SNAPSHOT"
val scalacheck: String = "1.14.3"
val scalacheckShapeless: String = "1.2.5"
val scalacheckDatetime: String = "0.3.5"
val jodaTime: String = "2.10.5"
val scalacheckShapeless: String = "1.2.5"
val scalatest: String = "3.1.1"
val scalatestplusScheck: String = "3.1.1.1"
}
}

import autoImport._
def dep(artifactId: String) = "org.scala-exercises" %% artifactId % V.scalaExercises

lazy val exercisesSettings = Seq(
libraryDependencies ++= Seq(
dep("exercise-compiler"),
dep("definitions"),
"joda-time" % "joda-time" % V.jodaTime,
"com.47deg" %% "scalacheck-toolbox-datetime" % V.scalacheckDatetime,
"com.chuusai" %% "shapeless" % V.shapeless,
"org.scalatest" %% "scalatest" % V.scalatest,
"org.scalacheck" %% "scalacheck" % V.scalacheck,
"org.scalatestplus" %% "scalacheck-1-14" % V.scalatestplusScheck,
"com.github.alexarchambault" %% "scalacheck-shapeless_1.14" % V.scalacheckShapeless
)
)
}

override def projectSettings: Seq[Def.Setting[_]] =
Seq(
description := "Scala Exercises: The path to enlightenment",
startYear := Option(2016),
orgGithubSetting := GitHubSettings(
organization = "scala-exercises",
project = name.value,
organizationName = "Scala Exercises",
groupId = "org.scala-exercises",
organizationHomePage = url("https://www.scala-exercises.org"),
organizationEmail = "[email protected]"
),
orgLicenseSetting := ApacheLicense,
scalaVersion := V.scala213,
scalaOrganization := "org.scala-lang",
organization := "org.scala-exercises",
organizationName := "47 Degrees",
organizationHomepage := Some(url("https://47deg.com")),
scalaVersion := autoImport.V.scala,
resolvers ++= Seq(
Resolver.mavenLocal,
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
),
scalacOptions := sbtorgpolicies.model.scalacCommonOptions,
headerLicense := Some(Custom(s"""| scala-exercises - ${name.value}
| Copyright (C) 2015-2019 47 Degrees, LLC. <http://www.47deg.com>
|
|""".stripMargin))
)
)
}
16 changes: 10 additions & 6 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots")
)

addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.6.0-SNAPSHOT")
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.12.0-M3")
resolvers += Resolver.sonatypeRepo("snapshots")
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.6.0-SNAPSHOT")
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")
18 changes: 0 additions & 18 deletions pubring.gpg

This file was deleted.

Binary file removed secring.gpg.enc
Binary file not shown.
12 changes: 3 additions & 9 deletions src/main/scala/scalachecklib/ArbitrarySection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ object ArbitrarySection extends Checkers with Matchers with org.scalaexercises.d

val validChars: Seq[Char] = res0

check(forAll { c: Char =>
validChars.contains(c)
})
check(forAll { c: Char => validChars.contains(c) })
}

/** This becomes more useful when we're dealing with our own data types.
Expand All @@ -78,9 +76,7 @@ object ArbitrarySection extends Checkers with Matchers with org.scalaexercises.d

implicit lazy val myFooArbitrary = Arbitrary(fooGen)

check(forAll { foo: Foo =>
(foo.intValue < 0) == res0 && !foo.charValue.isDigit
})
check(forAll { foo: Foo => (foo.intValue < 0) == res0 && !foo.charValue.isDigit })
}

/** The `Arbitrary.arbitrary` method also returns a `Gen` object.
Expand All @@ -93,9 +89,7 @@ object ArbitrarySection extends Checkers with Matchers with org.scalaexercises.d

val genEightBytes = listOfN(8, Arbitrary.arbitrary[Byte])

check(forAll(genEightBytes) { list =>
list.size == res0
})
check(forAll(genEightBytes)(list => list.size == res0))

}

Expand Down
12 changes: 3 additions & 9 deletions src/main/scala/scalachecklib/GeneratorsSection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ object GeneratorsSection
val validChars: Seq[Char] = res0

check {
forAll(vowel) { v =>
validChars.contains(v)
}
forAll(vowel)(v => validChars.contains(v))
}
}

Expand Down Expand Up @@ -120,9 +118,7 @@ object GeneratorsSection
}

check {
forAll(listOfN(10, posNum[Int])) { list =>
!list.exists(_ < 0) && list.length == res2
}
forAll(listOfN(10, posNum[Int]))(list => !list.exists(_ < 0) && list.length == res2)
}
}

Expand Down Expand Up @@ -166,9 +162,7 @@ object GeneratorsSection
} yield Foo(intValue, charValue)

check {
forAll(fooGen) { foo =>
foo.intValue > 0 && foo.charValue.isDigit == res0
}
forAll(fooGen)(foo => foo.intValue > 0 && foo.charValue.isDigit == res0)
}
}

Expand Down
28 changes: 7 additions & 21 deletions src/main/scala/scalachecklib/PropertiesSection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ object PropertiesSection
import org.scalacheck.Prop.forAll

check {
forAll { (s1: String, s2: String) =>
(s1 + s2).endsWith(s2) == res0
}
forAll((s1: String, s2: String) => (s1 + s2).endsWith(s2) == res0)
}

}
Expand All @@ -103,9 +101,7 @@ object PropertiesSection
val smallInteger = Gen.choose(0, 100)

check {
forAll(smallInteger) { n =>
(n >= 0 && n <= 100) == res0
}
forAll(smallInteger)(n => (n >= 0 && n <= 100) == res0)
}

}
Expand Down Expand Up @@ -142,9 +138,7 @@ object PropertiesSection
import org.scalacheck.Prop.{forAll, propBoolean}

check {
forAll { n: Int =>
(n % 2 == 0) ==> (n % 2 == res0)
}
forAll { n: Int => (n % 2 == 0) ==> (n % 2 == res0) }
}

}
Expand Down Expand Up @@ -177,9 +171,7 @@ object PropertiesSection
forAll(smallInteger) { n =>
(n > 100) == res0
} &&
forAll(smallInteger) { n =>
(n >= 0) == res1
}
forAll(smallInteger)(n => (n >= 0) == res1)
}

}
Expand All @@ -204,17 +196,11 @@ object PropertiesSection

import org.scalacheck.Prop.{forAll, propBoolean}

property("addition property") = forAll { n: Int =>
(n != 0) ==> (n + res0 == n)
}
property("addition property") = forAll { n: Int => (n != 0) ==> (n + res0 == n) }

property("additive inverse property") = forAll { n: Int =>
(n != 0) ==> (n + (-n) == res1)
}
property("additive inverse property") = forAll { n: Int => (n != 0) ==> (n + (-n) == res1) }

property("multiplication property") = forAll { n: Int =>
(n != 0) ==> (n * res2 == 0)
}
property("multiplication property") = forAll { n: Int => (n != 0) ==> (n * res2 == 0) }

}

Expand Down
8 changes: 2 additions & 6 deletions src/main/scala/scalachecklib/ScalacheckDatetimeSection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ object ScalacheckDatetimeSection
import org.scalacheck.Prop.forAll

check {
forAll { dt: DateTime =>
(dt.getDayOfMonth >= 1 && dt.getDayOfMonth <= 31) == res0
}
forAll { dt: DateTime => (dt.getDayOfMonth >= 1 && dt.getDayOfMonth <= 31) == res0 }
}
}

Expand Down Expand Up @@ -127,9 +125,7 @@ object ScalacheckDatetimeSection
val range = Period.years(1)

check {
forAll(genDateTimeWithinRange(from, range)) { dt =>
dt.getYear == res0
}
forAll(genDateTimeWithinRange(from, range))(dt => dt.getYear == res0)
}
}

Expand Down
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.