Skip to content

Update to Scala 2.13.1 #160

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

Merged
merged 2 commits into from
Feb 3, 2020
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 .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dist: xenial
language: scala
scala:
- 2.12.10
- 2.13.1
jdk:
- openjdk8
script:
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val scalaExercisesV = "0.5.0-SNAPSHOT"
val scalaExercisesV = "0.6.0-SNAPSHOT"

def dep(artifactId: String) =
"org.scala-exercises" %% artifactId % scalaExercisesV excludeAll (ExclusionRule("io.monix"))
Expand Down
6 changes: 3 additions & 3 deletions project/ProjectPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ object ProjectPlugin extends AutoPlugin {
object autoImport {

lazy val V = new {
val scala212: String = "2.12.10"
val scala213: String = "2.13.1"
val shapeless: String = "2.3.3"
val scalatest: String = "3.1.0"
val scalatestplusScheck: String = "3.1.0.0-RC2"
val scalacheck: String = "1.14.2"
val scalacheck: String = "1.14.3"
val scalacheckShapeless: String = "1.2.3"
}
}
Expand All @@ -40,7 +40,7 @@ object ProjectPlugin extends AutoPlugin {
organizationEmail = "hello@47deg.com"
),
orgLicenseSetting := ApacheLicense,
scalaVersion := V.scala212,
scalaVersion := V.scala213,
scalaOrganization := "org.scala-lang",
resolvers ++= Seq(
Resolver.mavenLocal,
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.8
sbt.version=1.3.7
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots")
)

addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.5.0-SNAPSHOT")
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.6.0-SNAPSHOT")
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.12.0-M3")
8 changes: 3 additions & 5 deletions src/main/scala/stdlib/Asserts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ object Asserts extends AnyFlatSpec with Matchers with org.scalaexercises.definit
*
* Come on, your turn: true and false values can be compared with should matchers:
*/
def scalaTestAsserts(res0: Boolean) {
def scalaTestAsserts(res0: Boolean) =
true should be(res0)
}

/** Booleans in asserts can test equality:
*/
def booleanAsserts(res0: Int) {
def booleanAsserts(res0: Int) = {
val v1 = 4
v1 shouldEqual res0

Expand All @@ -60,8 +59,7 @@ object Asserts extends AnyFlatSpec with Matchers with org.scalaexercises.definit

/** Sometimes we expect you to fill in the values:
*/
def valuesAsserts(res0: Int) {
def valuesAsserts(res0: Int) =
assert(res0 == 1 + 1)
}

}
18 changes: 9 additions & 9 deletions src/main/scala/stdlib/ByNameParameter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ object ByNameParameter

/** `() => Int` is a Function type that takes a `Unit` type. `Unit` is known as `void` to a Java programmer. The function returns an `Int`. You can place this as a method parameter so that you can you use it as a block, but still it doesn't look quite right:
*/
def takesUnitByNameParameter(res0: Either[Throwable, Int]) {
def calc(x: () Int): Either[Throwable, Int] = {
def takesUnitByNameParameter(res0: Either[Throwable, Int]) = {
def calc(x: () => Int): Either[Throwable, Int] = {
try {
Right(x()) //An explicit call of the x function
} catch {
case b: Throwable Left(b)
case b: Throwable => Left(b)
}
}

val y = calc { () //Having explicitly declaring that Unit is a parameter with ()
val y = calc { () => //Having explicitly declaring that Unit is a parameter with ()
14 + 15
}

Expand All @@ -36,13 +36,13 @@ object ByNameParameter

/** A by-name parameter does the same thing as the previous koan but there is no need to explicitly handle `Unit` or `()`. This is used extensively in Scala to create blocks:
*/
def byNameParameter(res0: Either[Throwable, Int]) {
def calc(x: Int): Either[Throwable, Int] = {
def byNameParameter(res0: Either[Throwable, Int]) = {
def calc(x: => Int): Either[Throwable, Int] = {
//x is a call by name parameter
try {
Right(x)
} catch {
case b: Throwable Left(b)
case b: Throwable => Left(b)
}
}

Expand All @@ -58,9 +58,9 @@ object ByNameParameter

/** By name parameters can also be used with `object` and `apply` to make interesting block-like calls:
*/
def withApplyByNameParameter(res0: String) {
def withApplyByNameParameter(res0: String) = {
object PigLatinizer {
def apply(x: String) = x.tail + x.head + "ay"
def apply(x: => String) = x.tail + x.head + "ay"
}

val result = PigLatinizer {
Expand Down
22 changes: 11 additions & 11 deletions src/main/scala/stdlib/CaseClasses.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def
*
* {{{
* object TermTest extends Application {
* def printTerm(term: Term) {
* def printTerm(term: Term) = {
* term match {
* case Var(n) =>
* print(n)
Expand Down Expand Up @@ -94,7 +94,7 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def
*
* Case classes have an automatic equals method that works:
*/
def caseClassesSupportEquality(res0: Boolean, res1: Boolean, res2: Boolean, res3: Boolean) {
def caseClassesSupportEquality(res0: Boolean, res1: Boolean, res2: Boolean, res3: Boolean) = {
case class Person(first: String, last: String)

val p1 = new Person("Fred", "Jones")
Expand All @@ -110,7 +110,7 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def

/** Case classes have an automatic hashcode method that works:
*/
def hashcodeMethodCaseClasses(res0: Boolean, res1: Boolean) {
def hashcodeMethodCaseClasses(res0: Boolean, res1: Boolean) = {
case class Person(first: String, last: String)

val p1 = new Person("Fred", "Jones")
Expand All @@ -123,7 +123,7 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def

/** Case classes can be created in a convenient way:
*/
def creationCaseClasses(res0: Boolean, res1: Boolean, res2: Boolean) {
def creationCaseClasses(res0: Boolean, res1: Boolean, res2: Boolean) = {
case class Dog(name: String, breed: String)

val d1 = Dog("Scooby", "Doberman")
Expand All @@ -137,15 +137,15 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def

/** Case classes have a convenient toString method defined:
*/
def toStringMethodCaseClasses(res0: String) {
def toStringMethodCaseClasses(res0: String) = {
case class Dog(name: String, breed: String)
val d1 = Dog("Scooby", "Doberman")
d1.toString should be(res0)
}

/** Case classes have automatic properties:
*/
def propertiesCaseClasses(res0: String, res1: String) {
def propertiesCaseClasses(res0: String, res1: String) = {
case class Dog(name: String, breed: String)

val d1 = Dog("Scooby", "Doberman")
Expand All @@ -155,7 +155,7 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def

/** Case classes can have mutable properties:
*/
def mutablePropertiesCaseClasses(res0: String, res1: String, res2: String, res3: String) {
def mutablePropertiesCaseClasses(res0: String, res1: String, res2: String, res3: String) = {
case class Dog(var name: String, breed: String) // you can rename a dog, but change its breed? nah!
val d1 = Dog("Scooby", "Doberman")

Expand All @@ -170,7 +170,7 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def

/** There are safer alternatives for altering case classes:
*/
def alteringCaseClasses(res0: String, res1: String, res2: String, res3: String) {
def alteringCaseClasses(res0: String, res1: String, res2: String, res3: String) = {
case class Dog(name: String, breed: String) // Doberman

val d1 = Dog("Scooby", "Doberman")
Expand Down Expand Up @@ -199,7 +199,7 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def
res9: String,
res10: Int,
res11: String,
res12: Boolean) {
res12: Boolean) = {
case class Person(first: String, last: String, age: Int = 0, ssn: String = "")
val p1 = Person("Fred", "Jones", 23, "111-22-3333")
val p2 = Person("Samantha", "Jones") // note missing age and ssn
Expand All @@ -226,7 +226,7 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def

/** Case classes can be disassembled to their constituent parts as a tuple:
*/
def asTupleCaseClasses(res0: String, res1: String, res2: Int, res3: String) {
def asTupleCaseClasses(res0: String, res1: String, res2: Int, res3: String) = {
case class Person(first: String, last: String, age: Int = 0, ssn: String = "")
val p1 = Person("Fred", "Jones", 23, "111-22-3333")

Expand All @@ -240,7 +240,7 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def

/** Case classes are `Serializable`:
*/
def serializableCaseClasses(res0: Boolean, res1: Boolean) {
def serializableCaseClasses(res0: Boolean, res1: Boolean) = {
case class PersonCC(firstName: String, lastName: String)
val indy = PersonCC("Indiana", "Jones")

Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/stdlib/Classes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object Classes extends AnyFlatSpec with Matchers with org.scalaexercises.definit
* Here is a class definition which defines a class Point:
*
* {{{
* class Point(x: Int, y: Int) {
* class Point(x: Int, y: Int) = {
* override def toString(): String = "(" + x + ", " + y + ")"
* }
* }}}
Expand All @@ -29,7 +29,7 @@ object Classes extends AnyFlatSpec with Matchers with org.scalaexercises.definit
*
* {{{
* object Classes {
* def main(args: Array[String]) {
* def main(args: Array[String]) = {
* val pt = new Point(1, 2)
* println(pt)
* }
Expand All @@ -41,7 +41,7 @@ object Classes extends AnyFlatSpec with Matchers with org.scalaexercises.definit
* This also demonstrates the use of value parameters in `ClassWithValParameter(val name: String)`, which automatically creates an internal property `val name: String` in the class:
*
*/
def classWithValParameterClasses(res0: String) {
def classWithValParameterClasses(res0: String) = {
class ClassWithValParameter(val name: String)
val aClass = new ClassWithValParameter("Gandalf")
aClass.name should be(res0)
Expand Down
26 changes: 10 additions & 16 deletions src/main/scala/stdlib/EmptyValues.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,69 +36,63 @@ object EmptyValues extends AnyFlatSpec with Matchers with org.scalaexercises.def
*
* An empty list can be represented by another nothing value: `Nil`
*/
def emptyValuesEmptyValues(res0: Boolean) {
def emptyValuesEmptyValues(res0: Boolean) =
List() === Nil shouldBe res0
}

/** [[http://www.scala-lang.org/api/current/index.html#scala.None None]] is the counterpart to [[http://www.scala-lang.org/api/current/index.html#scala.Some Some]], used when you're using Scala's [[http://www.scala-lang.org/api/current/index.html#scala.Option Option]] class to help avoid `null` references.
*
* `None` equals `None`:
*/
def avoidingNullEmptyValues(res0: Boolean) {
def avoidingNullEmptyValues(res0: Boolean) =
None === None shouldBe res0
}

/** `None` should be identical to `None`:
*/
def identicalNoneEmptyValues(res0: Boolean) {
def identicalNoneEmptyValues(res0: Boolean) =
None eq None shouldBe res0
}

/** `None` can be converted to a String:
*/
def noneToStringEmptyValues(res0: String) {
def noneToStringEmptyValues(res0: String) =
assert(None.toString === res0)
}

/** `None` can be converted to an empty list:
*/
def noneToListEmptyValues(res0: Boolean) {
def noneToListEmptyValues(res0: Boolean) =
None.toList === Nil shouldBe res0
}

/** `None` is considered empty:
*/
def noneAsEmptyEmptyValues(res0: Boolean) {
def noneAsEmptyEmptyValues(res0: Boolean) =
assert(None.isEmpty === res0)
}

/** `None` can be cast to `Any`, `AnyRef` or `AnyVal`:
*/
def noneToAnyEmptyValues(res0: Boolean, res1: Boolean, res2: Boolean) {
def noneToAnyEmptyValues(res0: Boolean, res1: Boolean, res2: Boolean) = {
None.asInstanceOf[Any] === None shouldBe res0
None.asInstanceOf[AnyRef] === None shouldBe res1
None.asInstanceOf[AnyVal] === None shouldBe res2
}

/** `None` can be used with `Option` instead of null references:
*/
def noneWithOptionEmptyValues(res0: Boolean, res1: Option[String]) {
def noneWithOptionEmptyValues(res0: Boolean, res1: Option[String]) = {
val optional: Option[String] = None
assert(optional.isEmpty === res0)
assert(optional === res1)
}

/** `Some` is the opposite of `None` for `Option` types:
*/
def someAgainstNoneEmptyValues(res0: Boolean, res1: Boolean) {
def someAgainstNoneEmptyValues(res0: Boolean, res1: Boolean) = {
val optional: Option[String] = Some("Some Value")
assert((optional == None) === res0, "Some(value) should not equal None")
assert(optional.isEmpty === res1, "Some(value) should not be empty")
}

/** `Option.getOrElse` can be used to provide a default in the case of `None`:
*/
def getOrElseEmptyValues(res0: String, res1: String) {
def getOrElseEmptyValues(res0: String, res1: String) = {
val optional: Option[String] = Some("Some Value")
val optional2: Option[String] = None
assert(optional.getOrElse("No Value") === res0, "Should return the value in the option")
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/stdlib/Enumerations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de
res2: String,
res3: String,
res4: Boolean,
res5: Boolean) {
res5: Boolean) = {
object Planets extends Enumeration {
val Mercury = Value
val Venus = Value
Expand Down Expand Up @@ -55,7 +55,7 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de
res2: String,
res3: String,
res4: Boolean,
res5: Boolean) {
res5: Boolean) = {
object GreekPlanets extends Enumeration {

val Mercury = Value(1, "Hermes")
Expand Down Expand Up @@ -88,7 +88,7 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de
res2: String,
res3: String,
res4: Boolean,
res5: Boolean) {
res5: Boolean) = {
object Planets extends Enumeration {
val Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto = Value
}
Expand All @@ -111,7 +111,7 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de
res2: String,
res3: String,
res4: Boolean,
res5: Boolean) {
res5: Boolean) = {
object GreekPlanets extends Enumeration {

val Mercury = Value("Hermes")
Expand All @@ -137,7 +137,7 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de

/** You can extend the `Enumeration` by extending the `Value` class.
*/
def extendingValueEnumerations(res0: Double, res1: Double) {
def extendingValueEnumerations(res0: Double, res1: Double) = {
object Planets extends Enumeration {

val G = 6.67300E-11
Expand Down
Loading