Fix --exec interactive prompt bug and create comprehensive test suite

Major fixes:
- Fixed --exec entering Python REPL instead of game loop
- Resolved screenshot transparency issue (requires timer callbacks)
- Added debug output to trace Python initialization

Test suite created:
- 13 comprehensive tests covering all Python-exposed methods
- Tests use timer callback pattern for proper game loop interaction
- Discovered multiple critical bugs and missing features

Critical bugs found:
- Grid class segfaults on instantiation (blocks all Grid functionality)
- Issue #78 confirmed: Middle mouse click sends 'C' keyboard event
- Entity property setters have argument parsing errors
- Sprite texture setter returns improper error
- keypressScene() segfaults on non-callable arguments

Documentation updates:
- Updated CLAUDE.md with testing guidelines and TDD practices
- Created test reports documenting all findings
- Updated ROADMAP.md with test results and new priorities

The Grid segfault is now the highest priority as it blocks all Grid-based functionality.
This commit is contained in:
John McCardle 2025-07-03 19:25:49 -04:00
commit 18cfe93a44
36 changed files with 2386 additions and 13 deletions

View file

@ -0,0 +1,69 @@
#!/usr/bin/env python3
"""Test for Sprite texture methods - Related to issue #19"""
import mcrfpy
print("Testing Sprite texture methods (Issue #19)...")
# Create test scene
mcrfpy.createScene("sprite_texture_test")
mcrfpy.setScene("sprite_texture_test")
ui = mcrfpy.sceneUI("sprite_texture_test")
# Create sprites
# Based on sprite2 syntax: Sprite(x, y, texture, sprite_index, scale)
sprite1 = mcrfpy.Sprite(10, 10, mcrfpy.default_texture, 0, 2.0)
sprite2 = mcrfpy.Sprite(100, 10, mcrfpy.default_texture, 5, 2.0)
ui.append(sprite1)
ui.append(sprite2)
# Test getting texture
try:
texture1 = sprite1.texture
texture2 = sprite2.texture
print(f"✓ Got textures: {texture1}, {texture2}")
if texture2 == mcrfpy.default_texture:
print("✓ Texture matches default_texture")
except Exception as e:
print(f"✗ Failed to get texture: {e}")
# Test setting texture (Issue #19 - get/set texture methods)
try:
# This should fail as texture is read-only currently
sprite1.texture = mcrfpy.default_texture
print("✗ Texture setter should not exist (Issue #19)")
except AttributeError:
print("✓ Texture is read-only (Issue #19 requests setter)")
except Exception as e:
print(f"✗ Unexpected error setting texture: {e}")
# Test sprite_number property
try:
print(f"Sprite2 sprite_number: {sprite2.sprite_number}")
sprite2.sprite_number = 10
print(f"✓ Changed sprite_number to: {sprite2.sprite_number}")
except Exception as e:
print(f"✗ sprite_number property failed: {e}")
# Test sprite index validation (Issue #33)
try:
# Try to set invalid sprite index
sprite2.sprite_number = 9999
print("✗ Should validate sprite index against texture range (Issue #33)")
except Exception as e:
print(f"✓ Sprite index validation works: {e}")
# Create grid of sprites to show different indices
y_offset = 100
for i in range(12): # Show first 12 sprites
sprite = mcrfpy.Sprite(10 + (i % 6) * 40, y_offset + (i // 6) * 40,
mcrfpy.default_texture, i, 2.0)
ui.append(sprite)
caption = mcrfpy.Caption(mcrfpy.Vector(10, 200),
text="Issue #19: Sprites need texture setter",
fill_color=mcrfpy.Color(255, 255, 255))
ui.append(caption)
print("PASS")