Skip to content

Instantly share code, notes, and snippets.

@asci
Created August 9, 2012 14:04
Show Gist options
  • Save asci/3304475 to your computer and use it in GitHub Desktop.
Save asci/3304475 to your computer and use it in GitHub Desktop.
Simple unit test
var code = function(num1, num2) {
// Сложная логика с предсказуемым результатом:
return num1 + num2;
}
var test = function (func, args, result) {
var res = func.apply(this, args);
if (res != result) {
console.log('FAIL, expected: ' + result + ', recieved ' + res);
} else {
console.log('PASS');
}
}
test(code, [1, 2], 3);
test(code, [5, 5], 10);
test(code, [1, 1], 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment