feat(ludic.base): Systems is an open registry - def a system from any module

The runner's list starts from the declared systems, in the order the
compiler gives an open registry, and core_add appends after them.
registry_test covers it; the README says ludic test runs the package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-25 05:15:56 +03:00
parent 73129b59d5
commit cac8c740fa
3 changed files with 43 additions and 12 deletions

View file

@ -0,0 +1,21 @@
# registry_test.ludic - systems declared with `def Systems ...` from outside the package: the
# runner starts from them in the registry's order, and core_add still appends after them
import "ludic.base"
program RegistryTest {
numbers float
var trail: string = ""
function late_tick(t: Tick) -> void { trail = trail + "l" }
function early_tick(t: Tick) -> void { trail = trail + "e" }
function added_tick(t: Tick) -> void { trail = trail + "a" }
def Systems late { phase: PH_RESOLVE, tick: fn late_tick }
def Systems early { phase: PH_INPUT, tick: fn early_tick }
test "the declared systems run, phase by phase" {
expect_eq(core_count(), 2)
expect(Systems[SYS_LATE].key == "late")
let s = system_new("added", PH_INPUT)
s.tick = fn added_tick
core_add(s)
core_tick_all(tick_new(0.016, 1, 0.0))
expect(trail == "eal")
}
}