Files
TheTree_mock/tests/run_tests.gd
Takeshi 5dde0c5ec2 Record original-alignment implementation and traceability checkpoint
Capture current source, content data, tests, asset licenses, and original-specification traceability. Original implementation remains incomplete. The accepted matching UI generation passed 154 suites and 12,253 checks, with eight rendered staff-contract screens reviewed. Latest native Windows and full-original acceptance remain outstanding.
2026-09-30 23:52:24 +09:00

81 lines
2.9 KiB
GDScript

extends SceneTree
var _failures := 0
var _checks := 0
func _initialize() -> void:
call_deferred("_run")
func _run() -> void:
print("The Tree: automated checks")
_test_game_clock()
_test_original_clock_scale()
_test_game_state()
_test_facility_data()
load("res://tests/s0/test_kernel_and_save.gd").run(Callable(self, "_expect"))
if _failures == 0:
print("PASS: %d checks" % _checks)
else:
push_error("FAIL: %d of %d checks failed" % [_failures, _checks])
quit(_failures)
func _test_game_clock() -> void:
var clock = load("res://autoload/game_clock.gd").new()
clock.reset(1, 6, 0)
_expect(clock.get_phase() == clock.Phase.MORNING, "06:00 is morning")
clock.advance_minutes(4 * 60)
_expect(clock.get_hour() == 10, "clock advances to 10:00")
_expect(clock.get_phase() == clock.Phase.DAY, "10:00 is day phase")
clock.set_speed(3)
_expect(clock.speed == 3, "clock accepts the original x3 speed")
clock.set_speed(4)
_expect(clock.speed == 3, "clock rejects unsupported x4")
_expect(clock.REAL_SECONDS_PER_GAME_HOUR == 10.0, "original scale is ten seconds per game hour")
clock.advance_minutes(14 * 60)
_expect(clock.day == 2 and clock.get_hour() == 0, "midnight starts the next day")
clock.free()
func _test_original_clock_scale() -> void:
var clock := SimulationKernel.new()
for multiplier: int in [1, 2, 3]:
clock.reset()
clock.set_speed(multiplier)
for frame in 600:
clock.process_real_delta(1.0 / 60.0)
_expect(clock.absolute_minute == 360 + 60 * multiplier, "ten real seconds produce one hour at x%d" % multiplier)
clock.set_paused(true)
var minute := clock.absolute_minute
clock.process_real_delta(10.0)
_expect(clock.absolute_minute == minute, "pause preserves game time")
var legacy := clock.clock_snapshot()
legacy[&"speed"] = 4
_expect(clock.restore_clock(legacy) and clock.speed == 3, "legacy x4 resumes at x3")
clock.free()
func _test_game_state() -> void:
var state = load("res://autoload/game_state.gd").new()
state.reset()
_expect(state.can_afford({&"gold": 500, &"materials": 5}), "default resources can afford starter room")
_expect(state.spend({&"gold": 500, &"materials": 5}), "spending succeeds")
_expect(state.get_resource(&"gold") == 4500, "gold is deducted atomically")
_expect(not state.spend({&"mana": 1000}), "overspending is rejected")
state.free()
func _test_facility_data() -> void:
var catalog_script = load("res://scripts/data/facility_catalog.gd")
var facilities: Array = catalog_script.load_all()
_expect(facilities.size() == 16, "MVP facility catalog loads all baseline definitions")
var seen_ids := {}
for facility in facilities:
_expect(facility.is_valid(), "%s has valid data" % facility.resource_path)
_expect(not seen_ids.has(facility.id), "%s has a unique id" % facility.id)
seen_ids[facility.id] = true
func _expect(condition: bool, label: String) -> void:
_checks += 1
if condition:
print(" ✓ %s" % label)
return
_failures += 1
push_error(" ✗ %s" % label)