Skip to content

Commit 35179cc

Browse files
authored
Merge pull request #160 from scala-exercises/enrique-2-13-1-update
Update to Scala 2.13.1
2 parents aafecd0 + 219c27e commit 35179cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+447
-496
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dist: xenial
22
language: scala
33
scala:
4-
- 2.12.10
4+
- 2.13.1
55
jdk:
66
- openjdk8
77
script:

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
val scalaExercisesV = "0.5.0-SNAPSHOT"
1+
val scalaExercisesV = "0.6.0-SNAPSHOT"
22

33
def dep(artifactId: String) =
44
"org.scala-exercises" %% artifactId % scalaExercisesV excludeAll (ExclusionRule("io.monix"))

project/ProjectPlugin.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ object ProjectPlugin extends AutoPlugin {
1616
object autoImport {
1717

1818
lazy val V = new {
19-
val scala212: String = "2.12.10"
19+
val scala213: String = "2.13.1"
2020
val shapeless: String = "2.3.3"
2121
val scalatest: String = "3.1.0"
2222
val scalatestplusScheck: String = "3.1.0.0-RC2"
23-
val scalacheck: String = "1.14.2"
23+
val scalacheck: String = "1.14.3"
2424
val scalacheckShapeless: String = "1.2.3"
2525
}
2626
}
@@ -40,7 +40,7 @@ object ProjectPlugin extends AutoPlugin {
4040
organizationEmail = "hello@47deg.com"
4141
),
4242
orgLicenseSetting := ApacheLicense,
43-
scalaVersion := V.scala212,
43+
scalaVersion := V.scala213,
4444
scalaOrganization := "org.scala-lang",
4545
resolvers ++= Seq(
4646
Resolver.mavenLocal,

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.8
1+
sbt.version=1.3.7

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ resolvers ++= Seq(
22
Resolver.sonatypeRepo("snapshots")
33
)
44

5-
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.5.0-SNAPSHOT")
5+
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.6.0-SNAPSHOT")
66
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.12.0-M3")

src/main/scala/stdlib/Asserts.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@ object Asserts extends AnyFlatSpec with Matchers with org.scalaexercises.definit
4545
*
4646
* Come on, your turn: true and false values can be compared with should matchers:
4747
*/
48-
def scalaTestAsserts(res0: Boolean) {
48+
def scalaTestAsserts(res0: Boolean) =
4949
true should be(res0)
50-
}
5150

5251
/** Booleans in asserts can test equality:
5352
*/
54-
def booleanAsserts(res0: Int) {
53+
def booleanAsserts(res0: Int) = {
5554
val v1 = 4
5655
v1 shouldEqual res0
5756

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

6160
/** Sometimes we expect you to fill in the values:
6261
*/
63-
def valuesAsserts(res0: Int) {
62+
def valuesAsserts(res0: Int) =
6463
assert(res0 == 1 + 1)
65-
}
6664

6765
}

src/main/scala/stdlib/ByNameParameter.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ object ByNameParameter
1818

1919
/** `() => 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:
2020
*/
21-
def takesUnitByNameParameter(res0: Either[Throwable, Int]) {
22-
def calc(x: () Int): Either[Throwable, Int] = {
21+
def takesUnitByNameParameter(res0: Either[Throwable, Int]) = {
22+
def calc(x: () => Int): Either[Throwable, Int] = {
2323
try {
2424
Right(x()) //An explicit call of the x function
2525
} catch {
26-
case b: Throwable Left(b)
26+
case b: Throwable => Left(b)
2727
}
2828
}
2929

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

@@ -36,13 +36,13 @@ object ByNameParameter
3636

3737
/** 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:
3838
*/
39-
def byNameParameter(res0: Either[Throwable, Int]) {
40-
def calc(x: Int): Either[Throwable, Int] = {
39+
def byNameParameter(res0: Either[Throwable, Int]) = {
40+
def calc(x: => Int): Either[Throwable, Int] = {
4141
//x is a call by name parameter
4242
try {
4343
Right(x)
4444
} catch {
45-
case b: Throwable Left(b)
45+
case b: Throwable => Left(b)
4646
}
4747
}
4848

@@ -58,9 +58,9 @@ object ByNameParameter
5858

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

6666
val result = PigLatinizer {

src/main/scala/stdlib/CaseClasses.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def
6060
*
6161
* {{{
6262
* object TermTest extends Application {
63-
* def printTerm(term: Term) {
63+
* def printTerm(term: Term) = {
6464
* term match {
6565
* case Var(n) =>
6666
* print(n)
@@ -94,7 +94,7 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def
9494
*
9595
* Case classes have an automatic equals method that works:
9696
*/
97-
def caseClassesSupportEquality(res0: Boolean, res1: Boolean, res2: Boolean, res3: Boolean) {
97+
def caseClassesSupportEquality(res0: Boolean, res1: Boolean, res2: Boolean, res3: Boolean) = {
9898
case class Person(first: String, last: String)
9999

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

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

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

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

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

138138
/** Case classes have a convenient toString method defined:
139139
*/
140-
def toStringMethodCaseClasses(res0: String) {
140+
def toStringMethodCaseClasses(res0: String) = {
141141
case class Dog(name: String, breed: String)
142142
val d1 = Dog("Scooby", "Doberman")
143143
d1.toString should be(res0)
144144
}
145145

146146
/** Case classes have automatic properties:
147147
*/
148-
def propertiesCaseClasses(res0: String, res1: String) {
148+
def propertiesCaseClasses(res0: String, res1: String) = {
149149
case class Dog(name: String, breed: String)
150150

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

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

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

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

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

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

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

241241
/** Case classes are `Serializable`:
242242
*/
243-
def serializableCaseClasses(res0: Boolean, res1: Boolean) {
243+
def serializableCaseClasses(res0: Boolean, res1: Boolean) = {
244244
case class PersonCC(firstName: String, lastName: String)
245245
val indy = PersonCC("Indiana", "Jones")
246246

src/main/scala/stdlib/Classes.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object Classes extends AnyFlatSpec with Matchers with org.scalaexercises.definit
1717
* Here is a class definition which defines a class Point:
1818
*
1919
* {{{
20-
* class Point(x: Int, y: Int) {
20+
* class Point(x: Int, y: Int) = {
2121
* override def toString(): String = "(" + x + ", " + y + ")"
2222
* }
2323
* }}}
@@ -29,7 +29,7 @@ object Classes extends AnyFlatSpec with Matchers with org.scalaexercises.definit
2929
*
3030
* {{{
3131
* object Classes {
32-
* def main(args: Array[String]) {
32+
* def main(args: Array[String]) = {
3333
* val pt = new Point(1, 2)
3434
* println(pt)
3535
* }
@@ -41,7 +41,7 @@ object Classes extends AnyFlatSpec with Matchers with org.scalaexercises.definit
4141
* 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:
4242
*
4343
*/
44-
def classWithValParameterClasses(res0: String) {
44+
def classWithValParameterClasses(res0: String) = {
4545
class ClassWithValParameter(val name: String)
4646
val aClass = new ClassWithValParameter("Gandalf")
4747
aClass.name should be(res0)

src/main/scala/stdlib/EmptyValues.scala

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,69 +36,63 @@ object EmptyValues extends AnyFlatSpec with Matchers with org.scalaexercises.def
3636
*
3737
* An empty list can be represented by another nothing value: `Nil`
3838
*/
39-
def emptyValuesEmptyValues(res0: Boolean) {
39+
def emptyValuesEmptyValues(res0: Boolean) =
4040
List() === Nil shouldBe res0
41-
}
4241

4342
/** [[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.
4443
*
4544
* `None` equals `None`:
4645
*/
47-
def avoidingNullEmptyValues(res0: Boolean) {
46+
def avoidingNullEmptyValues(res0: Boolean) =
4847
None === None shouldBe res0
49-
}
5048

5149
/** `None` should be identical to `None`:
5250
*/
53-
def identicalNoneEmptyValues(res0: Boolean) {
51+
def identicalNoneEmptyValues(res0: Boolean) =
5452
None eq None shouldBe res0
55-
}
5653

5754
/** `None` can be converted to a String:
5855
*/
59-
def noneToStringEmptyValues(res0: String) {
56+
def noneToStringEmptyValues(res0: String) =
6057
assert(None.toString === res0)
61-
}
6258

6359
/** `None` can be converted to an empty list:
6460
*/
65-
def noneToListEmptyValues(res0: Boolean) {
61+
def noneToListEmptyValues(res0: Boolean) =
6662
None.toList === Nil shouldBe res0
67-
}
6863

6964
/** `None` is considered empty:
7065
*/
71-
def noneAsEmptyEmptyValues(res0: Boolean) {
66+
def noneAsEmptyEmptyValues(res0: Boolean) =
7267
assert(None.isEmpty === res0)
73-
}
7468

7569
/** `None` can be cast to `Any`, `AnyRef` or `AnyVal`:
7670
*/
77-
def noneToAnyEmptyValues(res0: Boolean, res1: Boolean, res2: Boolean) {
71+
def noneToAnyEmptyValues(res0: Boolean, res1: Boolean, res2: Boolean) = {
7872
None.asInstanceOf[Any] === None shouldBe res0
7973
None.asInstanceOf[AnyRef] === None shouldBe res1
8074
None.asInstanceOf[AnyVal] === None shouldBe res2
8175
}
8276

8377
/** `None` can be used with `Option` instead of null references:
8478
*/
85-
def noneWithOptionEmptyValues(res0: Boolean, res1: Option[String]) {
79+
def noneWithOptionEmptyValues(res0: Boolean, res1: Option[String]) = {
8680
val optional: Option[String] = None
8781
assert(optional.isEmpty === res0)
8882
assert(optional === res1)
8983
}
9084

9185
/** `Some` is the opposite of `None` for `Option` types:
9286
*/
93-
def someAgainstNoneEmptyValues(res0: Boolean, res1: Boolean) {
87+
def someAgainstNoneEmptyValues(res0: Boolean, res1: Boolean) = {
9488
val optional: Option[String] = Some("Some Value")
9589
assert((optional == None) === res0, "Some(value) should not equal None")
9690
assert(optional.isEmpty === res1, "Some(value) should not be empty")
9791
}
9892

9993
/** `Option.getOrElse` can be used to provide a default in the case of `None`:
10094
*/
101-
def getOrElseEmptyValues(res0: String, res1: String) {
95+
def getOrElseEmptyValues(res0: String, res1: String) = {
10296
val optional: Option[String] = Some("Some Value")
10397
val optional2: Option[String] = None
10498
assert(optional.getOrElse("No Value") === res0, "Should return the value in the option")

src/main/scala/stdlib/Enumerations.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de
2424
res2: String,
2525
res3: String,
2626
res4: Boolean,
27-
res5: Boolean) {
27+
res5: Boolean) = {
2828
object Planets extends Enumeration {
2929
val Mercury = Value
3030
val Venus = Value
@@ -55,7 +55,7 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de
5555
res2: String,
5656
res3: String,
5757
res4: Boolean,
58-
res5: Boolean) {
58+
res5: Boolean) = {
5959
object GreekPlanets extends Enumeration {
6060

6161
val Mercury = Value(1, "Hermes")
@@ -88,7 +88,7 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de
8888
res2: String,
8989
res3: String,
9090
res4: Boolean,
91-
res5: Boolean) {
91+
res5: Boolean) = {
9292
object Planets extends Enumeration {
9393
val Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto = Value
9494
}
@@ -111,7 +111,7 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de
111111
res2: String,
112112
res3: String,
113113
res4: Boolean,
114-
res5: Boolean) {
114+
res5: Boolean) = {
115115
object GreekPlanets extends Enumeration {
116116

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

138138
/** You can extend the `Enumeration` by extending the `Value` class.
139139
*/
140-
def extendingValueEnumerations(res0: Double, res1: Double) {
140+
def extendingValueEnumerations(res0: Double, res1: Double) = {
141141
object Planets extends Enumeration {
142142

143143
val G = 6.67300E-11

0 commit comments

Comments
 (0)