| English | Português (Brasil) |
This document provides a comprehensive semantic coverage map across all 35 implemented subsystems in NES Pascal. It catalogs the current automated test protection across compiler phases, diagnostics, static assembly goldens, toolchain builds, Mesen emulator runtime verification, benchmark corpus measurement, and documentation/examples.
The matrix uses semantic verification tiers:
| # | Subsystem | Lexer / Parser | Semantic Analysis | Diagnostics & Fixtures | Memory Layout | Backend ASM | Golden ASM | Toolchain (ca65/ld65) | Mesen Runtime | Benchmark Corpus | Notes |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Variables & scalar types | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | byte, boolean, nes_color |
| 2 | Constants (const) |
Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Inline immediate values |
| 3 | Arithmetic (+, -) | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | 8-bit wrap, unary/binary |
| 4 | Relational comparisons | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Direct flag branching |
| 5 | Boolean expressions | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | not, and, or, short-circuit |
| 6 | Conditionals (if/else) |
Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Nested branches |
| 7 | Loops (while, repeat) |
Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Condition-controlled |
| 8 | Counting & loop control | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | for, inc, dec, break, continue |
| 9 | Procedures | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Parameterless, acyclic calls |
| 10 | Procedure parameters | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | byte/boolean value params |
| 11 | Definite assignment | N/A | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Rejection of uninitialized reads |
| 12 | Zero Page allocation | N/A | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Promotion threshold & fallback |
| 13 | Runtime memory layout | N/A | N/A | Strong | Strong | Strong | Strong | Strong | Strong | Strong | 2 KiB physical reconciliation |
| 14 | NMI & frame sync | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | nes.wait_frame, frame counter |
| 15 | Frame callbacks | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | nes.on_update, nes.on_vblank |
| 16 | Controller input | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Dual-port polling, button queries |
| 17 | CHR-ROM asset loading | N/A | Strong | Strong | Strong | Strong | Missing | Strong | Strong | Missing | --chr validation (8 KiB exact) |
| 18 | Nametable loading | Strong | Strong | Strong | Strong | Strong | Missing | Strong | Strong | Missing | Full raw 1 KiB upload |
| 19 | Runtime BG updates | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | 4-write VBlank queue, tile shadow; golden: queue traversal, PPU write, cancel-lock, shadow confirm |
| 20 | Palette management | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | 32-byte shadow, VBlank uploader; golden: dirty-flag loop, triplet PPU write, $3F/$2006 latch |
| 21 | Scrolling & PPU state | Strong | Strong | Strong | Strong | Strong | Missing | Strong | Strong | Strong | Scroll staging, latch restore; type fixtures for both arg positions |
| 22 | Basic hardware sprites | Strong | Strong | Strong | Strong | Strong | Missing | Strong | Strong | Strong | 64-entry OAM shadow, NMI DMA |
| 23 | Sprite management | Strong | Strong | Strong | Strong | Strong | Missing | Strong | Strong | Strong | Static 64-slot pool reservation |
| 24 | Metasprites | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Anchor geometry, flipping, clipping; golden: renderer loop, OAM shadow writes, inline DMA |
| 25 | Sprite animation | Strong | Strong | Strong | Strong | Strong | Missing | Strong | Strong | Strong | Sequences, timers, frame advance |
| 26 | Builtin infrastructure | Strong | Strong | Strong | Strong | Strong | Partial | Strong | Strong | Strong | Unified registry & validation |
| 27 | Low-risk codegen opts | N/A | N/A | N/A | Strong | Strong | Strong | Strong | Strong | Strong | Direct operands, flag branching |
| 28 | Arrays | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Fixed 1D, indexed access, boundaries |
| 29 | Enumerations | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Nominal one-byte types, exact-type equality and inequality |
| 30 | Records | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Nominal fixed layouts, typed fields, record arrays |
| 31 | Expression temporary allocation | N/A | N/A | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Scoped maximum-live pool, cache separation, exhaustion |
| 32 | Functions | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Typed returns, definite result, acyclic nested calls, call-safe temporaries |
| 33 | Collision helpers | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Half-open AABB, sprite/metasprite bounds, packed immutable map, wrap-safe edges |
| 34 | Random number generation | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Strong | Deterministic LFSR, bounded ranges, explicit/automatic seed |
| 35 | Game-state composition | Strong | Strong | N/A | Strong | Strong | Strong | Strong | Strong | Strong | Enum dispatch, explicit transitions/reset, pause and restart lifecycle |
--chr) — ✅ Resolved (P1): verify_chr_asset.lua now reads all 8 192 PPU pattern-table bytes ($0000–$1FFF) via emu.read(..., emu.memType.nesPpuDebug) and asserts the complete deterministic pattern from chr_asset.chr, including the unique terminal marker ($0A) at offset $1FFF.arithmetic.nsp, boolean_expressions.nsp, and conditionals.nsp do not have dedicated individual .lua scripts; however, their runtime behavior is thoroughly asserted transitively by verify_low_risk_codegen.lua, verify_arrays.lua, and verify_counting.lua.verify_chr_asset.lua now asserts the correct CHR pattern in the emulated PPU pattern table at runtime.invalid_set_scroll_x_type.nsp, invalid_set_scroll_y_type.nsp) now explicitly assert that passing a boolean to the x or y argument of nes.set_scroll raises E4004 (type mismatch) and that E3046 (argument count) does not take precedence.chr_asset (standalone CHR embedding)scrolling_ppu_state (scroll staging & mirroring)nametable_loading (raw startup nametable transfer)slow_update_callback (lag-frame coalescing)frame_synchronization (standalone loop synchronization)zero_page / memory_layout (pure layout benchmarks, although all benchmarks report memory layouts)ToolchainIntegrationTests.test_all_public_examples_assemble_and_link discovers every .nsp in examples/ and compiles, assembles, and links it with the required assets. This includes random_numbers.nsp and the complete game_state.nsp reference; focused tests and the benchmark corpus provide additional coverage.tests/golden/minimal.asm, tests/golden/memory_layout.asm, tests/golden/zero_page.asm, and tests/golden/frame_synchronization.asm capture complete generated assembly files.tests/test_backend.py check specific assembly comment formatting or temporary symbol names (expression_temporary_0). Behavior-oriented tests in test_backend_optimizations.py, test_arrays.py, test_records.py, and test_integration.py appropriately assert observable instruction sequences, memory allocations, and hardware state.tests/test_integration.py currently houses three distinct concerns:
ca65/ld65 build validation, ROM headers, CLI parameters).asm fixtures)test_parses_all_milestone_three_variable_types was identified and renamed to test_parses_scalar_and_color_variable_types.examples/metasprite_clipping.nsp) vs headless unit fixture (tests/fixtures/runtime/metasprite_clipping.nsp) serve distinct purposes (visual demo vs fast headless validation) and are now clearly documented.--chr)tests/mesen/verify_chr_asset.lua — reads all 8 192 PPU pattern-table bytes ($0000–$1FFF) via emu.memType.nesPpuDebug and verifies the deterministic pattern from examples/assets/chr_asset.chr, including the unique terminal byte $0A at $1FFF.MesenIntegrationTests.test_chr_asset_is_visible_in_ppu_pattern_tables in tests/test_integration.py.nes.set_scroll argument types (resolved):
tests/fixtures/diagnostics/invalid_set_scroll_x_type.nsp and invalid_set_scroll_y_type.nsp.test_boolean_x_argument_fixture_emits_type_diagnostic_not_argument_count and test_boolean_y_argument_fixture_emits_type_diagnostic_not_argument_count in tests/test_scrolling_ppu_state.py, each asserting E4004 and confirming E3046 does not take precedence.tests/golden/palette_support.asm — full-file golden for examples/palette_support.nsp; protects runtime_upload_queued_palettes dirty-flag loop, runtime_upload_palette_triplet PPU write sequence ($3F/$2006 latch, 3-byte shadow loop), NMI callsite order.tests/golden/background_updates.asm — full-file golden from the stable BackgroundUpdates test fixture; protects runtime_upload_queued_background cancel-lock guard, 4-slot loop, PPU $2006/$2007 writes, shadow confirmation, runtime_queue_background_write slot-find, overflow flag, atomic publication.tests/golden/metasprite_player.asm — full-file golden for examples/metasprite_player.nsp; protects runtime_metasprite_render component iteration, OAM shadow writes, anchor arithmetic, clip checks, flip encoding, inline OAM DMA (sta $4014) in NMI, frame geometry tables.test_palette_support_program_matches_golden_assembly, test_background_updates_program_matches_golden_assembly, test_metasprite_player_program_matches_golden_assembly in tests/test_backend.py::BackendGoldenTests.scrolling_ppu_state in benchmark corpus (resolved):
BenchmarkSpec("scrolling_ppu_state", "Scrolling and PPU State", "examples/scrolling_ppu_state.nsp") in tools/measure_benchmarks.py.ScrollingBenchmarkTests.test_scrolling_ppu_state_benchmark_reports_focused_resource_accounting in tests/test_scrolling_ppu_state.py asserts stable PRG, instruction count, cycle estimate, ZP/RAM accounting, and runtime feature set.tests/test_integration.py into focused test suites:
test_toolchain.py, test_goldens.py, test_mesen_runtime.py).[P1 ✅] verify_chr_asset.lua).tests/mesen/verify_chr_asset.lua validates all 8 192 PPU pattern-table bytes at runtime.[P1 ✅] nes.set_scroll argument types.invalid_set_scroll_x_type.nsp and invalid_set_scroll_y_type.nsp fixtures with test assertions for E4004 in both argument positions.[P2 ✅] scrolling_ppu_state benchmark spec to tools/measure_benchmarks.py.scrolling_ppu_state is now in the benchmark corpus with a dedicated focused resource-accounting regression test.[P2 ✅] tests/golden/palette_support.asm, tests/golden/background_updates.asm, and tests/golden/metasprite_player.asm added with three focused BackendGoldenTests in tests/test_backend.py.[P2] Separate tests/test_integration.py into test_toolchain.py, test_goldens.py, and test_mesen.py.[P3] Clean up legacy test naming and docstring conventions.