From f9938eb37a4cce46279621a7aa062fa4094809de Mon Sep 17 00:00:00 2001 From: Juan Pedro Moreno Date: Thu, 18 Jun 2020 13:35:42 +0200 Subject: [PATCH] Prepare repository for next release and SBT build improvements --- .scalafmt.conf | 2 +- CONTRIBUTING.md | 2 +- LICENSE.md | 2 +- NOTICE.md | 2 +- build.sbt | 31 +++- {.docs => docs}/AUTHORS.md | 0 {.docs => docs}/CODE_OF_CONDUCT.md | 0 {.docs => docs}/CONTRIBUTING.md | 0 {.docs => docs}/LICENSE.md | 0 {.docs => docs}/NOTICE.md | 0 project/ProjectPlugin.scala | 45 ----- project/build.properties | 2 +- project/plugins.sbt | 18 +- src/main/scala/stdlib/Asserts.scala | 18 +- src/main/scala/stdlib/ByNameParameter.scala | 24 +-- src/main/scala/stdlib/CaseClasses.scala | 50 ++++-- src/main/scala/stdlib/Classes.scala | 9 +- src/main/scala/stdlib/EmptyValues.scala | 36 ++-- src/main/scala/stdlib/Enumerations.scala | 21 ++- src/main/scala/stdlib/Extractors.scala | 31 ++-- src/main/scala/stdlib/ForExpressions.scala | 12 +- src/main/scala/stdlib/Formatting.scala | 21 ++- .../scala/stdlib/HigherOrderFunctions.scala | 41 +++-- src/main/scala/stdlib/Implicits.scala | 24 ++- .../InfixPrefixandPostfixOperators.scala | 21 ++- src/main/scala/stdlib/InfixTypes.scala | 12 +- src/main/scala/stdlib/Iterables.scala | 47 +++-- src/main/scala/stdlib/Lists.scala | 54 ++++-- src/main/scala/stdlib/LiteralBooleans.scala | 9 +- src/main/scala/stdlib/LiteralNumbers.scala | 23 +-- src/main/scala/stdlib/LiteralStrings.scala | 36 ++-- src/main/scala/stdlib/Maps.scala | 49 +++-- .../stdlib/NamedandDefaultArguments.scala | 24 ++- .../NamedandDefaultArgumentsHelper.scala | 2 +- src/main/scala/stdlib/Objects.scala | 23 ++- src/main/scala/stdlib/Options.scala | 27 +-- src/main/scala/stdlib/OptionsHelper.scala | 2 +- src/main/scala/stdlib/ParentClasses.scala | 21 ++- src/main/scala/stdlib/PartialFunctions.scala | 18 +- .../stdlib/PartiallyAppliedFunctions.scala | 18 +- src/main/scala/stdlib/PatternMatching.scala | 105 ++++++----- src/main/scala/stdlib/Ranges.scala | 26 +-- .../scala/stdlib/RepeatedParameters.scala | 30 +++- .../stdlib/RepeatedParametersHelper.scala | 2 +- .../scala/stdlib/SequencesandArrays.scala | 28 +-- src/main/scala/stdlib/Sets.scala | 45 +++-- src/main/scala/stdlib/StdLib.scala | 82 ++++----- src/main/scala/stdlib/Traits.scala | 17 +- src/main/scala/stdlib/Traversables.scala | 169 ++++++++++++------ src/main/scala/stdlib/Tuples.scala | 18 +- src/main/scala/stdlib/TypeSignatures.scala | 18 +- src/main/scala/stdlib/TypeVariance.scala | 27 +-- .../scala/stdlib/TypeVarianceHelper.scala | 2 +- .../scala/stdlib/UniformAccessPrinciple.scala | 10 +- src/test/scala/stdlib/AssertsSpec.scala | 2 +- .../scala/stdlib/ByNameParameterSpec.scala | 2 +- src/test/scala/stdlib/CaseClassesSpec.scala | 2 +- src/test/scala/stdlib/ClassesSpec.scala | 2 +- src/test/scala/stdlib/EmptyValuesSpec.scala | 2 +- src/test/scala/stdlib/ExtractorsSpec.scala | 2 +- .../scala/stdlib/ForExpressionsSpec.scala | 2 +- src/test/scala/stdlib/FormattingSpec.scala | 2 +- .../stdlib/HigherOrderFunctionsSpec.scala | 2 +- src/test/scala/stdlib/ImplicitsSpec.scala | 2 +- .../InfixPrefixAndPostfixOperatorsSpec.scala | 2 +- src/test/scala/stdlib/InfixTypesSpec.scala | 2 +- src/test/scala/stdlib/IterablesSpec.scala | 2 +- src/test/scala/stdlib/ListsSpec.scala | 2 +- .../scala/stdlib/LiteralBooleansSpec.scala | 2 +- .../scala/stdlib/LiteralNumbersSpec.scala | 2 +- .../scala/stdlib/LiteralStringsSpec.scala | 2 +- src/test/scala/stdlib/MapsSpec.scala | 2 +- .../stdlib/NamedAndDefaultArgumentsSpec.scala | 2 +- src/test/scala/stdlib/ObjectsSpec.scala | 2 +- src/test/scala/stdlib/OptionsSpec.scala | 2 +- src/test/scala/stdlib/ParentClassesSpec.scala | 2 +- .../scala/stdlib/PartialFunctionsSpec.scala | 2 +- .../PartiallyAppliedFunctionsSpec.scala | 2 +- .../scala/stdlib/PatternMatchingSpec.scala | 2 +- src/test/scala/stdlib/RangesSpec.scala | 2 +- .../scala/stdlib/RepeatedParametersSpec.scala | 2 +- .../scala/stdlib/SequencesAndArraysSpec.scala | 2 +- src/test/scala/stdlib/SetsSpec.scala | 2 +- src/test/scala/stdlib/TraitsSpec.scala | 2 +- src/test/scala/stdlib/TraversablesSpec.scala | 2 +- src/test/scala/stdlib/TuplesSpec.scala | 2 +- .../scala/stdlib/TypeSignaturesSpec.scala | 2 +- src/test/scala/stdlib/TypeVarianceSpec.scala | 2 +- .../stdlib/UniformAccessPrincipleSpec.scala | 2 +- 89 files changed, 843 insertions(+), 583 deletions(-) rename {.docs => docs}/AUTHORS.md (100%) rename {.docs => docs}/CODE_OF_CONDUCT.md (100%) rename {.docs => docs}/CONTRIBUTING.md (100%) rename {.docs => docs}/LICENSE.md (100%) rename {.docs => docs}/NOTICE.md (100%) delete mode 100644 project/ProjectPlugin.scala diff --git a/.scalafmt.conf b/.scalafmt.conf index 97595104..c67bf5c6 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version=2.4.2 +version=2.6.0 style = defaultWithAlign maxColumn = 100 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f881fe67..63d0b108 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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-stdlib_ 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? diff --git a/LICENSE.md b/LICENSE.md index fef1c3a0..c21be17b 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright (C) 2016-2020 47 Degrees + Copyright (C) 2016-2020 47 Degrees Open Source Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/NOTICE.md b/NOTICE.md index b14d9645..b23944c1 100644 --- a/NOTICE.md +++ b/NOTICE.md @@ -4,6 +4,6 @@ exercises-stdlib -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. \ No newline at end of file diff --git a/build.sbt b/build.sbt index 19cb197d..a21d284e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,20 +1,35 @@ 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-stdlib") - .settings(exercisesSettings) + .settings(name := "exercises-stdlib") + .settings( + libraryDependencies ++= Seq( + "org.scala-exercises" %% "exercise-compiler" % "0.6.1", + "org.scala-exercises" %% "definitions" % "0.6.1", + "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) - .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) diff --git a/.docs/AUTHORS.md b/docs/AUTHORS.md similarity index 100% rename from .docs/AUTHORS.md rename to docs/AUTHORS.md diff --git a/.docs/CODE_OF_CONDUCT.md b/docs/CODE_OF_CONDUCT.md similarity index 100% rename from .docs/CODE_OF_CONDUCT.md rename to docs/CODE_OF_CONDUCT.md diff --git a/.docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md similarity index 100% rename from .docs/CONTRIBUTING.md rename to docs/CONTRIBUTING.md diff --git a/.docs/LICENSE.md b/docs/LICENSE.md similarity index 100% rename from .docs/LICENSE.md rename to docs/LICENSE.md diff --git a/.docs/NOTICE.md b/docs/NOTICE.md similarity index 100% rename from .docs/NOTICE.md rename to docs/NOTICE.md diff --git a/project/ProjectPlugin.scala b/project/ProjectPlugin.scala deleted file mode 100644 index ba1e748b..00000000 --- a/project/ProjectPlugin.scala +++ /dev/null @@ -1,45 +0,0 @@ -import sbt.Keys._ -import sbt._ -import com.alejandrohdezma.sbt.github.SbtGithubPlugin - -object ProjectPlugin extends AutoPlugin { - - override def trigger: PluginTrigger = allRequirements - - override def requires: Plugins = plugins.JvmPlugin && SbtGithubPlugin - - object autoImport { - - lazy val V = new { - val shapeless: String = "2.3.3" - val scala: String = "2.13.2" - val scalaExercises: String = "0.6.0" - val scalacheck: String = "1.14.3" - val scalacheckShapeless: String = "1.2.5" - val scalatest: String = "3.1.2" - val scalatestplusScheck: String = "3.1.1.1" - } - - def dep(artifactId: String) = "org.scala-exercises" %% artifactId % V.scalaExercises - - lazy val exercisesSettings = Seq( - libraryDependencies ++= Seq( - dep("exercise-compiler"), - dep("definitions"), - "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( - organization := "org.scala-exercises", - organizationName := "47 Degrees", - organizationHomepage := Some(url("https://47deg.com")), - scalaVersion := autoImport.V.scala - ) -} diff --git a/project/build.properties b/project/build.properties index 742d2e04..654fe70c 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.3.11 +sbt.version=1.3.12 diff --git a/project/plugins.sbt b/project/plugins.sbt index 2ef287e2..729558cf 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,9 @@ -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") diff --git a/src/main/scala/stdlib/Asserts.scala b/src/main/scala/stdlib/Asserts.scala index e0dbbd7b..999ee9ee 100644 --- a/src/main/scala/stdlib/Asserts.scala +++ b/src/main/scala/stdlib/Asserts.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name asserts +/** + * @param name asserts */ object Asserts extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** ScalaTest makes three assertions available by default in any style trait. You can use: + /** + * ScalaTest makes three assertions available by default in any style trait. You can use: * * - `assert` for general assertions; * - `assertResult` to differentiate expected from actual values; @@ -41,7 +43,6 @@ object Asserts extends AnyFlatSpec with Matchers with org.scalaexercises.definit * Scala's `assert` will complete abruptly with an `AssertionError`. This behavior is provided by * the `assert` method defined in object `Predef`, whose members are implicitly imported into every Scala source file. * - * * ScalaTest provides a domain specific language (DSL) for expressing assertions in tests * using the word `should`. ScalaTest matchers provides five different ways to check equality, each designed to address a different need. They are: * @@ -58,16 +59,19 @@ object Asserts extends AnyFlatSpec with Matchers with org.scalaexercises.definit def scalaTestAsserts(res0: Boolean) = true should be(res0) - /** Booleans in asserts can test equality: + /** + * Booleans in asserts can test equality: */ def booleanAsserts(res0: Int) = { val v1 = 4 v1 shouldEqual res0 - /** `shouldEqual` is an assertion. It is from ScalaTest, not from the Scala language. */ + /** + * `shouldEqual` is an assertion. It is from ScalaTest, not from the Scala language. */ } - /** Sometimes we expect you to fill in the values: + /** + * Sometimes we expect you to fill in the values: */ def valuesAsserts(res0: Int) = assert(res0 == 1 + 1) diff --git a/src/main/scala/stdlib/ByNameParameter.scala b/src/main/scala/stdlib/ByNameParameter.scala index b78f3436..a424315c 100644 --- a/src/main/scala/stdlib/ByNameParameter.scala +++ b/src/main/scala/stdlib/ByNameParameter.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,20 +19,21 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name byname_parameter +/** + * @param name byname_parameter */ object ByNameParameter extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** `() => 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: + /** + * `() => 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] = { - try { - Right(x()) // An explicit call of the x function - } catch { + try Right(x()) // An explicit call of the x function + catch { case b: Throwable => Left(b) } } @@ -44,14 +45,14 @@ object ByNameParameter y should be(res0) } - /** 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: + /** + * 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] = { // x is a call by-name parameter - try { - Right(x) - } catch { + try Right(x) + catch { case b: Throwable => Left(b) } } @@ -66,7 +67,8 @@ object ByNameParameter y should be(res0) } - /** By-name parameters can also be used with `object` and `apply` to make interesting block-like calls: + /** + * By-name parameters can also be used with `object` and `apply` to make interesting block-like calls: */ def withApplyByNameParameter(res0: String) = { object PigLatinizer { diff --git a/src/main/scala/stdlib/CaseClasses.scala b/src/main/scala/stdlib/CaseClasses.scala index 3100a463..f8a92050 100644 --- a/src/main/scala/stdlib/CaseClasses.scala +++ b/src/main/scala/stdlib/CaseClasses.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name case_classes +/** + * @param name case_classes */ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Scala supports the notion of ''case classes''. Case classes are regular classes which export their constructor parameters and which provide a recursive decomposition mechanism via pattern matching. + /** + * Scala supports the notion of ''case classes''. Case classes are regular classes which export their constructor parameters and which provide a recursive decomposition mechanism via pattern matching. * * Here is an example for a class hierarchy which consists of an abstract superclass `Term` and three concrete case classes `Var`, `Fun`, and `App`: * @@ -118,7 +120,8 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def (p1 eq p3) should be(res3) // not identical, merely equal } - /** Case classes have an automatic hashcode method that works: + /** + * Case classes have an automatic hashcode method that works: */ def hashcodeMethodCaseClasses(res0: Boolean, res1: Boolean) = { case class Person(first: String, last: String) @@ -131,7 +134,8 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def (p1.hashCode == p3.hashCode) should be(res1) } - /** Case classes can be created in a convenient way: + /** + * Case classes can be created in a convenient way: */ def creationCaseClasses(res0: Boolean, res1: Boolean, res2: Boolean) = { case class Dog(name: String, breed: String) @@ -145,7 +149,8 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def (d2 == d3) should be(res2) } - /** Case classes have a convenient toString method defined: + /** + * Case classes have a convenient toString method defined: */ def toStringMethodCaseClasses(res0: String) = { case class Dog(name: String, breed: String) @@ -153,7 +158,8 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def d1.toString should be(res0) } - /** Case classes have automatic properties: + /** + * Case classes have automatic properties: */ def propertiesCaseClasses(res0: String, res1: String) = { case class Dog(name: String, breed: String) @@ -163,10 +169,14 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def d1.breed should be(res1) } - /** Case classes can have mutable properties: + /** + * Case classes can have mutable properties: */ 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! + case class Dog( + var name: String, + breed: String + ) // you can rename a dog, but change its breed? nah! val d1 = Dog("Scooby", "Doberman") d1.name should be(res0) @@ -178,7 +188,8 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def d1.breed should be(res3) } - /** There are safer alternatives for altering case classes: + /** + * There are safer alternatives for altering case classes: */ def alteringCaseClasses(res0: String, res1: String, res2: String, res3: String) = { case class Dog(name: String, breed: String) // Doberman @@ -194,7 +205,8 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def d2.breed should be(res3) // copied from the original } - /** Case classes can have default and named parameters: + /** + * Case classes can have default and named parameters: */ def parametersCaseClasses( res0: String, @@ -214,7 +226,12 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def 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 - val p3 = Person(last = "Jones", first = "Fred", ssn = "111-22-3333") // note the order can change, and missing age + val p3 = + Person( + last = "Jones", + first = "Fred", + ssn = "111-22-3333" + ) // note the order can change, and missing age val p4 = p3.copy(age = 23) p1.first should be(res0) @@ -235,13 +252,15 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def (p1 == p4) should be(res12) } - /** Case classes can be disassembled to their constituent parts as a tuple: + /** + * Case classes can be disassembled to their constituent parts as a tuple: */ 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") - val parts = Person.unapply(p1).get // this seems weird, but it's critical to other features of Scala + val parts = + Person.unapply(p1).get // this seems weird, but it's critical to other features of Scala parts._1 should be(res0) parts._2 should be(res1) @@ -249,7 +268,8 @@ object CaseClasses extends AnyFlatSpec with Matchers with org.scalaexercises.def parts._4 should be(res3) } - /** Case classes are `Serializable`: + /** + * Case classes are `Serializable`: */ def serializableCaseClasses(res0: Boolean, res1: Boolean) = { case class PersonCC(firstName: String, lastName: String) diff --git a/src/main/scala/stdlib/Classes.scala b/src/main/scala/stdlib/Classes.scala index 5f797b18..82ffc4e1 100644 --- a/src/main/scala/stdlib/Classes.scala +++ b/src/main/scala/stdlib/Classes.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name classes +/** + * @param name classes */ object Classes extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Classes in Scala are static templates that can be instantiated into many objects at runtime. + /** + * Classes in Scala are static templates that can be instantiated into many objects at runtime. * Here is a class definition which defines a class Point: * * {{{ @@ -49,7 +51,6 @@ object Classes extends AnyFlatSpec with Matchers with org.scalaexercises.definit * The program defines an executable application `Classes` in the form of a top-level singleton object with a `main` method. The `main` method creates a new `Point` and stores it in value `pt`. * * 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) = { class ClassWithValParameter(val name: String) diff --git a/src/main/scala/stdlib/EmptyValues.scala b/src/main/scala/stdlib/EmptyValues.scala index 02bd7bf3..2e743ce4 100644 --- a/src/main/scala/stdlib/EmptyValues.scala +++ b/src/main/scala/stdlib/EmptyValues.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name empty_values - * +/** + * @param name empty_values */ object EmptyValues extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** ==null== + /** + * ==null== * * Scala's `null` is the same as in Java. Any reference type can be `null`, like Strings, Objects, or your own classes. Also just like Java, value types like Ints can't be `null`. * @@ -49,34 +50,40 @@ object EmptyValues extends AnyFlatSpec with Matchers with org.scalaexercises.def 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. + /** + * [[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) = None === None shouldBe res0 - /** `None` should be identical to `None`: + /** + * `None` should be identical to `None`: */ def identicalNoneEmptyValues(res0: Boolean) = None eq None shouldBe res0 - /** `None` can be converted to a String: + /** + * `None` can be converted to a String: */ def noneToStringEmptyValues(res0: String) = assert(None.toString === res0) - /** `None` can be converted to an empty list: + /** + * `None` can be converted to an empty list: */ def noneToListEmptyValues(res0: Boolean) = None.toList === Nil shouldBe res0 - /** `None` is considered empty: + /** + * `None` is considered empty: */ def noneAsEmptyEmptyValues(res0: Boolean) = assert(None.isEmpty === res0) - /** `None` can be cast to `Any`, `AnyRef` or `AnyVal`: + /** + * `None` can be cast to `Any`, `AnyRef` or `AnyVal`: */ def noneToAnyEmptyValues(res0: Boolean, res1: Boolean, res2: Boolean) = { None.asInstanceOf[Any] === None shouldBe res0 @@ -84,7 +91,8 @@ object EmptyValues extends AnyFlatSpec with Matchers with org.scalaexercises.def None.asInstanceOf[AnyVal] === None shouldBe res2 } - /** `None` can be used with `Option` instead of null references: + /** + * `None` can be used with `Option` instead of null references: */ def noneWithOptionEmptyValues(res0: Boolean, res1: Option[String]) = { val optional: Option[String] = None @@ -92,7 +100,8 @@ object EmptyValues extends AnyFlatSpec with Matchers with org.scalaexercises.def assert(optional === res1) } - /** `Some` is the opposite of `None` for `Option` types: + /** + * `Some` is the opposite of `None` for `Option` types: */ def someAgainstNoneEmptyValues(res0: Boolean, res1: Boolean) = { val optional: Option[String] = Some("Some Value") @@ -100,7 +109,8 @@ object EmptyValues extends AnyFlatSpec with Matchers with org.scalaexercises.def assert(optional.isEmpty === res1, "Some(value) should not be empty") } - /** `Option.getOrElse` can be used to provide a default in the case of `None`: + /** + * `Option.getOrElse` can be used to provide a default in the case of `None`: */ def getOrElseEmptyValues(res0: String, res1: String) = { val optional: Option[String] = Some("Some Value") diff --git a/src/main/scala/stdlib/Enumerations.scala b/src/main/scala/stdlib/Enumerations.scala index 28ab5dfe..66fd53b4 100644 --- a/src/main/scala/stdlib/Enumerations.scala +++ b/src/main/scala/stdlib/Enumerations.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name enumerations - * +/** + * @param name enumerations */ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** To create an enumeration, create an object that extends the abstract class `Enumeration`, and set a `val` variable to the method `Value`. This is a trick to give values to each `val`. + /** + * To create an enumeration, create an object that extends the abstract class `Enumeration`, and set a `val` variable to the method `Value`. This is a trick to give values to each `val`. * * `Value` assigns a numerical value to fields, indexed from 0: */ @@ -58,7 +59,8 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de (Planets.Neptune == Planets.Jupiter) should be(res5) } - /** You can create an enumeration with your own index and your own Strings, in this exercise we will start with an index of one and use Greek names instead of Roman: + /** + * You can create an enumeration with your own index and your own Strings, in this exercise we will start with an index of one and use Greek names instead of Roman: */ def ownIndexEnumerations( res0: Int, @@ -92,7 +94,8 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de (GreekPlanets.Neptune == GreekPlanets.Jupiter) should be(res5) } - /** Enumerations can be declared in one line if you are merely setting variables to `Value`: + /** + * Enumerations can be declared in one line if you are merely setting variables to `Value`: */ def oneLineEnumerations( res0: Int, @@ -116,7 +119,8 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de (Planets.Neptune == Planets.Jupiter) should be(res5) } - /** Enumerations can be declared with a string value only: + /** + * Enumerations can be declared with a string value only: */ def stringValueEnumerations( res0: Int, @@ -149,7 +153,8 @@ object Enumerations extends AnyFlatSpec with Matchers with org.scalaexercises.de (GreekPlanets.Neptune == GreekPlanets.Jupiter) should be(res5) } - /** You can extend the `Enumeration` by extending the `Val` class. + /** + * You can extend the `Enumeration` by extending the `Val` class. */ def extendingValueEnumerations(res0: Double, res1: Double) = { object Planets extends Enumeration { diff --git a/src/main/scala/stdlib/Extractors.scala b/src/main/scala/stdlib/Extractors.scala index df18f2bf..58cfa97e 100644 --- a/src/main/scala/stdlib/Extractors.scala +++ b/src/main/scala/stdlib/Extractors.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name extractors - * +/** + * @param name extractors */ object Extractors extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** In Scala, patterns can be defined independently of case classes. To this end, a method named `unapply` is defined to yield a so-called extractor. + /** + * In Scala, patterns can be defined independently of case classes. To this end, a method named `unapply` is defined to yield a so-called extractor. * * For instance, the following code defines an extractor object `Twice`. * @@ -62,7 +63,6 @@ object Extractors extends AnyFlatSpec with Matchers with org.scalaexercises.defi * Sometimes, the number of sub-values isn't fixed and we would like to return a sequence. For this reason, you can also define patterns through `unapplySeq`. The last sub-value type `Tn` has to be `Seq[S]`. This mechanism is used for instance in pattern `case List(x1, ..., xn)`. * * When you create a case class, it automatically can be used with pattern matching since it has an extractor: - * */ def extractorsExtractors(res0: String) = { case class Employee(firstName: String, lastName: String) @@ -76,7 +76,8 @@ object Extractors extends AnyFlatSpec with Matchers with org.scalaexercises.defi result should be(res0) } - /** What's an extractor? In Scala it's a method in any `object` called `unapply`, and that method is used to disassemble the object given by returning a tuple wrapped in an option. Extractors can be used to assign values: + /** + * What's an extractor? In Scala it's a method in any `object` called `unapply`, and that method is used to disassemble the object given by returning a tuple wrapped in an option. Extractors can be used to assign values: */ def calledUnapplyExtractors(res0: String, res1: String, res2: Int, res3: Int) = { class Car(val make: String, val model: String, val year: Short, val topSpeed: Short) @@ -93,7 +94,8 @@ object Extractors extends AnyFlatSpec with Matchers with org.scalaexercises.defi d should be(res3) } - /** An extractor can also be used in pattern matching: + /** + * An extractor can also be used in pattern matching: */ def patternMatchingExtractors(res0: String, res1: String) = { class Car(val make: String, val model: String, val year: Short, val topSpeed: Short) @@ -111,7 +113,8 @@ object Extractors extends AnyFlatSpec with Matchers with org.scalaexercises.defi x._2 should be(res1) } - /** Since we aren't really using `u` and `v` in the previous pattern matching, they can be replaced with `_`: + /** + * Since we aren't really using `u` and `v` in the previous pattern matching, they can be replaced with `_`: */ def withWildcardExtractors(res0: String, res1: String) = { class Car(val make: String, val model: String, val year: Short, val topSpeed: Short) @@ -129,7 +132,8 @@ object Extractors extends AnyFlatSpec with Matchers with org.scalaexercises.defi x._2 should be(res1) } - /** As long as the method signatures aren't the same, you can have as many unapply methods as you want: + /** + * As long as the method signatures aren't the same, you can have as many unapply methods as you want: */ def multipleUnapplyExtractors(res0: String) = { class Car(val make: String, val model: String, val year: Short, val topSpeed: Short) @@ -149,7 +153,8 @@ object Extractors extends AnyFlatSpec with Matchers with org.scalaexercises.defi result should be(res0) } - /** An extractor can be any stable object, including instantiated classes with an unapply method: + /** + * An extractor can be any stable object, including instantiated classes with an unapply method: */ def anyObjectExtractors(res0: String) = { class Car(val make: String, val model: String, val year: Short, val topSpeed: Short) { @@ -166,7 +171,8 @@ object Extractors extends AnyFlatSpec with Matchers with org.scalaexercises.defi result should be(res0) } - /** A custom extractor is typically created in the companion object of the class. In this exercise, we use it as an assignment: + /** + * A custom extractor is typically created in the companion object of the class. In this exercise, we use it as an assignment: */ def asAssignmentExtractors(res0: String, res1: Option[String], res2: String) = { class Employee( @@ -191,7 +197,8 @@ object Extractors extends AnyFlatSpec with Matchers with org.scalaexercises.defi c should be(res2) } - /** In this exercise we use `unapply` for pattern matching employee objects: + /** + * In this exercise we use `unapply` for pattern matching employee objects: */ def unapplyForPatternMatchingExtractors(res0: String) = { class Employee( diff --git a/src/main/scala/stdlib/ForExpressions.scala b/src/main/scala/stdlib/ForExpressions.scala index d9ae609b..81a72a98 100644 --- a/src/main/scala/stdlib/ForExpressions.scala +++ b/src/main/scala/stdlib/ForExpressions.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,15 +19,16 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name for_expressions - * +/** + * @param name for_expressions */ object ForExpressions extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** `for` expressions can nest, with later generators varying more rapidly than earlier ones: + /** + * `for` expressions can nest, with later generators varying more rapidly than earlier ones: */ def canBeNestedForExpressions(res0: Int, res1: Int) = { val xValues = 1 to 4 @@ -39,7 +40,8 @@ object ForExpressions coordinates(4) should be((res0, res1)) } - /** Using `for` we can make more readable code: + /** + * Using `for` we can make more readable code: */ def readableCodeForExpressions(res0: List[Int]) = { val nums = List(List(1), List(2), List(3), List(4), List(5)) diff --git a/src/main/scala/stdlib/Formatting.scala b/src/main/scala/stdlib/Formatting.scala index 1ebc5689..e6eebb13 100644 --- a/src/main/scala/stdlib/Formatting.scala +++ b/src/main/scala/stdlib/Formatting.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,19 +19,21 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name formatting - * +/** + * @param name formatting */ object Formatting extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** String can be placed in format: + /** + * String can be placed in format: */ def placedInFormatFormatting(res0: String) = { val s = "Hello World" "Application %s".format(s) should be(res0) } - /** Character Literals can be a single character: + /** + * Character Literals can be a single character: */ def characterFormatting(res0: String, res1: String) = { val a = 'a' @@ -44,7 +46,8 @@ object Formatting extends AnyFlatSpec with Matchers with org.scalaexercises.defi "%c".format(b) should be(res1) } - /** Character Literals can be an escape sequence, including hexidecimal: + /** + * Character Literals can be an escape sequence, including hexidecimal: */ def escapeSequenceFormatting(res0: String, res1: String, res2: String) = { val c = '\u0061' //unicode for a @@ -56,14 +59,16 @@ object Formatting extends AnyFlatSpec with Matchers with org.scalaexercises.defi "%c".format(f) should be(res2) } - /** Formatting can also include numbers: + /** + * Formatting can also include numbers: */ def includingNumbersFormatting(res0: String) = { val j = 190 "%d bottles of beer on the wall" format j - 100 should be(res0) } - /** Formatting can be used for any number of items, like a string and a number: + /** + * Formatting can be used for any number of items, like a string and a number: */ def anyNumberOfItemsFormatting(res0: String) = { val j = 190 diff --git a/src/main/scala/stdlib/HigherOrderFunctions.scala b/src/main/scala/stdlib/HigherOrderFunctions.scala index 4112ecef..1678dde9 100644 --- a/src/main/scala/stdlib/HigherOrderFunctions.scala +++ b/src/main/scala/stdlib/HigherOrderFunctions.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,15 +19,16 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name higher_order_functions - * +/** + * @param name higher_order_functions */ object HigherOrderFunctions extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Meet lambda. Scala provides a relatively lightweight syntax for defining anonymous functions. Anonymous functions in source code are called function literals and at run time, function literals are instantiated into objects called function values. + /** + * Meet lambda. Scala provides a relatively lightweight syntax for defining anonymous functions. Anonymous functions in source code are called function literals and at run time, function literals are instantiated into objects called function values. * * Scala supports first-class functions, which means you can express functions in function literal syntax, i.e. ` (x: Int) => x + 1`, and those functions can be represented by objects, which are called function values. */ @@ -39,7 +40,7 @@ object HigherOrderFunctions res4: Int, res5: Int ) = { - def lambda = { x: Int => x + 1 } + def lambda = { x: Int => x + 1 } def lambda2 = (x: Int) => x + 2 val lambda3 = (x: Int) => x + 3 @@ -65,7 +66,8 @@ object HigherOrderFunctions result5 should be(res5) } - /** An anonymous function can also take on a different look by taking out the brackets: + /** + * An anonymous function can also take on a different look by taking out the brackets: */ def differentLookHigherOrderFunctions(res0: Int) = { def lambda = (x: Int) => x + 1 @@ -73,9 +75,10 @@ object HigherOrderFunctions result should be(res0) } - /** Here the only variable used in the function body, `i * 10`, is `i`, which is defined as a parameter to the function. + /** + * Here the only variable used in the function body, `i * 10`, is `i`, which is defined as a parameter to the function. * - *{{{ + * {{{ * val multiplier = (i:Int) => i * 10 * }}} * @@ -95,7 +98,8 @@ object HigherOrderFunctions result2 should be(res1) } - /** And then we get to Higher Order Functions: + /** + * And then we get to Higher Order Functions: * Higher Order Functions are functions that take functions as arguments and/or return functions. * * We can take that closure and throw it into a Higher Order Function and it will still hold the environment: @@ -114,7 +118,8 @@ object HigherOrderFunctions result2 should be(res1) } - /** Higher Order Function returning another function: + /** + * Higher Order Function returning another function: */ def returningFunctionHigherOrderFunctions(res0: Boolean, res1: Int, res2: Int) = { def addWithoutSyntaxSugar(x: Int): Function1[Int, Int] = { @@ -130,7 +135,8 @@ object HigherOrderFunctions fiveAdder(5) should be(res2) } - /** Function returning another function using an anonymous function: + /** + * Function returning another function using an anonymous function: */ def returningAnonymousFunctionHigherOrderFunctions(res0: Boolean, res1: Int, res2: Int) = { def addWithSyntaxSugar(x: Int) = (y: Int) => x + y @@ -142,7 +148,8 @@ object HigherOrderFunctions fiveAdder(5) should be(res2) } - /** `isInstanceOf` is the same as `instanceof` in java, but in this case the parameter types can be *blanked out* using existential types with a single underline, since parameter types are unknown at runtime. + /** + * `isInstanceOf` is the same as `instanceof` in java, but in this case the parameter types can be *blanked out* using existential types with a single underline, since parameter types are unknown at runtime. */ def isInstanceOfMethodHigherOrderFunctions(res0: Boolean) = { def addWithSyntaxSugar(x: Int) = (y: Int) => x + y @@ -150,7 +157,8 @@ object HigherOrderFunctions addWithSyntaxSugar(1).isInstanceOf[Function1[_, _]] should be(res0) } - /** Function taking another function as a parameter. Helps in composing functions. + /** + * Function taking another function as a parameter. Helps in composing functions. * * Hint: a map method applies the function to each element of a list. */ @@ -160,9 +168,10 @@ object HigherOrderFunctions res2: List[String], res3: List[Int] ) = { - def makeUpper(xs: List[String]) = xs map { - _.toUpperCase - } + def makeUpper(xs: List[String]) = + xs map { + _.toUpperCase + } def makeWhatEverYouLike(xs: List[String], sideEffect: String => String) = xs map sideEffect diff --git a/src/main/scala/stdlib/Implicits.scala b/src/main/scala/stdlib/Implicits.scala index d7267917..4e19eaf2 100644 --- a/src/main/scala/stdlib/Implicits.scala +++ b/src/main/scala/stdlib/Implicits.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,13 @@ import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers import scala.language.implicitConversions -/** @param name implicits - * +/** + * @param name implicits */ object Implicits extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** The actual arguments that are eligible to be passed to an implicit parameter fall into two categories: + /** + * The actual arguments that are eligible to be passed to an implicit parameter fall into two categories: * * - First, eligible are all identifiers x that can be accessed at the point of the method call without a prefix and that denote an implicit definition or an implicit parameter. * - Second, eligible are also all members of companion modules of the implicit parameter's type that are labeled implicit. @@ -79,7 +80,8 @@ object Implicits extends AnyFlatSpec with Matchers with org.scalaexercises.defin 20.isOdd should be(res1) } - /** Implicits rules can be imported into your scope with an import: + /** + * Implicits rules can be imported into your scope with an import: */ def importedImplicits(res0: Boolean, res1: Boolean) = { object MyPredef { @@ -100,7 +102,8 @@ object Implicits extends AnyFlatSpec with Matchers with org.scalaexercises.defin 20.isOdd should be(res1) } - /** Implicits can be used to automatically convert a value's type to another: + /** + * Implicits can be used to automatically convert a value's type to another: */ def convertTypeImplicits( res0: Boolean, @@ -126,7 +129,8 @@ object Implicits extends AnyFlatSpec with Matchers with org.scalaexercises.defin add(3, 6).intValue == 9 should be(res4) } - /** Implicits can be used to declare a value to be provided as a default as long as an implicit value is set with in the scope. These are called Implicit Function Parameters: + /** + * Implicits can be used to declare a value to be provided as a default as long as an implicit value is set with in the scope. These are called Implicit Function Parameters: */ def asDefaultImplicits(res0: BigDecimal) = { def howMuchCanIMake_?(hours: Int)(implicit dollarsPerHour: BigDecimal) = @@ -137,7 +141,8 @@ object Implicits extends AnyFlatSpec with Matchers with org.scalaexercises.defin howMuchCanIMake_?(30) should be(res0) } - /** Implicit Function Parameters can contain a list of implicits: + /** + * Implicit Function Parameters can contain a list of implicits: */ def listOfImplicitsImplicits(res0: String) = { def howMuchCanIMake_?(hours: Int)(implicit amount: BigDecimal, currencyName: String) = @@ -149,7 +154,8 @@ object Implicits extends AnyFlatSpec with Matchers with org.scalaexercises.defin howMuchCanIMake_?(30) should be(res0) } - /** Default arguments, though, are preferred to Implicit Function Parameters: + /** + * Default arguments, though, are preferred to Implicit Function Parameters: */ def defaultArgumentsImplicits(res0: String, res1: String) = { def howMuchCanIMake_?(hours: Int, amount: BigDecimal = 34, currencyName: String = "Dollars") = diff --git a/src/main/scala/stdlib/InfixPrefixandPostfixOperators.scala b/src/main/scala/stdlib/InfixPrefixandPostfixOperators.scala index 1cb405ed..e5e76d03 100644 --- a/src/main/scala/stdlib/InfixPrefixandPostfixOperators.scala +++ b/src/main/scala/stdlib/InfixPrefixandPostfixOperators.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,15 +20,16 @@ import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers import scala.language.postfixOps -/** @param name infix_prefix_and_postfix_operators - * +/** + * @param name infix_prefix_and_postfix_operators */ object InfixPrefixandPostfixOperators extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Any method which takes a single parameter can be used as an infix operator: `a.m(b)` can also be written as `a m b`. + /** + * Any method which takes a single parameter can be used as an infix operator: `a.m(b)` can also be written as `a m b`. */ def singleParameterInfixPrefixandPostfixOperators(res0: Int, res1: Int) = { val g: Int = 3 @@ -36,7 +37,8 @@ object InfixPrefixandPostfixOperators g.+(4) should be(res1) // same result but not using the infix operator } - /** Infix operators do NOT work if an object has a method that takes two parameters: + /** + * Infix operators do NOT work if an object has a method that takes two parameters: */ def notWithTwoInfixPrefixandPostfixOperators(res0: Int, res1: Int) = { val g: String = "Check out the big brains on Brad!" @@ -48,7 +50,8 @@ object InfixPrefixandPostfixOperators g.indexOf('o', 7) should be(res1) //indexOf(Char, Int) must use standard java/scala calls } - /** Any method which does not require a parameter can be used as a postfix operator: `a.m` can be written as `a m`. + /** + * Any method which does not require a parameter can be used as a postfix operator: `a.m` can be written as `a m`. * * For instance, `a.+(b)` is equivalent to `a + b` and `a.!` is the same as `a!`. * @@ -65,14 +68,16 @@ object InfixPrefixandPostfixOperators //Hint: The answer is "1f" } - /** Prefix operators work if an object has a method name that starts with `unary_` : + /** + * Prefix operators work if an object has a method name that starts with `unary_` : */ def startsWithUnaryInfixPrefixandPostfixOperators(res0: Int) = { val g: Int = 31 (-g) should be(res0) } - /** Here's how to create a prefix operator for our own class. The only identifiers that can be used as prefix operators are `+`, `-`, `!`, and `~`: + /** + * Here's how to create a prefix operator for our own class. The only identifiers that can be used as prefix operators are `+`, `-`, `!`, and `~`: */ def ourOwnOperatorInfixPrefixandPostfixOperators(res0: String, res1: String) = { class Stereo { diff --git a/src/main/scala/stdlib/InfixTypes.scala b/src/main/scala/stdlib/InfixTypes.scala index c1a5e26c..aae827c0 100644 --- a/src/main/scala/stdlib/InfixTypes.scala +++ b/src/main/scala/stdlib/InfixTypes.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name infix_types - * +/** + * @param name infix_types */ object InfixTypes extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** An infix type `T1 op T2` consists of an infix operator `op` which gets applied to two + /** + * An infix type `T1 op T2` consists of an infix operator `op` which gets applied to two * type operands `T1` and `T2`. The type is equivalent to the type application `op[T1,T2]`. * * The infix operator `op` may be an arbitrary identifier, except for `*`, which is reserved @@ -46,7 +47,8 @@ object InfixTypes extends AnyFlatSpec with Matchers with org.scalaexercises.defi announceCouple(new Loves(romeo, juliet)) should be(res0) } - /** Of course we can make this a bit more elegant by creating an infix operator method to use with our infix type: + /** + * Of course we can make this a bit more elegant by creating an infix operator method to use with our infix type: */ def infixOperatorInfixTypes(res0: String) = { case class Person(name: String) { diff --git a/src/main/scala/stdlib/Iterables.scala b/src/main/scala/stdlib/Iterables.scala index bb307d52..7ad86a53 100644 --- a/src/main/scala/stdlib/Iterables.scala +++ b/src/main/scala/stdlib/Iterables.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name iterables - * +/** + * @param name iterables */ object Iterables extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** The next trait from the top in the collections hierarchy is `Iterable`. All methods in this trait are defined in terms of an abstract method, `iterator`, which yields the collection's elements one by one. The `foreach` method from trait `Traversable` is implemented in `Iterable` in terms of `iterator`. Here is the actual implementation: + /** + * The next trait from the top in the collections hierarchy is `Iterable`. All methods in this trait are defined in terms of an abstract method, `iterator`, which yields the collection's elements one by one. The `foreach` method from trait `Traversable` is implemented in `Iterable` in terms of `iterator`. Here is the actual implementation: * * {{{ * def foreach[U](f: Elem => U): Unit = { @@ -36,17 +37,16 @@ object Iterables extends AnyFlatSpec with Matchers with org.scalaexercises.defin * Quite a few subclasses of `Iterable` override this standard implementation of `foreach` in `Iterable`, because they can provide a more efficient implementation. Remember that `foreach` is the basis of the implementation of all operations in `Traversable`, so its performance matters. * * Some common iterables are `Set`, `List`, `Vector`, `Stack` and `Stream`. Iterator has two important methods: `hasNext`, which answers whether the iterator has another element available, and `next` which returns the next element in the iterator. - * */ def collectionIterablesIterables(res0: Int) = { val list = List(3, 5, 9, 11, 15, 19, 21) val it = list.iterator - if (it.hasNext) { + if (it.hasNext) it.next should be(res0) - } } - /** `grouped` will return fixed-size `Iterable` chunks of an `Iterable`: + /** + * `grouped` will return fixed-size `Iterable` chunks of an `Iterable`: */ def groupedIterables( res0: Int, @@ -66,7 +66,8 @@ object Iterables extends AnyFlatSpec with Matchers with org.scalaexercises.defin it.next() should be(List(res6, res7, res8)) } - /** `sliding` will return an `Iterable` that shows a sliding window of an `Iterable`. + /** + * `sliding` will return an `Iterable` that shows a sliding window of an `Iterable`. */ def slidingIterables( res0: Int, @@ -86,7 +87,8 @@ object Iterables extends AnyFlatSpec with Matchers with org.scalaexercises.defin it.next() should be(List(res6, res7, res8)) } - /** `sliding` can take the size of the window as well the size of the step during each iteration: + /** + * `sliding` can take the size of the window as well the size of the step during each iteration: */ def slidingWindowIterables( res0: Int, @@ -106,21 +108,24 @@ object Iterables extends AnyFlatSpec with Matchers with org.scalaexercises.defin it.next() should be(List(res6, res7, res8)) } - /** `takeRight` is the opposite of 'take' in `Traversable`. It retrieves the last elements of an `Iterable`: + /** + * `takeRight` is the opposite of 'take' in `Traversable`. It retrieves the last elements of an `Iterable`: */ def takeRightIterables(res0: Int, res1: Int, res2: Int) = { val list = List(3, 5, 9, 11, 15, 19, 21, 24, 32) (list takeRight 3) should be(List(res0, res1, res2)) } - /** `dropRight` will drop a specified number of elements from the right: + /** + * `dropRight` will drop a specified number of elements from the right: */ def dropRightIterables(res0: Int, res1: Int, res2: Int, res3: Int, res4: Int, res5: Int) = { val list = List(3, 5, 9, 11, 15, 19, 21, 24, 32) (list dropRight 3) should be(List(res0, res1, res2, res3, res4, res5)) } - /** `zip` will stitch two iterables into an iterable of pairs of corresponding elements from both iterables. + /** + * `zip` will stitch two iterables into an iterable of pairs of corresponding elements from both iterables. * * e.g. `Iterable(x1, x2, x3) zip Iterable(y1, y2, y3)` will return `((x1, y1), (x2, y2), (x3, y3))`: */ @@ -130,10 +135,10 @@ object Iterables extends AnyFlatSpec with Matchers with org.scalaexercises.defin (xs zip ys) should be(List((res0, res1), (res2, res3), (res4, res5))) } - /** If two Iterables aren't the same size, then `zip` will only zip what can be paired. + /** + * If two Iterables aren't the same size, then `zip` will only zip what can be paired. * * e.g. `Iterable(x1, x2, x3) zip Iterable(y1, y2)` will return `((x1, y1), (x2, y2))`: - * */ def sameSizeZipIterables(res0: Int, res1: String, res2: Int, res3: String) = { val xs = List(3, 5, 9) @@ -141,7 +146,8 @@ object Iterables extends AnyFlatSpec with Matchers with org.scalaexercises.defin (xs zip ys) should be(List((res0, res1), (res2, res3))) } - /** If two `Iterables` aren't the same size, then `zipAll` can provide fillers for what it couldn't find a complement for. + /** + * If two `Iterables` aren't the same size, then `zipAll` can provide fillers for what it couldn't find a complement for. * * e.g. `Iterable(x1, x2, x3) zipAll (Iterable(y1, y2), x, y)` will return `((x1,y1), (x2, y2), (x3, y)))`: */ @@ -167,14 +173,16 @@ object Iterables extends AnyFlatSpec with Matchers with org.scalaexercises.defin } - /** `zipWithIndex` will zip an `Iterable` with its integer index: + /** + * `zipWithIndex` will zip an `Iterable` with its integer index: */ def zipWithIndexIterables(res0: String, res1: String, res2: Int, res3: String) = { val xs = List("Manny", "Moe", "Jack") xs.zipWithIndex should be(List((res0, 0), (res1, res2), (res3, 2))) } - /** `sameElements` will return true if the two `Iterables` produce the same elements in the same order. The iterator for a set created with less than 5 values will return elements in the order in which they were added, rather than the consistent, hash-based ordering used by iterators for larger Sets: + /** + * `sameElements` will return true if the two `Iterables` produce the same elements in the same order. The iterator for a set created with less than 5 values will return elements in the order in which they were added, rather than the consistent, hash-based ordering used by iterators for larger Sets: */ def sameElementsIterables(res0: Boolean, res1: Boolean, res2: Boolean, res3: Boolean) = { val xs = List("Manny", "Moe", "Jack") @@ -192,7 +200,8 @@ object Iterables extends AnyFlatSpec with Matchers with org.scalaexercises.defin val xt1 = Set(1, 2, 3) val yt1 = Set(3, 2, 1) xt1.iterator.sameElements(yt1) should be(res3) // Caution - see below! - /** Note that very small Sets (containing up to 4 elements) are implemented differently to larger Sets; as a result, their iterators produce the elements in the order that they were originally added. This causes the surprising (and arguably incorrect) behaviour in the final example above. */ + /** + * Note that very small Sets (containing up to 4 elements) are implemented differently to larger Sets; as a result, their iterators produce the elements in the order that they were originally added. This causes the surprising (and arguably incorrect) behaviour in the final example above. */ } } diff --git a/src/main/scala/stdlib/Lists.scala b/src/main/scala/stdlib/Lists.scala index 9be010d0..ea5996fd 100644 --- a/src/main/scala/stdlib/Lists.scala +++ b/src/main/scala/stdlib/Lists.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name lists - * +/** + * @param name lists */ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Scala Lists are quite similar to arrays, which means all the elements of a list have the same type - but there are two important differences. First, lists are immutable, which means elements of a list cannot be changed by assignment. Second, lists represent a linked list whereas arrays are flat. The type of a list that has elements of type `T` is written as `List[T]`. + /** + * Scala Lists are quite similar to arrays, which means all the elements of a list have the same type - but there are two important differences. First, lists are immutable, which means elements of a list cannot be changed by assignment. Second, lists represent a linked list whereas arrays are flat. The type of a list that has elements of type `T` is written as `List[T]`. * * `eq` tests identity (same object): */ @@ -34,7 +35,8 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio (a eq b) should be(res0) } - /** `==` tests equality (same content): + /** + * `==` tests equality (same content): */ def sameContentLists(res0: Boolean) = { val a = List(1, 2, 3) @@ -42,7 +44,8 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio (a == b) should be(res0) } - /** Nil lists are identical, even of different types: + /** + * Nil lists are identical, even of different types: */ def nilListsLists( res0: Boolean, @@ -65,14 +68,16 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio (a eq b) should be(res5) } - /** Lists can be easily created: + /** + * Lists can be easily created: */ def easilyCreatedLists(res0: Int, res1: Int, res2: Int) = { val a = List(1, 2, 3) a should equal(List(res0, res1, res2)) } - /** Lists can be accessed via `head`, `headOption` and `tail`. Accessing a list via `head` is unsafe and may result in a `IndexOutOfBoundsException`. + /** + * Lists can be accessed via `head`, `headOption` and `tail`. Accessing a list via `head` is unsafe and may result in a `IndexOutOfBoundsException`. */ def headAndTailLists(res0: Int, res1: Int, res2: Int) = { val a = List(1, 2, 3) @@ -80,7 +85,8 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio a.tail should equal(List(res1, res2)) } - /** Lists can be accessed by position: + /** + * Lists can be accessed by position: */ def byPositionLists(res0: Int, res1: Int, res2: Int) = { val a = List(1, 3, 5, 7, 9) @@ -93,7 +99,8 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio } } - /** Lists are immutable: + /** + * Lists are immutable: */ def areImmutableLists(res0: Int, res1: Int, res2: Int, res3: Int) = { val a = List(1, 3, 5, 7, 9) @@ -103,7 +110,8 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio b should equal(List(res0, res1, res2, res3)) } - /** Lists have many useful utility methods: + /** + * Lists have many useful utility methods: */ def usefulMethodsLists(res0: Int, res1: List[Int], res2: List[Int], res3: List[Int]) = { val a = List(1, 3, 5, 7, 9) @@ -125,7 +133,8 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio } should equal(res3) } - /** Functions over lists can use _ as shorthand: + /** + * Functions over lists can use _ as shorthand: */ def wildcardAsShorthandLists(res0: Int, res1: Int, res2: Int, res3: Int) = { val a = List(1, 2, 3) @@ -139,7 +148,8 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio } should equal(List(res3)) } - /** Functions over lists can use `()` instead of `{}`: + /** + * Functions over lists can use `()` instead of `{}`: */ def functionsOverListsLists(res0: Int, res1: Int, res2: Int, res3: Int, res4: Int) = { val a = List(1, 2, 3) @@ -147,7 +157,8 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio a.filter(_ % 2 != 0) should equal(List(res3, res4)) } - /** Lists can be reduced with a mathematical operation: + /** + * Lists can be reduced with a mathematical operation: */ def reducingListsLists(res0: Int, res1: Int) = { val a = List(1, 3, 5, 7) @@ -155,7 +166,8 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio a.reduceLeft(_ * _) should equal(res1) } - /** `foldLeft` is like `reduce`, but with an explicit starting value: + /** + * `foldLeft` is like `reduce`, but with an explicit starting value: */ def foldLeftLists(res0: Int, res1: Int, res2: Int, res3: Int) = { val a = List(1, 3, 5, 7) @@ -166,14 +178,16 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio a.foldLeft(0)(_ * _) should equal(res3) } - /** You can create a list from a range: + /** + * You can create a list from a range: */ def fromRangeLists(res0: List[Int]) = { val a = (1 to 5).toList a should be(res0) } - /** You can prepend elements to a List to get a new List: + /** + * You can prepend elements to a List to get a new List: */ def addElementsLists(res0: List[Int]) = { val a = List(1, 3, 5, 7) @@ -181,7 +195,8 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio 0 :: a should be(res0) } - /** Lists can be concatened and Nil is an empty List: + /** + * Lists can be concatened and Nil is an empty List: */ def concatenateLists(res0: List[Int], res1: List[Int]) = { val head = List(1, 3) @@ -191,7 +206,8 @@ object Lists extends AnyFlatSpec with Matchers with org.scalaexercises.definitio head ::: Nil should be(res1) } - /** Lists reuse their tails: + /** + * Lists reuse their tails: */ def reuseTailsLists( res0: Int, diff --git a/src/main/scala/stdlib/LiteralBooleans.scala b/src/main/scala/stdlib/LiteralBooleans.scala index b7b41d1b..a8b7821d 100644 --- a/src/main/scala/stdlib/LiteralBooleans.scala +++ b/src/main/scala/stdlib/LiteralBooleans.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,15 +19,16 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name literal_booleans - * +/** + * @param name literal_booleans */ object LiteralBooleans extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Boolean literals are either true or false, using the `true` or `false` keyword: + /** + * Boolean literals are either true or false, using the `true` or `false` keyword: */ def literalBooleanLiteralBooleans( res0: Boolean, diff --git a/src/main/scala/stdlib/LiteralNumbers.scala b/src/main/scala/stdlib/LiteralNumbers.scala index 26d6ea7d..44f209ee 100644 --- a/src/main/scala/stdlib/LiteralNumbers.scala +++ b/src/main/scala/stdlib/LiteralNumbers.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,15 +19,16 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name literal_numbers - * +/** + * @param name literal_numbers */ object LiteralNumbers extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Integer literals are 32-bit and can be created from decimals as well as hexadecimals: + /** + * Integer literals are 32-bit and can be created from decimals as well as hexadecimals: */ def integerLiteralsLiteralNumbers( res0: Int, @@ -40,11 +41,11 @@ object LiteralNumbers ) = { val a = 2 val b = 31 - val c = 0x30F + val c = 0x30f val e = 0 val f = -2 val g = -31 - val h = -0x30F + val h = -0x30f a should be(res0) b should be(res1) c should be(res2) //Hint: 30F = 783 @@ -54,7 +55,8 @@ object LiteralNumbers h should be(res6) //Hint: 30F = 783 } - /** Long literals are 64-bit. They are specified by appending an `L` at the end of the declaration: + /** + * Long literals are 64-bit. They are specified by appending an `L` at the end of the declaration: */ def longLiteralsLiteralNumbers( res0: Long, @@ -67,11 +69,11 @@ object LiteralNumbers ) = { val a = 2L val b = 31L - val c = 0x30FL + val c = 0x30fL val e = 0L val f = -2L val g = -31L - val h = -0x30FL + val h = -0x30fL a should be(res0) b should be(res1) @@ -82,7 +84,8 @@ object LiteralNumbers h should be(res6) //Hint: 30F = 783 } - /** Float and Double literals conform to [[https://en.wikipedia.org/wiki/IEEE_floating_point IEEE-754]]. Floats are 32-bit, while doubles are 64-bit. + /** + * Float and Double literals conform to [[https://en.wikipedia.org/wiki/IEEE_floating_point IEEE-754]]. Floats are 32-bit, while doubles are 64-bit. * Floats can be defined using a f or F suffix, while doubles use a d or D suffix. * Exponents are specified using e or E. */ diff --git a/src/main/scala/stdlib/LiteralStrings.scala b/src/main/scala/stdlib/LiteralStrings.scala index 5de57e0d..0467d14d 100644 --- a/src/main/scala/stdlib/LiteralStrings.scala +++ b/src/main/scala/stdlib/LiteralStrings.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,15 +19,16 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name literal_strings - * +/** + * @param name literal_strings */ object LiteralStrings extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Character literals are quoted with single quotes: + /** + * Character literals are quoted with single quotes: */ def characterLiteralsLiteralStrings(res0: String, res1: String) = { val a = 'a' @@ -37,7 +38,8 @@ object LiteralStrings b.toString should be(res1) } - /** Character literals can use hexadecimal Unicode: + /** + * Character literals can use hexadecimal Unicode: */ def characterLiteralsUnicodeLiteralStrings(res0: String) = { val c = '\u0061' //unicode for a @@ -45,7 +47,8 @@ object LiteralStrings c.toString should be(res0) } - /** Character literals can use escape sequences: + /** + * Character literals can use escape sequences: */ def escapeSequenceLiteralStrings(res0: String, res1: String) = { val e = '\"' @@ -55,7 +58,8 @@ object LiteralStrings f.toString should be(res1) } - /** One-line String literals are surrounded by quotation marks: + /** + * One-line String literals are surrounded by quotation marks: */ def oneLineLiteralStrings(res0: String) = { val a = "To be or not to be" @@ -63,9 +67,9 @@ object LiteralStrings } /* TODO rework exercise compiler issue where multiline string literals are not /** multilineLiteralStrings - * - * Multiline String literals are surrounded by three quotation marks. - */ + * + * Multiline String literals are surrounded by three quotation marks. + */ def multilineLiteralStrings(res0: Int) = { val a = """An apple a day @@ -74,11 +78,11 @@ object LiteralStrings } /** stripMarginLiteralStrings - * - * Use stripMargin to prettify multi-line strings: - * Multiline String literals can use | to specify the starting position - * of subsequent lines, then use stripMargin to remove the surplus indentation. - */ + * + * Use stripMargin to prettify multi-line strings: + * Multiline String literals can use | to specify the starting position + * of subsequent lines, then use stripMargin to remove the surplus indentation. + */ def stripMarginLiteralStrings(res0: String) = { val a = """An apple a day keeps @@ -86,6 +90,6 @@ object LiteralStrings a.stripMargin.split('\n')(1).charAt(0) should be(res0) } - */ + */ } diff --git a/src/main/scala/stdlib/Maps.scala b/src/main/scala/stdlib/Maps.scala index 13c21afa..e47d97ec 100644 --- a/src/main/scala/stdlib/Maps.scala +++ b/src/main/scala/stdlib/Maps.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name maps - * +/** + * @param name maps */ object Maps extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** A `Map` is an `Iterable` consisting of pairs of keys and values (also named mappings or associations). Scala's Predef class offers an implicit conversion that lets you write `key -> value` as an alternate syntax for the pair `(key, value)`. For instance `Map("x" -> 24, "y" -> 25, "z" -> 26)` means exactly the same as `Map(("x", 24), ("y", 25), ("z", 26))`, but reads better. + /** + * A `Map` is an `Iterable` consisting of pairs of keys and values (also named mappings or associations). Scala's Predef class offers an implicit conversion that lets you write `key -> value` as an alternate syntax for the pair `(key, value)`. For instance `Map("x" -> 24, "y" -> 25, "z" -> 26)` means exactly the same as `Map(("x", 24), ("y", 25), ("z", 26))`, but reads better. * * The fundamental operations on maps are similar to those on sets. They are summarized in the following table and fall into the following categories: * @@ -42,14 +43,16 @@ object Maps extends AnyFlatSpec with Matchers with org.scalaexercises.definition myMap.size should be(res0) } - /** Maps do not contain multiple identical pairs: + /** + * Maps do not contain multiple identical pairs: */ def distinctPairingsMaps(res0: Int) = { val myMap = Map("MI" -> "Michigan", "OH" -> "Ohio", "WI" -> "Wisconsin", "MI" -> "Michigan") myMap.size should be(res0) } - /** Maps can be added to easily: + /** + * Maps can be added to easily: */ def easilyAddedMaps(res0: Boolean) = { val myMap = Map("MI" -> "Michigan", "OH" -> "Ohio", "WI" -> "Wisconsin", "MI" -> "Michigan") @@ -57,7 +60,8 @@ object Maps extends AnyFlatSpec with Matchers with org.scalaexercises.definition aNewMap.contains("IL") should be(res0) } - /** Map values can be iterated: + /** + * Map values can be iterated: */ def canBeIteratedMaps(res0: Int, res1: String, res2: String) = { val myMap = Map("MI" -> "Michigan", "OH" -> "Ohio", "WI" -> "Wisconsin", "MI" -> "Michigan") @@ -71,7 +75,8 @@ object Maps extends AnyFlatSpec with Matchers with org.scalaexercises.definition } - /** Maps may be accessed: + /** + * Maps may be accessed: */ def mayBeAccessedMaps(res0: String, res1: String) = { val myMap = @@ -80,7 +85,8 @@ object Maps extends AnyFlatSpec with Matchers with org.scalaexercises.definition myMap("IA") should be(res1) } - /** Maps insertion with duplicate key updates previous entry with subsequent value: + /** + * Maps insertion with duplicate key updates previous entry with subsequent value: */ def duplicatedKeyInsertionMaps(res0: Int, res1: String) = { val myMap = Map("MI" -> "Michigan", "OH" -> "Ohio", "WI" -> "Wisconsin", "MI" -> "Meechigan") @@ -90,7 +96,8 @@ object Maps extends AnyFlatSpec with Matchers with org.scalaexercises.definition } - /** Map keys may be of mixed type: + /** + * Map keys may be of mixed type: */ def mixedTypeKeysMaps(res0: String, res1: String) = { val myMap = Map("Ann Arbor" -> "MI", 49931 -> "MI") @@ -98,7 +105,8 @@ object Maps extends AnyFlatSpec with Matchers with org.scalaexercises.definition myMap(49931) should be(res1) } - /** If a nonexistent map key is requested using `myMap(missingKey)`, a `NoSuchElementException` will be thrown. + /** + * If a nonexistent map key is requested using `myMap(missingKey)`, a `NoSuchElementException` will be thrown. * Default values may be provided using either `getOrElse` or `withDefaultValue` for the entire map: */ def defaultValuesMayBeProvidedMaps(res0: String, res1: String) = { @@ -110,11 +118,17 @@ object Maps extends AnyFlatSpec with Matchers with org.scalaexercises.definition myMap.getOrElse("TX", "missing data") should be(res0) val myMap2 = - Map("MI" -> "Michigan", "OH" -> "Ohio", "WI" -> "Wisconsin", "IA" -> "Iowa") withDefaultValue "missing data" + Map( + "MI" -> "Michigan", + "OH" -> "Ohio", + "WI" -> "Wisconsin", + "IA" -> "Iowa" + ) withDefaultValue "missing data" myMap2("TX") should be(res1) } - /** Map elements can be removed easily: + /** + * Map elements can be removed easily: */ def easilyRemovedMaps(res0: Boolean, res1: Boolean) = { val myMap = @@ -124,7 +138,8 @@ object Maps extends AnyFlatSpec with Matchers with org.scalaexercises.definition myMap.contains("MI") should be(res1) } - /** Map elements can be removed in multiple: + /** + * Map elements can be removed in multiple: */ def removedInMultipleMaps(res0: Boolean, res1: Boolean, res2: Boolean, res3: Int, res4: Int) = { val myMap = @@ -139,7 +154,8 @@ object Maps extends AnyFlatSpec with Matchers with org.scalaexercises.definition myMap.size should be(res4) } - /** Attempted removal of nonexistent elements from a map is handled gracefully: + /** + * Attempted removal of nonexistent elements from a map is handled gracefully: */ def attemptedRemovalMaps(res0: Boolean) = { val myMap = @@ -149,7 +165,8 @@ object Maps extends AnyFlatSpec with Matchers with org.scalaexercises.definition aNewMap.equals(myMap) should be(res0) } - /** Map equivalency is independent of order: + /** + * Map equivalency is independent of order: */ def orderIndependentMaps(res0: Boolean) = { val myMap1 = diff --git a/src/main/scala/stdlib/NamedandDefaultArguments.scala b/src/main/scala/stdlib/NamedandDefaultArguments.scala index 01dab556..c2b5f8f7 100644 --- a/src/main/scala/stdlib/NamedandDefaultArguments.scala +++ b/src/main/scala/stdlib/NamedandDefaultArguments.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,15 +20,16 @@ import NamedandDefaultArgumentsHelper._ import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name named_and_default_arguments - * +/** + * @param name named_and_default_arguments */ object NamedandDefaultArguments extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** When calling methods and functions, you can use the name of the variables explicitly in the call, like so: + /** + * When calling methods and functions, you can use the name of the variables explicitly in the call, like so: * * {{{ * def printName(first:String, last:String) = { @@ -95,7 +96,8 @@ object NamedandDefaultArguments myColor should equal((res0, res1, res2)) } - /** You can default arguments if you leave them off: + /** + * You can default arguments if you leave them off: */ def defaultArgumentsNamedandDefaultArguments(res0: Int, res1: Int, res2: Int) = { val me = new WithoutClassParameters() @@ -104,7 +106,8 @@ object NamedandDefaultArguments myColor should equal((res0, res1, res2)) } - /** You can access class parameters and specify arguments in any order if you use their names: + /** + * You can access class parameters and specify arguments in any order if you use their names: */ def anyOrderNamedandDefaultArguments(res0: Int, res1: Int, res2: Int) = { val me = new WithClassParameters(40, 50, 60) @@ -113,7 +116,8 @@ object NamedandDefaultArguments myColor should equal((res0, res1, res2)) } - /** You can access class parameters and default arguments if you leave them off: + /** + * You can access class parameters and default arguments if you leave them off: */ def accessClassParametersNamedandDefaultArguments(res0: Int, res1: Int, res2: Int) = { val me = new WithClassParameters(10, 20, 30) @@ -122,7 +126,8 @@ object NamedandDefaultArguments myColor should equal((res0, res1, res2)) } - /** You can default class parameters and have default arguments too: + /** + * You can default class parameters and have default arguments too: */ def defaultClassArgumentsNamedandDefaultArguments(res0: Int, res1: Int, res2: Int) = { val me = new WithClassParametersInClassDefinition() @@ -131,7 +136,8 @@ object NamedandDefaultArguments myColor should equal((res0, res1, res2)) } - /** Default parameters can be functions too: + /** + * Default parameters can be functions too: */ def functionalDefaulParametersNamedandDefaultArguments(res0: Int, res1: Int) = { def reduce(a: Int, f: (Int, Int) => Int = _ + _): Int = f(a, a) diff --git a/src/main/scala/stdlib/NamedandDefaultArgumentsHelper.scala b/src/main/scala/stdlib/NamedandDefaultArgumentsHelper.scala index eb220518..f0bc8067 100644 --- a/src/main/scala/stdlib/NamedandDefaultArgumentsHelper.scala +++ b/src/main/scala/stdlib/NamedandDefaultArgumentsHelper.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/stdlib/Objects.scala b/src/main/scala/stdlib/Objects.scala index 03bb14a7..029f2a4c 100644 --- a/src/main/scala/stdlib/Objects.scala +++ b/src/main/scala/stdlib/Objects.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name objects - * +/** + * @param name objects */ object Objects extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** An object is a singleton. One object, that's it. This object is a replacement of static in Java, and is called upon much in the same way: + /** + * An object is a singleton. One object, that's it. This object is a replacement of static in Java, and is called upon much in the same way: */ def singletonObjects(res0: String, res1: String) = { object Greeting { @@ -38,7 +39,8 @@ object Objects extends AnyFlatSpec with Matchers with org.scalaexercises.definit Greeting.espanol should be(res1) } - /** Here is a proof that an object is a singleton, and not a static method in a class: + /** + * Here is a proof that an object is a singleton, and not a static method in a class: */ def notStaticMethodObjects(res0: Boolean, res1: Boolean) = { object Greeting { @@ -57,7 +59,8 @@ object Objects extends AnyFlatSpec with Matchers with org.scalaexercises.definit x eq z should be(res1) } - /** An object that has the same name as a class is called a companion object of the class, and it is often used to contain factory methods for the class that it complements: + /** + * An object that has the same name as a class is called a companion object of the class, and it is often used to contain factory methods for the class that it complements: */ def companionObjectObjects(res0: String) = { class Movie(val name: String, val year: Short) @@ -77,10 +80,14 @@ object Objects extends AnyFlatSpec with Matchers with org.scalaexercises.definit Movie.academyAwardBestMoviesForYear(1932).get.name should be(res0) } - /** A companion object can also see private values and variables of the corresponding classes' instantiated objects: + /** + * A companion object can also see private values and variables of the corresponding classes' instantiated objects: */ def privateValuesObjects(res0: String, res1: String) = { - class Person(val name: String, private val superheroName: String) //The superhero name is private! + class Person( + val name: String, + private val superheroName: String + ) //The superhero name is private! object Person { def showMeInnerSecret(x: Person) = x.superheroName diff --git a/src/main/scala/stdlib/Options.scala b/src/main/scala/stdlib/Options.scala index ba1d4a94..6d37562b 100644 --- a/src/main/scala/stdlib/Options.scala +++ b/src/main/scala/stdlib/Options.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,13 @@ import OptionsHelper._ import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name options - * +/** + * @param name options */ object Options extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** If you have worked with Java at all in the past, it is very likely that you have come across a `NullPointerException` at some time (other languages will throw similarly named errors in such a case). Usually this happens because some method returns null when you were not expecting it and thus not dealing with that possibility in your client code. A value of `null` is often abused to represent an absent optional value. + /** + * If you have worked with Java at all in the past, it is very likely that you have come across a `NullPointerException` at some time (other languages will throw similarly named errors in such a case). Usually this happens because some method returns null when you were not expecting it and thus not dealing with that possibility in your client code. A value of `null` is often abused to represent an absent optional value. * * Scala tries to solve the problem by getting rid of `null` values altogether and providing its own type for representing optional values, i.e. values that may be present or not: the `Option[A]` trait. * @@ -39,7 +40,8 @@ object Options extends AnyFlatSpec with Matchers with org.scalaexercises.definit emptyValue should be(res1) } - /** Let's write a function that may or not give us a string, thus returning `Option[String]`: + /** + * Let's write a function that may or not give us a string, thus returning `Option[String]`: * * {{{ * def maybeItWillReturnSomething(flag: Boolean): Option[String] = { @@ -61,7 +63,8 @@ object Options extends AnyFlatSpec with Matchers with org.scalaexercises.definit } - /** Checking whether option has value: + /** + * Checking whether option has value: */ def isEmptyOptions(res0: Boolean, res1: Boolean) = { val value1 = maybeItWillReturnSomething(true) @@ -71,7 +74,8 @@ object Options extends AnyFlatSpec with Matchers with org.scalaexercises.definit value2.isEmpty should be(res1) } - /** Option can also be used with pattern matching: + /** + * Option can also be used with pattern matching: */ def matchOptions(res0: Double, res1: Double) = { val someValue: Option[Double] = Some(20.0) @@ -88,7 +92,8 @@ object Options extends AnyFlatSpec with Matchers with org.scalaexercises.definit value1 should be(res1) } - /** An alternative for pattern matching is performing collection style operations. + /** + * An alternative for pattern matching is performing collection style operations. * This is possible because an option could be looked at as a collection with either one or zero elements. * * One of these operations is `map`. This operation allows us to map the inner value to a different type while preserving the option: @@ -102,10 +107,12 @@ object Options extends AnyFlatSpec with Matchers with org.scalaexercises.definit result1 should be(res0) result2 should be(res1) - /** Note that the type of result1 is now Option[Double], thanks to the scala type inference. */ + /** + * Note that the type of result1 is now Option[Double], thanks to the scala type inference. */ } - /** Another operation is `fold`. This operation will extract the value from the option, or provide a default if the value is `None` + /** + * Another operation is `fold`. This operation will extract the value from the option, or provide a default if the value is `None` */ def foldOptions(res0: Int, res1: Int) = { val number: Option[Int] = Some(3) diff --git a/src/main/scala/stdlib/OptionsHelper.scala b/src/main/scala/stdlib/OptionsHelper.scala index 1743726b..11c6856d 100644 --- a/src/main/scala/stdlib/OptionsHelper.scala +++ b/src/main/scala/stdlib/OptionsHelper.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/stdlib/ParentClasses.scala b/src/main/scala/stdlib/ParentClasses.scala index e58561d2..8d874872 100644 --- a/src/main/scala/stdlib/ParentClasses.scala +++ b/src/main/scala/stdlib/ParentClasses.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,15 +19,15 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name parent_classes - * +/** + * @param name parent_classes */ object ParentClasses extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** In contrast to Java, all values in Scala are objects (including numerical values and functions). Since Scala is class-based, all values are instances of a class. + /** + * In contrast to Java, all values in Scala are objects (including numerical values and functions). Since Scala is class-based, all values are instances of a class. * * Class hierarchy is linear, a class can only extend from one parent class: - * */ def allValuesAreObjectsParentClasses(res0: String, res1: String) = { class Soldier(val firstName: String, val lastName: String) {} @@ -38,7 +38,8 @@ object ParentClasses extends AnyFlatSpec with Matchers with org.scalaexercises.d pilot.lastName should be(res1) } - /** A class that extends from another is polymorphic: + /** + * A class that extends from another is polymorphic: */ def polymorphicParentClasses(res0: String, res1: String) = { class Soldier(val firstName: String, val lastName: String) {} @@ -52,7 +53,8 @@ object ParentClasses extends AnyFlatSpec with Matchers with org.scalaexercises.d soldier.lastName should be(res1) } - /** An abstract class, as in Java, cannot be instantiated and only inherited: + /** + * An abstract class, as in Java, cannot be instantiated and only inherited: * * {{{ * abstract class Soldier(val firstName: String, val lastName: String) {} @@ -74,8 +76,9 @@ object ParentClasses extends AnyFlatSpec with Matchers with org.scalaexercises.d class Pilot(override val firstName: String, override val lastName: String, val squadron: Long) extends Soldier(firstName, lastName) - val pilot = new Pilot("John", "Yossarian", 256) - val catchNo = new pilot.Catch(22) //using the pilot instance's path, create an catch object for it. + val pilot = new Pilot("John", "Yossarian", 256) + val catchNo = + new pilot.Catch(22) //using the pilot instance's path, create an catch object for it. catchNo.number should be(res0) } diff --git a/src/main/scala/stdlib/PartialFunctions.scala b/src/main/scala/stdlib/PartialFunctions.scala index cdc41869..79458ae9 100644 --- a/src/main/scala/stdlib/PartialFunctions.scala +++ b/src/main/scala/stdlib/PartialFunctions.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,15 +19,16 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name partial_functions - * +/** + * @param name partial_functions */ object PartialFunctions extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** A partial function is a `trait` that when implemented can be used as building blocks to determine a solution. The trait `PartialFunction` requires that the method `isDefinedAt` and `apply` be implemented: + /** + * A partial function is a `trait` that when implemented can be used as building blocks to determine a solution. The trait `PartialFunction` requires that the method `isDefinedAt` and `apply` be implemented: */ def partialFunctionPartialFunctions(res0: Int, res1: Int) = { val doubleEvens: PartialFunction[Int, Int] = @@ -51,7 +52,8 @@ object PartialFunctions whatToDo(4) should be(res1) } - /** Case statements are a quick way to create partial functions. When you create a case statement, the `apply` and `isDefinedAt` methods are created automatically. + /** + * Case statements are a quick way to create partial functions. When you create a case statement, the `apply` and `isDefinedAt` methods are created automatically. */ def caseStatementsPartialFunctions(res0: Int, res1: Int) = { //These case statements are called case statements with guards @@ -67,7 +69,8 @@ object PartialFunctions whatToDo(4) should be(res1) } - /** The result of partial functions can have an `andThen` function added to the end of the chain: + /** + * The result of partial functions can have an `andThen` function added to the end of the chain: */ def andThenPartialFunctions(res0: Int, res1: Int) = { //These are called case statements with guards @@ -85,7 +88,8 @@ object PartialFunctions whatToDo(4) should be(res1) } - /** `andThen` can be used to continue onto another chain of logic: + /** + * `andThen` can be used to continue onto another chain of logic: */ def chainOfLogicPartialFunctions(res0: String, res1: String) = { val doubleEvens: PartialFunction[Int, Int] = { diff --git a/src/main/scala/stdlib/PartiallyAppliedFunctions.scala b/src/main/scala/stdlib/PartiallyAppliedFunctions.scala index 800c2801..7565f45b 100644 --- a/src/main/scala/stdlib/PartiallyAppliedFunctions.scala +++ b/src/main/scala/stdlib/PartiallyAppliedFunctions.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,15 +19,16 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name partially_applied_functions - * +/** + * @param name partially_applied_functions */ object PartiallyAppliedFunctions extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** A partially applied function is a function that you do not apply any or all the arguments, creating another function. This partially applied function doesn't apply any arguments. + /** + * A partially applied function is a function that you do not apply any or all the arguments, creating another function. This partially applied function doesn't apply any arguments. */ def partiallyAppliedPartiallyAppliedFunctions(res0: Int, res1: Int) = { def sum(a: Int, b: Int, c: Int) = a + b + c @@ -36,7 +37,8 @@ object PartiallyAppliedFunctions sum(4, 5, 6) should be(res1) } - /** Partially applied functions can replace any number of arguments: + /** + * Partially applied functions can replace any number of arguments: */ def anyNumberArgumentsPartiallyAppliedFunctions(res0: Int, res1: Int) = { def sum(a: Int, b: Int, c: Int) = a + b + c @@ -45,7 +47,8 @@ object PartiallyAppliedFunctions sum(4, 5, 6) should be(res1) } - /** Currying is a technique to transform a function with multiple parameters into multiple functions which each take one parameter: + /** + * Currying is a technique to transform a function with multiple parameters into multiple functions which each take one parameter: */ def curryingPartiallyAppliedFunctions( res0: Boolean, @@ -64,7 +67,8 @@ object PartiallyAppliedFunctions multiplyCurriedFour(4) should be(res4) } - /** Currying allows you to create specialized versions of generalized functions: + /** + * Currying allows you to create specialized versions of generalized functions: */ def specializedVersionPartiallyAppliedFunctions(res0: List[Int], res1: List[Int]) = { def customFilter(f: Int => Boolean)(xs: List[Int]) = diff --git a/src/main/scala/stdlib/PatternMatching.scala b/src/main/scala/stdlib/PatternMatching.scala index 84e8967d..e3331cc4 100644 --- a/src/main/scala/stdlib/PatternMatching.scala +++ b/src/main/scala/stdlib/PatternMatching.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,15 +19,16 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name pattern_matching - * +/** + * @param name pattern_matching */ object PatternMatching extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Scala has a built-in general pattern matching mechanism. It allows to match on any sort of data with a first-match policy. + /** + * Scala has a built-in general pattern matching mechanism. It allows to match on any sort of data with a first-match policy. * Here is a small example which shows how to match against an integer value: * * {{{ @@ -65,7 +66,8 @@ object PatternMatching myStuff should be(res0) } - /** Pattern matching can return complex values: + /** + * Pattern matching can return complex values: */ def returnComplexPatternMatching(res0: Int, res1: Int, res2: Int) = { val stuff = "blue" @@ -80,43 +82,49 @@ object PatternMatching myStuff should be((res0, res1, res2)) } - /** Pattern matching can match complex expressions: + /** + * Pattern matching can match complex expressions: */ def complexExpressionsPatternMatching(res0: String) = { - def goldilocks(expr: Any) = expr match { - case ("porridge", "Papa") => "Papa eating porridge" - case ("porridge", "Mama") => "Mama eating porridge" - case ("porridge", "Baby") => "Baby eating porridge" - case _ => "what?" - } + def goldilocks(expr: Any) = + expr match { + case ("porridge", "Papa") => "Papa eating porridge" + case ("porridge", "Mama") => "Mama eating porridge" + case ("porridge", "Baby") => "Baby eating porridge" + case _ => "what?" + } goldilocks(("porridge", "Mama")) should be(res0) } - /** Pattern matching can wildcard parts of expressions: + /** + * Pattern matching can wildcard parts of expressions: */ def wildcardParsPatternMatching(res0: String, res1: String) = { - def goldilocks(expr: Any) = expr match { - case ("porridge", _) => "eating" - case ("chair", "Mama") => "sitting" - case ("bed", "Baby") => "sleeping" - case _ => "what?" - } + def goldilocks(expr: Any) = + expr match { + case ("porridge", _) => "eating" + case ("chair", "Mama") => "sitting" + case ("bed", "Baby") => "sleeping" + case _ => "what?" + } goldilocks(("porridge", "Papa")) should be(res0) goldilocks(("chair", "Mama")) should be(res1) } - /** Pattern matching can substitute parts of expressions: + /** + * Pattern matching can substitute parts of expressions: */ def substitutePartsPatternMatching(res0: String, res1: String) = { - def goldilocks(expr: (String, String)) = expr match { - case ("porridge", bear) => - bear + " said someone's been eating my porridge" - case ("chair", bear) => bear + " said someone's been sitting in my chair" - case ("bed", bear) => bear + " said someone's been sleeping in my bed" - case _ => "what?" - } + def goldilocks(expr: (String, String)) = + expr match { + case ("porridge", bear) => + bear + " said someone's been eating my porridge" + case ("chair", bear) => bear + " said someone's been sitting in my chair" + case ("bed", bear) => bear + " said someone's been sleeping in my bed" + case _ => "what?" + } goldilocks(("porridge", "Papa")) should be(res0) goldilocks(("chair", "Mama")) should be(res1) @@ -144,17 +152,19 @@ object PatternMatching // goldilocks("Sitting Alert: bear=Mama, source=chair") should be(res1) // } - /** A backquote can be used to refer to a stable variable in scope to create a case statement - this prevents "variable shadowing": + /** + * A backquote can be used to refer to a stable variable in scope to create a case statement - this prevents "variable shadowing": */ def createCaseStatementPatternMatching(res0: String, res1: String, res2: String, res3: String) = { val foodItem = "porridge" - def goldilocks(expr: (String, String)) = expr match { - case (`foodItem`, _) => "eating" - case ("chair", "Mama") => "sitting" - case ("bed", "Baby") => "sleeping" - case _ => "what?" - } + def goldilocks(expr: (String, String)) = + expr match { + case (`foodItem`, _) => "eating" + case ("chair", "Mama") => "sitting" + case ("bed", "Baby") => "sleeping" + case _ => "what?" + } goldilocks(("porridge", "Papa")) should be(res0) goldilocks(("chair", "Mama")) should be(res1) @@ -162,19 +172,22 @@ object PatternMatching goldilocks(("beer", "Cousin")) should be(res3) } - /** A backquote can be used to refer to a method parameter as a stable variable to create a case statement: + /** + * A backquote can be used to refer to a method parameter as a stable variable to create a case statement: */ def stableVariablePatternMatching(res0: Boolean, res1: Boolean, res2: Boolean) = { - def patternEquals(i: Int, j: Int) = j match { - case `i` => true - case _ => false - } + def patternEquals(i: Int, j: Int) = + j match { + case `i` => true + case _ => false + } patternEquals(3, 3) should be(res0) patternEquals(7, 9) should be(res1) patternEquals(9, 9) should be(res2) } - /** To pattern match against a `List`, the list can be split into parts, in this case the head `x` and the tail `xs`. Since the case doesn't terminate in `Nil`, `xs` is interpreted as the rest of the list: + /** + * To pattern match against a `List`, the list can be split into parts, in this case the head `x` and the tail `xs`. Since the case doesn't terminate in `Nil`, `xs` is interpreted as the rest of the list: */ def againstListsPatternMatching(res0: Int) = { val secondElement = List(1, 2, 3) match { @@ -185,7 +198,8 @@ object PatternMatching secondElement should be(res0) } - /** To obtain the second element you can expand on the pattern. Where `x` is the first element, `y` is the second element, and `xs` is the rest: + /** + * To obtain the second element you can expand on the pattern. Where `x` is the first element, `y` is the second element, and `xs` is the rest: */ def againstListsIIPatternMatching(res0: Int) = { val secondElement = List(1, 2, 3) match { @@ -196,7 +210,8 @@ object PatternMatching secondElement should be(res0) } - /** Same koan as above, but we are pattern matching a list with only one item! + /** + * Same koan as above, but we are pattern matching a list with only one item! */ def againstListsIIIPatternMatching(res0: Int) = { val secondElement = List(1) match { @@ -207,7 +222,8 @@ object PatternMatching secondElement should be(res0) } - /** To pattern match against `List`, you can also establish a pattern match if you know the exact number of elements in a `List`: + /** + * To pattern match against `List`, you can also establish a pattern match if you know the exact number of elements in a `List`: */ def againstListsIVPatternMatching(res0: Int) = { val r = List(1, 2, 3) match { @@ -218,7 +234,8 @@ object PatternMatching r should be(res0) } - /** If a pattern is exactly one element longer than a `List`, it extracts the final `Nil`: + /** + * If a pattern is exactly one element longer than a `List`, it extracts the final `Nil`: */ def againstListsVPatternMatching(res0: Boolean) = { val r = List(1, 2, 3) match { diff --git a/src/main/scala/stdlib/Ranges.scala b/src/main/scala/stdlib/Ranges.scala index a6fc2bb0..4580e995 100644 --- a/src/main/scala/stdlib/Ranges.scala +++ b/src/main/scala/stdlib/Ranges.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,19 +19,20 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name ranges - * +/** + * @param name ranges */ object Ranges extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** A Range is an ordered sequence of integers that are equally spaced apart. For example, "1, 2, 3" is a range, as is "5, 8, 11, 14". To create a range in Scala, use the predefined methods `to`, `until`, and `by`. `1 to 3` generates "1, 2, 3" and `5 to 14 by 3` generates "5, 8, 11, 14". + /** + * A Range is an ordered sequence of integers that are equally spaced apart. For example, "1, 2, 3" is a range, as is "5, 8, 11, 14". To create a range in Scala, use the predefined methods `to`, `until`, and `by`. `1 to 3` generates "1, 2, 3" and `5 to 14 by 3` generates "5, 8, 11, 14". * * If you want to create a range that is exclusive of its upper limit, then use `until` instead of `to`: `1 until 3` generates "1, 2". * * Note that `Range(a, b, c)` is the same as `a until b by c` * * Ranges are represented in constant space, because they can be defined by just three numbers: their start, their end, and the stepping value. Because of this representation, most operations on ranges are extremely fast. - * + * * A range's upper bound is not inclusive: */ def upperNotInclusiveRangeExercises(res0: Int, res1: Int, res2: Int) = { @@ -44,7 +45,8 @@ object Ranges extends AnyFlatSpec with Matchers with org.scalaexercises.definiti last should be(res2) } - /** Ranges can be specified using 'until': + /** + * Ranges can be specified using 'until': */ def untilRangeExercises(res0: Boolean) = { val someNumbers = Range(0, 10) @@ -53,7 +55,8 @@ object Ranges extends AnyFlatSpec with Matchers with org.scalaexercises.definiti (someNumbers == otherRange) should be(res0) } - /** Range can specify a step for an increment: + /** + * Range can specify a step for an increment: */ def incrementsRangeExercises(res0: Int, res1: Int, res2: Int) = { val someNumbers = Range(2, 10, 3) @@ -65,7 +68,8 @@ object Ranges extends AnyFlatSpec with Matchers with org.scalaexercises.definiti last should be(res2) } - /** A range does not include its upper bound, even in a step increment: + /** + * A range does not include its upper bound, even in a step increment: */ def upperInIncrementRangeExercises(res0: Boolean, res1: Boolean, res2: Boolean) = { val someNumbers = Range(0, 34, 2) @@ -74,7 +78,8 @@ object Ranges extends AnyFlatSpec with Matchers with org.scalaexercises.definiti someNumbers.contains(34) should be(res2) } - /** Range can specify to include its upper bound value: + /** + * Range can specify to include its upper bound value: */ def specifyUpperRangeExercises(res0: Boolean) = { val someNumbers = Range(0, 34).inclusive @@ -82,7 +87,8 @@ object Ranges extends AnyFlatSpec with Matchers with org.scalaexercises.definiti someNumbers.contains(34) should be(res0) } - /** Inclusive ranges can be specified using 'to': + /** + * Inclusive ranges can be specified using 'to': */ def inclusiveWithToRangeExercises(res0: Boolean) = { val someNumbers = Range(0, 34).inclusive diff --git a/src/main/scala/stdlib/RepeatedParameters.scala b/src/main/scala/stdlib/RepeatedParameters.scala index d288e272..804c476b 100644 --- a/src/main/scala/stdlib/RepeatedParameters.scala +++ b/src/main/scala/stdlib/RepeatedParameters.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,15 +20,16 @@ import RepeatedParametersHelper._ import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name repeated_parameters - * +/** + * @param name repeated_parameters */ object RepeatedParameters extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** A repeated parameter must be the last parameter and this will let you add as many extra parameters as needed. + /** + * A repeated parameter must be the last parameter and this will let you add as many extra parameters as needed. * * Given: * @@ -38,21 +39,32 @@ object RepeatedParameters * } * }}} * Resolve: - * */ def theLastParameterRepeatedParameters(res0: String) = - repeatedParameterMethod(3, "egg", "a delicious sandwich", "protein", "high cholesterol") should be( + repeatedParameterMethod( + 3, + "egg", + "a delicious sandwich", + "protein", + "high cholesterol" + ) should be( res0 ) - /** A repeated parameter can accept a collection as the last parameter but will be considered a single object: + /** + * A repeated parameter can accept a collection as the last parameter but will be considered a single object: */ def acceptCollectionRepeatedParameters(res0: String) = - repeatedParameterMethod(3, "egg", List("a delicious sandwich", "protein", "high cholesterol")) should be( + repeatedParameterMethod( + 3, + "egg", + List("a delicious sandwich", "protein", "high cholesterol") + ) should be( res0 ) - /** A repeated parameter can accept a collection - if you want it expanded, add `:_*` + /** + * A repeated parameter can accept a collection - if you want it expanded, add `:_*` */ def expandCollectionRepeatedParameters(res0: String) = { repeatedParameterMethod( diff --git a/src/main/scala/stdlib/RepeatedParametersHelper.scala b/src/main/scala/stdlib/RepeatedParametersHelper.scala index 910252ca..55f380b8 100644 --- a/src/main/scala/stdlib/RepeatedParametersHelper.scala +++ b/src/main/scala/stdlib/RepeatedParametersHelper.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/stdlib/SequencesandArrays.scala b/src/main/scala/stdlib/SequencesandArrays.scala index efb30a64..d5dc2fff 100644 --- a/src/main/scala/stdlib/SequencesandArrays.scala +++ b/src/main/scala/stdlib/SequencesandArrays.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,15 +19,16 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name sequences_and_arrays - * +/** + * @param name sequences_and_arrays */ object SequencesandArrays extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Scala provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. + /** + * Scala provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. * * A list can be converted to an array: */ @@ -37,10 +38,10 @@ object SequencesandArrays a should equal(Array(res0, res1, res2)) } - /** Sequences are special cases of iterable collections of class `Iterable`. Unlike iterables, sequences always have a defined order of elements. + /** + * Sequences are special cases of iterable collections of class `Iterable`. Unlike iterables, sequences always have a defined order of elements. * * Any sequence can be converted to a list: - * */ def orderedElementsSequencesandArrays(res0: List[Int]) = { val a = Array(1, 2, 3) @@ -49,21 +50,24 @@ object SequencesandArrays l should equal(res0) } - /** You can create a sequence from a `for` loop: + /** + * You can create a sequence from a `for` loop: */ def fromForComprehensionSequencesandArrays(res0: List[Int]) = { val s = for (v <- 1 to 4) yield v s.toList should be(res0) } - /** You can create a sequence from a `for` loop with a filter: + /** + * You can create a sequence from a `for` loop with a filter: */ def withConditionSequencesandArrays(res0: List[Int]) = { val s = for (v <- 1 to 10 if v % 3 == 0) yield v s.toList should be(res0) } - /** You can filter any sequence based on a predicate: + /** + * You can filter any sequence based on a predicate: */ def filterPredicateSequencesandArrays(res0: String, res1: String) = { val s = Seq("hello", "to", "you") @@ -71,7 +75,8 @@ object SequencesandArrays filtered should be(Seq(res0, res1)) } - /** You can also filter Arrays in the same way: + /** + * You can also filter Arrays in the same way: */ def filterArraySequencesandArrays(res0: String, res1: String) = { val a = Array("hello", "to", "you", "again") @@ -79,7 +84,8 @@ object SequencesandArrays filtered should be(Array(res0, res1)) } - /** You can map values in a sequence through a function: + /** + * You can map values in a sequence through a function: */ def mapValuesSequencesandArrays(res0: Seq[String]) = { val s = Seq("hello", "world") diff --git a/src/main/scala/stdlib/Sets.scala b/src/main/scala/stdlib/Sets.scala index 90fa292f..bef58ff7 100644 --- a/src/main/scala/stdlib/Sets.scala +++ b/src/main/scala/stdlib/Sets.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name sets - * +/** + * @param name sets */ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** `Set`s are `Iterable`s that contain no duplicate elements. The operations on sets are summarized in the following table for general sets and in the table after that for mutable sets. They fall into the following categories: + /** + * `Set`s are `Iterable`s that contain no duplicate elements. The operations on sets are summarized in the following table for general sets and in the table after that for mutable sets. They fall into the following categories: * * - **Tests**: `contains`, `apply`, `subsetOf`. The `contains` method asks whether a set contains a given element. The `apply` method for a set is the same as `contains`, so `set(elem)` is the same as `set contains elem`. That means sets can also be used as test functions that return true for the elements they contain. * - **Additions**: `+` and `++`, which add one or more elements to a set, yielding a new set. @@ -38,14 +39,16 @@ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definition mySet.size should be(res0) } - /** Sets contain distinct values: + /** + * Sets contain distinct values: */ def distinctValuesSets(res0: Int) = { val mySet = Set("Michigan", "Ohio", "Wisconsin", "Michigan") mySet.size should be(res0) } - /** Sets can be added to easily: + /** + * Sets can be added to easily: */ def easilyAddedSets(res0: Boolean, res1: Boolean) = { val mySet = Set("Michigan", "Ohio", "Wisconsin", "Iowa") @@ -55,7 +58,8 @@ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definition mySet.contains("Illinois") should be(res1) } - /** Sets may be of mixed type: + /** + * Sets may be of mixed type: */ def mixedTypeSets(res0: Boolean, res1: Boolean) = { val mySet = Set("Michigan", "Ohio", 12) @@ -64,7 +68,8 @@ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definition mySet.contains("MI") should be(res1) } - /** Sets can be checked for member existence: + /** + * Sets can be checked for member existence: */ def checkExistenceSets(res0: Boolean, res1: Boolean) = { val mySet = Set("Michigan", "Ohio", 12) @@ -73,7 +78,8 @@ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definition mySet("MI") should be(res1) } - /** Set elements can be removed easily: + /** + * Set elements can be removed easily: */ def easilyRemovedSets(res0: Boolean, res1: Boolean) = { val mySet = Set("Michigan", "Ohio", "Wisconsin", "Iowa") @@ -83,7 +89,8 @@ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definition mySet.contains("Michigan") should be(res1) } - /** Set elements can be removed in multiple: + /** + * Set elements can be removed in multiple: */ def multipleRemovingSets(res0: Boolean, res1: Boolean, res2: Int) = { val mySet = Set("Michigan", "Ohio", "Wisconsin", "Iowa") @@ -94,7 +101,8 @@ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definition aNewSet.size should be(res2) } - /** Attempted removal of nonexistent elements from a set is handled gracefully: + /** + * Attempted removal of nonexistent elements from a set is handled gracefully: */ def nonexistentRemovalSets(res0: Boolean) = { val mySet = Set("Michigan", "Ohio", "Wisconsin", "Iowa") @@ -103,7 +111,8 @@ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definition aNewSet.equals(mySet) should be(res0) } - /** Two sets can be intersected easily: + /** + * Two sets can be intersected easily: */ def easilyIntersectedSets(res0: Boolean) = { val mySet1 = Set("Michigan", "Ohio", "Wisconsin", "Iowa") @@ -113,7 +122,8 @@ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definition aNewSet.equals(Set("Michigan", "Wisconsin")) should be(res0) } - /** Two sets can be joined as their union easily: + /** + * Two sets can be joined as their union easily: */ def easilyJoinedSets(res0: Boolean) = { val mySet1 = Set("Michigan", "Ohio", "Wisconsin", "Iowa") @@ -123,7 +133,8 @@ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definition aNewSet.equals(Set("Michigan", "Wisconsin", "Ohio", "Iowa", "Minnesota")) should be(res0) } - /** A set is either a subset of another set or it isn't: + /** + * A set is either a subset of another set or it isn't: */ def subsetSets(res0: Boolean, res1: Boolean) = { val mySet1 = Set("Michigan", "Ohio", "Wisconsin", "Iowa") @@ -134,7 +145,8 @@ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definition mySet3 subsetOf mySet1 should be(res1) } - /** The difference between two sets can be obtained easily: + /** + * The difference between two sets can be obtained easily: */ def easilyObtainedDifferencesSets(res0: Boolean) = { val mySet1 = Set("Michigan", "Ohio", "Wisconsin", "Iowa") @@ -144,7 +156,8 @@ object Sets extends AnyFlatSpec with Matchers with org.scalaexercises.definition aNewSet.equals(Set("Ohio", "Iowa")) should be(res0) } - /** Set equivalency is independent of order: + /** + * Set equivalency is independent of order: */ def equivalencySets(res0: Boolean) = { val mySet1 = Set("Michigan", "Ohio", "Wisconsin", "Iowa") diff --git a/src/main/scala/stdlib/StdLib.scala b/src/main/scala/stdlib/StdLib.scala index de2d981d..6d05a03a 100644 --- a/src/main/scala/stdlib/StdLib.scala +++ b/src/main/scala/stdlib/StdLib.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,7 +16,8 @@ package stdlib -/** Scala fuses object-oriented and functional programming in a statically typed programming language. +/** + * Scala fuses object-oriented and functional programming in a statically typed programming language. * * @param name std_lib */ @@ -26,43 +27,44 @@ object StdLib extends org.scalaexercises.definitions.Library { override def color = Some("#26525B") - override def sections = List( - Asserts, - Classes, - Options, - Objects, - Tuples, - HigherOrderFunctions, - Lists, - Maps, - Sets, - Formatting, - PatternMatching, - CaseClasses, - Ranges, - PartiallyAppliedFunctions, - PartialFunctions, - Implicits, - Traits, - ForExpressions, - InfixPrefixandPostfixOperators, - InfixTypes, - SequencesandArrays, - Iterables, - Traversables, - NamedandDefaultArguments, - Extractors, - ByNameParameter, - RepeatedParameters, - ParentClasses, - EmptyValues, - TypeSignatures, - UniformAccessPrinciple, - LiteralBooleans, - LiteralNumbers, - LiteralStrings, - TypeVariance, - Enumerations - ) + override def sections = + List( + Asserts, + Classes, + Options, + Objects, + Tuples, + HigherOrderFunctions, + Lists, + Maps, + Sets, + Formatting, + PatternMatching, + CaseClasses, + Ranges, + PartiallyAppliedFunctions, + PartialFunctions, + Implicits, + Traits, + ForExpressions, + InfixPrefixandPostfixOperators, + InfixTypes, + SequencesandArrays, + Iterables, + Traversables, + NamedandDefaultArguments, + Extractors, + ByNameParameter, + RepeatedParameters, + ParentClasses, + EmptyValues, + TypeSignatures, + UniformAccessPrinciple, + LiteralBooleans, + LiteralNumbers, + LiteralStrings, + TypeVariance, + Enumerations + ) override def logoPath = "std_lib" } diff --git a/src/main/scala/stdlib/Traits.scala b/src/main/scala/stdlib/Traits.scala index 411801e6..064e5130 100644 --- a/src/main/scala/stdlib/Traits.scala +++ b/src/main/scala/stdlib/Traits.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,13 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name traits +/** + * @param name traits */ object Traits extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Similar to interfaces in Java, traits are used to define object types by specifying the signature of the supported methods. In traits methods can have default implementations. In contrast to classes, traits may not have constructor parameters. + /** + * Similar to interfaces in Java, traits are used to define object types by specifying the signature of the supported methods. In traits methods can have default implementations. In contrast to classes, traits may not have constructor parameters. * * Here is an example: * @@ -60,7 +62,8 @@ object Traits extends AnyFlatSpec with Matchers with org.scalaexercises.definiti myListener.listen(evt) should be(res0) } - /** A class can only extend from one class or trait, any subsequent extension should use the keyword `with`: + /** + * A class can only extend from one class or trait, any subsequent extension should use the keyword `with`: */ def extendsFromOneTraits(res0: String) = { case class Event(name: String) @@ -86,7 +89,8 @@ object Traits extends AnyFlatSpec with Matchers with org.scalaexercises.definiti myListener.listen(evt) should be(res0) } - /** Traits are polymorphic. Any type can be referred to by another type if related by extension: + /** + * Traits are polymorphic. Any type can be referred to by another type if related by extension: */ def polymorphicTraits(res0: Boolean, res1: Boolean, res2: Boolean, res3: Boolean) = { case class Event(name: String) @@ -113,7 +117,8 @@ object Traits extends AnyFlatSpec with Matchers with org.scalaexercises.definiti myListener.isInstanceOf[AnyRef] should be(res3) } - /** Traits also can use self-types. A self-type lists the required dependencies for mixing in the trait. When mixing in the main trait, all self-type dependencies of that trait must also be mixed in, otherwise a compile-time error is thrown. + /** + * Traits also can use self-types. A self-type lists the required dependencies for mixing in the trait. When mixing in the main trait, all self-type dependencies of that trait must also be mixed in, otherwise a compile-time error is thrown. * * Also, the dependencies can't have identical method/property names or else you'll get an `illegal inheritance` error. */ diff --git a/src/main/scala/stdlib/Traversables.scala b/src/main/scala/stdlib/Traversables.scala index cfb6866f..c0617ca3 100644 --- a/src/main/scala/stdlib/Traversables.scala +++ b/src/main/scala/stdlib/Traversables.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,11 +22,13 @@ import scala.language.postfixOps import LazyList.cons -/** @param name traversables +/** + * @param name traversables */ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** At the top of the collection hierarchy is the trait `Traversable`. Its only abstract operation is `foreach`: + /** + * At the top of the collection hierarchy is the trait `Traversable`. Its only abstract operation is `foreach`: * * {{{ * def foreach[U](f: Elem => U) @@ -37,7 +39,7 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de * The `foreach` method is meant to traverse all elements of the collection, and apply the given operation, `f`, to each element. The type of the operation is `Elem => U`, where `Elem` is the type of the collection's elements and `U` is an arbitrary result type. The invocation of `f` is done for its side effect only; in fact any function result of `f` is discarded by `foreach`. * * Traversables are the superclass of `List`, `Array`, `Map`, `Set`, `Stream` and more. The methods involved can be applied to each other in a different type. - `++` appends two `Traversable`s together. The resulting `Traversable` is the same type of the first element. + * `++` appends two `Traversable`s together. The resulting `Traversable` is the same type of the first element. */ def topOfCollectionTraversables(res0: Int, res1: Int) = { val set = Set(1, 9, 10, 22) @@ -49,7 +51,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result2.size should be(res1) } - /** `map` will apply the given function on all elements of a `Traversable` and return a new collection of the result: + /** + * `map` will apply the given function on all elements of a `Traversable` and return a new collection of the result: */ def mapFunctionTraversables(res0: Option[Int]) = { val set = Set(1, 3, 4, 6) @@ -57,14 +60,16 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result.lastOption should be(res0) } - /** `flatten` will "pack" all child `Traversables` into a single `Traversable`: + /** + * `flatten` will "pack" all child `Traversables` into a single `Traversable`: */ def flattenFunctionTraversables(res0: List[Int]) = { val list = List(List(1), List(2, 3, 4), List(5, 6, 7), List(8, 9, 10)) list.flatten should be(res0) } - /** `flatMap` will not only apply the given function on all elements of a `Traversable`, but all elements within the elements and `flatten` the results: + /** + * `flatMap` will not only apply the given function on all elements of a `Traversable`, but all elements within the elements and `flatten` the results: */ def flatMapFunctionTraversables(res0: List[Int]) = { val list = List(List(1), List(2, 3, 4), List(5, 6, 7), List(8, 9, 10)) @@ -72,7 +77,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result should be(res0) } - /** `flatMap` of `Option`s will filter out all `None`s but keep the `Some`s: + /** + * `flatMap` of `Option`s will filter out all `None`s but keep the `Some`s: */ def flatMapOfOptionsTraversables(res0: List[Int]) = { val list = List(1, 2, 3, 4, 5) @@ -80,7 +86,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result should be(res0) } - /** `collect` will apply a partial function to all elements of a `Traversable` and return a different collection. In this exercise, a case fragment is a partial function: + /** + * `collect` will apply a partial function to all elements of a `Traversable` and return a different collection. In this exercise, a case fragment is a partial function: */ def collectFunctionTraversables(res0: List[Int]) = { val list = List(4, 6, 7, 8, 9, 13, 14) @@ -90,7 +97,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result should be(res0) } - /** Two case fragments can be chained to create a more robust result: + /** + * Two case fragments can be chained to create a more robust result: */ def collectFunctionIITraversables(res0: List[Int]) = { val list = List(4, 6, 7, 8, 9, 13, 14) @@ -104,7 +112,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result should be(res0) } - /** `foreach` will apply a function to all elements of a `Traversable`, but unlike the `map` function, it will not return anything since the return type is `Unit` - an equivalent to a `void` return type in Java/C++: + /** + * `foreach` will apply a function to all elements of a `Traversable`, but unlike the `map` function, it will not return anything since the return type is `Unit` - an equivalent to a `void` return type in Java/C++: */ def foreachFunctionTraversables(res0: List[Int]) = { val list = List(4, 6, 7, 8, 9, 13, 14) @@ -112,7 +121,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de list should be(res0) } - /** `toArray` will convert any `Traversable` to an `Array`, which is a special wrapper around a primitive Java array: + /** + * `toArray` will convert any `Traversable` to an `Array`, which is a special wrapper around a primitive Java array: */ def toArrayFunctionTraversables(res0: Boolean) = { val set = Set(4, 6, 7, 8, 9, 13, 14) @@ -120,7 +130,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result.isInstanceOf[Array[Int]] should be(res0) } - /** `toList` will convert any `Traversable` to a `List`. + /** + * `toList` will convert any `Traversable` to a `List`. */ def toListFunctionTraversables(res0: Boolean) = { val set = Set(4, 6, 7, 8, 9, 13, 14) @@ -129,7 +140,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result.isInstanceOf[List[_]] should be(res0) } - /** `toList`, as well as other conversion methods such as `toSet` and `toArray`, will not convert if the collection type is the same: + /** + * `toList`, as well as other conversion methods such as `toSet` and `toArray`, will not convert if the collection type is the same: */ def toListFunctionIITraversables(res0: Boolean) = { val list = List(5, 6, 7, 8, 9) @@ -137,7 +149,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result eq list should be(res0) } - /** `toIterable` will convert any `Traversable` to an `Iterable`. This is a base `trait` for all Scala collections that define an iterator method to iterate through the collection's elements: + /** + * `toIterable` will convert any `Traversable` to an `Iterable`. This is a base `trait` for all Scala collections that define an iterator method to iterate through the collection's elements: */ def toIterableFunctionTraversables(res0: Boolean) = { val set = Set(4, 6, 7, 8, 9, 13, 14) @@ -145,7 +158,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result.isInstanceOf[Iterable[_]] should be(res0) } - /** `toSeq` will convert any `Traversable` to a `Seq` which is an ordered `Iterable` and the superclass to `List`, `Queue`, and `Vector`. `Sequences` provide a method apply for indexing. Indices range from 0 up to the length of a sequence: + /** + * `toSeq` will convert any `Traversable` to a `Seq` which is an ordered `Iterable` and the superclass to `List`, `Queue`, and `Vector`. `Sequences` provide a method apply for indexing. Indices range from 0 up to the length of a sequence: */ def toSeqFunctionTraversables(res0: Boolean) = { val set = Set(4, 6, 7, 8, 9, 13, 14) @@ -153,7 +167,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result.isInstanceOf[Seq[_]] should be(res0) } - /** `toIndexedSeq` will convert any `Traversable` to an `IndexedSeq` which is an indexed sequence used in `Vectors` and `Strings`: + /** + * `toIndexedSeq` will convert any `Traversable` to an `IndexedSeq` which is an indexed sequence used in `Vectors` and `Strings`: */ def toIndexedSeqFunctionTraversables(res0: Boolean) = { val set = Set(4, 6, 7, 8, 9, 13, 14) @@ -161,7 +176,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result.isInstanceOf[IndexedSeq[_]] should be(res0) } - /** `toStream` will convert any `Traversable` to a `LazyList` where elements are evaluated as they are needed: + /** + * `toStream` will convert any `Traversable` to a `LazyList` where elements are evaluated as they are needed: */ def toLazyListFunctionTraversables(res0: Boolean, res1: LazyList[Int]) = { val list = List(4, 6, 7, 8, 9, 13, 14) @@ -170,7 +186,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de (result take 3) should be(res1) } - /** `toSet` will convert any `Traversable` to a `Set` which is a collection of unordered, unique values: + /** + * `toSet` will convert any `Traversable` to a `Set` which is a collection of unordered, unique values: */ def toSetFunctionTraversables(res0: Boolean) = { val list = List(4, 6, 7, 8, 9, 13, 14) @@ -178,7 +195,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result.isInstanceOf[Set[_]] should be(res0) } - /** `toMap` will convert any `Traversable` to a `Map`. How it's used depends on the original collection; if it's a `List` or `Seq`, it should be of parameterized type `Tuple2`: + /** + * `toMap` will convert any `Traversable` to a `Map`. How it's used depends on the original collection; if it's a `List` or `Seq`, it should be of parameterized type `Tuple2`: */ def toMapFunctionTraversables(res0: Boolean) = { val list = List("Phoenix" -> "Arizona", "Austin" -> "Texas") @@ -186,7 +204,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result.isInstanceOf[Map[_, _]] should be(res0) } - /** `toMap` will also convert a `Set` to a `Map`; it should be of parameterized type `Tuple2`: + /** + * `toMap` will also convert a `Set` to a `Map`; it should be of parameterized type `Tuple2`: */ def toMapFunctionIITraversables(res0: Boolean) = { val set = Set("Phoenix" -> "Arizona", "Austin" -> "Texas") @@ -194,7 +213,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result.isInstanceOf[Map[_, _]] should be(res0) } - /** `isEmpty` is pretty self-evident: + /** + * `isEmpty` is pretty self-evident: */ def isEmptyFunctionTraversables(res0: Boolean, res1: Boolean) = { val map = Map("Phoenix" -> "Arizona", "Austin" -> "Texas") @@ -204,7 +224,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de set.isEmpty should be(res1) } - /** `nonEmpty` is pretty self-evident too: + /** + * `nonEmpty` is pretty self-evident too: */ def nonEmptyFunctionTraversables(res0: Boolean, res1: Boolean) = { val map = Map("Phoenix" -> "Arizona", "Austin" -> "Texas") @@ -214,14 +235,16 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de set.nonEmpty should be(res1) } - /** `size` provides the size of the traversable: + /** + * `size` provides the size of the traversable: */ def sizeFunctionTraversables(res0: Int) = { val map = Map("Phoenix" -> "Arizona", "Austin" -> "Texas") map.size should be(res0) } - /** `knownSize` will return the number of elements if the traversable has a finite end, otherwise `-1`: + /** + * `knownSize` will return the number of elements if the traversable has a finite end, otherwise `-1`: */ def knownSizeFunctionTraversables(res0: Int, res1: Int) = { val map = Map("Phoenix" -> "Arizona", "Austin" -> "Texas") @@ -231,14 +254,16 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de stream.knownSize should be(res1) } - /** `head` will return the first element of an ordered collection, or some random element if order is not defined like in a `Set` or `Map`: + /** + * `head` will return the first element of an ordered collection, or some random element if order is not defined like in a `Set` or `Map`: */ def headFunctionTraversables(res0: Int) = { val list = List(10, 19, 45, 1, 22) list.head should be(res0) } - /** `headOption` will return the first element as an `Option` of an ordered collection, or some random element if order is not defined. If a first element is not available, then `None` is returned: + /** + * `headOption` will return the first element as an `Option` of an ordered collection, or some random element if order is not defined. If a first element is not available, then `None` is returned: */ def headOptionFunctionTraversables(res0: Option[Int], res1: Option[Int]) = { val list = List(10, 19, 45, 1, 22) @@ -248,14 +273,16 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de list2.headOption should be(res1) } - /** `last` will return the last element of an ordered collection, or some random element if order is not defined: + /** + * `last` will return the last element of an ordered collection, or some random element if order is not defined: */ def lastFunctionTraversables(res0: Int) = { val list = List(10, 19, 45, 1, 22) list.last should be(res0) } - /** `lastOption` will return the last element as an `Option` of an ordered collection, or some random element if order is not defined. If a last element is not available, then `None` is returned: + /** + * `lastOption` will return the last element as an `Option` of an ordered collection, or some random element if order is not defined. If a last element is not available, then `None` is returned: */ def lastOptionFunctionTraversables(res0: Option[Int], res1: Option[Int]) = { val list = List(10, 19, 45, 1, 22) @@ -265,7 +292,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de list2.lastOption should be(res1) } - /** `find` will locate the first item that matches the predicate `p` as `Some`, or `None` if an element is not found: + /** + * `find` will locate the first item that matches the predicate `p` as `Some`, or `None` if an element is not found: */ def findFunctionTraversables(res0: Option[Int], res1: Option[Int]) = { val list = List(10, 19, 45, 1, 22) @@ -275,35 +303,40 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de list2.find(_ % 2 != 0) should be(res1) } - /** `tail` will return the rest of the collection without the head: + /** + * `tail` will return the rest of the collection without the head: */ def tailFunctionTraversables(res0: List[Int]) = { val list = List(10, 19, 45, 1, 22) list.tail should be(res0) } - /** `init` will return the rest of the collection without the last: + /** + * `init` will return the rest of the collection without the last: */ def initFunctionTraversables(res0: List[Int]) = { val list = List(10, 19, 45, 1, 22) list.init should be(res0) } - /** Given a `from` index, and a `to` index, `slice` will return the part of the collection including `from`, and excluding `to`: + /** + * Given a `from` index, and a `to` index, `slice` will return the part of the collection including `from`, and excluding `to`: */ def sliceFunctionTraversables(res0: List[Int]) = { val list = List(10, 19, 45, 1, 22) list.slice(1, 3) should be(res0) } - /** `take` will return the first number of elements given: + /** + * `take` will return the first number of elements given: */ def takeFunctionTraversables(res0: List[Int]) = { val list = List(10, 19, 45, 1, 22) list.take(3) should be(res0) } - /** `take` is used often with `LazyList`, since they are also `Traversable`: + /** + * `take` is used often with `LazyList`, since they are also `Traversable`: */ def takeFunctionIITraversables(res0: List[Int]) = { def makeLazyList(v: Int): LazyList[Int] = cons(v, makeLazyList(v + 1)) @@ -311,7 +344,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de (a take 3 toList) should be(res0) } - /** `drop` will take the rest of the `Traversable` except the number of elements given: + /** + * `drop` will take the rest of the `Traversable` except the number of elements given: */ def dropFunctionTraversables(res0: List[Int]) = { def makeLazyList(v: Int): LazyList[Int] = cons(v, makeLazyList(v + 1)) @@ -319,35 +353,40 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de ((a drop 6) take 3).toList should be(res0) } - /** `takeWhile` will continually accumulate elements until a predicate is no longer satisfied: + /** + * `takeWhile` will continually accumulate elements until a predicate is no longer satisfied: */ def takeWhileFunctionTraversables(res0: List[Int]) = { val list = List(87, 44, 5, 4, 200, 10, 39, 100) list.takeWhile(_ < 100) should be(res0) } - /** `dropWhile` will continually drop elements until a predicate is no longer satisfied: + /** + * `dropWhile` will continually drop elements until a predicate is no longer satisfied: */ def dropWhileFunctionTraversables(res0: List[Int]) = { val list = List(87, 44, 5, 4, 200, 10, 39, 100) list.dropWhile(_ < 100) should be(res0) } - /** `filter` will take out all elements that don't satisfy a predicate. (An `Array` is also `Traversable`.) + /** + * `filter` will take out all elements that don't satisfy a predicate. (An `Array` is also `Traversable`.) */ def filterFunctionTraversables(res0: Array[Int]) = { val array = Array(87, 44, 5, 4, 200, 10, 39, 100) array.filter(_ < 100) should be(res0) } - /** `filterNot` will take out all elements that satisfy a predicate: + /** + * `filterNot` will take out all elements that satisfy a predicate: */ def filterNotFunctionTraversables(res0: Array[Int]) = { val array = Array(87, 44, 5, 4, 200, 10, 39, 100) array.filterNot(_ < 100) should be(res0) } - /** `splitAt` will split a `Traversable` at a position, returning a 2 product `Tuple`. `splitAt` is also defined as `(xs take n, xs drop n)` + /** + * `splitAt` will split a `Traversable` at a position, returning a 2 product `Tuple`. `splitAt` is also defined as `(xs take n, xs drop n)` */ def splitAtFunctionTraversables(res0: Array[Int], res1: Array[Int]) = { val array = Array(87, 44, 5, 4, 200, 10, 39, 100) @@ -356,7 +395,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result._2 should be(res1) } - /** `span` will split a `Traversable` according to a predicate, returning a 2 product `Tuple`. `span` is also defined as `(xs takeWhile p, xs dropWhile p)` + /** + * `span` will split a `Traversable` according to a predicate, returning a 2 product `Tuple`. `span` is also defined as `(xs takeWhile p, xs dropWhile p)` */ def spanFunctionTraversables(res0: Array[Int], res1: Array[Int]) = { val array = Array(87, 44, 5, 4, 200, 10, 39, 100) @@ -365,7 +405,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result._2 should be(res1) } - /** `partition` will split a `Traversable` according to a predicate, returning a 2 product `Tuple`. The left-hand side contains the elements satisfied by the predicate whereas the right hand side contains the rest of the elements. `partition` is also defined as `(xs filter p, xs filterNot p)` + /** + * `partition` will split a `Traversable` according to a predicate, returning a 2 product `Tuple`. The left-hand side contains the elements satisfied by the predicate whereas the right hand side contains the rest of the elements. `partition` is also defined as `(xs filter p, xs filterNot p)` */ def partitionFunctionTraversables(res0: Array[Int], res1: Array[Int]) = { val array = Array(87, 44, 5, 4, 200, 10, 39, 100) @@ -374,7 +415,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result._2 should be(res1) } - /** `groupBy` will categorize a `Traversable` according to a given function and return a map with the results. This exercise uses partial function chaining: + /** + * `groupBy` will categorize a `Traversable` according to a given function and return a map with the results. This exercise uses partial function chaining: */ def groupByFunctionTraversables(res0: Int, res1: Int) = { val array = Array(87, 44, 5, 4, 200, 10, 39, 100) @@ -411,7 +453,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de (result("Large Number") size) should be(res1) } - /** `forall` will determine if a predicate is valid for all members of a `Traversable`: + /** + * `forall` will determine if a predicate is valid for all members of a `Traversable`: */ def forallFunctionTraversables(res0: Boolean) = { val list = List(87, 44, 5, 4, 200, 10, 39, 100) @@ -419,7 +462,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result should be(res0) } - /** `exists` will determine if a predicate is valid for some members of a `Traversable`: + /** + * `exists` will determine if a predicate is valid for some members of a `Traversable`: */ def existsFunctionTraversables(res0: Boolean) = { val list = List(87, 44, 5, 4, 200, 10, 39, 100) @@ -427,7 +471,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result should be(res0) } - /** `count` will count the number of elements that satisfy a predicate in a `Traversable`: + /** + * `count` will count the number of elements that satisfy a predicate in a `Traversable`: */ def countFunctionTraversables(res0: Int) = { val list = List(87, 44, 5, 4, 200, 10, 39, 100) @@ -435,7 +480,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de result should be(res0) } - /** `foldLeft` will combine an operation starting with a seed and combining from the left. `foldLeft` takes as a first parameter the initial value of the fold. Once the fold is established, you provide a function that takes two arguments. The first argument is the running total of the operation, and the second element is the next element of the list. + /** + * `foldLeft` will combine an operation starting with a seed and combining from the left. `foldLeft` takes as a first parameter the initial value of the fold. Once the fold is established, you provide a function that takes two arguments. The first argument is the running total of the operation, and the second element is the next element of the list. * * Given a `Traversable (x1, x2, x3, x4)`, an initial value of `init`, an operation `op`, `foldLeft` is defined as: `(((init op x1) op x2) op x3) op x4)` */ @@ -452,7 +498,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de (((((0 - 5) - 4) - 3) - 2) - 1) should be(res2) } - /** `foldRight` will combine an operation starting with a seed and combining from the right. `foldRight` takes as a first parameter the initial value of the fold. Once the fold is established, you provide a function that takes two elements. The first is the next element of the list, and the second element is the running total of the operation. + /** + * `foldRight` will combine an operation starting with a seed and combining from the right. `foldRight` takes as a first parameter the initial value of the fold. Once the fold is established, you provide a function that takes two elements. The first is the next element of the list, and the second element is the running total of the operation. * * Given a `Traversable (x1, x2, x3, x4)`, an initial value of `init`, an operation `op`, `foldRight` is defined as: `x1 op (x2 op (x3 op (x4 op init)))` */ @@ -469,7 +516,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de (5 - (4 - (3 - (2 - (1 - 0))))) should be(res2) } - /** `reduceLeft` is similar to `foldLeft`, except that the seed is the head value: + /** + * `reduceLeft` is similar to `foldLeft`, except that the seed is the head value: */ def reduceLeftFunctionTraversables(res0: Int, res1: String) = { val intList = List(5, 4, 3, 2, 1) @@ -483,7 +531,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de } should be(res1) } - /** `reduceRight` is similar to `foldRight`, except that the seed is the last value: + /** + * `reduceRight` is similar to `foldRight`, except that the seed is the last value: */ def reduceRightFunctionTraversables(res0: Int, res1: String) = { val intList = List(5, 4, 3, 2, 1) @@ -497,7 +546,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de } should be(res1) } - /** There are some methods that take much of the folding work out by providing basic functionality. `sum` will add all the elements, `product` will multiply, `min` would determine the smallest element, and `max` the largest: + /** + * There are some methods that take much of the folding work out by providing basic functionality. `sum` will add all the elements, `product` will multiply, `min` would determine the smallest element, and `max` the largest: */ def sumFunctionTraversables(res0: Int, res1: Int, res2: Int, res3: Int) = { val intList = List(5, 4, 3, 2, 1) @@ -507,7 +557,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de intList.min should be(res3) } - /** The naive recursive implementation of `reduceRight` is not tail recursive and would lead to a stack overflow if used on larger traversables. + /** + * The naive recursive implementation of `reduceRight` is not tail recursive and would lead to a stack overflow if used on larger traversables. * However, `reduceLeft` can be implemented with tail recursion. * * To avoid the potential stack overflow with the naive implementation of `reduceRight` we can easily implement it based on `reduceLeft` by reversing the list and the inverting the reduce function. @@ -522,7 +573,8 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de intList.reverse.reduce((x, y) => y - x) should be(res2) } - /** `transpose` will take a traversable of traversables and group them by their position in it's own traversable, e.g.: + /** + * `transpose` will take a traversable of traversables and group them by their position in it's own traversable, e.g.: * `((x1, x2),(y1, y2)).transpose = (x1, y1), (x2, y2)` or * `((x1, x2, x3),(y1, y2, y3),(z1, z2, z3)).transpose = ((x1, y1, z1), (x2, y2, z2), (x3, y3, z3))` */ @@ -539,21 +591,24 @@ object Traversables extends AnyFlatSpec with Matchers with org.scalaexercises.de list2.transpose should be(List(res3)) } - /** `mkString` will format a `Traversable` using a given string as the delimiter: + /** + * `mkString` will format a `Traversable` using a given string as the delimiter: */ def mkStringFunctionTraversables(res0: String) = { val list = List(1, 2, 3, 4, 5) list.mkString(",") should be(res0) } - /** `mkString` will also take a beginning and ending string to surround the list.: + /** + * `mkString` will also take a beginning and ending string to surround the list.: */ def mkStringFunctionIITraversables(res0: String) = { val list = List(1, 2, 3, 4, 5) list.mkString(">", ",", "<") should be(res0) } - /** `addString` will take a StringBuilder to add the contents of list into the builder. + /** + * `addString` will take a StringBuilder to add the contents of list into the builder. */ def addStringFunctionTraversables(res0: String) = { val stringBuilder = new StringBuilder() diff --git a/src/main/scala/stdlib/Tuples.scala b/src/main/scala/stdlib/Tuples.scala index 648581d2..75a8bc49 100644 --- a/src/main/scala/stdlib/Tuples.scala +++ b/src/main/scala/stdlib/Tuples.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,12 +21,13 @@ import java.util.Date import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name tuples - * +/** + * @param name tuples */ object Tuples extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** Scala tuple combines a fixed number of items together so that they can be passed around as a whole. They are one-indexed. Unlike an array or list, a tuple can hold objects with different types but they are also immutable. Here is an example of a tuple holding an integer, a string, and the console: + /** + * Scala tuple combines a fixed number of items together so that they can be passed around as a whole. They are one-indexed. Unlike an array or list, a tuple can hold objects with different types but they are also immutable. Here is an example of a tuple holding an integer, a string, and the console: * * {{{ * val t = (1, "hello", Console) @@ -48,7 +49,8 @@ object Tuples extends AnyFlatSpec with Matchers with org.scalaexercises.definiti animal should be(res1) } - /** Tuples may be of mixed type: + /** + * Tuples may be of mixed type: */ def mixedTypeTuples(res0: Int, res1: String) = { val tuple5 = ("a", 1, 2.2, new Date(), "five") @@ -57,7 +59,8 @@ object Tuples extends AnyFlatSpec with Matchers with org.scalaexercises.definiti tuple5._5 should be(res1) } - /** You can assign multiple variables at once using tuples: + /** + * You can assign multiple variables at once using tuples: */ def assignVariablesTuples(res0: String, res1: Int, res2: Double) = { val student = ("Sean Rogers", 21, 3.5) @@ -68,7 +71,8 @@ object Tuples extends AnyFlatSpec with Matchers with org.scalaexercises.definiti gpa should be(res2) } - /** The `swap` method can be used to swap the elements of a Tuple2: + /** + * The `swap` method can be used to swap the elements of a Tuple2: */ def swappedTuples(res0: Int, res1: String) = { val tuple = ("apple", 3).swap diff --git a/src/main/scala/stdlib/TypeSignatures.scala b/src/main/scala/stdlib/TypeSignatures.scala index 3cd50468..0cb8947a 100644 --- a/src/main/scala/stdlib/TypeSignatures.scala +++ b/src/main/scala/stdlib/TypeSignatures.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,16 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name type_signatures +/** + * @param name type_signatures */ object TypeSignatures extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** A method's type signature comprises its name; the number, order, and types of its parameters, if any; and its result type. The type signature of a class, trait, or singleton object comprises its name, the type signatures of all of its members and constructors, and its declared inheritance and mixin relations. + /** + * A method's type signature comprises its name; the number, order, and types of its parameters, if any; and its result type. The type signature of a class, trait, or singleton object comprises its name, the type signatures of all of its members and constructors, and its declared inheritance and mixin relations. * * In Java you declare a generic type within a `<>`, in Scala `[]` is used: * @@ -41,7 +43,6 @@ object TypeSignatures * }}} * * A trait can be declared containing a type, where a concrete implementer will satisfy the type: - * */ def typeSignatureTypeSignatures(res0: Boolean) = { trait Randomizer[A] { @@ -59,14 +60,16 @@ object TypeSignatures (intRand.draw <= Int.MaxValue) should be(res0) } - /** Class meta-information can be retrieved by class name by using `classOf[className]`: + /** + * Class meta-information can be retrieved by class name by using `classOf[className]`: */ def retrieveMetaInformationTypeSignatures(res0: String, res1: String) = { classOf[String].getCanonicalName should be(res0) classOf[String].getSimpleName should be(res1) } - /** Class meta-information can be derived from an object reference using `getClass()`: + /** + * Class meta-information can be derived from an object reference using `getClass()`: */ def deriveMetaInformationTypeSignatures(res0: Boolean, res1: String, res2: String) = { val zoom = "zoom" @@ -75,7 +78,8 @@ object TypeSignatures zoom.getClass.getSimpleName should be(res2) } - /** `isInstanceOf[className]` is used to determine if an object reference is an instance of a given class: + /** + * `isInstanceOf[className]` is used to determine if an object reference is an instance of a given class: */ def isInstanceOfFunctionTypeSignatures(res0: Boolean, res1: Boolean, res2: Boolean) = { trait Randomizer[A] { diff --git a/src/main/scala/stdlib/TypeVariance.scala b/src/main/scala/stdlib/TypeVariance.scala index 5bb304bf..c9aeda2c 100644 --- a/src/main/scala/stdlib/TypeVariance.scala +++ b/src/main/scala/stdlib/TypeVariance.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,11 +20,13 @@ import TypeVarianceHelper._ import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name type_variance +/** + * @param name type_variance */ object TypeVariance extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** A traditional objection to static typing is that it has much syntactic overhead. Scala alleviates this by providing type inference. + /** + * A traditional objection to static typing is that it has much syntactic overhead. Scala alleviates this by providing type inference. * * The classic method for type inference in functional programming languages is Hindley-Milner, and it was first employed in ML. * @@ -41,7 +43,8 @@ object TypeVariance extends AnyFlatSpec with Matchers with org.scalaexercises.de fruitBasket.contents should be(res0) } - /** You can explicitly declare the type variable of the object during instantiation: + /** + * You can explicitly declare the type variable of the object during instantiation: */ def typeVariableTypeVariance(res0: String) = { class MyContainer[A](val a: A)(implicit manifest: scala.reflect.Manifest[A]) { @@ -52,7 +55,8 @@ object TypeVariance extends AnyFlatSpec with Matchers with org.scalaexercises.de fruitBasket.contents should be(res0) } - /** You can coerce your object to a type: + /** + * You can coerce your object to a type: */ def coerceObjectTypeVariance(res0: String) = { class MyContainer[A](val a: A)(implicit manifest: scala.reflect.Manifest[A]) { @@ -63,7 +67,8 @@ object TypeVariance extends AnyFlatSpec with Matchers with org.scalaexercises.de fruitBasket.contents should be(res0) } - /** Scala's type system has to account for class hierarchies together with polymorphism. Class hierarchies allow the expression of subtype relationships. A central question that comes up when mixing OO with polymorphism is: if `T'` is a subclass of `T`, is `Container[T']` considered a subclass of `Container[T]`? Variance annotations allow you to express the following relationships between class hierarchies & polymorphic types: + /** + * Scala's type system has to account for class hierarchies together with polymorphism. Class hierarchies allow the expression of subtype relationships. A central question that comes up when mixing OO with polymorphism is: if `T'` is a subclass of `T`, is `Container[T']` considered a subclass of `Container[T]`? Variance annotations allow you to express the following relationships between class hierarchies & polymorphic types: * * ==Covariant== * - `C[T']` is a subclass of `C[T]` @@ -77,7 +82,6 @@ object TypeVariance extends AnyFlatSpec with Matchers with org.scalaexercises.de * - `C[T]` and `C[T']` are not related * - Scala notation: `[T]` * - * * That one probably blew your mind. Now if you assign a type to the instantiation that is different to the variable type, you'll have problems. You may want to take time after this koan to compare and contrast with the previous one. * * {{{ @@ -100,7 +104,8 @@ object TypeVariance extends AnyFlatSpec with Matchers with org.scalaexercises.de fruitBasket.contents should be(res0) } - /** The problem with covariance is that you can't mutate, set or change the object since it has to guarantee that what you put into it is a valid type. In other words the reference is a fruit basket, but we still have to make sure that no other fruit can be placed in our orange basket: + /** + * The problem with covariance is that you can't mutate, set or change the object since it has to guarantee that what you put into it is a valid type. In other words the reference is a fruit basket, but we still have to make sure that no other fruit can be placed in our orange basket: */ def covarianceInmutableTypeVariance(res0: String) = { class MyContainer[+A](val a: A)(implicit manifest: scala.reflect.Manifest[A]) { @@ -115,7 +120,8 @@ object TypeVariance extends AnyFlatSpec with Matchers with org.scalaexercises.de //val tangeloBasket: MyContainer[Tangelo] = new MyContainer[Orange](new Orange()) //Bad! } - /** Declaring `-` indicates contravariance variance. Using `-` you can apply any container with a certain type to a container with a superclass of that type. This is reverse to covariant. In our example, we can set a citrus basket to an orange or tangelo basket. Since an orange or tangelo basket are a citrus basket. Contravariance is the opposite of covariance: + /** + * Declaring `-` indicates contravariance variance. Using `-` you can apply any container with a certain type to a container with a superclass of that type. This is reverse to covariant. In our example, we can set a citrus basket to an orange or tangelo basket. Since an orange or tangelo basket are a citrus basket. Contravariance is the opposite of covariance: */ def contravarianceVarianceTypeVariance(res0: String, res1: String, res2: String, res3: String) = { class MyContainer[-A](a: A)(implicit manifest: scala.reflect.Manifest[A]) { //Can't receive a val because it would be in a covariant position @@ -137,7 +143,8 @@ object TypeVariance extends AnyFlatSpec with Matchers with org.scalaexercises.de //val wrongCitrusBasket: MyContainer[Citrus] = new MyContainer[Orange](new Orange) //Bad! } - /** Declaring neither `-` nor `+` indicates invariance. You cannot use a superclass variable reference (contravariant position) or a subclass variable reference (covariant position) of that type. In our example, this means that if you create a citrus basket you can only reference that citrus basket with a citrus variable only. + /** + * Declaring neither `-` nor `+` indicates invariance. You cannot use a superclass variable reference (contravariant position) or a subclass variable reference (covariant position) of that type. In our example, this means that if you create a citrus basket you can only reference that citrus basket with a citrus variable only. * * Invariance means you need to specify the type exactly: */ diff --git a/src/main/scala/stdlib/TypeVarianceHelper.scala b/src/main/scala/stdlib/TypeVarianceHelper.scala index d74ed7ef..a59fe155 100644 --- a/src/main/scala/stdlib/TypeVarianceHelper.scala +++ b/src/main/scala/stdlib/TypeVarianceHelper.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/main/scala/stdlib/UniformAccessPrinciple.scala b/src/main/scala/stdlib/UniformAccessPrinciple.scala index 0bb3afc4..f5bfec93 100644 --- a/src/main/scala/stdlib/UniformAccessPrinciple.scala +++ b/src/main/scala/stdlib/UniformAccessPrinciple.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,18 +19,18 @@ package stdlib import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers -/** @param name uniform_access_principle - * +/** + * @param name uniform_access_principle */ object UniformAccessPrinciple extends AnyFlatSpec with Matchers with org.scalaexercises.definitions.Section { - /** The Scala language implements a programming concept known as the [[http://en.wikipedia.org/wiki/Uniform_access_principle Uniform Access Principle]], which was first put forth by Bertrand Meyer, the inventor of the Eiffel programming language. + /** + * The Scala language implements a programming concept known as the [[http://en.wikipedia.org/wiki/Uniform_access_principle Uniform Access Principle]], which was first put forth by Bertrand Meyer, the inventor of the Eiffel programming language. * * This principle states that variables and parameterless functions should be accessed using the same syntax. Scala supports this principle by allowing parentheses to not be placed at call sites of parameterless functions. As a result, a parameterless function definition can be changed to a `val`, or vice versa, without affecting client code: - * */ def uniformAccessPrincipleUniformAccessPrinciple(res0: Int, res1: Int) = { class Test1(val age: Int = 10) diff --git a/src/test/scala/stdlib/AssertsSpec.scala b/src/test/scala/stdlib/AssertsSpec.scala index 8f2d83be..3ca410d0 100644 --- a/src/test/scala/stdlib/AssertsSpec.scala +++ b/src/test/scala/stdlib/AssertsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/ByNameParameterSpec.scala b/src/test/scala/stdlib/ByNameParameterSpec.scala index 81dcdac7..a8d2fa5d 100644 --- a/src/test/scala/stdlib/ByNameParameterSpec.scala +++ b/src/test/scala/stdlib/ByNameParameterSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/CaseClassesSpec.scala b/src/test/scala/stdlib/CaseClassesSpec.scala index 4840e567..a30b4091 100644 --- a/src/test/scala/stdlib/CaseClassesSpec.scala +++ b/src/test/scala/stdlib/CaseClassesSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/ClassesSpec.scala b/src/test/scala/stdlib/ClassesSpec.scala index adb68cdf..022630a0 100644 --- a/src/test/scala/stdlib/ClassesSpec.scala +++ b/src/test/scala/stdlib/ClassesSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/EmptyValuesSpec.scala b/src/test/scala/stdlib/EmptyValuesSpec.scala index 29baf008..fe966758 100644 --- a/src/test/scala/stdlib/EmptyValuesSpec.scala +++ b/src/test/scala/stdlib/EmptyValuesSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/ExtractorsSpec.scala b/src/test/scala/stdlib/ExtractorsSpec.scala index 9dbce96e..c69978b3 100644 --- a/src/test/scala/stdlib/ExtractorsSpec.scala +++ b/src/test/scala/stdlib/ExtractorsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/ForExpressionsSpec.scala b/src/test/scala/stdlib/ForExpressionsSpec.scala index a11c7fcb..15931e3b 100644 --- a/src/test/scala/stdlib/ForExpressionsSpec.scala +++ b/src/test/scala/stdlib/ForExpressionsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/FormattingSpec.scala b/src/test/scala/stdlib/FormattingSpec.scala index 58fe9b82..a3e496f4 100644 --- a/src/test/scala/stdlib/FormattingSpec.scala +++ b/src/test/scala/stdlib/FormattingSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/HigherOrderFunctionsSpec.scala b/src/test/scala/stdlib/HigherOrderFunctionsSpec.scala index 823871d3..3051bbce 100644 --- a/src/test/scala/stdlib/HigherOrderFunctionsSpec.scala +++ b/src/test/scala/stdlib/HigherOrderFunctionsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/ImplicitsSpec.scala b/src/test/scala/stdlib/ImplicitsSpec.scala index a6695d44..eccc69a0 100644 --- a/src/test/scala/stdlib/ImplicitsSpec.scala +++ b/src/test/scala/stdlib/ImplicitsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/InfixPrefixAndPostfixOperatorsSpec.scala b/src/test/scala/stdlib/InfixPrefixAndPostfixOperatorsSpec.scala index 3c604118..3e71e292 100644 --- a/src/test/scala/stdlib/InfixPrefixAndPostfixOperatorsSpec.scala +++ b/src/test/scala/stdlib/InfixPrefixAndPostfixOperatorsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/InfixTypesSpec.scala b/src/test/scala/stdlib/InfixTypesSpec.scala index 211401e0..61cef462 100644 --- a/src/test/scala/stdlib/InfixTypesSpec.scala +++ b/src/test/scala/stdlib/InfixTypesSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/IterablesSpec.scala b/src/test/scala/stdlib/IterablesSpec.scala index 89ce0332..4dcdbcc6 100644 --- a/src/test/scala/stdlib/IterablesSpec.scala +++ b/src/test/scala/stdlib/IterablesSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/ListsSpec.scala b/src/test/scala/stdlib/ListsSpec.scala index 66e5456c..1d490522 100644 --- a/src/test/scala/stdlib/ListsSpec.scala +++ b/src/test/scala/stdlib/ListsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/LiteralBooleansSpec.scala b/src/test/scala/stdlib/LiteralBooleansSpec.scala index c1d659b7..ad8d5184 100644 --- a/src/test/scala/stdlib/LiteralBooleansSpec.scala +++ b/src/test/scala/stdlib/LiteralBooleansSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/LiteralNumbersSpec.scala b/src/test/scala/stdlib/LiteralNumbersSpec.scala index b8be5369..80a91476 100644 --- a/src/test/scala/stdlib/LiteralNumbersSpec.scala +++ b/src/test/scala/stdlib/LiteralNumbersSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/LiteralStringsSpec.scala b/src/test/scala/stdlib/LiteralStringsSpec.scala index b58078c3..d62e7350 100644 --- a/src/test/scala/stdlib/LiteralStringsSpec.scala +++ b/src/test/scala/stdlib/LiteralStringsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/MapsSpec.scala b/src/test/scala/stdlib/MapsSpec.scala index 54e920d1..11d5ec9d 100644 --- a/src/test/scala/stdlib/MapsSpec.scala +++ b/src/test/scala/stdlib/MapsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/NamedAndDefaultArgumentsSpec.scala b/src/test/scala/stdlib/NamedAndDefaultArgumentsSpec.scala index 0cf7d422..4149f67a 100644 --- a/src/test/scala/stdlib/NamedAndDefaultArgumentsSpec.scala +++ b/src/test/scala/stdlib/NamedAndDefaultArgumentsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/ObjectsSpec.scala b/src/test/scala/stdlib/ObjectsSpec.scala index 4e42140c..14142c4e 100644 --- a/src/test/scala/stdlib/ObjectsSpec.scala +++ b/src/test/scala/stdlib/ObjectsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/OptionsSpec.scala b/src/test/scala/stdlib/OptionsSpec.scala index 378460ca..46df97c4 100644 --- a/src/test/scala/stdlib/OptionsSpec.scala +++ b/src/test/scala/stdlib/OptionsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/ParentClassesSpec.scala b/src/test/scala/stdlib/ParentClassesSpec.scala index 23c3f466..faf8cfcb 100644 --- a/src/test/scala/stdlib/ParentClassesSpec.scala +++ b/src/test/scala/stdlib/ParentClassesSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/PartialFunctionsSpec.scala b/src/test/scala/stdlib/PartialFunctionsSpec.scala index afc198ee..f76228b9 100644 --- a/src/test/scala/stdlib/PartialFunctionsSpec.scala +++ b/src/test/scala/stdlib/PartialFunctionsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/PartiallyAppliedFunctionsSpec.scala b/src/test/scala/stdlib/PartiallyAppliedFunctionsSpec.scala index 4e73afbb..8bd9ac49 100644 --- a/src/test/scala/stdlib/PartiallyAppliedFunctionsSpec.scala +++ b/src/test/scala/stdlib/PartiallyAppliedFunctionsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/PatternMatchingSpec.scala b/src/test/scala/stdlib/PatternMatchingSpec.scala index b449d115..49137594 100644 --- a/src/test/scala/stdlib/PatternMatchingSpec.scala +++ b/src/test/scala/stdlib/PatternMatchingSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/RangesSpec.scala b/src/test/scala/stdlib/RangesSpec.scala index ef5111de..fb46d0a4 100644 --- a/src/test/scala/stdlib/RangesSpec.scala +++ b/src/test/scala/stdlib/RangesSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/RepeatedParametersSpec.scala b/src/test/scala/stdlib/RepeatedParametersSpec.scala index 86d197e4..9012ea29 100644 --- a/src/test/scala/stdlib/RepeatedParametersSpec.scala +++ b/src/test/scala/stdlib/RepeatedParametersSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/SequencesAndArraysSpec.scala b/src/test/scala/stdlib/SequencesAndArraysSpec.scala index bb10c5a9..a0822f6e 100644 --- a/src/test/scala/stdlib/SequencesAndArraysSpec.scala +++ b/src/test/scala/stdlib/SequencesAndArraysSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/SetsSpec.scala b/src/test/scala/stdlib/SetsSpec.scala index 3091a9ae..61f7c352 100644 --- a/src/test/scala/stdlib/SetsSpec.scala +++ b/src/test/scala/stdlib/SetsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/TraitsSpec.scala b/src/test/scala/stdlib/TraitsSpec.scala index 1716a8d0..c2b37529 100644 --- a/src/test/scala/stdlib/TraitsSpec.scala +++ b/src/test/scala/stdlib/TraitsSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/TraversablesSpec.scala b/src/test/scala/stdlib/TraversablesSpec.scala index b92ecced..c906bbb5 100644 --- a/src/test/scala/stdlib/TraversablesSpec.scala +++ b/src/test/scala/stdlib/TraversablesSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/TuplesSpec.scala b/src/test/scala/stdlib/TuplesSpec.scala index c622b5ab..04cea176 100644 --- a/src/test/scala/stdlib/TuplesSpec.scala +++ b/src/test/scala/stdlib/TuplesSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/TypeSignaturesSpec.scala b/src/test/scala/stdlib/TypeSignaturesSpec.scala index 65977a07..e285ead3 100644 --- a/src/test/scala/stdlib/TypeSignaturesSpec.scala +++ b/src/test/scala/stdlib/TypeSignaturesSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/TypeVarianceSpec.scala b/src/test/scala/stdlib/TypeVarianceSpec.scala index ec94c8da..d2a85b29 100644 --- a/src/test/scala/stdlib/TypeVarianceSpec.scala +++ b/src/test/scala/stdlib/TypeVarianceSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/test/scala/stdlib/UniformAccessPrincipleSpec.scala b/src/test/scala/stdlib/UniformAccessPrincipleSpec.scala index 21f436dd..a095b52d 100644 --- a/src/test/scala/stdlib/UniformAccessPrincipleSpec.scala +++ b/src/test/scala/stdlib/UniformAccessPrincipleSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 47 Degrees + * Copyright 2016-2020 47 Degrees Open Source * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.