flan/test/programs/sand-headless.flan
Joseph Ferano 259cf3b3e2 sand is one program again
The simulation was in a package of its own for one reason: importing raylib
linked libraylib on every target, so the headless run could not name the
package the interactive one needs. That reason is gone, and the split was
never anything else — the physics is the same code either way.

So sim.flan is back inside sand.flan, and test/programs/sand-headless.flan
imports sand.flan itself: window, raylib bindings, dev agent and all. It builds
for wasm32 anyway. Nothing it calls reaches raylib, so no shim is compiled, no
-lraylib is passed, and the front-end's functions are never emitted; sand.flan's
main is not exported, so the only main is the headless one. The hash is
unchanged on both targets at both optimisation levels, which is the point —
a refactor that moved the number would have moved the simulation.

The new cases cover what made it possible rather than only the result: a
package nothing calls into, native and wasm32; raylib reached both directly and
through sand.flan and read once; and the three refusals — sand/main, one
directory under two aliases, and two mains.

test_session's package-qualification case moves to vendor/agent, which is now
the package in the tree with a defn in it.
2026-09-11 20:11:01 +07:00

34 lines
1.3 KiB
Plaintext

;;;; sand.flan's other half: N frames, no window, hash the grid.
;;;;
;;;; This is the version CI runs on native *and* wasm32, and it imports
;;;; sand.flan itself — window, raylib bindings, dev agent and all. It builds
;;;; for wasm32 anyway because the link follows what the program reaches:
;;;; nothing here calls into raylib, so no shim is compiled and no -lraylib is
;;;; passed, and the front-end's own functions are never emitted. sand.flan's
;;;; main is not exported, so the only main is this one.
;;;;
;;;; A package is a directory, except when it is a single .flan file named
;;;; outright — which is this, because sand.flan shares the repository root
;;;; with three other loose programs.
;;;;
;;;; The hash is a regression test only because the sequence is reproducible:
;;;; rand-f32 is a seeded PRNG written in Flan, so the same seed gives the same
;;;; grains in the same places on both targets (plan.org, RNG is ours).
(import sand "../../sand.flan")
(defconst frames 40)
(defn main [] i32
(rand-seed 20260910)
;; Four clouds, spread across the top, one per colour. Deterministic
;; positions: the mouse is what the interactive driver has and this does not.
(dotimes [i 4]
(sand/next-color)
(sand/paint-at 4 (* (+ i 1) (/ sand/cols 5))))
(dotimes [f frames]
(sand/step))
(print-i64 (i64 (sand/hash-grid)))
(newline)
0)