Skip to content

Instantly share code, notes, and snippets.

@andremalan
Last active July 15, 2020 23:05
Show Gist options
  • Save andremalan/df39d4ef0714298d39acc0e9f442323f to your computer and use it in GitHub Desktop.
Save andremalan/df39d4ef0714298d39acc0e9f442323f to your computer and use it in GitHub Desktop.
A test harness for code pad like environments.
let tests = [
[Math.max(1, 3), 3, 'can pass'],
[Math.max(1, 4), 3, 'can fail'],
];
tests.forEach((test) =>
console.log(
test[0].toString() === test[1].toString() ? 'pass!' : 'fail!',
'expected:',
test[1],
'result:',
test[0],
'message:',
test[2],
),
);
console.log(tests.every((t) => t[0].toString() === t[1].toString()) ? 'SUITE PASSES' : 'SUITE FAILS');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment