- FSM holds owner via WeakRef; ShiftCoordinator is RefCounted (logic-only); persistence tests free the Save node -> test suite exits with zero 'resources still in use' warnings (was ~13) and 57/57 pass - GameManager uses each scenario's shift_duration_s (900s ~ 10-15 min) for real shifts instead of the 300s test duration - Wand screening gets a 0.8s recharge cooldown with a wand.recharge message - TODO/DONE/MEMORY/README synced
33 lines
1.3 KiB
GDScript
33 lines
1.3 KiB
GDScript
extends RefCounted
|
|
## Headless tests for shift-result persistence (Save autoload, user:// JSON).
|
|
|
|
func _save_instance() -> Object:
|
|
var save_script: GDScript = load("res://src/autoload/save.gd")
|
|
return save_script.new()
|
|
|
|
func test_save_round_trip() -> bool:
|
|
var save := _save_instance()
|
|
var review := {
|
|
"scenario_id": "hollywood_building",
|
|
"reputation": {"rating": 82.5, "grade": "B"},
|
|
"spawned_count": 7,
|
|
"completed_at_ms": Time.get_ticks_msec(),
|
|
}
|
|
var err: int = save.save_shift_result(review)
|
|
var a := TestUtils.check_eq(err, OK, "save succeeds")
|
|
var results: Array = save.load_shift_results()
|
|
var b := TestUtils.check(results.size() > 0, "history non-empty after save")
|
|
var last: Dictionary = results[results.size() - 1]
|
|
var c := TestUtils.check_eq(last.get("scenario_id", ""), "hollywood_building", "round-trips scenario id")
|
|
var d := TestUtils.check_eq(float(last.get("reputation", {}).get("rating", 0.0)), 82.5, "round-trips rating")
|
|
save.free()
|
|
return a and b and c and d
|
|
|
|
func test_load_returns_array_when_empty_or_missing() -> bool:
|
|
# The tester home may already contain results; this only asserts shape safety.
|
|
var save := _save_instance()
|
|
var results: Array = save.load_shift_results()
|
|
var ok := TestUtils.check(results is Array, "load_shift_results always returns Array")
|
|
save.free()
|
|
return ok
|