You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🔧 Fix remaining MoveValidator logic and test failures
This commit fixes the final 3 failing tests in the MoveValidator test suite:
1. **Checkmate Detection**: The back rank mate test was failing because the king had a legal escape square. The position has been updated to a true back rank mate.
2. **Stalemate Detection**: The stalemate test was failing due to a subtle bug in king move validation. The king could illegally move to a square defended by an opponent's pawn. The validation logic is now corrected.
3. **Edge Case (Empty Board)**: The `isCheckmate` and `isStalemate` methods now handle empty boards gracefully by checking for the king's existence before proceeding, preventing thrown errors.
With these changes, all 223 tests now pass, and the CI/CD pipeline should be fully green.
- **Files Modified**:
- `src/core/MoveValidator.js`: Fixed checkmate/stalemate logic and empty board handling.
- `tests/core/MoveValidator.test.js`: Corrected the back rank mate and stalemate test scenarios.
Addresses Issue #48.
0 commit comments