Skip to content

Commit

Permalink
Bump Scala to version 2.13 and scalatest to version 3.2.10 (#712)
Browse files Browse the repository at this point in the history
* Update version of sbt and scala for testgen

- This is from `2.12` -> `2.13`
- Adds `import scala.language.postfixOps` where needed
- Changes test generation for new version of `scalatest`

* Update scala version to 2.13.6

- This is a change in each `exercise/**/build.sbt`

* Updates `scalatest` to `3.2.10`

* Fixes two issues in `build.sbt`

- adds missing newlines for `exercises/**/build.sbt`
- imports play-json correctly in `build.sbt`

* Updates exercises for `scalatest` version bump

- `scalatest` is no longer monolithic, specific things must be imported
- `FunSuite` renamed to `AnyFunSuite`
- `FlatSpec` renamed to `AnyFlatSpec`
- `Matchers` used throughout were moved and refactored, these tests use
  `org.scalatest.matchers.should.Matchers`

See the [ScalaTest 3.2.0 release
notes](https://www.scalatest.org/release_notes/3.2.0) for details on
what was deprecated.

* Updates `INSTALLATION.md`

- Added callout to use SDKMAN
- Updated JDK Requirement to be JDK 11
- Updated sbt and Scala requirements
  • Loading branch information
CJSmith-0141 authored Feb 11, 2022
1 parent 17905da commit 582a3f5
Show file tree
Hide file tree
Showing 204 changed files with 616 additions and 408 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ bin/configlet
bin/configlet.exe

.bsp/

# metals workflow junk, shouldn't be commited
.bloop/
.metals/

project/
!project/build.properties
!project/plugins.sbt
project/target
src/test/scala/project/
target
11 changes: 8 additions & 3 deletions docs/INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

In addition to the exercism CLI and your favorite text editor, practicing with Exercism exercises in Scala requires:

* Recent build of the Java 8 Platform, such as [OpenJDK](http://openjdk.java.net/install/) or [Oracle Java JDK](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
* [Download](http://www.scala-sbt.org/release/docs/Setup.html) and install the Simple Build Tool (`sbt`)
* Java Development Kit (JDK) 11 or later. Use your preferred vendor or grab one from [Adoptium](https://adoptium.net/)
* [Scala 2.13.x](https://www.scala-lang.org/download/scala2.html)
* [sbt 1.6.x](https://www.scala-sbt.org/download.html)

If you don't want install these various dependencies by hand, consider using [SDKMAN](https://sdkman.io/) to manage your java and java-adjacent development tools and libraries.

---

Expand All @@ -18,4 +21,6 @@ To get started, see "[Running the Tests](http://exercism.io/languages/scala/test

* [IntelliJ IDEA with Scala Plugin](https://www.jetbrains.com/idea/)
* [ScalaIDE](http://scala-ide.org/index.html)
* [NetBeans with Scala Plugin](https://netbeans.org/)
* [NetBeans with Scala Plugin](https://netbeans.org/)
* [Metals with VS Code](https://scalameta.org/metals/docs/editors/vscode)
* [Metals with Vim or Neovim](https://scalameta.org/metals/docs/editors/vim)
5 changes: 4 additions & 1 deletion exercises/concept/basics/src/test/scala/LasagnaTest.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers

/** @version 1.3.0 */
class LasagnaTest extends FunSuite with Matchers {
class LasagnaTest extends AnyFunSuite with Matchers {

test("expected minutes in oven") {
new Lasagna().expectedMinutesInOven() should be(40)
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/accumulate/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FlatSpec}
import org.scalatest.matchers.should.Matchers
import org.scalatest.flatspec.AnyFlatSpec


/** @version created manually **/
class AccumulateTest extends FlatSpec with Matchers {
class AccumulateTest extends AnyFlatSpec with Matchers {

it should "allow empty accumulation" in {
val accumulate = new Accumulate
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/acronym/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
6 changes: 4 additions & 2 deletions exercises/practice/acronym/src/test/scala/AcronymTest.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 1.6.0 */
class AcronymTest extends FunSuite with Matchers {
class AcronymTest extends AnyFunSuite with Matchers {

test("basic") {
Acronym.abbreviate("Portable Network Graphics") should be ("PNG")
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/all-your-base/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 2.3.0 */
class AllYourBaseTest extends FunSuite with Matchers {
class AllYourBaseTest extends AnyFunSuite with Matchers {

test("single bit one to decimal") {
AllYourBase.rebase(2, List(1), 10) should be(Some(List(1)))
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/allergies/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 1.2.0 */
class AllergiesTest extends FunSuite with Matchers {
class AllergiesTest extends AnyFunSuite with Matchers {

test("Allergen.Peanuts - no allergies means not allergic") {
Allergies.allergicTo(Allergen.Peanuts, 0) should be(false)
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/alphametics/build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.5"

Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 1.3.0 */
class AlphameticsTest extends FunSuite with Matchers {
class AlphameticsTest extends AnyFunSuite with Matchers {

test("puzzle with three letters") {
Alphametics.solve("I + BB == ILL") should be(
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/anagram/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"

6 changes: 4 additions & 2 deletions exercises/practice/anagram/src/test/scala/AnagramTest.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 1.4.0 */
class AnagramTest extends FunSuite with Matchers {
class AnagramTest extends AnyFunSuite with Matchers {

test("no matches") {
Anagram.findAnagrams("diaper", List("hello", "world", "zombies", "pants")) should be(
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/armstrong-numbers/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 1.0.0 */
class ArmstrongNumbersTest extends FunSuite with Matchers {
class ArmstrongNumbersTest extends AnyFunSuite with Matchers {

test("Single digit numbers are Armstrong numbers") {
ArmstrongNumbers.isArmstrongNumber(5) should be (true)
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/atbash-cipher/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 1.2.0 */
class AtbashCipherTest extends FunSuite with Matchers {
class AtbashCipherTest extends AnyFunSuite with Matchers {

test("encode yes") {
AtbashCipher.encode("yes") should be("bvh")
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/bank-account/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import org.scalatest.concurrent.{IntegrationPatience, Conductors}
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version created manually **/
class BankAccountTest extends FunSuite with Matchers with Conductors with IntegrationPatience {
class BankAccountTest extends AnyFunSuite with Matchers with Conductors with IntegrationPatience {
test("open account") {
Bank.openAccount().getBalance should be (Some(0))
}
Expand Down Expand Up @@ -33,15 +35,15 @@ class BankAccountTest extends FunSuite with Matchers with Conductors with Integr

val acct = Bank.openAccount()

thread("t1") {
threadNamed("t1") {
acct.incrementBalance(10)
acct.getBalance should be (Some(10))
beat should be (1)
waitForBeat(2)
acct.getBalance should be (Some(15))
}

thread("t2") {
threadNamed("t2") {
waitForBeat(1)
acct.getBalance should be (Some(10))
acct.incrementBalance(5)
Expand All @@ -57,12 +59,12 @@ class BankAccountTest extends FunSuite with Matchers with Conductors with Integr

val acct = Bank.openAccount()

thread("t1") {
threadNamed("t1") {
for (a <- 1 to 10)
acct.incrementBalance(10)
}

thread("t2") {
threadNamed("t2") {
for (a <- 1 to 10)
acct.incrementBalance(5)
}
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/beer-song/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name := "beer-song"
scalaVersion := "2.12.2"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 2.1.0 */
class BeerSongTest extends FunSuite with Matchers {
class BeerSongTest extends AnyFunSuite with Matchers {

test("first generic verse") {
BeerSong.recite(99, 1) should be(
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/binary-search-tree/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FlatSpec}
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers


/** @version created manually **/
class BstTest extends FlatSpec with Matchers {
class BstTest extends AnyFlatSpec with Matchers {
val bst4 = Bst(4)

it should "retain data" in {
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/binary-search/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 1.3.0 */
class BinarySearchTest extends FunSuite with Matchers {
class BinarySearchTest extends AnyFunSuite with Matchers {

test("finds a value in an array with one element") {
BinarySearch.find(List(6), 6) should be(Some(0))
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/binary/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" % "scalatest_2.11" % "2.2.5" % "test"
6 changes: 4 additions & 2 deletions exercises/practice/binary/src/test/scala/BinaryTest.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers

class BinaryTest extends FunSuite with Matchers {

class BinaryTest extends AnyFunSuite with Matchers {
test("empty string") {
Binary("").toDecimal should be (0)
}
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/bob/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
6 changes: 4 additions & 2 deletions exercises/practice/bob/src/test/scala/BobTest.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 1.4.0 */
class BobTest extends FunSuite with Matchers {
class BobTest extends AnyFunSuite with Matchers {

test("stating something") {
Bob.response("Tom-ay-to, tom-aaaah-to.") should be("Whatever.")
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/book-store/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 1.4.0 */
class BookStoreTest extends FunSuite with Matchers {
class BookStoreTest extends AnyFunSuite with Matchers {


test("Only a single book") {
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/bowling/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
6 changes: 4 additions & 2 deletions exercises/practice/bowling/src/test/scala/BowlingTest.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 1.0.1 */
class BowlingTest extends FunSuite with Matchers {
class BowlingTest extends AnyFunSuite with Matchers {

test("should be able to score a game with all zeros") {
val score = List(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).foldLeft(Bowling())((acc, roll) => acc.roll(roll)).score()
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/change/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
6 changes: 4 additions & 2 deletions exercises/practice/change/src/test/scala/ChangeTest.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import org.scalatest.{Matchers, FunSuite}
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers


/** @version 1.2.0 */
class ChangeTest extends FunSuite with Matchers {
class ChangeTest extends AnyFunSuite with Matchers {

test("single coin change") {
Change.findFewestCoins(25, List(1, 5, 10, 25, 100)) should be (Some(List(25)))
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/clock/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
scalaVersion := "2.12.8"
scalaVersion := "2.13.6"

libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test"
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
Loading

0 comments on commit 582a3f5

Please sign in to comment.