Last active
August 29, 2015 14:20
-
-
Save Ajwah/715f4d32d5fa50cab457 to your computer and use it in GitHub Desktop.
Basic template to run unit tests in SML
This file contains 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
use "johnson_hw.sml"; | |
val name_hw = "2005 - Assignment Two" | |
(*Unit tests are of format string*bool where bool is represented by evaluation of a function to an expected value*) | |
val tests = [ | |
]; | |
print ("\n"^Int.toString(List.length(tests))^" TOTAL TESTS RUN----------------------"^name_hw^"--------------------------\n"); (*Name display to assert correct test file is running*) | |
fun all_tests(tests) = | |
let fun helper(tests: (string*bool) list, all_passed) = | |
case tests of | |
[] => all_passed | |
| (st, true)::rest => helper(rest, all_passed) (*I am only interested in the output if the test fails.*) | |
| (st, false)::rest => (print ("***" ^ st ^" !!!FAILED!!!\n"); helper(rest, false)) | |
in | |
helper(tests, true) | |
end; | |
case all_tests(tests) of | |
true => print "--------------EVERY TESTS PASSED-------------\n" | |
| false => print "--------------SOMETHING IS WRONG-------------------------\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment