diff --git a/dune-project b/dune-project index 3daa0b8..0157d2f 100644 --- a/dune-project +++ b/dune-project @@ -28,7 +28,7 @@ (tags ("test" "mutation testing")) (depends (ocaml (>= 4.12.0)) - (ocaml (and (< 5.2.0) :with-test)) + (ocaml (and (>= 5.2.0) :with-test)) (ppxlib (>= 0.37.0)) (ppx_deriving_yojson (>= 3.7.0)) stdlib-random diff --git a/mutaml.opam b/mutaml.opam index 6449790..ec5702b 100644 --- a/mutaml.opam +++ b/mutaml.opam @@ -19,7 +19,7 @@ bug-reports: "https://github.com/jmid/mutaml/issues" depends: [ "dune" {>= "3.22"} "ocaml" {>= "4.12.0"} - "ocaml" {< "5.2.0" & with-test} + "ocaml" {>= "5.2.0" & with-test} "ppxlib" {>= "0.37.0"} "ppx_deriving_yojson" {>= "3.7.0"} "stdlib-random" diff --git a/test/instrumentation-tests/gadts.t b/test/instrumentation-tests/gadts.t index 3e2a6c6..9a6d11a 100644 --- a/test/instrumentation-tests/gadts.t +++ b/test/instrumentation-tests/gadts.t @@ -38,11 +38,10 @@ Check that the example typechecks type _ t = | Int: int t | Bool: bool t - let f (type a) = - (function - | Int -> if __is_mutaml_mutant__ "test:0" then 1 else 0 - | Bool -> if __is_mutaml_mutant__ "test:1" then false else true : - a t -> a) + let f (type a) : a t -> a= + function + | Int -> if __is_mutaml_mutant__ "test:0" then 1 else 0 + | Bool -> if __is_mutaml_mutant__ "test:1" then false else true let () = (f Int) |> (Printf.printf "%i\n") This shouldn't fail. It should just fail to mutate the patterns. @@ -251,13 +250,13 @@ Check that the example typechecks type _ t = | Int: int t | Bool: bool t - let f (type a) = - (function - | [|Int;Int|] when not (__is_mutaml_mutant__ "test:3") -> - if __is_mutaml_mutant__ "test:0" then 1 else 0 - | [|Bool|] when not (__is_mutaml_mutant__ "test:2") -> - if __is_mutaml_mutant__ "test:1" then false else true - | _ -> failwith "ouch" : a t array -> a) + let f (type a) : a t array -> a= + function + | [|Int;Int|] when not (__is_mutaml_mutant__ "test:3") -> + if __is_mutaml_mutant__ "test:0" then 1 else 0 + | [|Bool|] when not (__is_mutaml_mutant__ "test:2") -> + if __is_mutaml_mutant__ "test:1" then false else true + | _ -> failwith "ouch" @@ -278,18 +277,7 @@ Pattern matching on GADT constructors in arrays: > EOF Check that the example typechecks - $ ocamlc -stop-after typing test.ml - File "test.ml", lines 6-11, characters 34-34: - 6 | ..................................function - 7 | | [| Int |] -> 0 - 8 | | [| Bool |] -> true - 9 | | [| Char |] -> 'c' - 10 | | _ when true (*2*2=2+2*) -> failwith "empty" - 11 | | _ when false -> failwith "dead" - Warning 8 [partial-match]: this pattern-matching is not exhaustive. - Here is an example of a case that is not matched: - [| |] - (However, some guarded clause may match this value.) + $ ocamlc -stop-after typing -w -partial-match test.ml $ export MUTAML_SEED=896745231 $ export MUTAML_GADT=true $ bash ../filter_dune_build.sh ./test.bc --instrument-with mutaml 2>&1 > output.txt @@ -299,6 +287,11 @@ Check that the example typechecks Created 4 mutations of test.ml Writing mutation info to test.muts ERROR MESSAGE + Running mutaml instrumentation on "test.ml" + Randomness seed: 896745231 Mutation rate: 100 GADTs enabled: true + Created 4 mutations of test.ml + Writing mutation info to test.muts + let __MUTAML_MUTANT__ = Stdlib.Sys.getenv_opt "MUTAML_MUTANT" let __is_mutaml_mutant__ m = match __MUTAML_MUTANT__ with @@ -308,26 +301,15 @@ Check that the example typechecks | Int: int t | Bool: bool t | Char: char t - let f (type a) = - (function - | [|Int|] -> if __is_mutaml_mutant__ "test:0" then 1 else 0 - | [|Bool|] -> if __is_mutaml_mutant__ "test:1" then false else true - | [|Char|] -> 'c' - | _ when if __is_mutaml_mutant__ "test:2" then false else true -> - failwith "empty" - | _ when if __is_mutaml_mutant__ "test:3" then true else false -> - failwith "dead" : a t array -> a) - File "test.ml", lines 6-11, characters 34-34: - 6 | ..................................function - 7 | | [| Int |] -> 0 - 8 | | [| Bool |] -> true - 9 | | [| Char |] -> 'c' - 10 | | _ when true (*2*2=2+2*) -> failwith "empty" - 11 | | _ when false -> failwith "dead" - Error (warning 8 [partial-match]): this pattern-matching is not exhaustive. - Here is an example of a case that is not matched: - [| |] - (However, some guarded clause may match this value.) + let f (type a) : a t array -> a= + function + | [|Int|] -> if __is_mutaml_mutant__ "test:0" then 1 else 0 + | [|Bool|] -> if __is_mutaml_mutant__ "test:1" then false else true + | [|Char|] -> 'c' + | _ when if __is_mutaml_mutant__ "test:2" then false else true -> + failwith "empty" + | _ when if __is_mutaml_mutant__ "test:3" then true else false -> + failwith "dead" @@ -362,13 +344,13 @@ Check that the example typechecks type _ t = | Int: int t | Bool: bool t - let f (type a) = - (function - | [|_x;Int|] when not (__is_mutaml_mutant__ "test:3") -> - if __is_mutaml_mutant__ "test:0" then 3 else 2 - | [|Bool;_x|] when not (__is_mutaml_mutant__ "test:2") -> - if __is_mutaml_mutant__ "test:1" then false else true - | _ -> failwith "eww" : a t array -> a) + let f (type a) : a t array -> a= + function + | [|_x;Int|] when not (__is_mutaml_mutant__ "test:3") -> + if __is_mutaml_mutant__ "test:0" then 3 else 2 + | [|Bool;_x|] when not (__is_mutaml_mutant__ "test:2") -> + if __is_mutaml_mutant__ "test:1" then false else true + | _ -> failwith "eww" @@ -403,20 +385,20 @@ Check that the example typechecks type _ t = | Int: int t | Bool: bool t - let _f (type a) (type b) = - (function - | (Int, _) when not (__is_mutaml_mutant__ "test:4") -> - if __is_mutaml_mutant__ "test:0" then 1 else 0 - | (_, Bool) when not (__is_mutaml_mutant__ "test:3") -> - if __is_mutaml_mutant__ "test:1" then 0 else 1 - | _ -> if __is_mutaml_mutant__ "test:2" then 3 else 2 : (a t * b t) -> int) - let _f (type a) (type b) = - (function - | (Int, Int) when not (__is_mutaml_mutant__ "test:9") -> - if __is_mutaml_mutant__ "test:5" then 1 else 0 - | (Bool, Bool) when not (__is_mutaml_mutant__ "test:8") -> - if __is_mutaml_mutant__ "test:6" then 0 else 1 - | _ -> if __is_mutaml_mutant__ "test:7" then 3 else 2 : (a t * b t) -> int) + let _f (type a) (type b) : (a t * b t) -> int= + function + | (Int, _) when not (__is_mutaml_mutant__ "test:4") -> + if __is_mutaml_mutant__ "test:0" then 1 else 0 + | (_, Bool) when not (__is_mutaml_mutant__ "test:3") -> + if __is_mutaml_mutant__ "test:1" then 0 else 1 + | _ -> if __is_mutaml_mutant__ "test:2" then 3 else 2 + let _f (type a) (type b) : (a t * b t) -> int= + function + | (Int, Int) when not (__is_mutaml_mutant__ "test:9") -> + if __is_mutaml_mutant__ "test:5" then 1 else 0 + | (Bool, Bool) when not (__is_mutaml_mutant__ "test:8") -> + if __is_mutaml_mutant__ "test:6" then 0 else 1 + | _ -> if __is_mutaml_mutant__ "test:7" then 3 else 2 diff --git a/test/instrumentation-tests/match.t b/test/instrumentation-tests/match.t index f380db9..edc65f5 100644 --- a/test/instrumentation-tests/match.t +++ b/test/instrumentation-tests/match.t @@ -946,6 +946,11 @@ Another example that would trigger merge-of-consecutive-patterns: Created 6 mutations of test.ml Writing mutation info to test.muts ERROR MESSAGE + Running mutaml instrumentation on "test.ml" + Randomness seed: 896745231 Mutation rate: 100 GADTs enabled: true + Created 6 mutations of test.ml + Writing mutation info to test.muts + let __MUTAML_MUTANT__ = Stdlib.Sys.getenv_opt "MUTAML_MUTANT" let __is_mutaml_mutant__ m = match __MUTAML_MUTANT__ with @@ -959,17 +964,6 @@ Another example that would trigger merge-of-consecutive-patterns: | [|_;_;_|] -> if __is_mutaml_mutant__ "test:3" then 4 else 3 | _ when if __is_mutaml_mutant__ "test:4" then false else true -> if __is_mutaml_mutant__ "test:5" then 1001 else 1000 - File "test.ml", lines 1-6, characters 11-23: - 1 | ...........match x with - 2 | | [| |] -> 0 - 3 | | [| _ |] -> 1 - 4 | | [| _;_ |] -> 2 - 5 | | [| _;_;_ |] -> 3 - 6 | | _ when true -> 1000 - Error (warning 8 [partial-match]): this pattern-matching is not exhaustive. - Here is an example of a case that is not matched: - [| _ ; _ ; _ ; _ |] - (However, some guarded clause may match this value.) diff --git a/test/write_dune_files.sh b/test/write_dune_files.sh index 82f13bd..60dc5d0 100755 --- a/test/write_dune_files.sh +++ b/test/write_dune_files.sh @@ -10,6 +10,6 @@ cat > dune <