Initial project sync

This commit is contained in:
wxm
2026-07-06 22:55:14 -07:00
commit 8cca00d0da
1066 changed files with 58585 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
extends SceneTree
var failures: Array[String] = []
func _init() -> void:
_run.call_deferred()
func _run() -> void:
await process_frame
var bus: Node = load("res://autoload/event_bus.gd").new()
bus.name = "EventBus"
root.add_child(bus)
var manager: Node = load("res://autoload/time_phase_manager.gd").new()
manager.name = "TimePhaseManager"
root.add_child(manager)
await process_frame
var facts: Array = []
bus.connect("time_phase_changed", func(previous: StringName, current: StringName, reason: StringName) -> void:
facts.append([previous, current, reason])
)
_expect_equal(manager.get("current_time_phase"), &"past", "initial time phase should be past")
manager.call("toggle_time_phase", &"time_anchor_broken")
_expect_equal(manager.get("current_time_phase"), &"future", "toggle should switch past to future")
_expect_int(facts.size(), 1, "toggle should broadcast one fact")
if facts.size() == 1:
_expect_equal(facts[0][0], &"past", "fact should carry previous phase")
_expect_equal(facts[0][1], &"future", "fact should carry current phase")
_expect_equal(facts[0][2], &"time_anchor_broken", "fact should carry reason")
manager.call("set_time_phase", &"future", &"debug")
_expect_int(facts.size(), 1, "setting the same phase should not broadcast")
manager.call("set_time_phase", &"bogus", &"debug")
_expect_equal(manager.get("current_time_phase"), &"future", "invalid phase values should be rejected")
_expect_int(facts.size(), 1, "invalid phase values should not broadcast")
manager.call("reset_to_initial", &"past")
_expect_equal(manager.get("current_time_phase"), &"past", "reset_to_initial should apply the initial phase")
_expect_int(facts.size(), 2, "reset that actually switches should broadcast")
if facts.size() == 2:
_expect_equal(facts[1][2], &"chart_init", "reset reason should be chart_init")
manager.call("reset_to_initial", &"past")
_expect_int(facts.size(), 2, "reset to the current phase should not broadcast")
manager.call("reset_to_initial", &"nonsense")
_expect_equal(manager.get("current_time_phase"), &"past", "invalid initial should fall back to past")
_finish()
func _expect_equal(actual: Variant, expected: Variant, label: String) -> void:
if actual != expected:
failures.append("%s: expected %s, got %s" % [label, expected, actual])
func _expect_int(actual: int, expected: int, label: String) -> void:
if actual != expected:
failures.append("%s: expected %d, got %d" % [label, expected, actual])
func _finish() -> void:
if failures.is_empty():
print("PASS time phase manager")
quit(0)
else:
for failure: String in failures:
push_error(failure)
quit(1)