Name a stray random pointer in browser runners
JavaScript and Python failed a list copy that leaves random on the original node without saying why: the JavaScript serializer printed -1 for each such pointer and the Python one raised a bare ValueError from list.index, while the C, C++ and Java harnesses already refuse it with "Returned random pointer must stay inside the copied list." Both browser runners now check random before the index lookup and refuse it with that same text. A correct deep copy still passes, and returning an original node still fails with "Returned list must be a deep copy."
The first commit adds the browser-check cases, which run that solution in JavaScript and Python and expect the message; on its own it fails at scripts/browser-check.cjs:1504. The second adds the check to both runners and the source assertions beside the C and C++ ones in tests/browser/compiler-explorer.test.js.
Validation on Windows 11, over 4faffce:
BROWSER_CHECK_AGENT=offline scripts/browser-check.shpasses at the second commit and fails at the first on the JavaScript case. Both runs skippedcheckWhiteboardInterview, which fails on this machine with "the board could not be cleared after drawing" before these cases are reached.node --test tests/browser/compiler-explorer.test.js tests/browser/runners.test.js: 65 pass, 3 skipped for want ofjavac. The new assertion fails without the runner change.- Not observed: the Python case failing before the change, since the run stops at the JavaScript case first.
scripts/test.shis not green on this Windows machine.face-detector, the lobby height test andgen-wire-fixtures.mjsfail the same way on unmodifiedmainhere, and the other failing gates touch none of these files.
Closes #364
Summary by cubic
JavaScript and Python browser runners now reject a random pointer left on the original list in Copy List with Random Pointer, matching the C, C++, and Java harnesses instead of printing -1 or raising a bare ValueError.
- Both runners throw
TypeError("Returned random pointer must stay inside the copied list.")before indexing the copied nodes; a correct deep copy, including one with nullrandompointers, still passes. - Browser checks now run the faulty solution in both languages, and source assertions enforce the same message beside the existing harness ones.