Class: DeepCover::Node::Case
- Inherits:
-
DeepCover::Node
- Object
- DeepCover::Node
- DeepCover::Node::Case
- Includes:
- Branch
- Defined in:
- lib/deep_cover/node/case.rb
Constant Summary
Constants inherited from DeepCover::Node
CLASSES, Complex, Cvasgn, Dsym, Erange, Float, Int, Ivar, Kwarg, Kwoptarg, Kwrestarg, OrAsgn, Rational, Sym, True, Zsuper
Instance Attribute Summary
Attributes inherited from DeepCover::Node
#base_node, #children, #index, #next_sibling, #parent, #previous_sibling
Instance Method Summary collapse
- #branches ⇒ Object
- #branches_summary(of_branches) ⇒ Object
- #execution_count ⇒ Object
- #has_else? ⇒ Boolean
Methods included from Branch
Methods inherited from DeepCover::Node
[], #[], atom, #children_nodes, #covered_code, define_module_class, #each_node, #fancy_type, #find_all, has_evaluated_segments, inherited, #initialize, #simple_literal?, #to_s, #type
Methods included from Memoize
Constructor Details
This class inherits a constructor from DeepCover::Node
Instance Method Details
#branches ⇒ Object
88 89 90 |
# File 'lib/deep_cover/node/case.rb', line 88 def branches whens.map(&:body) << self.else end |
#branches_summary(of_branches) ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/deep_cover/node/case.rb', line 92 def branches_summary(of_branches) texts = [] n = of_branches.size if of_branches.include? self.else texts << "#{'implicit ' unless has_else?}else" n -= 1 end texts.unshift "#{n} when clause#{'s' if n > 1}" if n > 0 texts.join(' and ') end |
#execution_count ⇒ Object
103 104 105 106 |
# File 'lib/deep_cover/node/case.rb', line 103 def execution_count return evaluate.flow_completion_count if evaluate flow_entry_count end |
#has_else? ⇒ Boolean
108 109 110 |
# File 'lib/deep_cover/node/case.rb', line 108 def has_else? !!base_node.loc.to_hash[:else] end |