Add class mutator

Fixes #619
This commit is contained in:
John Backus 2016-07-24 17:19:26 -07:00
parent d032274141
commit 96a3a5162f
No known key found for this signature in database
GPG key ID: 9A91898D0B0B2FBE
4 changed files with 33 additions and 1 deletions

View file

@ -117,6 +117,7 @@ require 'mutant/mutator/node/send/conditional'
require 'mutant/mutator/node/send/attribute_assignment'
require 'mutant/mutator/node/send/index'
require 'mutant/mutator/node/when'
require 'mutant/mutator/node/class'
require 'mutant/mutator/node/define'
require 'mutant/mutator/node/mlhs'
require 'mutant/mutator/node/nthref'

View file

@ -0,0 +1,21 @@
module Mutant
class Mutator
class Node
# Namespace for class mutations
class Class < self
handle :class
children :klass, :parent, :body
private
# Emit mutations only for class body
#
# @return [undefined]
def dispatch
emit_body_mutations if body
end
end # Class
end # Node
end # Mutator
end # Mutant

View file

@ -10,7 +10,7 @@ module Mutant
handle(
:ensure, :redo, :retry, :arg_expr, :blockarg,
:kwrestarg, :undef, :module, :empty,
:alias, :for, :xstr, :back_ref, :class, :restarg,
:alias, :for, :xstr, :back_ref, :restarg,
:sclass, :match_with_lvasgn, :while_post,
:until_post, :preexe, :postexe, :iflipflop, :eflipflop, :kwsplat,
:shadowarg, :rational, :complex, :__FILE__, :__LINE__

10
meta/class.rb Normal file
View file

@ -0,0 +1,10 @@
Mutant::Meta::Example.add :class do
source 'class Foo; bar; end'
mutation 'class Foo; nil; end'
mutation 'class Foo; self; end'
end
Mutant::Meta::Example.add :class do
source 'class Foo; end'
end