Skip to content

Commit

Permalink
test codegolf
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Oct 20, 2023
1 parent 0b2d9b8 commit 4b7e996
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion test-kit/src/test/scala/DividerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import MoveOrDrop.*
class DividerTest extends ChessTest:

def makeReplay(moves: String) =
format.pgn.Reader.full(moves).toOption.get match
format.pgn.Reader.full(moves).get match
case format.pgn.Reader.Result.Complete(replay) => replay.chronoMoves.map(_.fold(_.before, _.before))
case x => sys error s"Unexpected incomplete replay $x"

Expand Down
4 changes: 2 additions & 2 deletions test-kit/src/test/scala/format/pgn/DumperTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DumperTest extends ChessTest:
test("Check with pawn not be checkmate if pawn can be taken en passant"):
val game = Fen.readWithMoveNumber(EpdFen("8/3b4/6R1/1P2kp2/6pp/2N1P3/4KPPP/8 w - -")).get match
case s: Situation.AndFullMoveNumber => Game(s.situation, ply = s.ply)
val move = game(Square.F2, Square.F4).toOption.get._2
val move = game(Square.F2, Square.F4).get._2
assertEquals(Dumper(move), "f4+")

val gioachineGreco = makeGame.playMoves(
Expand Down Expand Up @@ -338,5 +338,5 @@ NRKNRQBB
val fen = EpdFen("r5k1/1b5p/N3p1p1/Q4p2/4r3/2P1q3/1PK2RP1/5R2 w - - 1 38")
val sit = Fen.read(fen).get
val game1 = Game(sit.board, sit.color)
val (game2, move) = game1(Square.F2, Square.F3).toOption.get
val (game2, move) = game1(Square.F2, Square.F3).get
assertEquals(Dumper(game1.situation, move, game2.situation), "Rf3")
2 changes: 1 addition & 1 deletion test-kit/src/test/scala/format/pgn/ParserCheck.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class ParserCheck extends ScalaCheckSuite:
test("ParserCheck"):
forAll(genPgn(Situation(Standard))): pgn =>
val str = pgn.render
val result = Parser.full(str).toOption.get.toPgn.render
val result = Parser.full(str).get.toPgn.render
assertEquals(result, str)
10 changes: 5 additions & 5 deletions test-kit/src/test/scala/format/pgn/RenderTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ class RenderTest extends ChessTest:

test("pgn round trip tests compare ParsedPgn"):
(pgns ++ wcc2023).foreach: x =>
val pgn = Parser.full(x).toOption.get
val output = Parser.full(pgn.toPgn.render).toOption.get
val pgn = Parser.full(x).get
val output = Parser.full(pgn.toPgn.render).get
assertEquals(output.cleanTags, pgn.cleanTags)

test("pgn round trip tests compare Pgn"):
List(pgn1, pgn3).foreach: x =>
val result = Parser.full(x).toOption.get.toPgn.render
val result = Parser.full(x).get.toPgn.render
assertEquals(result.value, x)

test("pgn round trip tests compare ouput"):
val results = pgns.map(Parser.full(_).toOption.get.toPgn.render).mkString("\n\n")
val results = pgns.map(Parser.full(_).get.toPgn.render).mkString("\n\n")
assertEquals(results, ouput)

test("wcc2023 study round trip tests"):
val results = wcc2023.map(Parser.full(_).toOption.get.toPgn.render).mkString("\n\n")
val results = wcc2023.map(Parser.full(_).get.toPgn.render).mkString("\n\n")
assertEquals(results, ouput2)

val pgn1 = """
Expand Down
4 changes: 2 additions & 2 deletions test-kit/src/test/scala/opening/OpeningTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class OpeningTest extends ChessTest:
assertEquals(searchStr("d4 c5 d5 e5").get.name, OpeningName("Benoni Defense: Old Benoni"))

test("search should find by replay in d4"):
val replay = Replay(List(SanStr("d4")), None, variant.Standard).toOption.get.valid.toOption.get
val replay = Replay(List(SanStr("d4")), None, variant.Standard).get.valid.get
val op = OpeningDb.search(replay).get
assertEquals(op.opening.name, OpeningName("Queen's Pawn Game"))
assertEquals(op.ply, Ply(1))
Expand All @@ -58,7 +58,7 @@ class OpeningTest extends ChessTest:
.toList,
None,
variant.Standard
).toOption.get.valid.toOption.get
).get.valid.get
val op = OpeningDb.search(replay).get
assertEquals(op.opening.name, OpeningName("King's Gambit Accepted: Muzio Gambit, Holloway Defense"))
assertEquals(op.ply, Ply(12))
Expand Down

0 comments on commit 4b7e996

Please sign in to comment.