class Mutiny::Mutants::Mutant
Attributes
code[R]
index[RW]
location[R]
mutation_name[R]
stillborn[R]
stillborn?[R]
subject[R]
Public Class Methods
new(subject: nil, code:, mutation_name: nil, index: nil, position: nil)
click to toggle source
# File lib/mutiny/mutants/mutant.rb, line 10 def initialize(subject: nil, code:, mutation_name: nil, index: nil, position: nil) @subject = subject @code = code @mutation_name = mutation_name @index = index @stillborn = false @location = Location.new(position: position, content: code) end
Public Instance Methods
apply()
click to toggle source
# File lib/mutiny/mutants/mutant.rb, line 23 def apply # Evaluate the mutated code, overidding any existing version. # We evaluate in the context of TOPLEVEL_BINDING as we want # the unit to be evaluated in its usual namespace. # rubocop:disable Eval eval(code, TOPLEVEL_BINDING) # rubocop:enable Eval rescue StandardError, ScriptError @stillborn = true end
eql?(other)
click to toggle source
# File lib/mutiny/mutants/mutant.rb, line 34 def eql?(other) other.subject == subject && other.code == code end
Also aliased as: ==
hash()
click to toggle source
# File lib/mutiny/mutants/mutant.rb, line 40 def hash [subject, code].hash end
identifier()
click to toggle source
# File lib/mutiny/mutants/mutant.rb, line 19 def identifier subject.relative_path.sub(/\.rb$/, ".#{index}.rb") end