Created
October 17, 2018 00:52
-
-
Save AKCodez/ede3626b4fc8a79c49e63875142ed5fc to your computer and use it in GitHub Desktop.
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
| /* | |
| Write an "assertEqual" function from scratch, from memory. | |
| Please DO NOT simply PASTE in from before. | |
| If you have to go back and look at your previously-implemented code once, fine, but come back here and write it from memory. | |
| Then use your assertion function in a series of test cases to thoroughly test the code. | |
| Use categorical reasoning to consider all the useful cases. | |
| Debug the code under test, if necessary. | |
| */ | |
| // Assertion function: | |
| function assertEqual(actual, expected, testName) { | |
| if(actual === expected){ | |
| console.log("passed"); | |
| } else { | |
| console.log("FAILED " + [testName] + "Expected " + expected + " but got" + actual); | |
| } | |
| } | |
| // Code Under Test: | |
| function square(n) { | |
| return n * n; | |
| } | |
| var output = square(5); | |
| assertEqual(output, 25, "it squares 5, ") | |
| // Calls to 'assertEqual': |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment