Module: Coverage

Defined in:
lib/coverband/utils/jruby_ext.rb

Overview

This exists in CRuby, but not in JRuby, so add it

Taken from: github.com/ruby/ruby/blob/c5eb24349a4535948514fe765c3ddb0628d81004/ext/coverage/lib/coverage.rb

Class Method Summary collapse

Class Method Details

.line_stub(file) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/coverband/utils/jruby_ext.rb', line 9

def self.line_stub(file)
  lines = File.foreach(file).map { nil }
  iseqs = [RubyVM::InstructionSequence.compile_file(file)]
  until iseqs.empty?
    iseq = iseqs.pop
    iseq.trace_points.each { |n, type| lines[n - 1] = 0 if type == :line }
    iseq.each_child { |child| iseqs << child }
  end
  lines
end