Sha256: ece56fbeccd8898ec6a9ff29c63fb7a03e845b77999d18c652fddf48b71fe81d

Contents?: true

Size: 742 Bytes

Versions: 14

Compression:

Stored size: 742 Bytes

Contents

require_relative 'subset'

module DeepCover
  class Analyser::Statement < Analyser
    include Analyser::Subset
    # Returns a map of Range => runs
    def results
      each_node.map do |node, _sub_statements|
        [node.expression, node_runs(node)]
      end.to_h
    end

    private

    def in_subset?(node, parent)
      is_statement = node.is_statement
      if node.expression.nil?
        false
      elsif is_statement != :if_incompatible
        is_statement
      else
        !compatible_runs?(node_runs(parent), node_runs(node))
      end
    end

    def compatible_runs?(expression_runs, sub_expression_runs)
      sub_expression_runs.nil? ||
        (sub_expression_runs == 0) == (expression_runs == 0)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
deep-cover-0.1.14 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.13 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.12 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.11 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.10 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.9 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.8 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.7 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.6 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.5 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.4 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.3 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.2 lib/deep_cover/analyser/statement.rb
deep-cover-0.1.1 lib/deep_cover/analyser/statement.rb