blob: 6821e744776fe75f67f4bfab28ebdde61f536efa (
plain)
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
40
41
42
43
44
45
46
47
48
49
50
|
signature TEST = sig
type test =
{
description: string
, expectedResult: string
, function: unit -> string
}
val single: test -> unit
val list: test list -> unit
end
structure Test = struct
fun single {description, expectedResult, function} =
let
val actualResult = function ()
in
if expectedResult = actualResult then
TextIO.output (
TextIO.stdErr
, (
description
^ " succeeded.\n"
)
)
else (
TextIO.output (
TextIO.stdErr
, (
description
^ " was supposed to be "
^ expectedResult
^ ", but was actually "
^ actualResult
^ ".\n"
)
); OS.Process.exit OS.Process.failure
)
end handle exception' => (
TextIO.output (
TextIO.stdErr
, (
description
^ " failed with exception "
^ exnMessage exception'
^ ".\n"
)
); OS.Process.exit OS.Process.failure
)
fun list tests = app single tests
end
|