Summary
Migrate Warcraft III gameplay tests from the C harness to .j fixtures wherever the JASS surface is a better fit. The goal is to make tests easier to follow, closer to production scripting, and smaller in the long term.
Why this change exists
- Tests written in
.j mirror the real Warcraft III scripting entrypoint more closely than direct C harness calls.
- The current harness is carrying a lot of game-state scaffolding that is only there to support gameplay assertions.
- Once dedicated server mode exists, these tests can run against the real game module instead of mocked C-side state.
Dependency
This issue is blocked by #116 (Add dedicated server mode (headless, no client)). We need a headless runtime before .j gameplay tests can run cleanly against the real game module.
What currently exists
- There is no
hero_inventory_test.j or similar gameplay fixture yet.
- The closest existing
.j file is test_jass_assertions.j, which tests JASS assertion natives rather than gameplay behavior.
- Gameplay coverage currently lives in C through
test_harness.c / test_harness.h.
The harness currently owns:
- Global game state that normally belongs in
g_main.c (gi, globals, game, level, g_edicts)
- Mock
gi function pointers for allocation, entity linking, edict queries, and similar plumbing
- Hardcoded unit metadata for test actors such as
hpea, hfoo, hbar, and Hpal
- Raw edict allocation helpers that bypass normal spawn/model setup
- Stubs for game symbols that are not linked into the test binary
Suggested migration order
- Make real game natives callable from the JASS test binary.
- Convert inventory tests first, since they already map cleanly to
UnitItemInSlot / UnitHasItem style checks.
- Convert hero, unit-flag, player, alliance, and group tests next.
- Delete the C tests that are fully replaced by
.j coverage.
- Remove dead harness helpers and unused stubs as each migration makes them obsolete.
- Trim the test build once the old callers are gone.
Good .j candidates
These are gameplay behaviors that map naturally to JASS natives:
- Inventory add/get and slot assignment
- Hero attributes, XP accumulation, and
SuspendHeroXP
- Unit flags such as invulnerable, paused, hidden, and no-pathing
- Player properties like color, name, and team
- Alliances
- Ownership and range checks
- Group membership helpers
Keep in C
These areas do not have a meaningful Warcraft III gameplay-script surface and should stay as C tests:
- Pathfinding
- SLK parsing
- JASS VM internals
- Collision and physics
- UI / FDF rendering and serialization
- Network and server protocol
- Combat math that lives in shared engine/game code rather than gameplay scripting
Acceptance criteria
- At least one
.j gameplay fixture exists and runs in CI.
- The JASS test binary can call the real game natives it needs.
- Replaced C tests are deleted once their
.j equivalents exist.
- Harness code shrinks where helpers become unused.
- The build still passes for the remaining C-only suites.
Definition of done
- Gameplay tests are represented by
.j fixtures instead of direct C harness calls where practical.
- The remaining C harness is smaller and easier to justify.
- The test suite is deterministic and self-contained.
Summary
Migrate Warcraft III gameplay tests from the C harness to
.jfixtures wherever the JASS surface is a better fit. The goal is to make tests easier to follow, closer to production scripting, and smaller in the long term.Why this change exists
.jmirror the real Warcraft III scripting entrypoint more closely than direct C harness calls.Dependency
This issue is blocked by #116 (
Add dedicated server mode (headless, no client)). We need a headless runtime before.jgameplay tests can run cleanly against the real game module.What currently exists
hero_inventory_test.jor similar gameplay fixture yet..jfile istest_jass_assertions.j, which tests JASS assertion natives rather than gameplay behavior.test_harness.c/test_harness.h.The harness currently owns:
g_main.c(gi,globals,game,level,g_edicts)gifunction pointers for allocation, entity linking, edict queries, and similar plumbinghpea,hfoo,hbar, andHpalSuggested migration order
UnitItemInSlot/UnitHasItemstyle checks..jcoverage.Good
.jcandidatesThese are gameplay behaviors that map naturally to JASS natives:
SuspendHeroXPKeep in C
These areas do not have a meaningful Warcraft III gameplay-script surface and should stay as C tests:
Acceptance criteria
.jgameplay fixture exists and runs in CI..jequivalents exist.Definition of done
.jfixtures instead of direct C harness calls where practical.