McRogueFace/tests/unit/test_timer_callback.py

27 lines
784 B
Python
Raw Normal View History

#!/usr/bin/env python3
"""
2026-01-03 22:44:53 -05:00
Test timer callback arguments with new Timer API (#173)
"""
import mcrfpy
import sys
call_count = 0
2026-01-03 22:44:53 -05:00
def new_style_callback(timer, runtime):
"""New style callback - receives timer object and runtime"""
global call_count
call_count += 1
2026-01-03 22:44:53 -05:00
print(f"Callback called with: timer={timer} (type: {type(timer)}), runtime={runtime} (type: {type(runtime)})")
if hasattr(timer, 'once'):
print(f"Got Timer object! once={timer.once}")
if call_count >= 2:
2026-01-03 22:44:53 -05:00
print("PASS")
sys.exit(0)
# Set up the scene
2026-01-03 22:44:53 -05:00
test_scene = mcrfpy.Scene("test_scene")
2026-01-03 10:59:52 -05:00
test_scene.activate()
2026-01-03 22:44:53 -05:00
print("Testing new Timer callback signature (timer, runtime)...")
timer = mcrfpy.Timer("test_timer", new_style_callback, 100)
print(f"Timer created: {timer}")