Skip to content

Commit

Permalink
fix sgf, sieve and linked list exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz-bielski committed Jul 21, 2024
1 parent f231d05 commit 94488d9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
11 changes: 0 additions & 11 deletions bin/test-in-docker

This file was deleted.

4 changes: 2 additions & 2 deletions exercises/practice/sgf-parsing/.meta/Example.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ object Sgf extends RegexParsers {

private val propValue: Parser[String] =
"[" ~ rep1(propValuePart) ~ "]" ^^ {
case _ ~ values ~ _ => values mkString
case _ ~ values ~ _ => values.mkString
} named "propValue"

private val propValuePart: Parser[String] = {
implicit class AsStringParser(self: String) { def p: Parser[String] = self }
val ignore = const("") _
val ignore = const("")

val escapedNewline: Parser[String] = "\\\n".p ^^ ignore
val escapedChar: Parser[String] = """\\.""".r ^^ (_.takeRight(1))
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/sieve/.meta/Example.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Sieve {
val primes = mutable.HashSet.empty ++ (2 to upperBound)

// Remove multiples of a possiblePrime from the primes set.
def checkPrime(possiblePrime: Int) {
def checkPrime(possiblePrime: Int) = {
if (primes contains possiblePrime) {
// remove multiples of possiblePrime from set
val possibleSquared = possiblePrime * possiblePrime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class SimpleLinkedListTest extends AnyFlatSpec with Matchers with ScalaCheckDriv

it should "handle reverse arbitrary list " in {
pending
forAll { seq: Seq[Int] =>
forAll { (seq: Seq[Int]) =>
assert(SimpleLinkedList.fromSeq(seq).reverse.toSeq == seq.reverse)
}
}
Expand All @@ -90,7 +90,7 @@ class SimpleLinkedListTest extends AnyFlatSpec with Matchers with ScalaCheckDriv
(0 until i).foldLeft(list)((acc, j) => acc.next).value
}

forAll { xs: Seq[Int] =>
forAll { (xs: Seq[Int]) =>
whenever(xs.nonEmpty) {
val list = SimpleLinkedList.fromSeq(xs)
xs.indices.foreach {
Expand All @@ -102,15 +102,15 @@ class SimpleLinkedListTest extends AnyFlatSpec with Matchers with ScalaCheckDriv

it should "return original arbitrary list from added list elements" in {
pending
forAll { xs: Seq[Int] =>
forAll { (xs: Seq[Int]) =>
val list = xs.foldLeft(SimpleLinkedList[Int]())(_.add(_))
assert(list.toSeq == xs)
}
}

it should "handle arbitrary generics" in {
pending
forAll { xs: Seq[String] =>
forAll { (xs: Seq[String]) =>
assert(SimpleLinkedList.fromSeq(xs).toSeq == xs)
}
}
Expand Down

0 comments on commit 94488d9

Please sign in to comment.