Class: DeepCover::Analyser::Branch

Inherits:
DeepCover::Analyser show all
Includes:
Subset
Defined in:
lib/deep_cover/analyser/branch.rb

Constant Summary collapse

SUBSET_CLASSES =
[Node::Branch].freeze

Instance Attribute Summary

Attributes included from Base

#options, #source

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Subset

#node_children

Methods included from Base

#covered_code, #each_node, #initialize, #node_children, #node_covered?, #node_runs_map, #node_stat_contributions, #node_stat_type, #stats

Methods included from Tools::Covered

#covered?

Class Method Details

.human_nameObject



7
8
9
# File 'lib/deep_cover/analyser/branch.rb', line 7

def self.human_name
  'Branches'
end

Instance Method Details

#node_runs(node) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/deep_cover/analyser/branch.rb', line 13

def node_runs(node)
  runs = super
  if node.is_a?(Node::Branch) && covered?(runs)
    worst = worst_branch_runs(node)
    runs = worst unless covered?(worst)
  end
  runs
end

#resultsObject



22
23
24
25
26
27
# File 'lib/deep_cover/analyser/branch.rb', line 22

def results
  each_node.map do |node|
    branches_runs = node.branches.map { |jump| [jump, branch_runs(jump)] }.to_h
    [node, branches_runs]
  end.to_h
end