Files
aego/modules/physics/world/pool_snapshot_test.go
sanspie 50be5c04bc
ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Stage 12.5: Art Workspace and asset authoring
Add dockable Art tools, animation and previews, guarded asset workflows,
and the Web Asset Studio built on the shared Art Core. Expand English and
Russian documentation, interactive Try scenes, examples and editor icons.

Add audio waveform navigation, source analysis, guarded previews and a
browser Worker mixer. Preserve source changes and recovery with bounded
checks, and strengthen native, browser and interoperability CI.

Prepare version 0.12.5 and manually built native artifact candidates.
Fix the production site image demo build dependency.
Reuse immutable scene indices when capturing keyframes.
Wait for real Persist save/load completion in component tests.
Stabilize browser Game View captures outside pointer hover.
Aseprite interchange and persistent Audio EDL recovery remain limited;
the artifact workflow does not publish releases or change stable.
2026-11-15 10:37:50 +03:00

73 lines
2.1 KiB
Go

package world
import (
"bytes"
"testing"
)
func TestFreshSnapshotDoesNotCopyUnusedPoolReserve(t *testing.T) {
w := fallingWorld(t)
if cap(w.bodies.items) <= len(w.bodies.items) || cap(w.shapes.items) <= len(w.shapes.items) {
t.Fatal("fixture must contain unused body and shape reserve")
}
oldBodies, oldShapes := cap(w.bodies.items), cap(w.shapes.items)
s := w.Snapshot()
if got, want := cap(s.bodies.items), len(w.bodies.items); got != want {
t.Errorf("fresh body snapshot capacity = %d, want %d populated slots", got, want)
}
if got, want := cap(s.shapes.items), len(w.shapes.items); got != want {
t.Errorf("fresh shape snapshot capacity = %d, want %d populated slots", got, want)
}
if cap(w.bodies.items) != oldBodies || cap(w.shapes.items) != oldShapes {
t.Fatal("snapshot altered the active world's reserve")
}
before := bytes.Clone(s.Bytes())
for range 40 {
w.Step(1.0 / 60)
}
if !bytes.Equal(s.Bytes(), before) {
t.Fatal("subsequent simulation changed an independent snapshot")
}
w.Restore(s)
if got := w.Snapshot().Bytes(); !bytes.Equal(got, before) {
t.Fatal("restoring a compact snapshot changed world state")
}
}
func TestCompactSnapshotReuseAfterGrowth(t *testing.T) {
w := fallingWorld(t)
var key Snapshot
w.SnapshotInto(&key)
original := bytes.Clone(key.Bytes())
other := w.Snapshot()
for range 30 {
d := DefaultBodyDef()
d.Type = Dynamic
h, err := w.CreateBody(d)
if err != nil {
t.Fatal(err)
}
if _, err := w.AddShape(h, ShapeDef{Geometry: Box{Half: Vec2{X: 1, Y: 1}}, Density: 1}); err != nil {
t.Fatal(err)
}
}
w.SnapshotInto(&key)
grown := bytes.Clone(key.Bytes())
if bytes.Equal(grown, original) {
t.Fatal("fixture failed to grow")
}
w.Restore(other)
if got := w.Snapshot().Bytes(); !bytes.Equal(got, original) {
t.Fatal("growing a reused key changed an independent snapshot")
}
w.Restore(&key)
if got := w.Snapshot().Bytes(); !bytes.Equal(got, grown) {
t.Fatal("grown snapshot did not restore")
}
w.Restore(other)
w.SnapshotInto(&key)
if got := key.Bytes(); !bytes.Equal(got, original) {
t.Fatal("reusing a grown snapshot for a smaller world changed state")
}
}