Skip to content

Add unit tests for ColonySim utility methods - #305

Merged
joryirving merged 1 commit into
mainfrom
foreman/wl-misospace-windowstead-296/issue-296
Aug 3, 2026
Merged

Add unit tests for ColonySim utility methods#305
joryirving merged 1 commit into
mainfrom
foreman/wl-misospace-windowstead-296/issue-296

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

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).

@itsmiso-ai
itsmiso-ai requested a review from joryirving as a code owner August 2, 2026 11:36
its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai
itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-296/issue-296 branch from 918db6d to 43c3308 Compare August 2, 2026 15:00
@its-saffron
its-saffron Bot dismissed their stale review August 2, 2026 15:02

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai
itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-296/issue-296 branch from 43c3308 to 52f4fdf Compare August 2, 2026 22:57
@its-saffron
its-saffron Bot dismissed their stale review August 2, 2026 22:59

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai
itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-296/issue-296 branch 2 times, most recently from 15008c6 to cf618a1 Compare August 3, 2026 04:06
@its-saffron
its-saffron Bot dismissed their stale review August 3, 2026 04:07

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai itsmiso-ai added the needs-human Human input or decision is required. label Aug 3, 2026
@itsmiso-ai

Copy link
Copy Markdown
Contributor Author

⚠️ This PR fix item has been marked as BLOCKED and needs human attention.

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

@itsmiso-ai
itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-296/issue-296 branch from cf618a1 to 91f5967 Compare August 3, 2026 11:56
@its-saffron
its-saffron Bot dismissed their stale review August 3, 2026 11:57

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai
itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-296/issue-296 branch from 91f5967 to 29f9eb0 Compare August 3, 2026 13:09
@its-saffron
its-saffron Bot dismissed their stale review August 3, 2026 13:11

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

@itsmiso-ai
itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-296/issue-296 branch from 29f9eb0 to 660ffce Compare August 3, 2026 14:12
@its-saffron
its-saffron Bot dismissed their stale review August 3, 2026 14:16

Superseded by a newer automated review for this pull request.

its-saffron[bot]

This comment was marked as outdated.

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>
@itsmiso-ai
itsmiso-ai force-pushed the foreman/wl-misospace-windowstead-296/issue-296 branch from 660ffce to af743f6 Compare August 3, 2026 14:42
@its-saffron
its-saffron Bot dismissed their stale review August 3, 2026 14:44

Superseded by a newer automated review for this pull request.

@its-saffron its-saffron Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_true helpers.
  • File location tests/test_colony_sim_types.gd matches 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 by test_data_to_vec_basic
  • vec_to_data(Vector2i(3,5)) → {x:3,y:5} — covered by test_vec_to_data_basic
  • step_toward((0,0),(5,3)) moves one step — covered by test_step_toward_positive_direction
  • step_toward((5,3),(5,3)) stays in place — covered by test_step_toward_same_position
  • find_open_ground() returns a ground tile — covered by test_find_open_ground_returns_valid_tile
  • is_pos_in_bounds in/out positions — covered by four boundary tests
  • seed_tile determinism — covered by test_seed_tile_deterministic
  • rebuild_reservations_from_workers with/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.

@joryirving
joryirving merged commit 4e50684 into main Aug 3, 2026
7 checks passed
@joryirving
joryirving deleted the foreman/wl-misospace-windowstead-296/issue-296 branch August 3, 2026 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-human Human input or decision is required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P3] Missing unit tests for ColonySim utility methods (data_to_vec, step_toward, seed_tile, etc.)

2 participants