Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mutaml.opam
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
112 changes: 47 additions & 65 deletions test/instrumentation-tests/gadts.t
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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"



Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"



Expand Down Expand Up @@ -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"



Expand Down Expand Up @@ -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



Expand Down
16 changes: 5 additions & 11 deletions test/instrumentation-tests/match.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.)



Expand Down
2 changes: 1 addition & 1 deletion test/write_dune_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ cat > dune <<EOF
(executable
(name test)
(modes byte)
(ocamlc_flags -dsource)
(ocamlc_flags -dsource -w -partial-match)
(instrumentation (backend mutaml)))
EOF
Loading