Skip to content

Commit 17a7795

Browse files
xclercmshinwell
andauthored
Remove CRs from the test suite (#2097)
* Reclassify 'CR ocaml 5 runtime' comments * CR * Reimport "lib-hashtbl" test from upstream. * Simplify "pr7168" test. --------- Co-authored-by: Mark Shinwell <[email protected]>
1 parent b0c85d7 commit 17a7795

File tree

3 files changed

+28
-31
lines changed

3 files changed

+28
-31
lines changed

ocaml/testsuite/tests/lib-hashtbl/htbl.ml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
(* TEST
2-
*)
3-
4-
(* CR ocaml 5 runtime: [String] will gain a [seeded_hash]
5-
function, implemented in the OCaml 5 runtime. When that
6-
happens, we should checkout this test to [tip-5].
7-
*)
1+
(* TEST *)
82

93
(* Hashtable operations, using maps as a reference *)
104

115
open Printf
126

13-
module Test(H: Hashtbl.S) (M: Map.S with type key = H.key) = struct
7+
module Test(H: Hashtbl.SeededS) (M: Map.S with type key = H.key) = struct
148

159
let incl_mh m h =
1610
try
@@ -90,31 +84,31 @@ module SS = struct
9084
type t = string
9185
let compare (x:t) (y:t) = Stdlib.compare x y
9286
let equal (x:t) (y:t) = x=y
93-
let hash = Hashtbl.hash
87+
let seeded_hash = Hashtbl.seeded_hash
9488
end
9589
module SI = struct
9690
type t = int
9791
let compare (x:t) (y:t) = Stdlib.compare x y
9892
let equal (x:t) (y:t) = x=y
99-
let hash = Hashtbl.hash
93+
let seeded_hash = Hashtbl.seeded_hash
10094
end
10195
module SSP = struct
10296
type t = string*string
10397
let compare (x:t) (y:t) = Stdlib.compare x y
10498
let equal (x:t) (y:t) = x=y
105-
let hash = Hashtbl.hash
99+
let seeded_hash = Hashtbl.seeded_hash
106100
end
107101
module SSL = struct
108102
type t = string list
109103
let compare (x:t) (y:t) = Stdlib.compare x y
110104
let equal (x:t) (y:t) = x=y
111-
let hash = Hashtbl.hash
105+
let seeded_hash = Hashtbl.seeded_hash
112106
end
113107
module SSA = struct
114108
type t = string array
115109
let compare (x:t) (y:t) = Stdlib.compare x y
116110
let equal (x:t) (y:t) = x=y
117-
let hash = Hashtbl.hash
111+
let seeded_hash = Hashtbl.seeded_hash
118112
end
119113

120114
module MS = Map.Make(SS)
@@ -126,11 +120,11 @@ module MSA = Map.Make(SSA)
126120

127121
(* Generic hash wrapped as a functorial hash *)
128122

129-
module HofM (M: Map.S) : Hashtbl.S with type key = M.key =
123+
module HofM (M: Map.S) : Hashtbl.SeededS with type key = M.key =
130124
struct
131125
type key = M.key
132126
type 'a t = (key, 'a) Hashtbl.t
133-
let create s = Hashtbl.create s
127+
let create ?random:bool s = Hashtbl.create s
134128
let clear = Hashtbl.clear
135129
let reset = Hashtbl.reset
136130
let copy = Hashtbl.copy
@@ -161,13 +155,22 @@ module HSL = HofM(MSL)
161155

162156
(* Specific functorial hashes *)
163157

164-
module HS2 = Hashtbl.Make(SS)
165-
module HI2 = Hashtbl.Make(SI)
158+
module HS2 = Hashtbl.MakeSeeded(SS)
159+
module HS3 = Hashtbl.MakeSeeded(String)
160+
module HI2 = Hashtbl.MakeSeeded(SI)
161+
162+
(* Specific weak functorial hashes *)
163+
module WS = Ephemeron.K1.MakeSeeded(SS)
164+
module WSP1 = Ephemeron.K1.MakeSeeded(SSP)
165+
module WSP2 = Ephemeron.K2.MakeSeeded(SS)(SS)
166+
module WSL = Ephemeron.K1.MakeSeeded(SSL)
167+
module WSA = Ephemeron.Kn.MakeSeeded(SS)
166168

167169
(* Instantiating the test *)
168170

169171
module TS1 = Test(HS1)(MS)
170172
module TS2 = Test(HS2)(MS)
173+
module TS3 = Test(HS3)(MS)
171174
module TI1 = Test(HI1)(MI)
172175
module TI2 = Test(HI2)(MI)
173176
module TSP = Test(HSP)(MSP)
@@ -244,11 +247,12 @@ let _ =
244247
TS1.test d;
245248
printf "-- Strings, functorial interface\n%!";
246249
TS2.test d;
250+
printf "-- Strings, functorial(String) interface\n%!";
251+
TS3.test d;
247252
printf "-- Pairs of strings\n%!";
248253
TSP.test (pair_data d);
249254
printf "-- Lists of strings\n%!";
250255
TSL.test (list_data d)
251-
;;
252256

253257

254258
let () =

ocaml/testsuite/tests/lib-hashtbl/htbl.reference

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ Removal: passed
1414
Insertion: passed
1515
Insertion: passed
1616
Removal: passed
17+
-- Strings, functorial(String) interface
18+
Insertion: passed
19+
Insertion: passed
20+
Removal: passed
1721
-- Pairs of strings
1822
Insertion: passed
1923
Insertion: passed

ocaml/testsuite/tests/misc/pr7168.ml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,5 @@ let rec f x =
7272
()
7373

7474
let _ =
75-
(* CR ocaml 5 runtime: we should be able
76-
* to simplify this test along the same
77-
* lines as upstream, as stack overflow
78-
* detection is always supported in
79-
* ocaml 5. *)
80-
if (Gc.get ()).Gc.stack_limit = 0 then begin
81-
(* We are in native code. Skip the test because some platforms cannot
82-
reliably detect stack overflow. *)
83-
Printf.printf "OK\n"
84-
end else begin
85-
try Sys.with_async_exns (fun () -> f 1)
86-
with Stack_overflow -> Printf.printf "OK\n"
87-
end
75+
try Sys.with_async_exns (fun () -> f 1)
76+
with Stack_overflow -> Printf.printf "OK\n"

0 commit comments

Comments
 (0)