Skip to content

test(sim): compare every enum-valued read with its catalog literal - #147

Merged
e54-bot merged 1 commit into
mainfrom
test/enum-reads-vs-literals
Nov 3, 2026
Merged

e54-bot merged 1 commit into
mainfrom
test/enum-reads-vs-literals

Conversation

@e54-bot

@e54-bot e54-bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #142

What

One test, crates/athena-sim/tests/enum_reads.rs. It lists every catalog value entry whose return type is an enum domain, then runs Compare(<read>, ==, <enum literal>) for each modeled read and asserts true.

How the read set is derived

athena-sim has no registry of modeled reads: dispatch is match name arms in call.rs and player.rs. So the set comes from the workshop-rs catalog (entries_of(Kind::Value) with return_type() in an enum domain; the Vector domain is excluded because its reads yield numeric vectors).

A new catalog read in that set fails the test until it is added to MODELED or UNMODELED. A new enum-valued read therefore cannot go uncovered, but it needs a one-line table entry, because the call arguments cannot be generated. A read in UNMODELED must not complete, so modeling it later fails the test and forces a move to MODELED.

Reads covered

Modeled, compared with the literal: hero, getHero (Hero Of), teamOf, currentMap, getCurrentGamemode, gameMode, workshop setting hero (createWorkshopSettingHero). The scenario uses ana, team1, king's row, skirmish, none equal to the member ids.
Unmodeled, asserted not to complete: oppositeTeamOf, getHeroOfDuplication, getControlScoringTeam, eventAbility, customColor.

Bug found

None. Every modeled read is true on current main.

Mutation evidence

Changed "getHero" => player.hero_member.clone() to player.hero.clone() in player.rs (authored spelling), ran the test, then git checkout:

every_enum_valued_read_equals_its_enum_literal --- FAILED
assertion `left == right` failed: getHero: Hero Of(Host Player)
  left: Bool(false)
 right: Bool(true)

Verification

  • cargo test: all pass
  • cargo clippy --all-targets -- -D warnings: clean
  • cargo fmt --check: clean

The read set comes from the workshop-rs catalog's value entries with an enum return type. A read in neither the modeled nor the unmodeled table fails the test.

Fixes #142
@e54-bot

e54-bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Verdict: LGTM (head 57cb085)

Independent check, not from the PR's own tests.

  1. Derivation. I listed entries_of(Kind::Value) with an enum-domain return type from the catalog. Excluding Vector leaves 12 reads: hero, getHero, teamOf, oppositeTeamOf, customColor, currentMap, eventAbility, getHeroOfDuplication, createWorkshopSettingHero, getControlScoringTeam, getCurrentGamemode, gameMode. MODELED (7) + UNMODELED (5) equal this set exactly. Only Vector is a non-member-id enum domain among the catalog's enum-returning values, so no other exclusion is needed. Deleting the eventAbility table line fails with "enum-valued read eventAbility is in neither MODELED nor UNMODELED".
  2. Classification. All 5 UNMODELED reads stop with NotModeled for the read itself (value oppositeTeamOf, value getHeroOfDuplication, value getControlScoringTeam, value eventAbility), not for a missing scenario key. customColor is modeled as a Display token (call.rs, athena#113) and the Compare against Color(Red) is rejected as NotModeled. That is sound: a display token has no member id. Every read that dispatch models and that returns an enum is in MODELED.
  3. Spellings. The scenario uses ana, team1, king's row, skirmish; the member ids differ. getHero, teamOf, currentMap and getCurrentGamemode exercise the member-id path. hero, gameMode and createWorkshopSettingHero are literal constructors, so the scenario spelling does not reach them. This is cheap, harmless coverage; no change needed.
  4. Mutation. getHero => player.hero.clone() fails (getHero: Hero Of(Host Player), left Bool(false), right Bool(true)). Team Of returning a lowercased debug spelling fails the same way (teamOf: Team Of(Host Player)). Both restored.
  5. Size and shape. One file, no new dependency, named for behavior. The existing Hero Of tests check specific reads, so the table-driven test does not duplicate them.
  6. Gates. cargo test passes. cargo clippy --all-targets -- -D warnings is clean. cargo fmt --check is clean. git diff --check origin/main...HEAD is clean. CI passes (Quality, WebAssembly build). The workflow lint job is skipped. mergeStateStatus is CLEAN.

@e54-bot
e54-bot merged commit e0459c4 into main Nov 3, 2026
4 checks passed
@e54-bot
e54-bot deleted the test/enum-reads-vs-literals branch November 3, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test every enum-valued read against its catalog literal

2 participants