Cleanup Mutant::Mutation interface
* Equalize on sha1 * Expose code (for mutation filters) * Expose node
This commit is contained in:
parent
565058f566
commit
61b22c49bf
1 changed files with 24 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
||||||
module Mutant
|
module Mutant
|
||||||
# Represent a mutated node with its subject
|
# Represent a mutated node with its subject
|
||||||
class Mutation
|
class Mutation
|
||||||
include Immutable
|
include Immutable, Equalizer.new(:sha1)
|
||||||
|
|
||||||
# Return mutation subject
|
# Return mutation subject
|
||||||
#
|
#
|
||||||
|
@ -11,6 +11,14 @@ module Mutant
|
||||||
#
|
#
|
||||||
def subject; @subject; end
|
def subject; @subject; end
|
||||||
|
|
||||||
|
# Return mutated node
|
||||||
|
#
|
||||||
|
# @return [Subject]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def node; @node; end
|
||||||
|
|
||||||
# Return mutated root node
|
# Return mutated root node
|
||||||
#
|
#
|
||||||
# @return [Rubinius::AST::Script]
|
# @return [Rubinius::AST::Script]
|
||||||
|
@ -40,17 +48,29 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def identification
|
def identification
|
||||||
"#{subject.identification}:#{sha1[0..4]}"
|
"#{subject.identification}:#{code}"
|
||||||
end
|
end
|
||||||
|
memoize :identification
|
||||||
|
|
||||||
# Return sha1 sum of source
|
# Return mutation code
|
||||||
|
#
|
||||||
|
# @return [String]
|
||||||
|
#
|
||||||
|
# @api private
|
||||||
|
#
|
||||||
|
def code
|
||||||
|
sha1[0..4]
|
||||||
|
end
|
||||||
|
memoize :code
|
||||||
|
|
||||||
|
# Return sha1 sum of source and subject identification
|
||||||
#
|
#
|
||||||
# @return [String]
|
# @return [String]
|
||||||
#
|
#
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def sha1
|
def sha1
|
||||||
SHA1.hexdigest(source)
|
SHA1.hexdigest(subject.identification + source)
|
||||||
end
|
end
|
||||||
memoize :sha1
|
memoize :sha1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue