Skip to content

Commit

Permalink
chore(test): clean up all deprecations and most warnings (#801)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored Oct 21, 2023
1 parent a09fb39 commit 9597451
Show file tree
Hide file tree
Showing 97 changed files with 1,134 additions and 1,160 deletions.
14 changes: 7 additions & 7 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions jscomp/test/a_recursive_type.ml
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
type t = A of (t -> int)

let g = fun x ->
match x with
let g = fun x ->
match x with
| A v -> v x

let loop = g (A g )
let loop = g (A g )

let non_terminate = (fun x ->
match x with
let non_terminate = (fun x ->
match x with
| A v -> v x) (A g)

type t0 = { xx : t0 }
type[@ocaml.warning "-69"] t0 = { xx : t0 }
(* [@@unboxed]*)

let rec xx = { xx }

type t1 =
type[@ocaml.warning "-34-37"] t1 =
| A of t1 array



type t2 =

type[@ocaml.warning "-34-37"] t2 =
| A2 of t2 array [@@unboxed]

(* let rec h = A [|h|]
(* let rec h = A [|h|]
let rec h1 = A [|h1|] // could be relaxed
let rec h2 = A2 [|h2|]
let rec h2 = A2 [|h2|]
;; Js.log (h,h2) *)
(** If we inline g's definition -- it will be the same, inline uncarefully
(** If we inline g's definition -- it will be the same, inline uncarefully
(inline the inlined result)
will make it non-terminating
*)
3 changes: 1 addition & 2 deletions jscomp/test/abstract_type.mli
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
type t
type t

type arrow_type = int -> int

type 'a poly_type = 'a
type 'a poly_abstract_type
open Mt
62 changes: 31 additions & 31 deletions jscomp/test/bal_set_mini.ml
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
type 'a t =
| Empty
| Node of 'a t * 'a * 'a t * int
let rec height = function
| Empty -> 0
| Node(_,_,_,h) -> h
type 'a t =
| Empty
| Node of 'a t * 'a * 'a t * int
let height = function
| Empty -> 0
| Node(_,_,_,h) -> h

let create l v r =
let hl = height l in
let hr = height r in
Node(l,v,r, if hl >= hr then hl + 1 else hr + 1)
let create l v r =
let hl = height l in
let hr = height r in
Node(l,v,r, if hl >= hr then hl + 1 else hr + 1)


let bal l v r =
let hl = height l in
let hr = height r in
if hl > hr + 2 then
let hr = height r in
if hl > hr + 2 then
match l with
| Empty -> Empty (* impossible *)
| Node(ll, lv, lr, _) ->
| Node(ll, lv, lr, _) ->
if height ll >= height lr then
create ll lv (create lr v r)
else
else
match lr with
| Empty -> Empty (* impossible *)
| Node(lrl, lrv, lrr, _)->
create (create ll lv lrl) lrv (create lrr v r)
else if hr > hl + 2 then
else if hr > hl + 2 then
match r with
| Empty -> Empty (* impossible *)
| Node(rl, rv, rr, _) ->
if height rr >= height rl then
create (create l v rl) rv rr
else
else
match rl with
| Empty -> Empty (* impossible *)
| Node(rll, rlv, rlr, _) ->
create (create l v rll) rlv (create rlr rv rr)
else
Node(l, v, r, (if hl >= hr then hl + 1 else hr + 1))
Node(l, v, r, (if hl >= hr then hl + 1 else hr + 1))

let compare_int (x : int) y = if x > y then 1 else if x = y then 0 else -1

let rec add x = function
let rec add x = function
| Empty -> Node(Empty, x, Empty, 1)
| Node(l, v, r, _) as t ->
let c = compare_int x v in
if c = 0 then t else
if c < 0 then bal (add x l) v r else bal l v (add x r)

let rec min_elt def = function
let rec min_elt def = function
| Empty -> def
| Node(Empty, v, r, _) -> v
| Node(l, v, r, _) -> min_elt v l

(*
let rec remove_min_elt tree = match tree with
let rec remove_min_elt tree = match tree with
| Empty -> Empty (* impossible *)
| Node(Empty, v, r, _) -> r
| Node(l, v, r, _) -> bal (remove_min_elt l) v r
*)
let rec remove_min_elt l v r =
match l with
| Empty -> r
| Node(ll,lv,lr,_) -> bal (remove_min_elt ll lv lr) v r
let rec remove_min_elt l v r =
match l with
| Empty -> r
| Node(ll,lv,lr,_) -> bal (remove_min_elt ll lv lr) v r

let internal_merge l r =
match (l, r) with
Expand All @@ -71,34 +71,34 @@ let internal_merge l r =
| (_, Node (rl,rv,rr,_) ) -> bal l (min_elt rv r) (remove_min_elt rl rv rr)

let rec remove x tree =
match tree with
match tree with
| Empty -> Empty
| Node(l, v, r, _) ->
let c = compare_int x v in
if c = 0 then internal_merge l r else
if c < 0 then bal (remove x l) v r else bal l v (remove x r)

let rec mem x = function
let rec mem x = function
| Empty -> false
| Node(l, v, r, _) ->
let c = compare_int x v in
c = 0 || mem x (if c < 0 then l else r)



let () =
let v = ref Empty in
let v = ref Empty in
let iter = 1_00_000 in
for i = 0 to iter do
v := add i !v
done;

for i = 0 to iter do
if not (mem i !v) then print_endline "impossible"
done;
done;
for i = 0 to iter do
v := remove i !v
v := remove i !v
done;
match !v with
match !v with
| Empty -> ()
| Node _ -> print_endline "impossible"
50 changes: 25 additions & 25 deletions jscomp/test/bdd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ let rec eval bdd vars =
| Node(l, v, _, h) ->
if vars.(v) then eval h vars else eval l vars

let getId bdd =
match bdd with
let getId bdd =
match bdd with
Node(_,_,id,_) -> id
| Zero -> 0
| One -> 1
Expand All @@ -42,10 +42,10 @@ let resize newSize =
let newSz_1 = newSize-1 in
let newArr = Array.make newSize [] in
let rec copyBucket bucket =
match bucket with
match bucket with
[] -> ()
| n :: ns ->
match n with
| n :: ns ->
match n with
| Node(l,v,_,h) ->
let ind = hashVal (getId l) (getId h) v land newSz_1
in
Expand All @@ -60,7 +60,7 @@ let resize newSize =
sz_1 := newSz_1


let rec insert idl idh v ind bucket newNode =
let insert idl idh v ind bucket newNode =
if !n_items <= !sz_1
then ( (!htab).(ind) <- (newNode :: bucket);
incr n_items )
Expand All @@ -80,18 +80,18 @@ let resetUnique () = (

let mkNode low v high =
let idl = getId low in
let idh = getId high
let idh = getId high
in
if idl = idh
then low
else let ind = hashVal idl idh v land (!sz_1) in
let bucket = (!htab).(ind) in
let rec lookup b =
match b with
let rec lookup b =
match b with
[] -> let n = Node(low, v, (incr nodeC; !nodeC), high)
in
insert (getId low) (getId high) v ind bucket n; n
| n :: ns ->
| n :: ns ->
match n with
| Node(l,v',id,h) ->
if v = v' && idl = getId l && idh = getId h
Expand All @@ -104,7 +104,7 @@ let mkNode low v high =
type ordering = LESS | EQUAL | GREATER

let cmpVar (x : int) (y : int) =
if x<y then LESS else if x>y then GREATER else EQUAL
if x<y then LESS else if x>y then GREATER else EQUAL

let zero = Zero
let one = One
Expand All @@ -123,7 +123,7 @@ let notslot1 = Array.make cacheSize 0
let notslot2 = Array.make cacheSize one
let hash x y = ((x lsl 1)+y) mod cacheSize

let rec not n =
let rec not n =
match n with
Zero -> One
| One -> Zero
Expand All @@ -134,9 +134,9 @@ match n with
in
notslot1.(h) <- id; notslot2.(h) <- f; f

let rec and2 n1 n2 =
let rec and2 n1 n2 =
match n1 with
Node(l1, v1, i1, r1)
Node(l1, v1, i1, r1)
-> (match n2 with
Node(l2, v2, i2, r2)
-> let h = hash i1 i2
Expand All @@ -147,8 +147,8 @@ match n1 with
| LESS -> mkNode (and2 l1 n2) v1 (and2 r1 n2)
| GREATER -> mkNode (and2 n1 l2) v2 (and2 n1 r2)
in
andslot1.(h) <- i1;
andslot2.(h) <- i2;
andslot1.(h) <- i1;
andslot2.(h) <- i2;
andslot3.(h) <- f;
f
| Zero -> Zero
Expand All @@ -157,9 +157,9 @@ match n1 with
| One -> n2


let rec xor n1 n2 =
let rec xor n1 n2 =
match n1 with
Node(l1, v1, i1, r1)
Node(l1, v1, i1, r1)
-> (match n2 with
Node(l2, v2, i2, r2)
-> let h = hash i1 i2
Expand All @@ -174,19 +174,19 @@ match n1 with
andslot2.(h) <- i2;
andslot3.(h) <- f;
f
| Zero -> n1
| Zero -> n1
| One -> not n1)
| Zero -> n2
| One -> not n2

let hwb n =
let hwb n =
let rec h i j = if i=j
then mkVar i
else xor (and2 (not(mkVar j)) (h i (j-1)))
(and2 (mkVar j) (g i (j-1)))
and g i j = if i=j
then mkVar i
else xor (and2 (not(mkVar i)) (h (i+1) j))
else xor (and2 (not(mkVar i)) (h (i+1) j))
(and2 (mkVar i) (g (i+1) j))
in
h 0 (n-1)
Expand All @@ -202,12 +202,12 @@ let random_vars n =
for i = 0 to n - 1 do vars.(i) <- random() done;
vars

let bool_equal a b =
let bool_equal a b =
match a, b with
| true, true
| true, true
| false, false
-> true
| _ -> false
| _ -> false

let test_hwb bdd vars =
(* We should have
Expand All @@ -227,7 +227,7 @@ let main () =
(* if Array.length Sys.argv >= 3 then int_of_string Sys.argv.(2) else 100 in *)
let bdd = hwb n in
let succeeded = ref true in
for i = 1 to ntests do
for _i = 1 to ntests do
succeeded := !succeeded && test_hwb bdd (random_vars n)
done;
assert !succeeded
Expand Down
Loading

0 comments on commit 9597451

Please sign in to comment.