1 /** 2 Copyright: Copyright (c) 2021, Joakim Brännström. All rights reserved. 3 License: MPL-2 4 Author: Joakim Brännström (joakim.brannstrom@gmx.com) 5 6 This Source Code Form is subject to the terms of the Mozilla Public License, 7 v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 8 one at http://mozilla.org/MPL/2.0/. 9 10 How mutants of different types cover other mutants on the same source code 11 location that have the status unknown. 12 13 Mutation.Kind,status -> Mutation.Kind 14 */ 15 module dextool.plugin.mutate.backend.mutation_type.cover; 16 17 import std.traits : EnumMembers; 18 19 import my.set; 20 21 import dextool.plugin.mutate.backend.mutation_type.aor; 22 import dextool.plugin.mutate.backend.mutation_type.aors; 23 import dextool.plugin.mutate.backend.mutation_type.dcr; 24 import dextool.plugin.mutate.backend.mutation_type.lcr; 25 import dextool.plugin.mutate.backend.mutation_type.ror; 26 import dextool.plugin.mutate.backend.mutation_type.uoi; 27 import dextool.plugin.mutate.backend.type : Mutation; 28 29 struct Cover { 30 Mutation.Kind kind; 31 Mutation.Status status; 32 33 size_t toHash() @safe pure nothrow const @nogc scope { 34 auto a = kind.hashOf(); 35 return status.hashOf(a); 36 } 37 } 38 39 const Mutation.Kind[][Cover] covers; 40 41 shared static this() { 42 Mutation.Kind[][Cover] s; 43 scope (success) 44 covers = cast(const) s; 45 46 s[Cover(Mutation.Kind.stmtDel, Mutation.Status.alive)] = [ 47 EnumMembers!(Mutation.Kind) 48 ]; 49 50 // one surviving is enough. when a user fix it then the others are 51 // executed. Most probably killed then. 52 // lcrb not needed because it is just binary. no use in doing a cover operation. 53 foreach (k; aorMutationsAll) 54 s[Cover(k, Mutation.Status.alive)] = aorMutationsAll.dup; 55 foreach (k; aorsMutationsAll) 56 s[Cover(k, Mutation.Status.alive)] = aorsMutationsAll.dup; 57 foreach (k; dcrMutationsAll) 58 s[Cover(k, Mutation.Status.alive)] = dcrMutationsAll.dup; 59 foreach (k; lcrMutationsAll) 60 s[Cover(k, Mutation.Status.alive)] = lcrMutationsAll.dup; 61 foreach (k; rorMutationsAll) 62 s[Cover(k, Mutation.Status.alive)] = rorMutationsAll.dup; 63 foreach (k; rorpMutationsAll) 64 s[Cover(k, Mutation.Status.alive)] = rorpMutationsAll.dup; 65 foreach (k; uoiLvalueMutations) 66 s[Cover(k, Mutation.Status.alive)] = uoiLvalueMutations.dup; 67 foreach (k; uoiRvalueMutations) 68 s[Cover(k, Mutation.Status.alive)] = uoiRvalueMutations.dup; 69 }