Add new tests and implement frame budget management

- Introduced `civilization_benchmark.gd` and `legacy_quantity_math.gd` for benchmarking and legacy quantity calculations.
- Created `test_dynamic_math.gd`, `test_frame_evolution.gd`, and `test_sparse_batches.gd` to validate mathematical operations and frame evolution logic.
- Implemented `frame_budget.gd` to manage cooperative work on the main thread, ensuring no partially calculated state is published.
- Added UID files for all new scripts to maintain unique identifiers.
This commit is contained in:
Kirill
2026-10-01 23:43:34 +03:00
parent f51eea6c0f
commit c4e7302567
53 changed files with 1313 additions and 397 deletions
+13
View File
@@ -58,6 +58,19 @@ func run() -> void:
check(E.eq(completions.size(), 2), "Repeated requests coalesce behind active write")
check(E.eq(manager.load_data("latest", "test-password").state.energy, 3), "Last queued snapshot wins")
var pending_clock: Dictionary = preload("res://world/owniverse/simulation_time.gd").advance(world.state.time, 0.01, 1)
data.simulation = {"requested_clock": pending_clock, "active_clock": pending_clock, "speed": 1, "productions": [{"id": "H", "amount": 7, "resource": true}]}
manager.request_save("checkpoint", "test-password", data)
manager.flush_saves()
check(E.eq(manager.load_data("checkpoint", "test-password").simulation, data.simulation), "Encrypted save preserves requested time and queued production")
var malformed: Dictionary = manager._snapshot("probe", "test-password", data).payload
malformed.simulation.productions[0].id = "missing-entity"
check(manager.validate_data(malformed).contains("queued production"), "Unknown queued production is rejected before resume")
malformed = manager._snapshot("probe", "test-password", data).payload
malformed.simulation.requested_clock.year = -1
check(manager.validate_data(malformed).contains("simulation clock"), "Invalid requested clock is rejected before resume")
data.erase("simulation")
var incompatible_path: String = directory.path_join("incompatible.adventure")
var incompatible = FileAccess.open_encrypted_with_pass(incompatible_path, FileAccess.WRITE, "test-password")
incompatible.store_var({"format_version": E.neg(1), "state": {"unknown": true}}, false)