From d60bea1a98ce5afd9ffe71009b7507a16734cc8a Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 30 Jul 2020 10:02:16 -0400 Subject: [PATCH] fix build for 4.11 by working around `-nolabels` --- qtest/dune | 2 +- qtest/make.ml | 2 ++ src/core/CCArray.ml | 16 ------------- src/core/CCList.ml | 26 ++++---------------- src/core/CCString.ml | 15 ------------ src/core/tests/check_labelled_mods.ml | 34 +++++++++++++++++++++++++++ src/core/tests/dune | 13 ++++++++++ 7 files changed, 55 insertions(+), 53 deletions(-) create mode 100644 src/core/tests/check_labelled_mods.ml create mode 100644 src/core/tests/dune diff --git a/qtest/dune b/qtest/dune index b3ef0799..e3b5e712 100644 --- a/qtest/dune +++ b/qtest/dune @@ -14,7 +14,7 @@ (modes native) (modules run_qtest) ; disable some warnings in qtests - (flags :standard -warn-error -a -w -3-33-35-27-39-50 -nolabels) + (flags :standard -warn-error -a -w -3-33-35-27-39-50) (libraries iter gen qcheck containers containers.unix unix uutf threads)) (alias diff --git a/qtest/make.ml b/qtest/make.ml index edc22068..15cada1c 100644 --- a/qtest/make.ml +++ b/qtest/make.ml @@ -10,6 +10,7 @@ let str_sub ?(offset=0) ~sub:s' s = aux offset let is_suffix ~sub s = + String.length s >= String.length sub && str_sub ~offset:(String.length s - String.length sub) ~sub s let is_code file = is_suffix ~sub:".ml" file || is_suffix ~sub:".mli" file @@ -22,6 +23,7 @@ let do_not_test file = is_suffix ~sub:"mkflags.ml" file || is_suffix ~sub:"mkshims.ml" file || is_suffix ~sub:"unlabel.ml" file || + is_suffix ~sub:"check_labelled_mods.ml" file || is_suffix ~sub:"utop.ml" file let prefix = "src" diff --git a/src/core/CCArray.ml b/src/core/CCArray.ml index fd1b6595..09a8af01 100644 --- a/src/core/CCArray.ml +++ b/src/core/CCArray.ml @@ -713,19 +713,3 @@ module Infix = struct end include Infix - - -(* test consistency of interfaces *) -(*$inject - module FA = CCShimsArray_.Floatarray - module type L = module type of CCArray with module Floatarray := FA - module type LL = module type of CCArrayLabels with module Floatarray := FA -*) - -(*$R - ignore (module CCArrayLabels : L) -*) - -(*$R - ignore (module CCArray : LL) -*) diff --git a/src/core/CCList.ml b/src/core/CCList.ml index 84ec3402..d29cdc1d 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -1052,8 +1052,8 @@ let remove ~eq x l = remove' eq x [] l (*$T - remove ~eq:CCInt.equal 1 [2;1;3;3;2;1] = [2;3;3;2] - remove ~eq:CCInt.equal 10 [1;2;3] = [1;2;3] + remove ~eq:CCInt.equal ~key:1 [2;1;3;3;2;1] = [2;3;3;2] + remove ~eq:CCInt.equal ~key:10 [1;2;3] = [1;2;3] *) let filter_map f l = @@ -1568,13 +1568,13 @@ module Assoc = struct (*$= [1,"1"; 2,"22"] \ (Assoc.update ~eq:CCInt.equal \ - (function Some "2" -> Some "22" | _ -> assert false) 2 [1,"1"; 2,"2"] |> lsort) + ~f:(function Some "2" -> Some "22" | _ -> assert false) 2 [1,"1"; 2,"2"] |> lsort) [1,"1"; 3,"3"] \ (Assoc.update ~eq:CCInt.equal \ - (function Some "2" -> None | _ -> assert false) 2 [1,"1"; 2,"2"; 3,"3"] |> lsort) + ~f:(function Some "2" -> None | _ -> assert false) 2 [1,"1"; 2,"2"; 3,"3"] |> lsort) [1,"1"; 2,"2"; 3,"3"] \ (Assoc.update ~eq:CCInt.equal \ - (function None -> Some "3" | _ -> assert false) 3 [1,"1"; 2,"2"] |> lsort) + ~f:(function None -> Some "3" | _ -> assert false) 3 [1,"1"; 2,"2"] |> lsort) *) let remove ~eq x l = @@ -1811,19 +1811,3 @@ let pp ?(pp_start=fun _ () -> ()) ?(pp_stop=fun _ () -> ()) ~pp_stop:(fun fmt () -> Format.fprintf fmt "]") CCFormat.int)) \ [1;2;3]) *) - - -(* test consistency of interfaces *) -(*$inject - module type L = module type of CCList - module type LL = module type of CCListLabels -*) - -(*$R - ignore (module CCListLabels : L) -*) - -(*$R - ignore (module CCList : LL) -*) - diff --git a/src/core/CCString.ml b/src/core/CCString.ml index 8f93c036..7665b7b1 100644 --- a/src/core/CCString.ml +++ b/src/core/CCString.ml @@ -1072,18 +1072,3 @@ include Infix "ab" < "abc" "123" < "14" *) - -(* test consistency of interfaces *) -(*$inject - module type L = module type of CCString - module type LL = module type of CCStringLabels -*) - -(*$R - ignore (module CCStringLabels : L) -*) - -(*$R - ignore (module CCString : LL) -*) - diff --git a/src/core/tests/check_labelled_mods.ml b/src/core/tests/check_labelled_mods.ml new file mode 100644 index 00000000..7745095b --- /dev/null +++ b/src/core/tests/check_labelled_mods.ml @@ -0,0 +1,34 @@ + + +module A = struct + (* test consistency of interfaces *) + module FA = CCShimsArray_.Floatarray + module type L = module type of CCArray with module Floatarray := FA + module type LL = module type of CCArrayLabels with module Floatarray := FA + + let () = ignore (module CCArrayLabels : L) + + let () = ignore (module CCArray : LL) +end + +module S = struct + (* test consistency of interfaces *) + module type L = module type of CCString + module type LL = module type of CCStringLabels + + let () = ignore (module CCStringLabels : L) + + let () = ignore (module CCString : LL) + +end + +module L = struct + (* test consistency of interfaces *) + module type L = module type of CCList + module type LL = module type of CCListLabels + let () = ignore (module CCListLabels : L) + + let () = ignore (module CCList : LL) +end + +let () = print_endline "labelled modules are consistent ✔" diff --git a/src/core/tests/dune b/src/core/tests/dune new file mode 100644 index 00000000..a52331d7 --- /dev/null +++ b/src/core/tests/dune @@ -0,0 +1,13 @@ + + +(executable + (name check_labelled_mods) + (flags :standard -warn-error -a -w -3-33-35-27-39-50 -nolabels) + (libraries containers)) + +; what matters is that it compiles +(alias + (name runtest) + (locks ctest) + (package containers) + (action (run ./check_labelled_mods.exe)))