Fix verify-pass code bugs #317/#318/#319
Three small bugs surfaced by the #314 docstring-accuracy verify pass: #317 automation.scroll() dropped the x of its position argument: scroll() resolved (x, y) but called injectMouseEvent(MouseWheelScrolled, clicks, y), passing the scroll amount as x. injectMouseEvent now takes the scroll delta as its own parameter and scroll() forwards the real x/y. #318 GridView.texture always returned None (a TODO stub). It now returns a Texture wrapper sharing the underlying shared_ptr<PyTexture>, mirroring Grid.texture. (mcrfpy.Grid and mcrfpy.GridView are the same type post-#252, so this fixes both names.) #319 Entity.visible_entities(radius=None) raised TypeError: radius was parsed with the 'i' format code, which rejects None. It now parses radius as an object and treats None / omitted / -1 as "use the grid's default fov_radius"; a non-int, non-None radius raises a clear TypeError. - regression tests for each under tests/regression/ - api_surface snapshot re-baselined (visible_entities signature; texture property now Texture | None) and docs/stubs regenerated; frozen docstring gate still 100% closes #317 closes #318 closes #319 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KnywUddaFRhkxo5kijxJnv
This commit is contained in:
parent
265425321c
commit
98489a96fd
12 changed files with 303 additions and 55 deletions
68
tests/regression/issue_317_scroll_position_test.py
Normal file
68
tests/regression/issue_317_scroll_position_test.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
"""
|
||||
Regression test for issue #317 -- automation.scroll() ignored the x-coordinate
|
||||
of its position argument.
|
||||
|
||||
Root cause: scroll() resolved (x, y) from pos but called
|
||||
injectMouseEvent(MouseWheelScrolled, clicks, y)
|
||||
passing `clicks` as the x argument, so the resolved x was dropped AND the event's
|
||||
mouseWheelScroll.x was set to the scroll amount. The fix gives the scroll delta
|
||||
its own injectMouseEvent parameter and forwards the real x/y.
|
||||
|
||||
LIMITATION: no Python-observable handler currently consumes a scroll event's
|
||||
position (GameEngine maps only the wheel *delta* to a wheel_up/wheel_down action),
|
||||
so this test cannot assert the forwarded x end-to-end. It is therefore a smoke /
|
||||
API-contract regression guard: scroll(clicks, pos=(x, y)) must accept any x, all
|
||||
documented pos forms, and not raise after the injectMouseEvent refactor (which is
|
||||
the part that changed how the scroll delta is passed). The x-forwarding itself is
|
||||
verified by code inspection (McRFPy_Automation.cpp scroll/injectMouseEvent).
|
||||
|
||||
ASCII-only. Prints PASS/FAIL + exit.
|
||||
"""
|
||||
|
||||
import mcrfpy
|
||||
from mcrfpy import automation
|
||||
import sys
|
||||
|
||||
failures = []
|
||||
|
||||
|
||||
def check(label, fn):
|
||||
try:
|
||||
fn()
|
||||
ok = True
|
||||
except Exception as e:
|
||||
ok = False
|
||||
label = "%s (raised %s: %s)" % (label, type(e).__name__, e)
|
||||
if not ok:
|
||||
failures.append(label)
|
||||
print((" ok " if ok else " FAIL ") + label)
|
||||
|
||||
|
||||
# A scene must be current for event injection to have a target.
|
||||
scene = mcrfpy.Scene("issue317")
|
||||
mcrfpy.current_scene = scene
|
||||
|
||||
# Vary x across the position argument; previously x was silently dropped.
|
||||
check("scroll(3) no position", lambda: automation.scroll(3))
|
||||
check("scroll(3, pos=None)", lambda: automation.scroll(3, pos=None))
|
||||
check("scroll(3, (100, 50)) tuple x!=0", lambda: automation.scroll(3, (100, 50)))
|
||||
check("scroll(-2, (0, 50)) x==0", lambda: automation.scroll(-2, (0, 50)))
|
||||
check("scroll(1, [250, 75]) list", lambda: automation.scroll(1, [250, 75]))
|
||||
check("scroll(5, pos=(640, 480)) keyword", lambda: automation.scroll(5, pos=(640, 480)))
|
||||
check("scroll(-5, mcrfpy.Vector(12, 34)) Vector",
|
||||
lambda: automation.scroll(-5, mcrfpy.Vector(12, 34)))
|
||||
|
||||
# Same y, different x must both be accepted (the regression dropped x entirely).
|
||||
check("scroll(2, (10, 200))", lambda: automation.scroll(2, (10, 200)))
|
||||
check("scroll(2, (900, 200))", lambda: automation.scroll(2, (900, 200)))
|
||||
|
||||
|
||||
print("")
|
||||
if failures:
|
||||
print("FAIL -- %d check(s) failed:" % len(failures))
|
||||
for f in failures:
|
||||
print(" - " + f)
|
||||
sys.exit(1)
|
||||
print("PASS -- automation.scroll accepts a full (x, y) position across all forms "
|
||||
"(x-forwarding verified by code inspection; no observable consumer yet).")
|
||||
sys.exit(0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue