tangled
alpha
login
or
join now
anil.recoil.org
/
unpac-unpac
0
fork
atom
The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork
atom
overview
issues
pulls
pipelines
Track B0_testing.
Daniel Bünzli
1 year ago
5b2d3af7
24a1dc57
+10
-25
2 changed files
expand all
collapse all
unified
split
vendor
opam
mtime
test
test_mtime.ml
test_mtime_clock.ml
+6
-14
vendor/opam/mtime/test/test_mtime.ml
···
5
5
6
6
open B0_testing
7
7
8
8
-
let test_pp_span () =
8
8
+
let test_pp_span =
9
9
Test.test "Mtime.pp_span" @@ fun () ->
10
10
(* The floating point stuff here comes from the previous incarnations
11
11
of the formatter. Let's keep that it exercices a bit the of_float_ns. *)
···
225
225
Test.string ~__POS__ (span "0u63115200_000_000_001") "2a1d";
226
226
()
227
227
228
228
-
let test_span_compare () =
228
228
+
let test_span_compare =
229
229
Test.test "Mtime.Span.{compare,is_shorter,is_longer}" @@ fun () ->
230
230
let zero_mtime = Mtime.Span.of_uint64_ns 0_L in
231
231
let large_mtime = Mtime.Span.of_uint64_ns Int64.max_int in
···
247
247
test_less_than (fun x y -> Mtime.Span.is_longer y ~than:x);
248
248
()
249
249
250
250
-
let test_span_constants () =
250
250
+
let test_span_constants =
251
251
Test.test "Mtime.Span.{zero,one,max_span,min_span}" @@ fun () ->
252
252
let (<) x y = Mtime.Span.compare x y < 0 in
253
253
assert (Mtime.Span.zero < Mtime.Span.one);
···
257
257
assert (Mtime.Span.one < Mtime.Span.max_span);
258
258
()
259
259
260
260
-
let test_span_arith () =
260
260
+
let test_span_arith =
261
261
Test.test "Mtime.Span.{abs_diff,add}" @@ fun () ->
262
262
assert (Mtime.Span.(equal (add zero one) one));
263
263
assert (Mtime.Span.(equal (add one zero) one));
264
264
assert (Mtime.Span.(equal (add (abs_diff max_span one) one) max_span));
265
265
()
266
266
267
267
-
let test_float_ns () =
267
267
+
let test_float_ns =
268
268
Test.test "Mtime.{to,of}_float_ns" @@ fun () ->
269
269
assert (Mtime.Span.to_float_ns Mtime.Span.max_span = (2. ** 64.) -. 1.);
270
270
assert (Mtime.Span.to_float_ns Mtime.Span.min_span = 0.);
···
279
279
assert (Mtime.Span.of_float_ns 1. = Some Mtime.Span.one);
280
280
()
281
281
282
282
-
let main () =
283
283
-
Test.main @@ fun () ->
284
284
-
test_pp_span ();
285
285
-
test_span_compare ();
286
286
-
test_span_constants ();
287
287
-
test_span_arith ();
288
288
-
test_float_ns ();
289
289
-
()
290
290
-
282
282
+
let main () = Test.main @@ fun () -> Test.autorun ()
291
283
let () = if !Sys.interactive then () else exit (main ())
+4
-11
vendor/opam/mtime/test/test_mtime_clock.ml
···
10
10
let test_available () = try ignore (Mtime_clock.elapsed ()) with
11
11
| Sys_error e -> Test.failstop "No monotonic time available: %s" e
12
12
13
13
-
let test_counters () =
13
13
+
let test_counters =
14
14
Test.test "Mtime_clock.counter" @@ fun () ->
15
15
let count max =
16
16
let c = Mtime_clock.counter () in
···
32
32
do_count 1;
33
33
()
34
34
35
35
-
let test_elapsed () =
35
35
+
let test_elapsed =
36
36
Test.test "Mtime_clock.elapsed ns - s - pp - dump" @@ fun () ->
37
37
let span = Mtime_clock.elapsed () in
38
38
Test.log " %Luns - %gs - %a - %a"
···
42
42
Mtime.Span.dump span;
43
43
()
44
44
45
45
-
let test_now () =
45
45
+
let test_now =
46
46
Test.test "Mtime_clock.now ns - s - pp - dump " @@ fun () ->
47
47
let t = Mtime_clock.now () in
48
48
let span = Mtime.(span t (of_uint64_ns 0_L)) in
···
51
51
Mtime.pp t Mtime.dump t;
52
52
()
53
53
54
54
-
let main () =
55
55
-
Test.main @@ fun () ->
56
56
-
test_available ();
57
57
-
test_counters ();
58
58
-
test_elapsed ();
59
59
-
test_now ();
60
60
-
()
61
61
-
54
54
+
let main () = Test.main @@ fun () -> Test.autorun ()
62
55
let () = if !Sys.interactive then () else exit (main ())