mirror of
https://github.com/got-feedBack/feedBack.git
synced 2026-09-11 06:54:31 +00:00
test(h3d-carve-4): fix vacuous module-scope check in bc_panel.test.js (Toby r1)
Test 2 used s.indexOf which matched the JSDoc comment at offset 133, not
the real assignment at line 183 — so it passed even with the assignment
indented inside a function.
Fix: s.search(/^window\.h3dBcApplySettings\s*=/m) anchored to line-start.
An indented assignment (inside a function) does not match /^window\./m and
returns -1. Also removed the erroneous firstFnIdx comparison: the assignment
is legitimately after _bcIsDesktop in the file and still at module scope.
Mutation-verify:
indent assignment → node --test tests/js/highway_3d_bc_panel.test.js
not ok 2 (fail 1/11) ✓ RED
restore → node --test tests/js/highway_3d*.test.js plugins/highway_3d/tests/*.test.js
tests 221 pass 221 fail 0 ✓ GREEN
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014uZ169yfoFYArXz962g7KW
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
4e060cbf7b
commit
81b366746e
@@ -60,11 +60,13 @@ test('window.h3dBcApplySettings is assigned at module scope (not inside a functi
|
||||
// Structural check: the assignment must appear BEFORE the first `function`
|
||||
// or `export function` declaration in bc-panel.js (i.e. at module scope).
|
||||
const s = src();
|
||||
const assignIdx = s.indexOf('window.h3dBcApplySettings');
|
||||
const firstFnIdx = s.search(/^(?:export\s+)?function\s+_bc/m);
|
||||
assert.ok(assignIdx >= 0, 'window.h3dBcApplySettings must be assigned in bc-panel.js');
|
||||
assert.ok(firstFnIdx < 0 || assignIdx < firstFnIdx,
|
||||
'window.h3dBcApplySettings must appear before the first _bc* function declaration (module scope)');
|
||||
// Line-anchored regex: `^window.` matches only an unindented assignment.
|
||||
// A comment mention or an indented assignment (inside a function body) both
|
||||
// fail to match and return -1 — so this single check is sufficient.
|
||||
const assignIdx = s.search(/^window\.h3dBcApplySettings\s*=/m);
|
||||
assert.ok(assignIdx >= 0,
|
||||
'window.h3dBcApplySettings must be assigned at line-start (module scope) in bc-panel.js — ' +
|
||||
'an indented assignment (inside a function) would not match /^window\\./m');
|
||||
});
|
||||
|
||||
// ── 3. _bcIsDesktop guards all three required conditions ──────────────────────
|
||||
|
||||
Reference in New Issue
Block a user