extends SceneTree var failures: Array[String] = [] func _init() -> void: _run.call_deferred() func _run() -> void: var bus_script: Script = load("res://autoload/event_bus.gd") _expect(bus_script != null, "EventBus script should load") if bus_script != null: var legacy_signal := StringName("rhythm" + "_action_requested") var bus: Node = bus_script.new() _expect_int(_signal_arg_count(bus, "judgement_made"), 3, "EventBus.judgement_made should expose quality, offset_ms, beat_index") _expect(not bus.has_signal(legacy_signal), "EventBus should not expose the legacy rhythm action request signal") bus.free() var rhythm_script: Script = load("res://autoload/rhythm_manager.gd") _expect(rhythm_script != null, "RhythmManager script should load") if rhythm_script != null: var legacy_method := StringName("judge" + "_action") var rhythm: Node = rhythm_script.new() _expect(not rhythm.has_method(legacy_method), "RhythmManager should not expose the legacy action judgement method") _expect(_has_property(rhythm, "clock_volume_db"), "RhythmManager should expose clock_volume_db") var rating: Dictionary = rhythm.call("judge", 0.0) _expect(rating.has("nearest_beat"), "RhythmManager.judge should return nearest_beat") _expect(typeof(rating.get("nearest_beat")) == TYPE_INT, "nearest_beat should be an int") rhythm.free() _finish() func _signal_arg_count(node: Node, signal_name: StringName) -> int: for signal_info: Dictionary in node.get_signal_list(): if StringName(str(signal_info.get("name"))) == signal_name: return (signal_info.get("args") as Array).size() return -1 func _has_property(object: Object, property_name: StringName) -> bool: for property: Dictionary in object.get_property_list(): if StringName(str(property.get("name"))) == property_name: return true return false func _expect(condition: bool, label: String) -> void: if not condition: failures.append(label) 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 judgement payload") quit(0) else: for failure: String in failures: push_error(failure) quit(1)