Merge branch 'lang/ecs' into lang/uifree

This commit is contained in:
Orkun ÇAKILKAYA 2026-09-28 10:12:48 +03:00
commit f294484c02
7 changed files with 52637 additions and 52025 deletions

View file

@ -11,6 +11,15 @@ program ActionsTest {
reducer Door on Knock(d: mut Door, a: Knock) {
if a.times >= 2 { d.open = true }
}
state Tally {
sum: int = 0
words: string = ""
}
action Note { n: int = 7, word: string = "hi" }
reducer Tally on Note(t: mut Tally, a: Note) {
t.sum = t.sum + a.n
t.words = t.words + a.word
}
function input_tick(t: Tick) -> void { dispatch Knock { times: 2 } }
function sim_tick(d: mut Door, t: Tick) -> void {
if d.open { d.seen = d.seen + "o" } else { d.seen = d.seen + "c" }
@ -27,4 +36,16 @@ program ActionsTest {
expect(d.open)
expect_eq(d.seen, "o")
}
test "a dispatched record is kept and filled again: what a dispatch leaves out is its default, not the last one's" (t: Tally) {
dispatch Note { n: 1, word: "a" }
dispatch Note { n: 2, word: "b" }
drain_actions()
expect_eq(t.sum, 3)
dispatch Note { }
dispatch Note { word: "c" }
dispatch Note { n: 5 }
drain_actions()
expect_eq(t.sum, 3 + 7 + 7 + 5)
expect_eq(t.words, "abhichi")
}
}