plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
1163e3e
— Peter John
2026-11-02T14:10:32+05:30
T4: native host: Backend, wasmtime binding, macroquad, recorder
- plum-game/tests/host_test.rs +27 -0
plum-game/tests/host_test.rs
CHANGED
|
@@ -151,3 +151,30 @@ fn manyFramesDoNotAccumulateRoots() {
|
|
|
151
151
|
g.draw().unwrap();
|
|
152
152
|
assert_eq!(g.backend().calls.last().unwrap(), "drawText(\"frames 2000\",0,0,8,1,1,1,1)");
|
|
153
153
|
}
|
|
154
|
+
|
|
155
|
+
#[test]
|
|
156
|
+
fn kamViewerInitAndDrawWithRealAssets() {
|
|
157
|
+
use plum_game::api::Backend;
|
|
158
|
+
let assets = plum_game::assets::AssetRoot::resolve(None);
|
|
159
|
+
if !assets.join("sprites").is_dir() {
|
|
160
|
+
eprintln!("skipping: asset root {} not found", assets.display());
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
// Map size, read through a separate backend so the minimap rect count is exact.
|
|
164
|
+
let mut probe = Recorder::with_assets(None);
|
|
165
|
+
let m = probe.map_load("Maps/A new Beginning/A new Beginning.map");
|
|
166
|
+
assert!(m >= 0);
|
|
167
|
+
let cells = (probe.map_width(m) * probe.map_height(m)) as usize;
|
|
168
|
+
|
|
169
|
+
let wasm = compile(&Path::new(env!("CARGO_MANIFEST_DIR")).join("kam/Main.plum"));
|
|
170
|
+
let mut g = PlumGame::load(&wasm, Recorder::with_assets(None)).expect("load viewer");
|
|
171
|
+
g.init().expect("init must not trap");
|
|
172
|
+
g.update(0.016).expect("update must not trap");
|
|
173
|
+
g.draw().expect("first draw must not trap");
|
|
174
|
+
g.draw().expect("second draw must not trap");
|
|
175
|
+
let calls = &g.backend().calls;
|
|
176
|
+
assert!(calls.iter().any(|c| c.starts_with("drawTile(")), "no drawTile recorded");
|
|
177
|
+
let rects = calls.iter().filter(|c| c.starts_with("drawRect(")).count();
|
|
178
|
+
assert!(rects >= cells, "minimap drew {rects} rects, expected at least {cells}");
|
|
179
|
+
assert!(!calls.iter().any(|c| c.contains("assets not found")), "assets-not-found was drawn");
|
|
180
|
+
}
|