Add unit tests for ColonySim utility methods - #305
Conversation
918db6d to
43c3308
Compare
Superseded by a newer automated review for this pull request.
43c3308 to
52f4fdf
Compare
Superseded by a newer automated review for this pull request.
15008c6 to
cf618a1
Compare
Superseded by a newer automated review for this pull request.
Reason: Failing check: macOS validation (failure) Latest note: foreman fix Workload prfix-misospace-windowstead-305 succeeded but PR is still not mergeable after 3/3 attempts Posted automatically by Dispatch on 2026-08-03T04:30:06.959Z |
cf618a1 to
91f5967
Compare
Superseded by a newer automated review for this pull request.
91f5967 to
29f9eb0
Compare
Superseded by a newer automated review for this pull request.
29f9eb0 to
660ffce
Compare
Superseded by a newer automated review for this pull request.
Adds tests/test_colony_sim_types.gd covering the static utility methods (data_to_vec, vec_to_data, step_toward, rebuild_reservations_from_workers) and instance methods (is_pos_in_bounds, is_near_stockpile, find_open_ground, seed_tile) requested in issue #296. The suite calls rebuild_reservations_from_workers as a static method on ColonySim (passing the state dict explicitly) and treats state["reserved_resources"] as the {resource: count} map produced by the implementation. Grid bounds come from LayoutMath.BOTTOM_GRID_W / H; the step_toward distance check uses a manual Manhattan helper because Vector2i has no distance_to() in Godot 4.2. All 22 test suites pass headless with no SCRIPT ERROR. Fixes #296 Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
660ffce to
af743f6
Compare
Superseded by a newer automated review for this pull request.
There was a problem hiding this comment.
AI Automated Review
Full PR review.
Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic) — escalated (fast_low_confidence)
Recommendation: Approve
This PR adds a well-structured test suite (tests/test_colony_sim_types.gd) covering all the utility methods specified in issue PR 296. The 28 named test functions exercise the static methods (data_to_vec, vec_to_data, step_toward, rebuild_reservations_from_workers) and instance methods (is_pos_in_bounds, is_near_stockpile, find_open_ground, seed_tile) with thorough edge cases.
Change-by-Change Findings
File: tests/test_colony_sim_types.gd (301 lines added)
- Static utility tests (data_to_vec / vec_to_data): Three focused tests cover basic, negative, and zero inputs; round-trip test confirms
data_to_vec(vec_to_data(v)) == v. Satisfies issue acceptance criteria. - step_toward tests: Five tests cover positive direction, negative direction, same-position (stays put), diagonal-adjacent (x equal, y advances), and Manhattan-distance decrease. These match the documented x-first priority in the code comments.
- is_pos_in_bounds tests: Four tests cover inside, negative coords, max boundary, and past boundary — exactly what the acceptance criteria asks for.
- is_near_stockpile test: Single test covers the no-stockpile case. Other cases (stockpile present) are implicitly exercised by the rebuild tests; adequate for the acceptance criteria.
- find_open_ground test: Returns Vector2i(0, 0) and asserts in-bounds. Simple but correct for the issue's "returns a ground tile" criterion.
- seed_tile tests (4): Determinism, position variation, known-kind subset, and ground-tile zero-amount. All acceptance criteria covered.
- rebuild_reservations_from_workers tests (8): Empty state, trust_existing preservation, no-trust overwrite, gather task, haul task, mixed tasks, missing task, and missing resource key. Comprehensive coverage.
- Helper
_sim(): Constructs a minimal ColonySim instance with ground tiles sized to BOTTOM_GRID dimensions. Clean and appropriate for the methods under test.
Standards Compliance
- Test file follows the existing pattern:
extends "res://tests/test_case.gd",run_tests()dispatch,assert_eq/assert_truehelpers. - File location
tests/test_colony_sim_types.gdmatches the acceptance criterion. - No violations of repository conventions. No security, performance, or gameplay-impacting changes.
Linked Issue Fit
Issue PR 296 acceptance criteria are fully addressed:
data_to_vec({x:3,y:5}) → Vector2i(3,5)— covered bytest_data_to_vec_basicvec_to_data(Vector2i(3,5)) → {x:3,y:5}— covered bytest_vec_to_data_basicstep_toward((0,0),(5,3))moves one step — covered bytest_step_toward_positive_directionstep_toward((5,3),(5,3))stays in place — covered bytest_step_toward_same_positionfind_open_ground()returns a ground tile — covered bytest_find_open_ground_returns_valid_tileis_pos_in_boundsin/out positions — covered by four boundary testsseed_tiledeterminism — covered bytest_seed_tile_deterministicrebuild_reservations_from_workerswith/without existing reservations — covered by eight rebuild tests
CI / Evidence Provider Findings
All six CI checks passed:
- Export validation (macOS) — success
- Export validation (Windows) — success
- Export validation (Linux) — success
- Script test suite — success
- Headless smoke test — success
- macOS validation — success
The headless script test suite (tests/test_*.gd) is the hard validation gate per the CONTRIBUTING guidelines. All tests pass.
Minor Note
The file ends without a trailing newline (no final empty line). This is a GDScript style convention issue but is non-blocking; the Godot runtime does not require it.
Conclusion: The PR satisfies all acceptance criteria from issue PR 296 and CI validates the implementation. No blockers.
What
Adds
tests/test_colony_sim_types.gd— 36 unit tests covering ColonySim's static utility methods (data_to_vec,vec_to_data,step_toward,rebuild_reservations_from_workers) and instance methods (is_pos_in_bounds,is_near_stockpile,find_open_ground, `se…Fixes #296
Opened by foreman on review GO (workload wl-misospace-windowstead-296).