Files
2026-07-06 22:59:47 -07:00

76 lines
2.5 KiB
GDScript

extends SceneTree
var failures: Array[String] = []
func _init() -> void:
_run.call_deferred()
func _run() -> void:
var combo_script: Script = load("res://scenes/components/combo_window.gd")
_expect(combo_script != null, "ComboWindow script should load")
if combo_script == null:
_finish()
return
var combo: Node = combo_script.new()
root.add_child(combo)
await process_frame
combo.set("size", 4)
combo.call("record", &"A")
combo.call("record", &"Ø")
combo.call("record", &"SP")
_expect_array(combo.call("get_slots"), [&"A", &"Ø", &"SP"], "ComboWindow should preserve visible miss slots")
_expect_string(str(combo.call("get_pattern")), "ASP", "get_pattern should ignore miss placeholders")
_expect_string(str(combo.call("get_contiguous_pattern")), "SP", "contiguous pattern should not cross miss placeholders")
_expect_bool(bool(combo.call("has_pending_clear")), false, "three slots should not request full clear")
combo.call("clear", &"reset")
for symbol: StringName in [&"A", &"D", &"W", &"S"]:
combo.call("record", symbol)
_expect_array(combo.call("get_slots"), [&"A", &"D", &"W", &"S"], "fourth input should remain visible before clear")
_expect_bool(bool(combo.call("has_pending_clear")), true, "fourth input should queue full clear")
_expect_string(str(combo.call("consume_pending_clear_reason")), "full", "fourth input clear reason")
combo.call("queue_clear", &"full", 0.001)
combo.call("flush_pending_clear")
_expect_array(combo.call("get_slots"), [], "flush_pending_clear should clear full window")
combo.call("record", &"A")
combo.call("record", &"A")
combo.call("clear", &"skill:ground_attack_left_2")
_expect_array(combo.call("get_slots"), [], "successful skill clear should empty slots")
combo.free()
_finish()
func _expect(condition: bool, label: String) -> void:
if not condition:
failures.append(label)
func _expect_bool(actual: bool, expected: bool, label: String) -> void:
if actual != expected:
failures.append("%s: expected %s, got %s" % [label, expected, actual])
func _expect_array(actual: Array, expected: Array, label: String) -> void:
if actual != expected:
failures.append("%s: expected %s, got %s" % [label, expected, actual])
func _expect_string(actual: String, expected: String, label: String) -> void:
if actual != expected:
failures.append("%s: expected %s, got %s" % [label, expected, actual])
func _finish() -> void:
if failures.is_empty():
print("PASS combo window")
quit(0)
else:
for failure: String in failures:
push_error(failure)
quit(1)