Skip to content

Commit 8a50600

Browse files
committed
Update test.ml
1 parent ed9167b commit 8a50600

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

workspace/test.ml

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,44 @@
11
open OUnit
22

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:>"
54

6-
let cw_print_success = function
7-
| _ -> print_endline ("\n<PASSED::>Test passed")
5+
let cw_print_success () = print_endline "\n<PASSED::>Test passed"
86

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)
118

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)
1410

1511
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 _ -> ()
2016

2117
let cw_print_test_event = function
22-
| EResult result -> cw_print_result result
23-
| _ -> ()
18+
| EResult result -> cw_print_result result
19+
| EStart _ | EEnd _ -> ()
2420

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);
2832
run_tests tests;
29-
print_endline("\n<COMPLETEDIN::>");
33+
print_endline "\n<COMPLETEDIN::>";
3034
end
3135

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-
4436
and run_test = function
4537
| TestList tests -> "" >::: tests |> run_test
4638
| TestCase func -> "" >:: func |> run_test
47-
| TestLabel(label, test) -> dispatch_labeled_test(label, test)
39+
| TestLabel (label, test) -> dispatch_labeled_test label test
4840

49-
and run_tests = function
50-
| tests -> List.iter run_test tests
41+
and run_tests tests = List.iter run_test tests
5142

5243
(* `solution` and `fixture` are concatenated to `fixture.ml` *)
5344
let () = run_tests Fixture.Tests.suite

0 commit comments

Comments
 (0)