Created
January 28, 2013 09:09
-
-
Save kvalle/4654074 to your computer and use it in GitHub Desktop.
Simple function for testing Standard ML code
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 "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