Files
gen1recomp/tests/engine/gen2_rom_text_registry_test.lua
thibautbus 23aeda4871 Expose localized Gen2 content registries
GEN2_STATUS_IDS (psn/brn/frz/par/paralysis/slp -> Gen 2's own registry ids)
was declared verbatim in both PartyMenu.lua and SummaryMenu.lua; move it to
Status.GEN2_ID_ALIASES so a future status alias fix only has one copy to
update.

SummaryMenu.TYPE_NAMES was left behind after this branch switched its two
former internal uses to the shared TypeChart.displayName/DISPLAY_NAMES; it
has no remaining callers anywhere in src/ or tests/.
2026-09-01 21:52:42 +02:00

52 lines
1.8 KiB
Lua

-- Gold has two text datasets: VM script text keyed by bank:address and
-- engine prose keyed by disassembly label. Their public registries must not
-- alias even though the shared RomText helper reads the latter at data.text.
package.path = "./?.lua;./?/init.lua;" .. package.path
local T = require("tests.modkit")
local RomText = require("src.core.RomText")
local Schemas = require("src.mods.Schemas")
local files = T.sdk.memfs({
["mods/rom_text_probe/manifest.json"] = [[{
"id": "rom_text_probe",
"name": "Rom Text Probe",
"version": "1.0.0",
"entry": "main.lua",
"api": 2,
"gen2compat": true
}]],
["mods/rom_text_probe/main.lua"] = [[
local mod = ...
mod.content.rom_text:override("_WokeUpText", "{USER} se réveille !")
mod.content.text:override("55:4067", "SCRIPT PATCH")
]],
})
local data = {
text = { _WokeUpText = "{USER} woke up!" },
gen2Text = { ["55:4067"] = "SCRIPT BASE" },
}
local run = T.sdk.loadMods({ "mods/rom_text_probe" }, {
fs = files, data = data, generation = 2,
})
T.eq(#run.errors, 0,
"the rom_text mod loads cleanly (" .. table.concat(run.errors, "; ") .. ")")
T.eq(Schemas.targetFor("rom_text", Schemas.REGISTRIES.rom_text, 2), "text",
"rom_text routes to the label-keyed Gen 2 table")
T.eq(Schemas.targetFor("text", Schemas.REGISTRIES.text, 2), "gen2Text",
"text keeps the VM script table")
T.eq(RomText(run.data, "_WokeUpText", "%s woke up!", "GOLD"),
"GOLD se réveille !", "RomText consumes the merged rom_text override")
T.eq(run.data.gen2Text["55:4067"], "SCRIPT PATCH",
"the ordinary text registry still patches Gen 2 script text")
T.eq(run.data.gen2Text._WokeUpText, nil,
"the rom_text label does not leak into gen2Text")
T.eq(run.data.text["55:4067"], nil,
"the VM script address does not leak into rom_text")
run.release()
T.finish("gen2_rom_text_registry")