|
1 | 1 | open OUnit |
2 | 2 |
|
3 | | -let _esc_lf s = |
4 | | - s |> Str.global_replace (Str.regexp_string "\n") "<:LF:>";; |
| 3 | +let _esc_lf = Str.global_replace (Str.regexp_string "\n") "<:LF:>" |
5 | 4 |
|
6 | | -let cw_print_success = function |
7 | | - | _ -> print_endline ("\n<PASSED::>Test passed") |
| 5 | +let cw_print_success () = print_endline "\n<PASSED::>Test passed" |
8 | 6 |
|
9 | | -let cw_print_failure = function |
10 | | - | err -> print_endline ("\n<FAILED::>" ^ (_esc_lf err)) |
| 7 | +let cw_print_failure err = print_endline ("\n<FAILED::>" ^ _esc_lf err) |
11 | 8 |
|
12 | | -let cw_print_error = function |
13 | | - | err -> print_endline ("\n<ERROR::>" ^ (_esc_lf err)) |
| 9 | +let cw_print_error err = print_endline ("\n<ERROR::>" ^ _esc_lf err) |
14 | 10 |
|
15 | 11 | let cw_print_result = function |
16 | | - | RSuccess _ -> cw_print_success() |
17 | | - | RFailure(_, err) -> cw_print_failure err |
18 | | - | RError (_, err) -> cw_print_error err |
19 | | - | _ -> () |
| 12 | + | RSuccess _ -> cw_print_success () |
| 13 | + | RFailure (_, err) -> cw_print_failure err |
| 14 | + | RError (_, err) -> cw_print_error err |
| 15 | + | RSkip _ | RTodo _ -> () |
20 | 16 |
|
21 | 17 | let cw_print_test_event = function |
22 | | - | EResult result -> cw_print_result result |
23 | | - | _ -> () |
| 18 | + | EResult result -> cw_print_result result |
| 19 | + | EStart _ | EEnd _ -> () |
24 | 20 |
|
25 | | -let rec dispatch_test_group = function |
26 | | - | label, TestList tests -> begin |
27 | | - print_endline("\n<DESCRIBE::>"^label); |
| 21 | +let dispatch_test_case label test_case = |
| 22 | + print_endline ("\n<IT::>" ^ label); |
| 23 | + perform_test cw_print_test_event test_case |> ignore; |
| 24 | + print_endline "\n<COMPLETEDIN::>" |
| 25 | + |
| 26 | +let rec dispatch_labeled_test label test = |
| 27 | + match test with |
| 28 | + | TestLabel (nested_label, nested_test) -> dispatch_labeled_test nested_label nested_test |
| 29 | + | TestCase _ -> dispatch_test_case label test |
| 30 | + | TestList tests -> begin |
| 31 | + print_endline ("\n<DESCRIBE::>" ^ label); |
28 | 32 | run_tests tests; |
29 | | - print_endline("\n<COMPLETEDIN::>"); |
| 33 | + print_endline "\n<COMPLETEDIN::>"; |
30 | 34 | end |
31 | 35 |
|
32 | | -and dispatch_test_case = function |
33 | | - | label, test_case -> begin |
34 | | - print_endline("\n<IT::>"^label); |
35 | | - perform_test cw_print_test_event test_case |> ignore; |
36 | | - print_endline("\n<COMPLETEDIN::>"); |
37 | | - end |
38 | | - |
39 | | -and dispatch_labeled_test = function |
40 | | - | label, TestLabel (nested_label, test) -> dispatch_labeled_test (nested_label, test) |
41 | | - | label, TestCase test_fun -> dispatch_test_case(label, TestCase test_fun) |
42 | | - | label, TestList test_group -> dispatch_test_group(label, TestList test_group) |
43 | | - |
44 | 36 | and run_test = function |
45 | 37 | | TestList tests -> "" >::: tests |> run_test |
46 | 38 | | TestCase func -> "" >:: func |> run_test |
47 | | - | TestLabel(label, test) -> dispatch_labeled_test(label, test) |
| 39 | + | TestLabel (label, test) -> dispatch_labeled_test label test |
48 | 40 |
|
49 | | -and run_tests = function |
50 | | - | tests -> List.iter run_test tests |
| 41 | +and run_tests tests = List.iter run_test tests |
51 | 42 |
|
52 | 43 | (* `solution` and `fixture` are concatenated to `fixture.ml` *) |
53 | 44 | let () = run_tests Fixture.Tests.suite |
0 commit comments