@@ -75,7 +75,7 @@ open OUnitTypes
75
75
76
76
(** Most simple heuristic, just pick the first test. *)
77
77
let simple state =
78
- (* 130 *) List.hd state.tests_planned
78
+ (* 132 *) List.hd state.tests_planned
79
79
80
80
end
81
81
module OUnitUtils
@@ -98,22 +98,22 @@ let is_success =
98
98
let is_failure =
99
99
function
100
100
| RFailure _ -> (* 0 *) true
101
- | RSuccess _ | RError _ | RSkip _ | RTodo _ -> (* 260 *) false
101
+ | RSuccess _ | RError _ | RSkip _ | RTodo _ -> (* 264 *) false
102
102
103
103
let is_error =
104
104
function
105
105
| RError _ -> (* 0 *) true
106
- | RSuccess _ | RFailure _ | RSkip _ | RTodo _ -> (* 260 *) false
106
+ | RSuccess _ | RFailure _ | RSkip _ | RTodo _ -> (* 264 *) false
107
107
108
108
let is_skip =
109
109
function
110
110
| RSkip _ -> (* 0 *) true
111
- | RSuccess _ | RFailure _ | RError _ | RTodo _ -> (* 260 *) false
111
+ | RSuccess _ | RFailure _ | RError _ | RTodo _ -> (* 264 *) false
112
112
113
113
let is_todo =
114
114
function
115
115
| RTodo _ -> (* 0 *) true
116
- | RSuccess _ | RFailure _ | RError _ | RSkip _ -> (* 260 *) false
116
+ | RSuccess _ | RFailure _ | RError _ | RSkip _ -> (* 264 *) false
117
117
118
118
let result_flavour =
119
119
function
@@ -145,7 +145,7 @@ let rec was_successful =
145
145
| [] -> (* 3 *) true
146
146
| RSuccess _::t
147
147
| RSkip _::t ->
148
- (* 390 *) was_successful t
148
+ (* 396 *) was_successful t
149
149
150
150
| RFailure _::_
151
151
| RError _::_
@@ -155,22 +155,22 @@ let rec was_successful =
155
155
let string_of_node =
156
156
function
157
157
| ListItem n ->
158
- (* 520 *) string_of_int n
158
+ (* 528 *) string_of_int n
159
159
| Label s ->
160
- (* 780 *) s
160
+ (* 792 *) s
161
161
162
162
(* Return the number of available tests *)
163
163
let rec test_case_count =
164
164
function
165
- | TestCase _ -> (* 130 *) 1
166
- | TestLabel (_, t) -> (* 151 *) test_case_count t
165
+ | TestCase _ -> (* 132 *) 1
166
+ | TestLabel (_, t) -> (* 153 *) test_case_count t
167
167
| TestList l ->
168
168
(* 21 *) List.fold_left
169
- (fun c t -> (* 150 *) c + test_case_count t)
169
+ (fun c t -> (* 152 *) c + test_case_count t)
170
170
0 l
171
171
172
172
let string_of_path path =
173
- (* 260 *) String.concat ":" (List.rev_map string_of_node path)
173
+ (* 264 *) String.concat ":" (List.rev_map string_of_node path)
174
174
175
175
let buff_format_printf f =
176
176
(* 0 *) let buff = Buffer.create 13 in
@@ -194,12 +194,12 @@ let mapi f l =
194
194
195
195
let fold_lefti f accu l =
196
196
(* 21 *) let rec rfold_lefti cnt accup l =
197
- (* 171 *) match l with
197
+ (* 173 *) match l with
198
198
| [] ->
199
199
(* 21 *) accup
200
200
201
201
| h::t ->
202
- (* 150 *) rfold_lefti (cnt + 1) (f accup h cnt) t
202
+ (* 152 *) rfold_lefti (cnt + 1) (f accup h cnt) t
203
203
in
204
204
rfold_lefti 0 accu l
205
205
@@ -217,7 +217,7 @@ open OUnitUtils
217
217
type event_type = GlobalEvent of global_event | TestEvent of test_event
218
218
219
219
let format_event verbose event_type =
220
- (* 782 *) match event_type with
220
+ (* 794 *) match event_type with
221
221
| GlobalEvent e ->
222
222
(* 2 *) begin
223
223
match e with
@@ -276,31 +276,31 @@ let format_event verbose event_type =
276
276
end
277
277
278
278
| TestEvent e ->
279
- (* 780 *) begin
279
+ (* 792 *) begin
280
280
let string_of_result =
281
281
if verbose then
282
- (* 390 *) function
283
- | RSuccess _ -> (* 130 *) "ok\n"
282
+ (* 396 *) function
283
+ | RSuccess _ -> (* 132 *) "ok\n"
284
284
| RFailure (_, _) -> (* 0 *) "FAIL\n"
285
285
| RError (_, _) -> (* 0 *) "ERROR\n"
286
286
| RSkip (_, _) -> (* 0 *) "SKIP\n"
287
287
| RTodo (_, _) -> (* 0 *) "TODO\n"
288
288
else
289
- (* 390 *) function
290
- | RSuccess _ -> (* 130 *) "."
289
+ (* 396 *) function
290
+ | RSuccess _ -> (* 132 *) "."
291
291
| RFailure (_, _) -> (* 0 *) "F"
292
292
| RError (_, _) -> (* 0 *) "E"
293
293
| RSkip (_, _) -> (* 0 *) "S"
294
294
| RTodo (_, _) -> (* 0 *) "T"
295
295
in
296
296
if verbose then
297
- (* 390 *) match e with
297
+ (* 396 *) match e with
298
298
| EStart p ->
299
- (* 130 *) Printf.sprintf "%s start\n" (string_of_path p)
299
+ (* 132 *) Printf.sprintf "%s start\n" (string_of_path p)
300
300
| EEnd p ->
301
- (* 130 *) Printf.sprintf "%s end\n" (string_of_path p)
301
+ (* 132 *) Printf.sprintf "%s end\n" (string_of_path p)
302
302
| EResult result ->
303
- (* 130 *) string_of_result result
303
+ (* 132 *) string_of_result result
304
304
| ELog (lvl, str) ->
305
305
(* 0 *) let prefix =
306
306
match lvl with
@@ -312,21 +312,21 @@ let format_event verbose event_type =
312
312
| ELogRaw str ->
313
313
(* 0 *) str
314
314
else
315
- (* 390 *) match e with
316
- | EStart _ | EEnd _ | ELog _ | ELogRaw _ -> (* 260 *) ""
317
- | EResult result -> (* 130 *) string_of_result result
315
+ (* 396 *) match e with
316
+ | EStart _ | EEnd _ | ELog _ | ELogRaw _ -> (* 264 *) ""
317
+ | EResult result -> (* 132 *) string_of_result result
318
318
end
319
319
320
320
let file_logger fn =
321
321
(* 1 *) let chn = open_out fn in
322
322
(fun ev ->
323
- (* 391 *) output_string chn (format_event true ev);
323
+ (* 397 *) output_string chn (format_event true ev);
324
324
flush chn),
325
325
(fun () -> (* 1 *) close_out chn)
326
326
327
327
let std_logger verbose =
328
328
(* 1 *) (fun ev ->
329
- (* 391 *) print_string (format_event verbose ev);
329
+ (* 397 *) print_string (format_event verbose ev);
330
330
flush stdout),
331
331
(fun () -> (* 1 *) ())
332
332
@@ -343,7 +343,7 @@ let create output_file_opt verbose (log,close) =
343
343
(* 0 *) null_logger
344
344
in
345
345
(fun ev ->
346
- (* 391 *) std_log ev; file_log ev; log ev),
346
+ (* 397 *) std_log ev; file_log ev; log ev),
347
347
(fun () ->
348
348
(* 1 *) std_close (); file_close (); close ())
349
349
@@ -711,7 +711,7 @@ let assert_string str =
711
711
(* 0 *) if not (str = "") then (* 0 *) assert_failure str
712
712
713
713
let assert_equal ?(cmp = ( = )) ?printer ?pp_diff ?msg expected actual =
714
- (* 2001486 *) let get_error_string () =
714
+ (* 2001488 *) let get_error_string () =
715
715
(* 0 *) let res =
716
716
buff_format_printf
717
717
(fun fmt ->
@@ -951,7 +951,7 @@ let (@?) = assert_bool
951
951
952
952
(* Some shorthands which allows easy test construction *)
953
953
let (>:) s t = (* 0 *) TestLabel(s, t) (* infix *)
954
- let (>::) s f = (* 130 *) TestLabel(s, TestCase(f)) (* infix *)
954
+ let (>::) s f = (* 132 *) TestLabel(s, TestCase(f)) (* infix *)
955
955
let (>:::) s l = (* 21 *) TestLabel(s, TestList(l)) (* infix *)
956
956
957
957
(* Utility function to manipulate test *)
@@ -1087,7 +1087,7 @@ let maybe_backtrace = ""
1087
1087
(* Run all tests, report starts, errors, failures, and return the results *)
1088
1088
let perform_test report test =
1089
1089
(* 1 *) let run_test_case f path =
1090
- (* 130 *) try
1090
+ (* 132 *) try
1091
1091
f ();
1092
1092
RSuccess path
1093
1093
with
@@ -1106,22 +1106,22 @@ let perform_test report test =
1106
1106
let rec flatten_test path acc =
1107
1107
function
1108
1108
| TestCase(f) ->
1109
- (* 130 *) (path, f) :: acc
1109
+ (* 132 *) (path, f) :: acc
1110
1110
1111
1111
| TestList (tests) ->
1112
1112
(* 21 *) fold_lefti
1113
1113
(fun acc t cnt ->
1114
- (* 150 *) flatten_test
1114
+ (* 152 *) flatten_test
1115
1115
((ListItem cnt)::path)
1116
1116
acc t)
1117
1117
acc tests
1118
1118
1119
1119
| TestLabel (label, t) ->
1120
- (* 151 *) flatten_test ((Label label)::path) acc t
1120
+ (* 153 *) flatten_test ((Label label)::path) acc t
1121
1121
in
1122
1122
let test_cases = List.rev (flatten_test [] [] test) in
1123
1123
let runner (path, f) =
1124
- (* 130 *) let result =
1124
+ (* 132 *) let result =
1125
1125
report (EStart path);
1126
1126
run_test_case f path
1127
1127
in
@@ -1130,18 +1130,18 @@ let perform_test report test =
1130
1130
result
1131
1131
in
1132
1132
let rec iter state =
1133
- (* 131 *) match state.tests_planned with
1133
+ (* 133 *) match state.tests_planned with
1134
1134
| [] ->
1135
1135
(* 1 *) state.results
1136
1136
| _ ->
1137
- (* 130 *) let (path, f) = !global_chooser state in
1137
+ (* 132 *) let (path, f) = !global_chooser state in
1138
1138
let result = runner (path, f) in
1139
1139
iter
1140
1140
{
1141
1141
results = result :: state.results;
1142
1142
tests_planned =
1143
1143
List.filter
1144
- (fun (path', _) -> (* 8515 *) path <> path') state.tests_planned
1144
+ (fun (path', _) -> (* 8778 *) path <> path') state.tests_planned
1145
1145
}
1146
1146
in
1147
1147
iter {results = []; tests_planned = test_cases}
@@ -1171,7 +1171,7 @@ let run_test_tt ?verbose test =
1171
1171
time_fun
1172
1172
perform_test
1173
1173
(fun ev ->
1174
- (* 390 *) log (OUnitLogger.TestEvent ev))
1174
+ (* 396 *) log (OUnitLogger.TestEvent ev))
1175
1175
test
1176
1176
in
1177
1177
@@ -1294,6 +1294,12 @@ val map2i : (int -> 'a -> 'b -> 'c ) -> 'a array -> 'b array -> 'c array
1294
1294
1295
1295
val to_list_map : ('a -> 'b option) -> 'a array -> 'b list
1296
1296
1297
+ val to_list_map_acc :
1298
+ ('a -> 'b option) ->
1299
+ 'a array ->
1300
+ 'b list ->
1301
+ 'b list
1302
+
1297
1303
val of_list_map : ('a -> 'b) -> 'a list -> 'b array
1298
1304
1299
1305
val rfind_with_index : 'a array -> ('a -> 'b -> bool) -> 'b -> int
@@ -1414,15 +1420,20 @@ let map2i f a b =
1414
1420
else
1415
1421
(* 0 *) Array.mapi (fun i a -> (* 0 *) f i a ( Array.unsafe_get b i )) a
1416
1422
1417
- let to_list_map f a =
1418
- (* 0 *) let rec tolist i res =
1419
- (* 0 *) if i < 0 then (* 0 *) res else
1420
- (* 0 *) let v = Array.unsafe_get a i in
1421
- tolist (i - 1)
1423
+
1424
+ let rec tolist_aux a f i res =
1425
+ (* 14 *) if i < 0 then (* 2 *) res else
1426
+ (* 12 *) let v = Array.unsafe_get a i in
1427
+ tolist_aux a f (i - 1)
1422
1428
(match f v with
1423
- | Some v -> (* 0 *) v :: res
1424
- | None -> (* 0 *) res) in
1425
- tolist (Array.length a - 1) []
1429
+ | Some v -> (* 6 *) v :: res
1430
+ | None -> (* 6 *) res)
1431
+
1432
+ let to_list_map f a =
1433
+ (* 0 *) tolist_aux a f (Array.length a - 1) []
1434
+
1435
+ let to_list_map_acc f a acc =
1436
+ (* 2 *) tolist_aux a f (Array.length a - 1) acc
1426
1437
1427
1438
1428
1439
(* TODO: What would happen if [f] raise, memory leak? *)
@@ -2262,7 +2273,19 @@ let suites =
2262
2273
(* 1 *) Ext_array.of_list_map succ [] =~ [||];
2263
2274
Ext_array.of_list_map succ [1] =~ [|2|];
2264
2275
Ext_array.of_list_map succ [1;2;3] =~ [|2;3;4|];
2265
- end
2276
+ end;
2277
+ __LOC__ >:: begin fun _ ->
2278
+ (* 1 *) Ext_array.to_list_map_acc
2279
+ (fun x -> (* 6 *) if x mod 2 = 0 then (* 3 *) Some x else (* 3 *) None )
2280
+ [|1;2;3;4;5;6|] [1;2;3]
2281
+ =~ [2;4;6;1;2;3]
2282
+ end;
2283
+ __LOC__ >:: begin fun _ ->
2284
+ (* 1 *) Ext_array.to_list_map_acc
2285
+ (fun x -> (* 6 *) if x mod 2 = 0 then (* 3 *) Some x else (* 3 *) None )
2286
+ [|1;2;3;4;5;6|] []
2287
+ =~ [2;4;6]
2288
+ end;
2266
2289
]
2267
2290
end
2268
2291
module Ounit_tests_util
@@ -3539,6 +3562,7 @@ val commonjs : string
3539
3562
val amdjs : string
3540
3563
val goog : string
3541
3564
val es6 : string
3565
+ val es6_global : string
3542
3566
val unused_attribute : string
3543
3567
end = struct
3544
3568
#1 "literals.ml"
@@ -3639,7 +3663,7 @@ let commonjs = "commonjs"
3639
3663
let amdjs = "amdjs"
3640
3664
let goog = "goog"
3641
3665
let es6 = "es6"
3642
-
3666
+ let es6_global = "es6-global"
3643
3667
let unused_attribute = "Unused attribute "
3644
3668
end
3645
3669
module Ounit_cmd_util : sig
0 commit comments