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
|
||||
# Represent a mutated node with its subject
|
||||
class Mutation
|
||||
include Immutable
|
||||
include Immutable, Equalizer.new(:sha1)
|
||||
|
||||
# Return mutation subject
|
||||
#
|
||||
|
@ -11,6 +11,14 @@ module Mutant
|
|||
#
|
||||
def subject; @subject; end
|
||||
|
||||
# Return mutated node
|
||||
#
|
||||
# @return [Subject]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def node; @node; end
|
||||
|
||||
# Return mutated root node
|
||||
#
|
||||
# @return [Rubinius::AST::Script]
|
||||
|
@ -40,17 +48,29 @@ module Mutant
|
|||
# @api private
|
||||
#
|
||||
def identification
|
||||
"#{subject.identification}:#{sha1[0..4]}"
|
||||
"#{subject.identification}:#{code}"
|
||||
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]
|
||||
#
|
||||
# @api private
|
||||
#
|
||||
def sha1
|
||||
SHA1.hexdigest(source)
|
||||
SHA1.hexdigest(subject.identification + source)
|
||||
end
|
||||
memoize :sha1
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue