windowstead #70: Extract layout math and add dock/regression tests - #73
Merged
Merged
Conversation
- Extract pure dock/layout math from main.gd into layout_math.gd for deterministic testing without DisplayServer or scene nodes - Add 22 regression tests covering: - anchor family selection (bottom vs vertical) - tile sizing with zoom scaling - grid dimensions per anchor - world panel size calculations - dock padding and window size - dock position for left/bottom/right anchors - popup sidebar positioning and bounds checking - stockpile position per anchor - anchor swap round-trips - Wire main.gd to use LayoutMath for all layout calculations Part of #70: Add deterministic regression tests for dock and layout behavior
Contributor
|
✅ Automated recommendation: APPROVE Analysis engine: MiniMax-M2.7@https://api.minimax.io/v1 PR Review: Extract layout math and add dock/regression tests (PR #73)Recommendation: ApproveThis PR cleanly extracts pure layout geometry math from Change-by-Change Findings1.
|
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.
Fixes #70.
Extract pure dock/layout math from
main.gdintoscripts/layout_math.gdso layout logic can be tested directly without requiring a full scene or DisplayServer access.Changes
New file:
scripts/layout_math.gd— pure static math functions:tile_px_for_anchor()— square tile size per anchor + zoomworld_pixel_size()— world panel dimensionsgrid_dims_for_anchor()— grid width/height per anchordock_padding_for_anchor()— padding per anchordock_size_for_anchor()— full window sizedock_position_for_anchor()— window position within screenpopup_position_for_anchor()— sidebar panel positionpopup_within_bounds()— bounds checking helperanchor_family_from_dock_anchor()— anchor string mappingstockpile_pos_for_anchor()— stockpile position per anchorNew file:
tests/test_layout_math.gd— 22 deterministic regression tests:Modified:
scripts/main.gd— delegates all layout math to LayoutMath (18 insertions, 43 deletions — net shrink).Run tests
Part of #70 — more regression tests can be added for specific known failures (issues #40, #52, #53, #54) as they're identified.