Skip to content

Instantly share code, notes, and snippets.

@kvalle
Created January 28, 2013 09:09
Show Gist options
  • Save kvalle/4654074 to your computer and use it in GitHub Desktop.
Save kvalle/4654074 to your computer and use it in GitHub Desktop.
Simple function for testing Standard ML code
use "hw2.sml";
fun test (tests) =
let
fun assess ([], _) = []
| assess (x::rest, num) = if x then assess(rest,num+1)
else Int.toString(num)^""::assess(rest,num+1)
val results = assess(tests,1)
in
case results of [] => "OK"
| _ => "FAILURES: " ^ String.concatWith", " results
end
val task_1a = test [
all_except_option("foo", []) = NONE,
all_except_option("foo", ["foo","bar"]) = SOME ["bar"],
all_except_option("bar", ["foo","bar"]) = SOME ["foo"],
all_except_option("bar", ["foo","bar", "baz"]) = SOME ["foo","baz"],
all_except_option("xxx", ["foo","bar"]) = NONE,
all_except_option("foo", ["foo"]) = SOME []
]
(* etc *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment