github.com/mshitrit/go-mutesting@v0.0.0-20210528084812-ff81dcaedfea/mutator/branch/mutatecase.go (about) 1 package branch 2 3 import ( 4 "go/ast" 5 "go/types" 6 7 "github.com/zimmski/go-mutesting/astutil" 8 "github.com/zimmski/go-mutesting/mutator" 9 ) 10 11 func init() { 12 mutator.Register("branch/case", MutatorCase) 13 } 14 15 // MutatorCase implements a mutator for case clauses. 16 func MutatorCase(pkg *types.Package, info *types.Info, node ast.Node) []mutator.Mutation { 17 n, ok := node.(*ast.CaseClause) 18 if !ok { 19 return nil 20 } 21 22 old := n.Body 23 24 return []mutator.Mutation{ 25 { 26 Change: func() { 27 n.Body = []ast.Stmt{ 28 astutil.CreateNoopOfStatements(pkg, info, n.Body), 29 } 30 }, 31 Reset: func() { 32 n.Body = old 33 }, 34 }, 35 } 36 }