McRogueFace/tests/regression
John McCardle 2d2c333cd7 Refactor UIEntity::grid to shared_ptr<GridData>; add entity.texture; closes #313
UIEntity now depends on the grid DATA layer only:
- GridData gains cell_width_px/cell_height_px (mirrored from the grid
  texture in UIGrid's 5-arg ctor; texture is write-once) so entity
  tile<->pixel math no longer reaches into rendering (getTexture()).
- GridData gains markDirty()/markCompositeDirty(): set the flag on the
  UIGrid subobject AND notify owning_view, covering both render paths.
  UIGrid disambiguates via 'using UIDrawable::markDirty' so all
  pre-existing UIGrid-receiver calls resolve exactly as before.
- The three Python wrappers that still need the full UIGrid (GridPoint
  from entity.at(), the _GridData fallback in get_grid, find_path's temp
  wrapper) reconstruct it via a single aliasing-downcast helper
  (grid_as_uigrid) that documents the never-independently-allocated
  GridData invariant; init/set_grid simplify (share grid_data directly).
  Removing the casts is deferred to #252.

entity.texture (new, frozen surface +1): thin get/set over the entity's
own UISprite. Entities render with their OWN texture (default_texture
fallback at construction); the grid's texture only determines cell size.
Setter preserves sprite_index; rejects non-Texture (TypeError),
null-data Texture wrappers (ValueError), and deletion.

Adversarial review fixes folded in:
- set_texture/get_texture guard uninitialized Entity wrappers
  (RuntimeError), isinstance errors, and null-data Textures.
- PyUIGridViewType tp_dealloc no longer unconditionally severs
  GridData::owning_view: gated on last-owner (#251 use_count pattern)
  plus owning-view identity. Previously ANY Grid wrapper GC while the
  view lived (e.g. scene.children.append(mcrfpy.Grid(...))) silently
  broke entity.grid -> Grid identity and data-layer dirty notification.

Tests: tests/regression/issue_313_entity_grid_data_test.py (texture
semantics, grid-cell-size invariance, entity.grid identity, #251 gate
survival, GridPoint outliving teardown, review-fix guards, owning_view
survival) + tests/unit/entity_texture_test.py. API snapshot golden
re-baselined: exactly +1 surface line (Entity.texture) + writability
probe flip. Docs/stubs regenerated. Native + Emscripten builds verified.

Known edges recorded in docs/api-audit-2026-04.md: texture read-back is
a fresh wrapper each get (no Texture __eq__); sprite_index not
re-validated against a new atlas. Multi-view markDirty broadcast and
pure-GridData wrappers remain deferred to #252. Addresses #314.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 00:51:22 -04:00
..
frame_children_mutation_test.py Add regression tests for Frame.children mutation and parent=None removal 2026-04-01 11:27:47 -04:00
grid_backward_compat_test.py Phase 4.3: Grid auto-creates GridView with rendering property sync 2026-03-19 11:24:47 -04:00
issue_9_rendertexture_resize_test.py Test suite modernization 2026-02-09 08:15:18 -05:00
issue_37_simple_test.py update tests: new scene API 2026-01-03 10:59:52 -05:00
issue_76_test.py Test suite modernization 2026-02-09 08:15:18 -05:00
issue_79_color_properties_test.py Test suite modernization 2026-02-09 08:15:18 -05:00
issue_99_texture_font_properties_test.py Test suite modernization 2026-02-09 08:15:18 -05:00
issue_123_chunk_system_test.py Test suite modernization 2026-02-09 08:15:18 -05:00
issue_146_fov_returns_none.py Test suite modernization 2026-02-09 08:15:18 -05:00
issue_147_grid_layers.py Test suite modernization 2026-02-09 08:15:18 -05:00
issue_148_layer_dirty_flags.py Test suite modernization 2026-02-09 08:15:18 -05:00
issue_176_entity_position_test.py Phase 2: Entity data model extensions for behavior system 2026-03-15 22:05:06 -04:00
issue_177_gridpoint_grid_pos_test.py Test suite modernization 2026-02-09 08:15:18 -05:00
issue_179_181_grid_vectors_test.py Remove redundant Grid.position alias, keep only Grid.pos, closes #308 2026-04-09 22:18:30 -04:00
issue_180_timer_orphan_test.py Organize test suite: add README, move loose tests to proper directories 2026-01-21 21:34:22 -05:00
issue_180_timer_stopped_test.py Organize test suite: add README, move loose tests to proper directories 2026-01-21 21:34:22 -05:00
issue_182_caption_size_test.py Organize test suite: add README, move loose tests to proper directories 2026-01-21 21:34:22 -05:00
issue_183_parent_quirks_test.py tests for the last few issues (these test scripts should work with recent APIs, while the rest of the test suite needs an overhaul) 2026-01-08 10:31:21 -05:00
issue_184_189_module_test.py Organize test suite: add README, move loose tests to proper directories 2026-01-21 21:34:22 -05:00
issue_185_188_bounds_test.py Organize test suite: add README, move loose tests to proper directories 2026-01-21 21:34:22 -05:00
issue_190_layer_docs_test.py Test suite modernization 2026-02-09 08:15:18 -05:00
issue_212_to_217_test.py Add input validation and fix Entity repr 2026-01-16 19:18:27 -05:00
issue_223_clip_children_test.py Fix UIFrame RenderTexture positioning and toggling issues 2026-01-22 22:54:50 -05:00
issue_251_callback_gc_test.py Fix callback/timer GC: prevent premature destruction of Python callbacks 2026-02-19 20:53:50 -05:00
issue_251_timer_gc_test.py Fix callback/timer GC: prevent premature destruction of Python callbacks 2026-02-19 20:53:50 -05:00
issue_253_spatial_hash_test.py Phase 1: Safety & performance foundation for Grid/Entity overhaul 2026-03-15 21:48:24 -04:00
issue_254_tilelayer_texture_test.py Phase 1: Safety & performance foundation for Grid/Entity overhaul 2026-03-15 21:48:24 -04:00
issue_256_animation_spatial_hash_test.py Update spatial hash in animation setProperty for entity position, closes #256 2026-04-10 01:40:29 -04:00
issue_258_gridstate_resize_test.py Fix gridstate heap overflows and spatial hash cleanup 2026-03-07 22:56:16 -05:00
issue_264_gridpoint_dangle_test.py Convert raw pointers to coordinate-based access (closes #264, closes #265) 2026-03-07 23:30:32 -05:00
issue_266_entity_lifecycle_test.py Remove entity self-reference cycle 2026-03-07 23:22:58 -05:00
issue_266_subclass_identity_test.py Preserve Python subclass identity for entities in grids (reopens #266) 2026-03-09 00:24:26 -04:00
issue_267_275_refcount_test.py Add regression tests for GridPointState dangle and refcount leaks, refs #287 2026-04-10 02:06:10 -04:00
issue_268_vector_null_test.py Add regression tests for vector NULL safety and uniform owner validity, closes #287 2026-04-10 02:57:32 -04:00
issue_270_277_parent_grid_dangle_test.py Null parent_grid pointers in GridData destructor, closes #270, closes #271, closes #277 2026-04-10 01:34:33 -04:00
issue_272_uniform_owner_test.py Add regression tests for vector NULL safety and uniform owner validity, closes #287 2026-04-10 02:57:32 -04:00
issue_273_die_during_iteration_test.py Add regression test for entity.die() during iteration, refs #273 2026-04-10 01:45:23 -04:00
issue_274_set_grid_spatial_hash_test.py Add missing spatial_hash.insert() in set_grid() grid transfer, closes #274 2026-04-10 01:45:18 -04:00
issue_288_291_dirty_flags_test.py Add missing markDirty()/markCompositeDirty() to all Python property setters 2026-04-10 01:01:41 -04:00
issue_292_fov_dedup_test.py Phase 1: Safety & performance foundation for Grid/Entity overhaul 2026-03-15 21:48:24 -04:00
issue_294_perspective_map_test.py Replace UIEntity gridstate with DiscreteMap perspective_map; closes #294 2026-04-17 23:04:27 -04:00
issue_295_cell_pos_test.py Phase 2: Entity data model extensions for behavior system 2026-03-15 22:05:06 -04:00
issue_307_color_eq_test.py Fix audit type count (44->46) and add regression test for Color __eq__, refs #307 2026-04-09 21:45:12 -04:00
issue_309_caption_numeric_setter_test.py Clamp Caption numeric setters to prevent UBSan float->uint UB 2026-04-16 23:31:58 -04:00
issue_310_compute_fov_enum_test.py Route Grid.compute_fov algorithm through PyFOV::from_arg 2026-04-16 23:32:09 -04:00
issue_311_dijkstra_bounds_test.py Bounds-check DijkstraMap coordinates at the Python boundary 2026-04-16 23:32:19 -04:00
issue_313_entity_grid_data_test.py Refactor UIEntity::grid to shared_ptr<GridData>; add entity.texture; closes #313 2026-06-11 00:51:22 -04:00
issue_315_path_provider_test.py Refactor EntityBehavior SEEK/FLEE to use PathProvider strategy; refs #315 2026-04-18 09:19:05 -04:00
issue_callback_refcount_test.py Simplify on_enter/on_exit callbacks to position-only signature 2026-01-28 17:36:02 -05:00
parent_none_removal_test.py Add regression tests for Frame.children mutation and parent=None removal 2026-04-01 11:27:47 -04:00
recursive_animation_callback_segfault.py fix: animations modifying animations during callback is now safe 2026-02-04 10:25:59 -05:00
subclass_callback_segfault_test.py Remove legacy string enum comparisons from InputState/Key/MouseButton, closes #306 2026-04-09 22:19:02 -04:00
test_type_preservation_solution.py Test suite modernization 2026-02-09 08:15:18 -05:00