Concepts
Behavior-preserving refactoring
Verify a refactored implementation against independently specified public behavior, not merely against old code.
Formal Syntax & Structure
javascript syntaxjavascript
assert.deepStrictEqual(refactored(input), expected)Working Example
Example Snippetjavascript
(async () => {const assert=require("node:assert/strict");const valid=n=>Number.isInteger(n)&&n>=0;const clean=rows=>rows.filter(valid);assert.deepStrictEqual(clean([0,-1,3,1.5]),[0,3]);console.log(JSON.stringify(clean([0,-1,3,1.5])));})()