-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtesting.sml
More file actions
executable file
·39 lines (32 loc) · 854 Bytes
/
testing.sml
File metadata and controls
executable file
·39 lines (32 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use "asserts.sml";
signature TESTS =
sig
val test : string * string -> string
val run : unit -> string
end
structure SmlTests :> TESTS =
struct
val suite : (string * string) list ref = ref [];
fun test (desc, result) =
(suite := (desc, result)::(!suite);
desc)
fun print_errors tests =
case tests of
[] => ()
| (description,result)::rest =>
(print("FAILED: " ^ description ^ "\n -- " ^ result ^ "\n");
print_errors(rest))
fun run () =
let
val failed = List.filter (fn (_,result) => result <> TEST_PASSED) (!suite)
val return = Int.toString(length (!suite)) ^ " tests total"
in
case failed of
[] => (print("\nTESTS PASSED\n\n");
return)
| _ => (print("\n");
print_errors(failed);
print("\n" ^ Int.toString(length(failed)) ^" test(s) failed\n\n");
return)
end
end