test: add Game current position invariant coverage#119
Draft
CorentinGS wants to merge 1 commit into
Draft
Conversation
167f09a to
13ec153
Compare
71524c3 to
230454f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Game.Clone() correctness by preserving the game’s current move cursor (and corresponding current position) when cloning, and adds invariant-focused tests to ensure Game consistently reports its current position across common operations.
Changes:
- Update
Game.Clone()to mapg.currentMoveinto the cloned move tree (instead of defaulting to the last mainline move). - Ensure cloned games’
postracks the clonedcurrentMove.position. - Add invariant tests covering current-position consistency after cloning, navigation, PGN parsing, and
Split().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
game.go |
Fixes clone behavior by preserving the current move cursor via a move-tree search and syncing pos to the cloned cursor position. |
game_invariants_test.go |
Adds tests asserting Game’s “current position” invariants across clone/navigation/PGN/split workflows. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
13ec153 to
93c8d1f
Compare
230454f to
966ebee
Compare
93c8d1f to
222d597
Compare
966ebee to
8bca1f0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Game.Clone()to preserve the current cursor and keepPosition(),CurrentPosition(),g.pos, andcurrentMove.positionconsistent.Verification
go test ./...