Skip to content

Commit 1111c0f

Browse files
committed
wip: convert tests into testlib
1 parent 91ddccc commit 1111c0f

29 files changed

+997
-1056
lines changed

src/data/CCBV.ml

Lines changed: 0 additions & 311 deletions
Large diffs are not rendered by default.

src/data/CCBijection.ml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,3 @@ module Make(L : OrderedType)(R : OrderedType) = struct
117117

118118
let to_iter m yield = MapL.iter (fun k v -> yield (k,v)) m.left
119119
end
120-
121-
(*$inject
122-
open Containers
123-
module M = Make(Int)(String)
124-
125-
*)
126-
127-
(*$=
128-
2 (M.of_list [1,"1"; 2, "2"] |> M.cardinal)
129-
"1" (M.of_list [1,"1"; 2, "2"] |> M.find_left 1)
130-
"2" (M.of_list [1,"1"; 2, "2"] |> M.find_left 2)
131-
1 (M.of_list [1,"1"; 2, "2"] |> M.find_right "1")
132-
2 (M.of_list [1,"1"; 2, "2"] |> M.find_right "2")
133-
*)

src/data/CCBitField.ml

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,59 +7,6 @@ exception Frozen
77

88
let max_width = Sys.word_size - 2
99

10-
(*$R
11-
let module B = CCBitField.Make(struct end) in
12-
let x = B.mk_field () in
13-
let y = B.mk_field () in
14-
let z = B.mk_field () in
15-
16-
let f = B.empty |> B.set x true |> B.set y true in
17-
18-
assert_bool "z_false" (not (B.get z f)) ;
19-
20-
assert_bool "z_true" (f |> B.set z true |> B.get z);
21-
*)
22-
23-
(*$R
24-
let module B = CCBitField.Make(struct end) in
25-
let _ = B.mk_field () in
26-
B.freeze();
27-
assert_bool "must raise"
28-
(try ignore (B.mk_field()); false with Frozen -> true);
29-
30-
*)
31-
32-
(*$R
33-
let module B = CCBitField.Make(struct end) in
34-
35-
let x = B.mk_field () in
36-
let y = B.mk_field () in
37-
let z = B.mk_field () in
38-
let u = B.mk_field () in
39-
B.freeze();
40-
41-
let f = B.empty
42-
|> B.set y true
43-
|> B.set z true
44-
in
45-
46-
assert_equal ~printer:CCInt.to_string 6 (f :> int) ;
47-
48-
assert_equal false (B.get x f) ;
49-
assert_equal true (B.get y f) ;
50-
assert_equal true (B.get z f);
51-
52-
let f' = B.set u true f in
53-
54-
assert_equal false (B.get x f') ;
55-
assert_equal true (B.get y f') ;
56-
assert_equal true (B.get z f');
57-
assert_equal true (B.get u f');
58-
59-
()
60-
*)
61-
62-
6310
module type S = sig
6411
type t = private int
6512
(** Generative type of bitfields. Each instantiation of the functor
@@ -94,13 +41,6 @@ let rec all_bits_ acc w =
9441
let acc = acc lor (1 lsl w-1) in
9542
all_bits_ acc (w-1)
9643

97-
(*$T
98-
all_bits_ 0 1 = 1
99-
all_bits_ 0 2 = 3
100-
all_bits_ 0 3 = 7
101-
all_bits_ 0 4 = 15
102-
*)
103-
10444
(* increment and return previous value *)
10545
let get_then_incr n =
10646
let x = !n in

src/data/CCCache.ml

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,6 @@ let with_cache_rec ?(cb=default_callback_) c f =
5555
let rec f' x = with_cache ~cb c (f f') x in
5656
f'
5757

58-
(*$R
59-
let c = unbounded ~eq:Int64.equal 256 in
60-
let fib = with_cache_rec c
61-
(fun self n -> match n with
62-
| 1L | 2L -> 1L
63-
| _ -> CCInt64.(self (n-1L) + self (n-2L))
64-
)
65-
in
66-
assert_equal 55L (fib 10L);
67-
assert_equal 832040L (fib 30L);
68-
assert_equal 12586269025L (fib 50L);
69-
assert_equal 190392490709135L (fib 70L)
70-
*)
71-
7258
let size c = c.size ()
7359

7460
let iter c f = c.iter f
@@ -311,36 +297,6 @@ let lru (type a) ~eq ?(hash=default_hash_) size =
311297
iter=L.iter c;
312298
}
313299

314-
(*$T
315-
let eq (i1,_)(i2,_) = i1=i2 and hash (i,_) = CCInt.hash i in \
316-
let c = lru ~eq ~hash 2 in \
317-
ignore (with_cache c CCFun.id (1, true)); \
318-
ignore (with_cache c CCFun.id (1, false)); \
319-
with_cache c CCFun.id (1, false) = (1, true)
320-
*)
321-
322-
(*$T
323-
let f = (let r = ref 0 in fun _ -> incr r; !r) in \
324-
let c = lru ~eq:CCInt.equal 2 in \
325-
let res1 = with_cache c f 1 in \
326-
let res2 = with_cache c f 2 in \
327-
let res3 = with_cache c f 3 in \
328-
let res1_bis = with_cache c f 1 in \
329-
res1 <> res2 && res2 <> res3 && res3 <> res1_bis && res1_bis <> res1
330-
*)
331-
332-
(*$R
333-
let f = (let r = ref 0 in fun _ -> incr r; !r) in
334-
let c = lru ~eq:CCEqual.unit 2 in
335-
let x = with_cache c f () in
336-
assert_equal 1 x;
337-
assert_equal 1 (size c);
338-
clear c ;
339-
assert_equal 0 (size c);
340-
let y = with_cache c f () in
341-
assert_equal 2 y ;
342-
*)
343-
344300
module UNBOUNDED(X:HASH) = struct
345301
module H = Hashtbl.Make(X)
346302

0 commit comments

Comments
 (0)