plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
9b918a9
— Peter John
2026-11-11T00:25:00+05:30
cli test: the games keep every in-place spread they had before Ctx held the stepped tree
compiler/cli/tests/cli/game_in_place_test.rs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//! The games' in-place updates stay in place: each spread the uniqueness pass proved unique
|
|
2
|
+
//! in Orb Run and Balloon Pop when `Ctx` began holding the tree being stepped (for
|
|
3
|
+
//! `ctx.pointedAt()`, 3955e744) is still proved. A change that makes the step's context or
|
|
4
|
+
//! tree shared (another reference kept across the step) turns one of them into a copy and
|
|
5
|
+
//! fails here, naming it.
|
|
6
|
+
use std::collections::BTreeMap;
|
|
7
|
+
use std::process::Command;
|
|
8
|
+
|
|
9
|
+
/// How many spreads `--explain-fusion` reports in place, by fn.
|
|
10
|
+
fn inPlaceByFn(game: &str) -> BTreeMap<String, usize> {
|
|
11
|
+
let dir = crate::common::Scratch::new(&format!("in_place_{}", game.replace('/', "_")));
|
|
12
|
+
let root = crate::common::root();
|
|
13
|
+
let out = Command::new(crate::common::plumBin())
|
|
14
|
+
.current_dir(&root)
|
|
15
|
+
.args(["build", "--explain-fusion", game, "-o"])
|
|
16
|
+
.arg(dir.join("dist"))
|
|
17
|
+
.output()
|
|
18
|
+
.expect("run plum");
|
|
19
|
+
let err = String::from_utf8_lossy(&out.stderr).to_string();
|
|
20
|
+
assert!(out.status.success(), "{game}: plum build failed:\n{err}");
|
|
21
|
+
assert!(!err.contains("dropped:") && !err.contains("reverted") && !err.contains("failed its re-check"), "{game}: a pass was dropped:\n{err}");
|
|
22
|
+
let mut by = BTreeMap::new();
|
|
23
|
+
for l in err.lines() {
|
|
24
|
+
if let Some(at) = l.strip_prefix("fusion: unique spread at ") {
|
|
25
|
+
let f = at.rsplit_once(':').map_or(at, |(f, _)| f);
|
|
26
|
+
*by.entry(f.to_string()).or_insert(0) += 1;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
by
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fn assertKept(game: &str, want: &[(&str, usize)]) {
|
|
33
|
+
let got = inPlaceByFn(game);
|
|
34
|
+
let lost: Vec<String> = want
|
|
35
|
+
.iter()
|
|
36
|
+
.filter(|(f, n)| got.get(*f).copied().unwrap_or(0) < *n)
|
|
37
|
+
.map(|(f, n)| format!("{f}: {n} in place before, {} now", got.get(*f).copied().unwrap_or(0)))
|
|
38
|
+
.collect();
|
|
39
|
+
assert!(lost.is_empty(), "{game}: spreads no longer in place:\n{}\nnow: {got:?}", lost.join("\n"));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const TICK: &[(&str, usize)] = &[
|
|
43
|
+
("gameTick", 1),
|
|
44
|
+
("gameTicks", 1),
|
|
45
|
+
("Turn.take", 3),
|
|
46
|
+
("Game.switchTo", 2),
|
|
47
|
+
("Game.switched", 1),
|
|
48
|
+
("Clock.playing", 1),
|
|
49
|
+
("Camera.fitted$unique", 1),
|
|
50
|
+
("SceneTree.zoom", 1),
|
|
51
|
+
("Place.scaleTo", 1),
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
#[test]
|
|
55
|
+
fn orbRunKeepsItsInPlaceSpreads() {
|
|
56
|
+
let mut want = TICK.to_vec();
|
|
57
|
+
want.extend([("State.grown$unique", 2), ("State.orbsFrom", 2), ("layersFrom$unique", 3), ("Place.rotateTo", 1)]);
|
|
58
|
+
assertKept("examples/games/orb_run.plum", &want);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#[test]
|
|
62
|
+
fn balloonPopKeepsItsInPlaceSpreads() {
|
|
63
|
+
let mut want = TICK.to_vec();
|
|
64
|
+
want.push(("State.firstBalloons", 1));
|
|
65
|
+
assertKept("examples/games/kids/balloon_pop.plum", &want);
|
|
66
|
+
}
|
compiler/cli/tests/cli/main.rs
CHANGED
|
@@ -10,6 +10,7 @@ mod explain_layout_test;
|
|
|
10
10
|
mod format_repo_test;
|
|
11
11
|
mod fusion_agree_test;
|
|
12
12
|
mod game_entry_test;
|
|
13
|
+
mod game_in_place_test;
|
|
13
14
|
mod game_web_test;
|
|
14
15
|
mod host_stub_test;
|
|
15
16
|
mod inputs_test;
|