@@ -75,7 +75,7 @@ open OUnitTypes
75
75
76
76
(* * Most simple heuristic, just pick the first test. *)
77
77
let simple state =
78
- (* 70 *) List. hd state.tests_planned
78
+ (* 72 *) 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 _ -> (* 140 *) false
101
+ | RSuccess _ | RError _ | RSkip _ | RTodo _ -> (* 144 *) false
102
102
103
103
let is_error =
104
104
function
105
105
| RError _ -> (* 0 *) true
106
- | RSuccess _ | RFailure _ | RSkip _ | RTodo _ -> (* 140 *) false
106
+ | RSuccess _ | RFailure _ | RSkip _ | RTodo _ -> (* 144 *) false
107
107
108
108
let is_skip =
109
109
function
110
110
| RSkip _ -> (* 0 *) true
111
- | RSuccess _ | RFailure _ | RError _ | RTodo _ -> (* 140 *) false
111
+ | RSuccess _ | RFailure _ | RError _ | RTodo _ -> (* 144 *) false
112
112
113
113
let is_todo =
114
114
function
115
115
| RTodo _ -> (* 0 *) true
116
- | RSuccess _ | RFailure _ | RError _ | RSkip _ -> (* 140 *) false
116
+ | RSuccess _ | RFailure _ | RError _ | RSkip _ -> (* 144 *) 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
- (* 210 *) was_successful t
148
+ (* 216 *) 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
- (* 280 *) string_of_int n
158
+ (* 288 *) string_of_int n
159
159
| Label s ->
160
- (* 420 *) s
160
+ (* 432 *) s
161
161
162
162
(* Return the number of available tests *)
163
163
let rec test_case_count =
164
164
function
165
- | TestCase _ -> (* 70 *) 1
166
- | TestLabel (_ , t ) -> (* 83 *) test_case_count t
165
+ | TestCase _ -> (* 72 *) 1
166
+ | TestLabel (_ , t ) -> (* 85 *) test_case_count t
167
167
| TestList l ->
168
168
(* 13 *) List. fold_left
169
- (fun c t -> (* 82 *) c + test_case_count t)
169
+ (fun c t -> (* 84 *) c + test_case_count t)
170
170
0 l
171
171
172
172
let string_of_path path =
173
- (* 140 *) String. concat " :" (List. rev_map string_of_node path)
173
+ (* 144 *) 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
(* 13 *) let rec rfold_lefti cnt accup l =
197
- (* 95 *) match l with
197
+ (* 97 *) match l with
198
198
| [] ->
199
199
(* 13 *) accup
200
200
201
201
| h ::t ->
202
- (* 82 *) rfold_lefti (cnt + 1 ) (f accup h cnt) t
202
+ (* 84 *) 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
- (* 422 *) match event_type with
220
+ (* 434 *) match event_type with
221
221
| GlobalEvent e ->
222
222
(* 2 *) begin
223
223
match e with
@@ -276,18 +276,18 @@ let format_event verbose event_type =
276
276
end
277
277
278
278
| TestEvent e ->
279
- (* 420 *) begin
279
+ (* 432 *) begin
280
280
let string_of_result =
281
281
if verbose then
282
282
function
283
- | RSuccess _ -> (* 70 *) " ok\n "
283
+ | RSuccess _ -> (* 72 *) " 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
289
function
290
- | RSuccess _ -> (* 70 *) " ."
290
+ | RSuccess _ -> (* 72 *) " ."
291
291
| RFailure (_ , _ ) -> (* 0 *) " F"
292
292
| RError (_ , _ ) -> (* 0 *) " E"
293
293
| RSkip (_ , _ ) -> (* 0 *) " S"
@@ -296,11 +296,11 @@ let format_event verbose event_type =
296
296
if verbose then
297
297
match e with
298
298
| EStart p ->
299
- (* 70 *) Printf. sprintf " %s start\n " (string_of_path p)
299
+ (* 72 *) Printf. sprintf " %s start\n " (string_of_path p)
300
300
| EEnd p ->
301
- (* 70 *) Printf. sprintf " %s end\n " (string_of_path p)
301
+ (* 72 *) Printf. sprintf " %s end\n " (string_of_path p)
302
302
| EResult result ->
303
- (* 70 *) string_of_result result
303
+ (* 72 *) string_of_result result
304
304
| ELog (lvl , str ) ->
305
305
(* 0 *) let prefix =
306
306
match lvl with
@@ -313,20 +313,20 @@ let format_event verbose event_type =
313
313
(* 0 *) str
314
314
else
315
315
match e with
316
- | EStart _ | EEnd _ | ELog _ | ELogRaw _ -> (* 140 *) " "
317
- | EResult result -> (* 70 *) string_of_result result
316
+ | EStart _ | EEnd _ | ELog _ | ELogRaw _ -> (* 144 *) " "
317
+ | EResult result -> (* 72 *) 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
- (* 211 *) output_string chn (format_event true ev);
323
+ (* 217 *) 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
- (* 211 *) print_string (format_event verbose ev);
329
+ (* 217 *) 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
- (* 211 *) std_log ev; file_log ev; log ev),
346
+ (* 217 *) std_log ev; file_log ev; log ev),
347
347
(fun () ->
348
348
(* 1 *) std_close () ; file_close () ; close () )
349
349
@@ -709,7 +709,7 @@ let assert_string str =
709
709
(* 0 *) if not (str = " " ) then assert_failure str
710
710
711
711
let assert_equal ?(cmp = ( = )) ?printer ?pp_diff ?msg expected actual =
712
- (* 2000387 *) let get_error_string () =
712
+ (* 2000391 *) let get_error_string () =
713
713
(* 0 *) let res =
714
714
buff_format_printf
715
715
(fun fmt ->
@@ -925,7 +925,7 @@ let (@?) = assert_bool
925
925
926
926
(* Some shorthands which allows easy test construction *)
927
927
let (>:) s t = (* 0 *) TestLabel (s, t) (* infix *)
928
- let (>::) s f = (* 70 *) TestLabel (s, TestCase (f)) (* infix *)
928
+ let (>::) s f = (* 72 *) TestLabel (s, TestCase (f)) (* infix *)
929
929
let (>:::) s l = (* 13 *) TestLabel (s, TestList (l)) (* infix *)
930
930
931
931
(* Utility function to manipulate test *)
@@ -1061,7 +1061,7 @@ let maybe_backtrace = ""
1061
1061
(* Run all tests, report starts, errors, failures, and return the results *)
1062
1062
let perform_test report test =
1063
1063
(* 1 *) let run_test_case f path =
1064
- (* 70 *) try
1064
+ (* 72 *) try
1065
1065
f () ;
1066
1066
RSuccess path
1067
1067
with
@@ -1080,22 +1080,22 @@ let perform_test report test =
1080
1080
let rec flatten_test path acc =
1081
1081
function
1082
1082
| TestCase (f ) ->
1083
- (* 70 *) (path, f) :: acc
1083
+ (* 72 *) (path, f) :: acc
1084
1084
1085
1085
| TestList (tests ) ->
1086
1086
(* 13 *) fold_lefti
1087
1087
(fun acc t cnt ->
1088
- (* 82 *) flatten_test
1088
+ (* 84 *) flatten_test
1089
1089
((ListItem cnt)::path)
1090
1090
acc t)
1091
1091
acc tests
1092
1092
1093
1093
| TestLabel (label , t ) ->
1094
- (* 83 *) flatten_test ((Label label)::path) acc t
1094
+ (* 85 *) flatten_test ((Label label)::path) acc t
1095
1095
in
1096
1096
let test_cases = List. rev (flatten_test [] [] test) in
1097
1097
let runner (path , f ) =
1098
- (* 70 *) let result =
1098
+ (* 72 *) let result =
1099
1099
report (EStart path);
1100
1100
run_test_case f path
1101
1101
in
@@ -1104,18 +1104,18 @@ let perform_test report test =
1104
1104
result
1105
1105
in
1106
1106
let rec iter state =
1107
- (* 71 *) match state.tests_planned with
1107
+ (* 73 *) match state.tests_planned with
1108
1108
| [] ->
1109
1109
(* 1 *) state.results
1110
1110
| _ ->
1111
- (* 70 *) let (path, f) = ! global_chooser state in
1111
+ (* 72 *) let (path, f) = ! global_chooser state in
1112
1112
let result = runner (path, f) in
1113
1113
iter
1114
1114
{
1115
1115
results = result :: state .results;
1116
1116
tests_planned =
1117
1117
List. filter
1118
- (fun (path' , _ ) -> (* 2485 *) path <> path') state.tests_planned
1118
+ (fun (path' , _ ) -> (* 2628 *) path <> path') state.tests_planned
1119
1119
}
1120
1120
in
1121
1121
iter {results = [] ; tests_planned = test_cases}
@@ -1145,7 +1145,7 @@ let run_test_tt ?verbose test =
1145
1145
time_fun
1146
1146
perform_test
1147
1147
(fun ev ->
1148
- (* 210 *) log (OUnitLogger. TestEvent ev))
1148
+ (* 216 *) log (OUnitLogger. TestEvent ev))
1149
1149
test
1150
1150
in
1151
1151
@@ -3614,6 +3614,12 @@ external hash_string : string -> int = "caml_bs_hash_string" "noalloc";;
3614
3614
3615
3615
external hash_string_int : string -> int -> int = " caml_bs_hash_string_and_int" " noalloc" ;;
3616
3616
3617
+ external hash_string_small_int : string -> int -> int = " caml_bs_hash_string_and_small_int" " noalloc" ;;
3618
+
3619
+ external hash_stamp_and_name : int -> string -> int = " caml_bs_hash_stamp_and_name" " noalloc" ;;
3620
+
3621
+ external hash_small_int : int -> int = " caml_bs_hash_small_int" " noalloc" ;;
3622
+
3617
3623
external hash_int : int -> int = " caml_bs_hash_int" " noalloc" ;;
3618
3624
3619
3625
end
@@ -4303,6 +4309,9 @@ let bench () =
4303
4309
done
4304
4310
end
4305
4311
4312
+
4313
+ type id (* = Ident .t * ) = { stamp : int ; name : string ; mutable flags : int ; }
4314
+ let hash id = (* 4 *) Bs_hash_stubs. hash_stamp_and_name id.stamp id.name
4306
4315
let suites =
4307
4316
__FILE__
4308
4317
> :::
@@ -4324,7 +4333,18 @@ let suites =
4324
4333
(* 1 *) Array. init 100 (fun i -> (* 100 *) String. make i 'a' )
4325
4334
|> Array. iter (fun x ->
4326
4335
(* 100 *) Bs_hash_stubs. hash_string x =~ Hashtbl. hash x)
4336
+ end;
4337
+ __LOC__ > :: begin fun _ ->
4338
+ (* * only stamp matters here *)
4339
+ (* 1 *) hash {stamp = 1 ; name = " xx" ; flags = 0 } =~ Bs_hash_stubs. hash_small_int 1 ;
4340
+ hash {stamp = 11 ; name = " xx" ; flags = 0 } =~ Bs_hash_stubs. hash_small_int 11 ;
4341
+ end;
4342
+ __LOC__ > :: begin fun _ ->
4343
+ (* only string matters here *)
4344
+ (* 1 *) hash {stamp = 0 ; name = " Pervasives" ; flags = 0 } =~ Bs_hash_stubs. hash_string " Pervasives" ;
4345
+ hash {stamp = 0 ; name = " UU" ; flags = 0 } =~ Bs_hash_stubs. hash_string " UU" ;
4327
4346
end
4347
+
4328
4348
]
4329
4349
4330
4350
end
0 commit comments