Concepts

Table-driven boundary tests

Try the free JavaScript compiler

Test selected inputs from the stated contract using independent expected values.

Formal Syntax & Structure

javascript syntaxjavascript
for (const [input, expected] of cases) { assert.strictEqual(fn(input), expected); }

Working Example

Example Snippetjavascript
(async () => {const assert=require("node:assert/strict");const valid=n=>Number.isInteger(n)&&n>=0&&n<=10;const cases=[[-1,false],[0,true],[10,true],[11,false],[1.5,false]];for(const [n,want] of cases)assert.strictEqual(valid(n),want);console.log(cases.length);})()
JavaScript Reference