Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion test-kit/src/test/scala/CastlingTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class CastlingTest extends ChessTest:
test("threat on king prevents castling: by a knight"):
assertEquals(board.place(Black.knight, D3).flatMap(_.destsFrom(E1)), Set(D1, D2, E2, F1))

test("threat on king prevents castling: by a bishop"):
assertEquals(board.place(Black.bishop, A5).flatMap(_.destsFrom(E1)), Set(D1, E2, F2, F1))

test("threat on castle trip prevents castling: king side"):
val board: Board = """R QK R"""
assertEquals(board.place(Black.rook, F3).flatMap(_.destsFrom(E1)), Set(D2, E2))
Expand All @@ -42,10 +45,14 @@ class CastlingTest extends ChessTest:
val board: Board = """R QK R"""
assertEquals(board.place(Black.rook, H3).flatMap(_.destsFrom(E1)), Set(D2, E2, F1, F2, G1, H1))

test("threat on rook does not prevent castling king side"):
test("threat on rook does not prevent castling queen side"):
val board: Board = """R KB R"""
assertEquals(board.place(Black.rook, A3).flatMap(_.destsFrom(E1)), Set(A1, C1, D1, D2, E2, F2))

test("threat on rooks trip does not prevent castling queen side"):
val board: Board = """R KB R"""
assertEquals(board.place(Black.rook, B3).flatMap(_.destsFrom(E1)), Set(A1, C1, D1, D2, E2, F2))

test("unmovedRooks and castles are consistent"):
val s1 = Fen.read(Standard, Fen.Full("rnbqk2r/pppppppp/8/8/8/8/PPPPPPPP/RNBQK2R w Qq - 0 1")).get
val s2 = s1.focus(_.board.history.unmovedRooks).replace(UnmovedRooks.corners)
Expand Down
24 changes: 12 additions & 12 deletions test-kit/src/test/scala/PawnTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ class PawnTest extends ChessTest:

import compare.dests

test("move towards rank by 1 square"):
test("move towards rank by 1 square (white pawn)"):
assertEquals(
makeBoard(
A4 -> White.pawn
).destsFrom(A4),
Set(A5)
)

test("not move to positions that are occupied by the same color"):
test("not move to positions that are occupied by the same color (white pawn)"):
assertEquals(
makeBoard(
A4 -> White.pawn,
Expand All @@ -24,7 +24,7 @@ class PawnTest extends ChessTest:
Set()
)

test("capture in diagonal"):
test("capture in diagonal (white pawn)"):
assertEquals(
makeBoard(
D4 -> White.pawn,
Expand All @@ -34,7 +34,7 @@ class PawnTest extends ChessTest:
Set(C5, D5, E5)
)

test("require a capture to move in diagonal"):
test("require a capture to move in diagonal (white pawn)"):
assertEquals(
makeBoard(
A4 -> White.pawn,
Expand All @@ -43,7 +43,7 @@ class PawnTest extends ChessTest:
Set(A5)
)

test("move towards rank by 2 squares"):
test("move towards rank by 2 squares (white pawn)"):
// "if the path is free" in:
assertEquals(
makeBoard(
Expand Down Expand Up @@ -85,7 +85,7 @@ class PawnTest extends ChessTest:
).destsFrom(A2),
Set(A3)
)
test("capture en passant"):
test("capture en passant (white pawn)"):
// "with proper position" in:
val board = makeBoard(
D5 -> White.pawn,
Expand Down Expand Up @@ -152,15 +152,15 @@ class PawnTest extends ChessTest:
Set(D6)
)

test("move towards rank by 1 square"):
test("move towards rank by 1 square (black pawn)"):
assertEquals(
makeBoard(
A4 -> Black.pawn
).destsFrom(A4),
Set(A3)
)

test("not move to positions that are occupied by the same color"):
test("not move to positions that are occupied by the same color (black pawn)"):
assertEquals(
makeBoard(
A4 -> Black.pawn,
Expand All @@ -169,7 +169,7 @@ class PawnTest extends ChessTest:
Set()
)

test("capture in diagonal"):
test("capture in diagonal (black pawn)"):
assertEquals(
makeBoard(
D4 -> Black.pawn,
Expand All @@ -179,7 +179,7 @@ class PawnTest extends ChessTest:
Set(C3, D3, E3)
)

test("require a capture to move in diagonal"):
test("require a capture to move in diagonal (black pawn)"):
assertEquals(
makeBoard(
A4 -> Black.pawn,
Expand All @@ -188,7 +188,7 @@ class PawnTest extends ChessTest:
Set(A3)
)

test("move towards rank by 2 squares"):
test("move towards rank by 2 squares (black pawn)"):
// "if the path is free" in:
assertEquals(
makeBoard(
Expand Down Expand Up @@ -230,7 +230,7 @@ class PawnTest extends ChessTest:
).destsFrom(A7),
Set(A6)
)
test("capture en passant"):
test("capture en passant (black pawn)"):
// "with proper position" in:
val board = makeBoard(
D4 -> Black.pawn,
Expand Down