class Mutest::Meta::Example::Verification
Example
verification
Public Instance Methods
error_report()
click to toggle source
Error report
@return [String]
# File lib/mutest/meta/example/verification.rb, line 19 def error_report raise 'no error report on successful validation' if success? YAML.dump( 'file' => example.file, 'original_ast' => example.node.inspect, 'original_source' => example.source, 'missing' => format_mutations(missing), 'unexpected' => format_mutations(unexpected), 'no_diff' => no_diff_report ) end
success?()
click to toggle source
Test
if mutation was verified successfully
@return [Boolean]
# File lib/mutest/meta/example/verification.rb, line 12 def success? missing.empty? && unexpected.empty? && no_diffs.empty? end
Private Instance Methods
format_mutations(nodes)
click to toggle source
Mutation
report
@param [Array<Parser::AST::Node>] nodes
@return [Array<Hash>]
# File lib/mutest/meta/example/verification.rb, line 55 def format_mutations(nodes) nodes.map do |node| { 'node' => node.inspect, 'source' => Unparser.unparse(node) } end end
missing()
click to toggle source
Missing mutations
@return [Array<Parser::AST::Node>]
# File lib/mutest/meta/example/verification.rb, line 79 def missing example.expected - mutations.map(&:node) end
no_diff_report()
click to toggle source
No diff mutation report
@return [Array, nil]
# File lib/mutest/meta/example/verification.rb, line 67 def no_diff_report no_diffs.map do |mutation| { 'node' => mutation.node.inspect, 'source' => mutation.source } end end
no_diffs()
click to toggle source
Mutations with no diff to original
@return [Enumerable<Mutation>]
# File lib/mutest/meta/example/verification.rb, line 45 def no_diffs mutations.select { |mutation| mutation.source.eql?(example.source) } end
unexpected()
click to toggle source
Unexpected mutations
@return [Array<Parser::AST::Node>]
# File lib/mutest/meta/example/verification.rb, line 37 def unexpected mutations.map(&:node) - example.expected end