Cleanup Mutant::Mutation interface

* Equalize on sha1
* Expose code (for mutation filters)
* Expose node
This commit is contained in:
Markus Schirp 2012-08-29 13:33:47 +02:00
parent 565058f566
commit 61b22c49bf

View file

@ -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