Created
August 9, 2012 14:04
-
-
Save asci/3304475 to your computer and use it in GitHub Desktop.
Simple unit test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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