Refactor example verification to reduce redundant unparsing
This commit is contained in:
parent
bfd41e6948
commit
9219e3b018
1 changed files with 19 additions and 15 deletions
|
@ -34,12 +34,24 @@ module Mutant
|
||||||
|
|
||||||
# Unexpected mutations
|
# Unexpected mutations
|
||||||
#
|
#
|
||||||
# @return [Array<Parser::AST::Node>]
|
# @return [Array<Mutation>]
|
||||||
def unexpected
|
def unexpected
|
||||||
mutations.map(&:node) - example.expected
|
mutations.reject do |mutation|
|
||||||
|
example.expected.include?(mutation.node)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
memoize :unexpected
|
memoize :unexpected
|
||||||
|
|
||||||
|
# Missing mutations
|
||||||
|
#
|
||||||
|
# @return [Array<Mutation>]
|
||||||
|
def missing
|
||||||
|
(example.expected - mutations.map(&:node)).map do |node|
|
||||||
|
Mutation::Evil.new(self, node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
memoize :missing
|
||||||
|
|
||||||
# Mutations with no diff to original
|
# Mutations with no diff to original
|
||||||
#
|
#
|
||||||
# @return [Enumerable<Mutation>]
|
# @return [Enumerable<Mutation>]
|
||||||
|
@ -50,14 +62,14 @@ module Mutant
|
||||||
|
|
||||||
# Mutation report
|
# Mutation report
|
||||||
#
|
#
|
||||||
# @param [Array<Parser::AST::Node>] nodes
|
# @param [Array<Mutation>] mutations
|
||||||
#
|
#
|
||||||
# @return [Array<Hash>]
|
# @return [Array<Hash>]
|
||||||
def format_mutations(nodes)
|
def format_mutations(mutations)
|
||||||
nodes.map do |node|
|
mutations.map do |mutation|
|
||||||
{
|
{
|
||||||
'node' => node.inspect,
|
'node' => mutation.node.inspect,
|
||||||
'source' => Unparser.unparse(node)
|
'source' => mutation.source
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -74,14 +86,6 @@ module Mutant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Missing mutations
|
|
||||||
#
|
|
||||||
# @return [Array<Parser::AST::Node>]
|
|
||||||
def missing
|
|
||||||
example.expected - mutations.map(&:node)
|
|
||||||
end
|
|
||||||
memoize :missing
|
|
||||||
|
|
||||||
end # Verification
|
end # Verification
|
||||||
end # Example
|
end # Example
|
||||||
end # Meta
|
end # Meta
|
||||||
|
|
Loading…
Add table
Reference in a new issue