diff --git a/CHANGES.md b/CHANGES.md index bf53af8..efa1a32 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,11 @@ Next release ------------ -- Use dune.3.18 support to generate `x-maintenance-intent` entry -- Patch `ppx_yojson_conv` dependency which was missing a `v`-prefix +- Support ppxlib 0.37 and 0.38 and require dune.3.22.0 #49 +- Adjust test suite to be compatible with >= dune.3.22.0 #48 +- Switch to using `ppx_deriving_yojson` instead of `ppx_yojson_conv` #47 +- Use dune.3.18 support to generate `x-maintenance-intent` entry #45 +- Patch `ppx_yojson_conv` dependency which was missing a `v`-prefix #43 - Introduce a `mutaml.opam.template` to avoid opam linting failure #41 - Adjust RE to support `runtest` on OpenBSD too #40 - Remove `which` and `conf-which` dependency #39 diff --git a/dune-project b/dune-project index 8417d91..3daa0b8 100644 --- a/dune-project +++ b/dune-project @@ -1,4 +1,4 @@ -(lang dune 3.18) +(lang dune 3.22) (name mutaml) @@ -28,9 +28,8 @@ (tags ("test" "mutation testing")) (depends (ocaml (>= 4.12.0)) - (dune (>= 3.18)) - (dune (and (>= 3.22.0) :with-test)) - (ppxlib (and (>= 0.28.0) (< 0.36.0))) + (ocaml (and (< 5.2.0) :with-test)) + (ppxlib (>= 0.37.0)) (ppx_deriving_yojson (>= 3.7.0)) stdlib-random conf-timeout diff --git a/mutaml.opam b/mutaml.opam index 4758bf7..6449790 100644 --- a/mutaml.opam +++ b/mutaml.opam @@ -17,10 +17,10 @@ homepage: "https://github.com/jmid/mutaml" doc: "https://github.com/jmid/mutaml" bug-reports: "https://github.com/jmid/mutaml/issues" depends: [ + "dune" {>= "3.22"} "ocaml" {>= "4.12.0"} - "dune" {>= "3.18"} - "dune" {>= "3.22.0" & with-test} - "ppxlib" {>= "0.28.0" & < "0.36.0"} + "ocaml" {< "5.2.0" & with-test} + "ppxlib" {>= "0.37.0"} "ppx_deriving_yojson" {>= "3.7.0"} "stdlib-random" "conf-timeout" diff --git a/src/ppx/mutaml_ppx.ml b/src/ppx/mutaml_ppx.ml index 0071e5d..c6a73f1 100644 --- a/src/ppx/mutaml_ppx.ml +++ b/src/ppx/mutaml_ppx.ml @@ -463,10 +463,13 @@ class mutate_mapper (rs : RS.t) = self#mutaml_mutant ctx loc(*e0.pexp_loc*) [%expr ()] e0' (string_of_exp e1) in { e0 with pexp_desc = Pexp_sequence (e0'',e1') } - | _, Pexp_function cases -> - self#cases ctx cases >>| fun cases_pure -> (* all cases are pure in 'function' *) - let function_ = { e with pexp_desc = Pexp_function cases_pure } in - if Match.cases_contain_matching_patterns cases_pure + | _, Pexp_function (params, constrs, fbody) -> + self#function_body ctx fbody >>| fun fbody -> + let function_ = { e with pexp_desc = Pexp_function (params, constrs, fbody) } in + let contains_matching_patterns = (match fbody with + | Pfunction_body _ -> false + | Pfunction_cases (cases_pure,_,_) -> Match.cases_contain_matching_patterns cases_pure) in + if contains_matching_patterns then Exp.attr function_ (* disable pattern-match warning *) { attr_name = {txt = "ocaml.warning"; loc}; @@ -489,6 +492,14 @@ class mutate_mapper (rs : RS.t) = | _ -> super#expression ctx e + method! function_body ctx body = match body with + | Pfunction_body e -> + self#expression ctx e >>| fun e -> + Pfunction_body e + | Pfunction_cases (cases,loc,attrs) -> + self#cases ctx cases >>| fun cases_pure -> (* all cases are pure in 'function' *) + Pfunction_cases (cases_pure,loc,attrs) + (* don't mutate attribute parameters such as 'false' in [@@deriving show {with_path=false}] *) method! attributes _ctx attrs = return attrs diff --git a/test/instrumentation-tests/function-merge-consecutive.t b/test/instrumentation-tests/function-merge-consecutive.t index cbc8d2c..e0d3bc8 100644 --- a/test/instrumentation-tests/function-merge-consecutive.t +++ b/test/instrumentation-tests/function-merge-consecutive.t @@ -658,18 +658,19 @@ Same example that triggers merge-of-consecutive-patterns w/GADTs false | X | Lit of int | Binop of aexp * binop * aexp - let rec interpret xval = - ((function - | X -> xval - | Lit i -> i - | Binop (ae0, Add, ae1) when not (__is_mutaml_mutant__ "test:2") -> - let v0 = interpret xval ae0 in - let v1 = interpret xval ae1 in - if __is_mutaml_mutant__ "test:0" then v0 - v1 else v0 + v1 - | Binop (ae0, Add, ae1) | Binop (ae0, Mul, ae1) -> - let v0 = interpret xval ae0 in - let v1 = interpret xval ae1 in - if __is_mutaml_mutant__ "test:1" then v0 + v1 else v0 * v1) + let rec interpret = + ((fun xval -> + function + | X -> xval + | Lit i -> i + | Binop (ae0, Add, ae1) when not (__is_mutaml_mutant__ "test:2") -> + let v0 = interpret xval ae0 in + let v1 = interpret xval ae1 in + if __is_mutaml_mutant__ "test:0" then v0 - v1 else v0 + v1 + | Binop (ae0, Add, ae1) | Binop (ae0, Mul, ae1) -> + let v0 = interpret xval ae0 in + let v1 = interpret xval ae1 in + if __is_mutaml_mutant__ "test:1" then v0 + v1 else v0 * v1) [@ocaml.warning "-8"]) let () = (interpret (if __is_mutaml_mutant__ "test:3" then 3 else 2) diff --git a/test/negative-tests/ppx-negtests.t b/test/negative-tests/ppx-negtests.t index be77ab1..b206b32 100644 --- a/test/negative-tests/ppx-negtests.t +++ b/test/negative-tests/ppx-negtests.t @@ -269,6 +269,8 @@ Instrument and check that it was received -dont-apply Exclude these transformations -cookie NAME=EXPR Set the cookie NAME to EXPR --cookie Same as -cookie + -raise-embedded-errors Raise the first embedded error found in the processed AST + -allow-deriving-end Whether to allow [@@@deriving.end], which will soon be deprecated. -seed Set randomness seed for mutaml's instrumentation -mut-rate Set probability in % of mutating a syntax tree node (default: 50%) -gadt Allow only pattern mutations compatible with GADTs (default: true)