Skip to content

Instantly share code, notes, and snippets.

@microbial
Last active August 29, 2015 13:58
Show Gist options
  • Save microbial/10371477 to your computer and use it in GitHub Desktop.
Save microbial/10371477 to your computer and use it in GitHub Desktop.
Spike-Test - Useful for test driving spikes and snippets
/*********TinyTest********
* The test function will test if two returned values are exactly the same
* //Pass and Fail Examples
* test(square(3), 9) -> Pass: 9 === 9
* test(square(3), 6) -> Fail: 9 expected but got 6
**/
function test(conditionToTest, expectedResult) {
var failMsg = 'Fail: ' + expectedResult + ' expected but got ' + conditionToTest,
passMsg = 'Pass: ' + expectedResult + ' === ' + conditionToTest,
conditionPasses = conditionToTest === expectedResult;
console.log(conditionPasses ? passMsg : failMsg);
}
@microbial
Copy link
Author

Test-drive with speed. This tool has next-to-no features but allows for rapid TDD. Works well with JSBin. Just drop the function at the bottom of the page out-of-sight and write inline tests and code. Results will appear in the console pane.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment