test(h3d-carve-5): fix test 14 defined-set to full identifier scan

Toby r2 finding: the declaration-only regex only captured the first
variable from multi-var let statements. bg-control.js lines 81-88 have
a single let with 8 state symbols (_pcEl, _pcSel, _pcReactive, _pcIntensity,
_pcIntensityWrap, _pcReason, _pcRetry, _pcRetryTimer); 7 of 8 were
invisible to the guard, so a bare _pcEl ref in screen.js escaped all tests.

Fix: replace the declaration-pattern matchAll with a full identifier
scan (/\b(_pc\w+)\b/g). Every _pc* word in bg-control.js lands in
`defined`; the privateSymbols filter (excluding destructured public API)
is unchanged.

Mutation-verified RED:
  _pcEl.remove() injected in screen.js → not ok 14, fail 1 (Toby's mutant)
  _pcSync() injected in screen.js      → not ok 14, fail 1 (Mut B, still works)
Suite: 236/236.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014uZ169yfoFYArXz962g7KW
This commit is contained in:
byrongamatos
2026-09-05 09:49:23 +02:00
co-authored by Claude Sonnet 4.6
parent 97799fff37
commit 90283f9d3a
+5 -3
View File
@@ -256,10 +256,12 @@ test('no private bg-control.js symbol appears bare in screen.js IIFE body', () =
const bgSrc = src();
const scrSrc = screenSrc();
// All _pc* symbols defined in bg-control.js (functions, lets, consts).
// All _pc* identifiers in bg-control.js. Full scan (not just declaration
// syntax) so multi-var lets like `let _pcEl, _pcSel, _pcReactive, ...`
// on a single line are all captured — the previous declaration-only regex
// only matched the first id per statement.
const defined = new Set(
[...bgSrc.matchAll(/\bfunction\s+(_pc\w+)|(?:let|const)\s+(_pc\w+)/g)]
.map(m => m[1] || m[2])
[...bgSrc.matchAll(/\b(_pc\w+)\b/g)].map(m => m[1])
);
// Public symbols (in the destructure) are legitimately referenced in screen.js.