Skip to content

Instantly share code, notes, and snippets.

@mcmillhj
Last active February 21, 2017 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcmillhj/a762fe2f159d946bb61c474a7d26ced9 to your computer and use it in GitHub Desktop.
Save mcmillhj/a762fe2f159d946bb61c474a7d26ced9 to your computer and use it in GitHub Desktop.
fun run_tests _ [] = []
| run_tests f (x :: xs) =
let
fun aux { description, is_correct } =
let
val expl = description ^ ": " ^
(if is_correct then "PASSED" else "FAILED") ^ "\n"
in
(print (expl); is_correct)
end
in
(aux x) :: run_tests f xs
end
fun evaluateList f { description, input, expected } =
{ description = description, is_correct = (f input) = expected }
fun evaluateAllergicTo f { description, input, allergen, expected } =
{ description = description, is_correct = (f input allergen) = expected }
val testResults = run_tests list (List.map (evaluateList list) (#list test_cases))
@ run_tests list (List.map (evaluateAllergicTo allergic_to) (#allergic_to test_cases));
val passedTests = List.filter (fn x => x) testResults;
val failedTests = List.filter (fn x => not x) testResults;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment